示例#1
0
class PhysServValidator(serializers.Serializer):
    id = serializers.IntegerField(
        required=False, error_messages=serializers.CommonErrorMessages('id'))
    cfg_id = serializers.CharField(
        max_length=100,
        error_messages=serializers.CommonErrorMessages(_(u'编号')))
    name = serializers.CharField(
        max_length=100,
        error_messages=serializers.CommonErrorMessages(_(u'名称')))
    cpu = serializers.IntegerField(
        error_messages=serializers.CommonErrorMessages(_(u'CPU 数')))
    memory = serializers.IntegerField(
        error_messages=serializers.CommonErrorMessages(_(u'内存数')))
    cabinet = serializers.CharField(
        max_length=100,
        error_messages=serializers.CommonErrorMessages(_(u'所在机柜')))
    gbe = serializers.IntegerField(
        error_messages=serializers.CommonErrorMessages(_(u'千兆网卡接口')))
    gbex10 = serializers.IntegerField(
        error_messages=serializers.CommonErrorMessages(_(u'万兆网卡接口')))
    lan_ip = serializers.RegexField(
        regex=REGEXP_IPS,
        max_length=100,
        error_messages=serializers.CommonErrorMessages(_(u'内网 IP')))
    wan_ip = serializers.RegexField(
        regex=REGEXP_IPS,
        max_length=100,
        error_messages=serializers.CommonErrorMessages(_(u'外网 IP')))
示例#2
0
class WafBaseSerializer(serializers.Serializer):
    """
    每秒查询频率、HTTP连接数、CPU使用率、内存使用率
    请求次数统计、响应时间统计、安全防护日志
    基础防护、HTTP协议防护、防错误信息泄露、WAF规则
    url白名单
    系统信息
    """
    owner = serializers.CharField(
        required=True, error_messages=serializers.CommonErrorMessages(u"用户"))

    zone = serializers.ChoiceField(
        required=True,
        choices=["dev", "prod", "test"],
        error_messages=serializers.CommonErrorMessages(u"分区"))

    waf_id = serializers.CharField(
        required=True,
        error_messages=serializers.CommonErrorMessages(u"waf_id"))

    smc_ip = serializers.IPAddressField(
        required=True,
        error_messages=serializers.CommonErrorMessages(u"smc_ip"))

    page_index = serializers.IntegerField(default=1, required=False)

    page_size = serializers.IntegerField(default=0, required=False)
示例#3
0
class DescribeDepartmentMemberValidator(serializers.Serializer):
    department_id = serializers.CharField(max_length=20,
                                          required=False,
                                          validators=[department_validator],
                                          error_messages=error_message('部门id'))

    page_size = serializers.IntegerField(
        required=False,
        max_value=settings.MAX_PAGE_SIZE,
        min_value=10,
        default=10,
        error_messages=error_message('page_size'))

    page_num = serializers.IntegerField(
        required=False,
        max_value=settings.MAX_PAGE_NUM,
        min_value=0,
        default=1,
        error_messages=error_message('page_num'))

    def validate(self, data):
        department_id = data.get('department_id', None)
        if not department_id:
            department_id = PortalDepartment.objects.first().department_id
            data['department_id'] = department_id
        else:
            department_validator(department_id)
        return data
示例#4
0
class ListWafNodesSerializer(SmcBaseSerializer):
    """
    waf节点信息
    """
    page_index = serializers.IntegerField(required=False)

    page_size = serializers.IntegerField(default=0, required=False)
示例#5
0
class ListWafInfoSerializer(SmcBaseSerializer):
    """
    waf列表
    """
    page_index = serializers.IntegerField(required=False, default=1)

    page_size = serializers.IntegerField(default=0, required=False)
