| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- from enum import Enum
- __author__ = 'James Iter'
- __date__ = '2017/3/21'
- __contact__ = 'james.iter.cn@gmail.com'
- __copyright__ = '(c) 2017 by James Iter.'
- # TODO: 考虑按视角归类,比如自身视角名称(uuid),外部视角名称(guest_uuid)
- class Rules(Enum):
- # 正则表达式方便校验其来自URL的参数
- REG_NUMBER = 'regex:^\d{1,17}$'
- REG_NUMBERS = 'regex:^(\d{1,17})(,\d{1,17})*$'
- REG_UUIDS = 'regex:^([\w-]{36})(,[\w-]{36})*$'
- REG_HOSTS_NAME = 'regex:^([\S-]{1,128})(,[\S-]{1,128})*$'
- 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))))$'
- OFFSET = (REG_NUMBER, 'offset')
- LIMIT = (REG_NUMBER, 'limit')
- PAGE = (REG_NUMBER, 'page')
- PAGE_SIZE = (REG_NUMBER, 'page_size')
- ORDER_BY = (basestring, 'order_by', (1, 30))
- ORDER = (basestring, 'order', ['asc', 'desc'])
- KEYWORD = (basestring, 'keyword')
- ID = (REG_NUMBER, 'id')
- IDS = (REG_NUMBERS, 'ids')
- HOSTS_NAME = (REG_HOSTS_NAME, 'hosts_name')
- CONFIG_ID = (int, 'id')
- JIMV_EDITION = (int, 'jimv_edition')
- STORAGE_MODE = (int, 'storage_mode')
- DFS_VOLUME = (basestring, 'dfs_volume')
- STORAGE_PATH = (basestring, 'storage_path')
- VM_NETWORK = (basestring, 'vm_network')
- VM_MANAGE_NETWORK = (basestring, 'vm_manage_network')
- START_IP = (REG_IP, 'start_ip')
- END_IP = (REG_IP, 'end_ip')
- START_VNC_PORT = (int, 'start_vnc_port')
- NETMASK = (REG_IP, 'netmask')
- GATEWAY = (REG_IP, 'gateway')
- DNS1 = (REG_IP, 'dns1')
- DNS2 = (REG_IP, 'dns2')
- IOPS_BASE = (int, 'iops_base')
- IOPS_PRE_UNIT = (int, 'iops_pre_unit')
- IOPS_CAP = (int, 'iops_cap')
- IOPS_MAX = (int, 'iops_max')
- IOPS_MAX_LENGTH = (int, 'iops_max_length')
- BPS_BASE = (int, 'iops_base')
- BPS_PRE_UNIT = (int, 'iops_pre_unit')
- BPS_CAP = (int, 'iops_cap')
- BPS_MAX = (int, 'iops_max')
- BPS_MAX_LENGTH = (int, 'iops_max_length')
- SSH_KEY_ID_EXT = (REG_NUMBER, 'ssh_key_id')
- SSH_KEYS_ID = (list, 'ssh_keys_id')
- PUBLIC_KEY = (basestring, 'public_key')
- UUID = (basestring, 'uuid', (36, 36))
- NODE_ID = (basestring, 'node_id', (16, 16))
- UUIDS = (REG_UUIDS, 'uuids')
- CPU = (int, 'cpu')
- MEMORY = (int, 'memory')
- OS_TEMPLATE_IMAGE_ID = (int, 'os_template_image_id')
- QUANTITY = (int, 'quantity')
- NAME = (basestring, 'name')
- PATH = (basestring, 'path')
- LOGIN_NAME = (basestring, 'login_name')
- PASSWORD = (basestring, 'password')
- LEASE_TERM = (int, 'lease_term')
- DESTINATION_HOST = (basestring, 'destination_host', (5, 64))
- DISK_UUID = (basestring, 'disk_uuid', (36, 36))
- DISK_SIZE = (int, 'size')
- DISK_SIZE_STR = (REG_NUMBER, 'size')
- IOPS = (int, 'iops')
- IOPS_RD = (int, 'iops_rd')
- IOPS_WR = (int, 'iops_wr')
- BPS = (int, 'bps')
- BPS_RD = (int, 'bps_rd')
- BPS_WR = (int, 'bps_wr')
- INFLUENCE_CURRENT_GUEST = (bool, 'influence_current_guest')
- GUEST_UUID = (basestring, 'guest_uuid', (36, 36))
- SNAPSHOT_ID = (REG_NUMBER, 'snapshot_id')
- SNAPSHOTS_ID = (REG_NUMBERS, 'snapshots_id')
- REMARK = (basestring, 'remark')
- USE_FOR = (int, 'use_for')
- LABEL = (basestring, 'label')
- DESCRIPTION = (basestring, 'description')
- OS_TYPE = (basestring, 'os_type')
- OS_DISTRO = (basestring, 'os_distro')
- OS_MAJOR = (int, 'os_major')
- OS_MINOR = (int, 'os_minor')
- OS_ARCH = (basestring, 'os_arch')
- OS_PRODUCT_NAME = (basestring, 'os_product_name')
- ACTIVE = (bool, 'active')
- ICON = (basestring, 'icon')
- LOGO = (basestring, 'logo')
- OS_TEMPLATE_PROFILE_ID_EXT = (int, 'os_template_profile_id')
- OS_TEMPLATE_INITIALIZE_OPERATE_SET_ID_EXT = (int, 'os_template_initialize_operate_set_id')
- OS_TEMPLATE_INITIALIZE_OPERATE_KIND = (int, 'kind')
- OS_TEMPLATE_INITIALIZE_OPERATE_SEQUENCE = (int, 'sequence')
- OS_TEMPLATE_INITIALIZE_OPERATE_PATH = (basestring, 'path')
- OS_TEMPLATE_INITIALIZE_OPERATE_CONTENT = (basestring, 'content')
- OS_TEMPLATE_INITIALIZE_OPERATE_COMMAND = (basestring, 'command')
- OPERATE_RULE_KIND = (int, 'kind')
- OPERATE_RULE_SEQUENCE = (int, 'sequence')
- OPERATE_RULE_PATH = (basestring, 'path')
- OPERATE_RULE_CONTENT = (basestring, 'content')
- OPERATE_RULE_COMMAND = (basestring, 'command')
- TOKEN = (basestring, 'token')
|