rules.py 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. from enum import Enum
  4. __author__ = 'James Iter'
  5. __date__ = '2017/3/21'
  6. __contact__ = 'james.iter.cn@gmail.com'
  7. __copyright__ = '(c) 2017 by James Iter.'
  8. class Rules(Enum):
  9. # 正则表达式方便校验其来自URL的参数
  10. REG_NUMBER = 'regex:^\d{1,17}$'
  11. REG_NUMBERS = 'regex:^(\d{1,17})(,\d{1,17})*$'
  12. REG_UUIDS = 'regex:^([\w-]{36})(,[\w-]{36})*$'
  13. REG_IP = 'regex:^((?:(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d))))$'
  14. OFFSET = (REG_NUMBER, 'offset')
  15. LIMIT = (REG_NUMBER, 'limit')
  16. PAGE = (REG_NUMBER, 'page')
  17. PAGE_SIZE = (REG_NUMBER, 'page_size')
  18. ORDER_BY = (basestring, 'order_by', (1, 30))
  19. ORDER = (basestring, 'order', ['asc', 'desc'])
  20. KEYWORD = (basestring, 'keyword')
  21. ID = (REG_NUMBER, 'id')
  22. IDS = (REG_NUMBERS, 'ids')
  23. BOOT_JOBS_ID = (REG_NUMBERS, 'boot_jobs_id')
  24. CONFIG_ID = (int, 'id')
  25. JIMV_EDITION = (int, 'jimv_edition')
  26. STORAGE_MODE = (int, 'storage_mode')
  27. DFS_VOLUME = (basestring, 'dfs_volume')
  28. STORAGE_PATH = (basestring, 'storage_path')
  29. VM_NETWORK = (basestring, 'vm_network')
  30. VM_MANAGE_NETWORK = (basestring, 'vm_manage_network')
  31. START_IP = (REG_IP, 'start_ip')
  32. END_IP = (REG_IP, 'end_ip')
  33. START_VNC_PORT = (int, 'start_vnc_port')
  34. NETMASK = (REG_IP, 'netmask')
  35. GATEWAY = (REG_IP, 'gateway')
  36. DNS1 = (REG_IP, 'dns1')
  37. DNS2 = (REG_IP, 'dns2')
  38. IOPS_BASE = (int, 'iops_base')
  39. IOPS_PRE_UNIT = (int, 'iops_pre_unit')
  40. IOPS_CAP = (int, 'iops_cap')
  41. IOPS_MAX = (int, 'iops_max')
  42. IOPS_MAX_LENGTH = (int, 'iops_max_length')
  43. BPS_BASE = (int, 'iops_base')
  44. BPS_PRE_UNIT = (int, 'iops_pre_unit')
  45. BPS_CAP = (int, 'iops_cap')
  46. BPS_MAX = (int, 'iops_max')
  47. BPS_MAX_LENGTH = (int, 'iops_max_length')
  48. RSA_PRIVATE = (basestring, 'rsa_private')
  49. RSA_PUBLIC = (basestring, 'rsa_public')
  50. UUID = (basestring, 'uuid', (36, 36))
  51. NODE_ID = (basestring, 'node_id', (14, 15))
  52. UUIDS = (REG_UUIDS, 'uuids')
  53. CPU = (int, 'cpu')
  54. MEMORY = (int, 'memory')
  55. OS_TEMPLATE_ID = (int, 'os_template_id')
  56. QUANTITY = (int, 'quantity')
  57. NAME = (basestring, 'name')
  58. PATH = (basestring, 'path')
  59. LOGIN_NAME = (basestring, 'login_name')
  60. PASSWORD = (basestring, 'password')
  61. LEASE_TERM = (int, 'lease_term')
  62. GUEST_ON_HOST = (basestring, 'on_host', (1, 128))
  63. DESTINATION_HOST = (basestring, 'destination_host', (5, 64))
  64. DISK_UUID = (basestring, 'disk_uuid', (36, 36))
  65. DISK_SIZE = (int, 'size')
  66. DISK_SIZE_STR = (REG_NUMBER, 'size')
  67. DISK_ON_HOST = (basestring, 'on_host', (1, 128))
  68. IOPS = (int, 'iops')
  69. IOPS_RD = (int, 'iops_rd')
  70. IOPS_WR = (int, 'iops_wr')
  71. BPS = (int, 'bps')
  72. BPS_RD = (int, 'bps_rd')
  73. BPS_WR = (int, 'bps_wr')
  74. INFLUENCE_CURRENT_GUEST = (bool, 'influence_current_guest')
  75. REMARK = (basestring, 'remark')
  76. USE_FOR = (int, 'use_for')
  77. LABEL = (basestring, 'label')
  78. OS_TYPE = (int, 'os_type')
  79. ACTIVE = (bool, 'active')
  80. ICON = (basestring, 'icon')
  81. BOOT_JOB_ID_EXT = (int, 'boot_job_id')
  82. OPERATE_RULE_KIND = (int, 'kind')
  83. OPERATE_RULE_SEQUENCE = (int, 'sequence')
  84. OPERATE_RULE_PATH = (basestring, 'path')
  85. OPERATE_RULE_CONTENT = (basestring, 'content')
  86. OPERATE_RULE_COMMAND = (basestring, 'command')
  87. TOKEN = (basestring, 'token')