示例#6
0
class GetImageFileValidator(serializers.Serializer):
    owner = serializers.CharField(
        max_length=40,
        required=True,
        error_messages=serializers.CommonErrorMessages(_(u"owner")))

    name = serializers.CharField(
        max_length=2048,
        required=True,
        error_messages=serializers.CommonErrorMessages(_(u"name")))

    index = serializers.IntegerField(
        required=True,
        error_messages=serializers.CommonErrorMessages(_(u"index")))

    total_size = serializers.IntegerField(
        required=True,
        error_messages=serializers.CommonErrorMessages(_(u"total_size")))

    fileSplitSize = serializers.IntegerField(
        required=True,
        error_messages=serializers.CommonErrorMessages(_(u"fileSplitSize")))

    md5 = serializers.CharField(max_length=100,
                                required=True,
                                error_messages=serializers.CommonErrorMessages(
                                    _(u"md5")))

    date = serializers.IntegerField(
        required=True,
        error_messages=serializers.CommonErrorMessages(_(u"date")))
示例#7
0
class DataBaseValidator(serializers.Serializer):
    id = serializers.IntegerField(
        required=False, error_messages=serializers.CommonErrorMessages('id'))
    cfg_id = serializers.CharField(
        max_length=100,
        error_messages=serializers.CommonErrorMessages(_(u'编号')))
    name = serializers.CharField(
        max_length=100,
        error_messages=serializers.CommonErrorMessages(_(u'数据库名')))
    version = serializers.CharField(
        max_length=100,
        error_messages=serializers.CommonErrorMessages(_(u'版本')))
    memo = serializers.CharField(
        required=False,
        default='',
        max_length=100,
        error_messages=serializers.CommonErrorMessages(_(u'备注')))
    instance = serializers.CharField(
        max_length=100,
        error_messages=serializers.CommonErrorMessages(_(u'所在实例')))
    net = serializers.RegexField(
        regex=REGEXP_NET,
        max_length=100,
        error_messages=serializers.CommonErrorMessages(_(u'所属网络')))
    capacity = serializers.IntegerField(
        error_messages=serializers.CommonErrorMessages(_(u'实例容量')))
示例#8
0
class CreatePortalorderValidator(serializers.Serializer):
    type = serializers.ChoiceField(choices=(PortalOrderType.TEST,
                                            PortalOrderType.FORMAL))

    lessee_id = serializers.CharField(
        max_length=100,
        validators=[username_validator],
        error_messages=serializers.CommonErrorMessages(_(u'租户')))

    seller_name = serializers.CharField(max_length=100)

    seller_id = serializers.CharField(max_length=100)

    duration_type = serializers.ChoiceField(
        choices=(PortalOrderDurationType.MONTH, PortalOrderDurationType.YEAR))

    duration_value = serializers.IntegerField(min_value=1)

    expire_at = serializers.IntegerField(min_value=1486546424)

    cabinet_count = serializers.IntegerField(min_value=0)

    platform_type = serializers.CharField(max_length=100)

    platform_version = serializers.CharField(max_length=100)

    contract_money = serializers.FloatField(min_value=0.01)

    contract_id = serializers.CharField(max_length=100)
