Example #1
0
class UpdateRdsConfigValidator(serializers.Serializer):
    config_id = serializers.CharField(
        required=True,
        validators=[config_id_validator],
        error_messages=serializers.CommonErrorMessages('config_id'))
    configurations = serializers.DictField(
        required=True,
        error_messages=serializers.CommonErrorMessages('configurations'))
Example #2
0
class UpdateAlarmRuleValidator(serializers.Serializer):
    alarm_id = serializers.CharField(required=True,
                                     max_length=20,
                                     validators=[alarm_id_validator])
    rule_id = serializers.CharField(required=True,
                                    max_length=20,
                                    validators=[alarm_rule_id_validator])
    trigger_condition = serializers.DictField(required=True, validators=[])
Example #3
0
class GetRdsIOPSInfoValidator(serializers.Serializer):
    rds_info = serializers.DictField(required=False, validators=[])

    def validate(self, attrs):
        if attrs.get("rds_info"):
            if 'flavor_id' not in attrs.get("rds_info") or \
                    'volume_type' not in attrs.get("rds_info"):
                raise serializers.ValidationError(
                    "rds_info should contain flavor_id and volume_type")
        return attrs
Example #4
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=[])
Example #5
0
class ModifyRdsAccountAuthorityValidator(serializers.Serializer):
    username = serializers.CharField(
        required=True,
        max_length=32,
        validators=[db_account_validator],
        error_messages=serializers.CommonErrorMessages('username'))
    rds_id = serializers.CharField(
        required=True,
        validators=[rds_id_validator],
        error_messages=serializers.CommonErrorMessages('rds_id'))
    grant = serializers.DictField(
        required=True,
        validators=[account_authority_vaidator],
        error_messages=serializers.CommonErrorMessages('grant'))
Example #6
0
class UpdateBoardFrameValidator(ValidatorBase):

    owner = serializers.CharField(
        max_length=32,
        error_messages=serializers.CommonErrorMessages('owner')
    )
    frame_id = serializers.CharField(
        max_length=32,
        error_messages=serializers.CommonErrorMessages('frame_id')
    )
    meta_data = serializers.DictField(
        validators=[validate_meta_data],
        error_messages=serializers.CommonErrorMessages('meta_data')
    )

    def handler(self, validated_data):
        frame = FrameModel.objects.update_frame(
            validated_data['owner'],
            validated_data['frame_id'],
            validated_data['meta_data']
        )
        serializer = FrameSerializer(frame)
        return ConsoleResponse(ret_set=serializer.data)
Example #7
0
class CreateAlarmValidator(serializers.Serializer):
    alarm_name = serializers.CharField(required=True,
                                       max_length=100,
                                       validators=[])
    resource_type = serializers.ChoiceField(required=True,
                                            choices=resource_type_choice,
                                            validators=[])
    period = serializers.IntegerField(required=True,
                                      min_value=1,
                                      validators=[])
    trigger_condition = serializers.ListField(child=serializers.DictField(),
                                              required=True,
                                              validators=[])
    resource = serializers.ListField(required=True, validators=[])
    notify_at = serializers.CharField(required=True,
                                      max_length=100,
                                      validators=[])
    notify_group_id = serializers.CharField(required=True,
                                            max_length=20,
                                            validators=[group_id_validator])
    notify_method = serializers.CharField(required=True,
                                          max_length=100,
                                          validators=[])
Example #8
0
class CreateRdsAccountValidator(serializers.Serializer):
    username = serializers.CharField(
        required=True,
        max_length=16,
        validators=[db_account_validator],
        error_messages=serializers.CommonErrorMessages('username'))
    password = serializers.CharField(
        required=True,
        validators=[password_validator],
        error_messages=serializers.CommonErrorMessages('password'))
    rds_id = serializers.CharField(
        required=True,
        validators=[rds_id_validator],
        error_messages=serializers.CommonErrorMessages('rds_id'))
    grant = serializers.DictField(
        required=True,
        validators=[account_authority_vaidator],
        error_messages=serializers.CommonErrorMessages('grant'))
    notes = serializers.CharField(
        required=True,
        allow_null=True,
        allow_blank=True,
        max_length=100,
        error_messages=serializers.CommonErrorMessages('notes'))
Example #9
0
class CreateRdsConfigValidator(serializers.Serializer):
    db_version_id = serializers.CharField(
        required=True,
        validators=[db_version_id_validator],
        error_messages=serializers.CommonErrorMessages('db_version_id'))
    config_name = serializers.CharField(
        required=True,
        min_length=2,
        max_length=32,
        allow_null=False,
        validators=[config_name_validator],
        error_messages=serializers.CommonErrorMessages('config_name'))
    config_type = serializers.ChoiceField(
        required=True,
        choices=CONFIG_TYPE_CHOICE,
        error_messages=serializers.CommonErrorMessages('config_type'))
    description = serializers.CharField(
        required=False,
        max_length=100,
        error_messages=serializers.CommonErrorMessages('description'))
    reference_id = serializers.CharField(
        required=False,
        validators=[config_id_validator],
        error_messages=serializers.CommonErrorMessages('reference_id'))
    configurations = serializers.DictField(
        required=False,
        validators=[],
        error_messages=serializers.CommonErrorMessages('configurations'))

    def validate(self, attrs):
        if not attrs.get("reference_id") and \
                not attrs.get("configurations"):
            raise serializers.ValidationError(
                "need at least one of "
                "reference_id and configurations")
        return attrs
Example #10
0
class AddTicketProcessSerializer(serializers.Serializer):
    owner = serializers.CharField(required=False)
    zone = serializers.CharField(required=True)
    ticket_id = serializers.CharField(required=False, default=None)
    ticket_type = serializers.CharField(required=False, default=None)
    fill_data = serializers.DictField(required=True)
Example #11
0
class DeleteNetValidator(serializers.Serializer):
    nets = serializers.ListField(
        required=True,
        child=serializers.DictField(),
    )