示例#9
0
class NewHostSerializer(serializers.Serializer):
    # 所有者
    owner = serializers.CharField(
        required=True,
        max_length=30,
        error_messages=serializers.CommonErrorMessages(_(u"用户")))

    # zone
    zone = serializers.ChoiceField(
        required=True,
        choices=["dev", "test", "prod"],
        error_messages=serializers.CommonErrorMessages(_(u"区域")))

    # 堡垒机IP
    jumper_ip = serializers.IPAddressField(
        required=True,
        error_messages=serializers.CommonErrorMessages(_(u"堡垒机IP")))
    # 主机ID
    instance_id = serializers.CharField(
        required=True,
        max_length=30,
        error_messages=serializers.CommonErrorMessages(_(u"主机ID")))

    # 主机名
    instance_name = serializers.CharField(
        required=True,
        error_messages=serializers.CommonErrorMessages(_(u"主机名称")))

    # 子网ID
    # net_id = serializers.ListField(
    #     required=True,
    #     error_messages=serializers.CommonErrorMessages(_(u"子网ID"))
    # )

    # rdp端口
    rdp_port = serializers.IntegerField(
        required=True,
        max_value=65536,
        error_messages=serializers.CommonErrorMessages(_(u"rdp端口号")))

    # ssh端口
    ssh_port = serializers.IntegerField(
        required=True,
        max_value=65536,
        error_messages=serializers.CommonErrorMessages(_(u"ssh端口号")))

    # rdp键盘记录
    enable_keyboard_record = serializers.BooleanField(
        required=True,
        error_messages=serializers.CommonErrorMessages(_(u"是否启用rdp键盘记录")))

    # rdp打印机/驱动器映射
    enable_disk_redirection = serializers.BooleanField(
        required=True,
        error_messages=serializers.CommonErrorMessages(_(u"是否启用rdp打印机/驱动器映射")))

    # rdp剪切板
    enable_clipboard = serializers.BooleanField(
        required=True,
        error_messages=serializers.CommonErrorMessages(_(u"是否启用rdp剪切板")))
示例#10
0
class CreateInstanceBySuiteValidator(serializers.Serializer):
    id = serializers.CharField(max_length=128)
    count = serializers.IntegerField(min_value=0)
    passwd = serializers.CharField(max_length=128)
    biz = serializers.IntegerField(required=False, min_value=0, default=None)
    compute = serializers.CharField(max_length=100)
    storage = serializers.CharField(max_length=100)
示例#11
0
class ElasticGroupTriggerMonitorSwitchValidator(serializers.Serializer):
    threshold = serializers.IntegerField(min_value=1, max_value=99)
    stat = serializers.ChoiceField(choices=(('avg', 'AVG'), ('min', 'MIN'),
                                            ('max', 'MAX')))
    compare = serializers.ChoiceField(choices=(('ge', 'greater or equal'),
                                               ('le', 'less or equal')))
    step = serializers.IntegerField(min_value=1)
示例#12
0
class CreateLoadbalancerMemberSerializer(serializers.Serializer):
    lb_id = serializers.CharField(required=True,
                                  allow_blank=False,
                                  max_length=20,
                                  validators=[lb_id_validator])

    lbl_id = serializers.CharField(required=True,
                                   allow_blank=False,
                                   max_length=20,
                                   validators=[lbl_id_validator])

    instance_id = serializers.CharField(required=True,
                                        max_length=20,
                                        validators=[instance_id_validator])

    #ip_address = serializers.IPAddressField(
    #    protocol='IPv4'
    #)

    port = serializers.IntegerField(
        required=True,
        min_value=1,
        max_value=65536,
    )

    weight = serializers.IntegerField(
        required=False,
        allow_null=False,
        max_value=100,
        min_value=1,
    )
示例#13
0
class DescribeNoticeValidator(serializers.Serializer):
    page_index = serializers.IntegerField(min_value=1,
                                          default=1,
                                          required=False)
    page_size = serializers.IntegerField(min_value=1,
                                         default=10,
                                         required=False)
示例#14
0
class DescribeMonitorVMInfoValidator(serializers.Serializer):
    num = serializers.IntegerField(
        required=False,
        min_value=0,
        error_messages=serializers.CommonErrorMessages('num'))

    sort = serializers.ChoiceField(
        required=False,
        choices=SORT_METHOD,
        error_messages=serializers.CommonErrorMessages('sort'))

    format = serializers.ChoiceField(
        required=False,
        choices=PERIOD_CHOICE,
        error_messages=serializers.CommonErrorMessages('format'))

    poolname = serializers.CharField(
        required=False,
        error_messages=serializers.CommonErrorMessages('poolname'))

    items = serializers.ListField(
        required=False,
        child=serializers.ChoiceField(required=False, choices=VM_ITEM),
        error_messages=serializers.CommonErrorMessages('items'))

    timestamp = serializers.IntegerField(required=False, validators=[])
    point_num = serializers.IntegerField(required=False, validators=[])

    VM_type = serializers.ChoiceField(
        required=False,
        choices=('KVM', 'VMWARE'),
    )
示例#15
0
class DescribeDisksValidator(serializers.Serializer):

    # 硬盘的唯一id, 非api disk id
    disk_id = serializers.CharField(required=False,
                                    max_length=11,
                                    validators=[disk_id_validator])
    # 特定的要展示的硬盘id
    disks = serializers.ListField(required=False,
                                  validators=[disk_id_validator])

    sort_key = serializers.CharField(required=False,
                                     max_length=20,
                                     validators=[disk_sort_key_valiator])

    limit = serializers.IntegerField(required=False, min_value=0)
    offset = serializers.IntegerField(required=False, min_value=0)

    availability_zone = serializers.CharField(required=False, max_length=64)

    search_key = serializers.CharField(required=False,
                                       max_length=64,
                                       allow_blank=True)

    status = serializers.ChoiceField(
        required=False,
        choices=(('available', u'available'), ('in-use', u'in-use'),
                 ('creating', u'creating'), ('deleting', u'deleting'),
                 ('attaching', u'attaching'), ('detaching', u'detaching'),
                 ('error', u'error'), ('error_deleting', u'error_deleting'),
                 ('backing-up', u'backing-up'), ('restoring-backup',
                                                 u'restoring-backup')))
示例#16
0
class DescribeInstanceQuotaSerializer(serializers.Serializer):
    count = serializers.IntegerField(
        required=True,
        max_value=1000,
        min_value=0,
    )
    capacity = serializers.IntegerField(required=True, validators=[])
示例#17
0
class DescribeBackupsValidator(serializers.Serializer):

    backup_type = serializers.ChoiceField(choices=BACKUP_TYPE_CHOICES)
    resource_id = serializers.CharField(
        max_length=20,
        required=False,
        default=None,
    )
    status = serializers.CharField(
        max_length=100,
        required=False,
        default=None,
    )
    backup_id = serializers.CharField(
        max_length=20,
        required=False,
        default=None,
    )
    instance_to_image = serializers.IntegerField(required=False, min_value=0)
    hypervisor_type = serializers.CharField(required=False, )
    search_key = serializers.CharField(
        required=False,
        default='',
        allow_blank=True,
        max_length=64,
    )
    limit = serializers.IntegerField(required=False, min_value=0)
    offset = serializers.IntegerField(required=False, min_value=0)
示例#18
0
class VirtServValidator(serializers.Serializer):
    id = serializers.IntegerField(
        required=False, error_messages=serializers.CommonErrorMessages('id'))
    cfg_id = serializers.CharField(
        max_length=100,
        error_messages=serializers.CommonErrorMessages(_(u'主机 ID')))
    name = serializers.CharField(
        max_length=100,
        error_messages=serializers.CommonErrorMessages(_(u'主机名')))
    cpu = serializers.IntegerField(
        error_messages=serializers.CommonErrorMessages(_(u'CPU 数')))
    memory = serializers.IntegerField(
        error_messages=serializers.CommonErrorMessages(_(u'内存数')))
    net = serializers.RegexField(
        regex=REGEXP_NET,
        max_length=100,
        error_messages=serializers.CommonErrorMessages(_(u'网络')))
    wan_ip = serializers.RegexField(
        regex=REGEXP_IPS,
        max_length=100,
        error_messages=serializers.CommonErrorMessages(_(u'公网 IP')))
    os = serializers.CharField(max_length=100,
                               error_messages=serializers.CommonErrorMessages(
                                   _(u'操作系统')))
    sys = serializers.CharField(max_length=100,
                                error_messages=serializers.CommonErrorMessages(
                                    _(u'应用系统')))
示例#19
0
class ChangeJumperAccountInfoSerializer(serializers.Serializer):
    jumper_ip = serializers.IPAddressField(
        required=True,
        error_messages=serializers.CommonErrorMessages(_(u"堡垒机IP")))

    host_id = serializers.IntegerField(
        required=True,
        error_messages=serializers.CommonErrorMessages(_(u"主机ID")))

    account_id = serializers.IntegerField(
        required=True,
        error_messages=serializers.CommonErrorMessages(_(u"账户ID")))

    protocol = serializers.ChoiceField(
        choices=["SSH", "RDP"],
        required=True,
        error_messages=serializers.CommonErrorMessages(_(u"协议")))

    auth_mode = serializers.ChoiceField(
        choices=["autoLogin", "manualLogin"],
        required=True,
        error_messages=serializers.CommonErrorMessages(_(u"登录方式")))

    account_name = serializers.CharField(
        required=True,
        error_messages=serializers.CommonErrorMessages(_(u"用户名")))

    password = serializers.CharField(
        required=False,
        default="",
        error_messages=serializers.CommonErrorMessages(_(u"密码")))
示例#20
0
class DescribeRecordsValidator(serializers.Serializer):
    """
    获取用户的操作日志
    """
    # 服务
    service = serializers.CharField(max_length=20,
                                    required=False,
                                    validators=[service_name_validator])
    # 开始日期
    start_date = serializers.DateField(required=False)
    # 结束日期
    end_date = serializers.DateField(required=False)
    # 页数
    page = serializers.IntegerField(required=True,
                                    max_value=settings.MAX_PAGE_NUM,
                                    validators=[page_validator])
    # 每页数量
    page_size = serializers.IntegerField(required=True,
                                         max_value=settings.MAX_PAGE_SIZE)
    # 动作
    action = serializers.CharField(max_length=20,
                                   required=False,
                                   validators=[])
    # 状态
    status = serializers.CharField(
        max_length=20,
        required=False,
    )
示例#21
0
class DescribeAlarmHistoryValidator(serializers.Serializer):
    eventid = serializers.CharField(required=False,
                                    max_length=64,
                                    validators=[])
    page = serializers.IntegerField(required=True, min_value=1, validators=[])
    pagesize = serializers.IntegerField(required=True,
                                        min_value=1,
                                        validators=[])
示例#22
0
class ListTrashDiskValidator(serializers.Serializer):
    hyperType = serializers.CharField(required=True, )
    diskType = serializers.CharField(required=True, )
    searchWord = serializers.CharField(
        required=True,
        allow_blank=True,
    )
    pageNum = serializers.IntegerField()
    pageSize = serializers.IntegerField()
示例#23
0
class UpdateLoadbalancerListenerSerializer(serializers.Serializer):
    lb_id = serializers.CharField(required=True,
                                  allow_blank=False,
                                  max_length=20,
                                  validators=[lb_id_validator])

    lbl_id = serializers.CharField(required=True,
                                   allow_blank=False,
                                   max_length=20,
                                   validators=[lbl_id_validator])

    lbl_name = serializers.CharField(required=True,
                                     allow_blank=True,
                                     max_length=20,
                                     validators=[])

    lb_algorithm = serializers.ChoiceField(required=True,
                                           allow_blank=False,
                                           choices=LB_ALGORITHM_CHOICES)

    health_check_type = serializers.ChoiceField(
        required=True, allow_blank=False, choices=HEALTH_CHECK_TYPE_CHOICES)

    health_check_delay = serializers.IntegerField(required=True,
                                                  min_value=1,
                                                  max_value=300)

    health_check_timeout = serializers.IntegerField(required=True,
                                                    min_value=1,
                                                    max_value=50)

    health_check_max_retries = serializers.IntegerField(required=True,
                                                        min_value=2,
                                                        max_value=10)

    health_check_url_path = serializers.CharField(required=False,
                                                  allow_blank=False,
                                                  max_length=255,
                                                  default="/")

    health_check_expected_codes = serializers.CharField(
        required=False,
        allow_blank=False,
        max_length=9,
        validators=[health_check_expected_codes_validator],
        default="2")

    session_persistence_type = serializers.ChoiceField(
        required=True,
        choices=SESSION_PERSISTENCE_TYPE_CHOICES,
    )

    cookie_name = serializers.CharField(required=False,
                                        allow_blank=False,
                                        max_length=1024,
                                        validators=[])
示例#24
0
class UpdateMonitorTemplateRuleValidator(serializers.Serializer):
    id = serializers.CharField(max_length=128)
    compare = serializers.CharField(max_length=128)
    threshold = serializers.IntegerField(min_value=0,
                                         default=80,
                                         required=False)
    times = serializers.IntegerField(min_value=0, default=3, required=False)
    action = serializers.CharField(max_length=128,
                                   default='always',
                                   required=False)
示例#25
0
class DescribeCmdbValidator(serializers.Serializer):
    type = serializers.ChoiceField(
        choices=CFG_TYPE_CHOICES,
        error_messages=serializers.CommonErrorMessages('type'))
    keyword = serializers.CharField(
        required=False,
        default=None,
        max_length=100,
        error_messages=serializers.CommonErrorMessages(_(u'查询关键字')))
    page_index = serializers.IntegerField(required=False, default=1)
    page_size = serializers.IntegerField(required=False, default=0)
示例#26
0
class SingleMonitorValidator(serializers.Serializer):
    instance_id = serializers.CharField(required=True,
                                        max_length=60,
                                        validators=[])
    data_fmt = serializers.ChoiceField(required=True,
                                       choices=model.PERIOD_CHOICE)
    item_set = serializers.DictField(
        required=False, validators=[single_host_monitor_validator])
    timestamp = serializers.IntegerField(required=False, validators=[])
    point_num = serializers.IntegerField(required=False, validators=[])
    standard_point_num = serializers.CharField(required=False, validators=[])
示例#27
0
class AddInstanceTypesSerializer(serializers.Serializer):
    # 因为 flavor id 的生成算法有溢出漏洞
    # ram 和 vcpus 必须限制在 100 以内
    zone = serializers.CharField(required=True)
    owner = serializers.CharField(required=True)
    flavor_name = serializers.CharField(required=True)
    ram = serializers.IntegerField(required=True, min_value=1, max_value=99)
    vcpus = serializers.IntegerField(required=True, min_value=1, max_value=99)
    disk = serializers.IntegerField(required=True, min_value=20)
    is_public = serializers.BooleanField(required=True)
    tenant_list = serializers.CharField(required=False)
示例#28
0
class CreateMonitorRemoteBusinessValidator(serializers.Serializer):
    type = serializers.CharField(max_length=128)
    business = serializers.CharField(max_length=128)
    targets = serializers.ListField(child=serializers.CharField(
        max_length=128))
    executor = serializers.CharField(max_length=128)
    cycle = serializers.IntegerField(min_value=0, default=60, required=False)
    tries = serializers.IntegerField(min_value=0, default=5, required=False)
    when = serializers.ListField(child=serializers.CharField(max_length=128))
    who = serializers.CharField(max_length=128)
    how = serializers.ListField(child=serializers.CharField(max_length=128))
示例#29
0
class CreateBackupsValidator(serializers.Serializer):
    # 被备份的资源id

    resource_id = serializers.CharField(max_length=20,
                                        validators=[resource_id_validator])
    backup_name = serializers.CharField(max_length=30)
    charge_mode = serializers.ChoiceField(choices=('pay_on_time',
                                                   'pay_by_month',
                                                   'pay_by_year'))
    package_size = serializers.IntegerField(min_value=0)

    instance_to_image = serializers.IntegerField(required=False, min_value=0)
示例#30
0
class DescribeOverviewTicketsValidator(serializers.Serializer):

    num = serializers.IntegerField(
        required=True,
        min_value=0,
        error_messages=serializers.CommonErrorMessages('num'))

    type = serializers.IntegerField(
        required=True,
        min_value=0,
        max_value=6,
        error_messages=serializers.CommonErrorMessages('type'))