def _verify_duplicate_subscription(self, subscriber_name, subscriber_row,
                                       subscription_row, subscription_schema,
                                       resource_uri):
        app_log.debug("Verifying if the subscription is a duplicate")
        subscriber_subscriptions = \
            get_column_data_from_row(subscriber_row,
                                     subscription_schema.plural_name)

        # Length == 1 indicates this is the only subscription
        if not subscriber_subscriptions or \
                len(subscriber_subscriptions) == 1:
            app_log.debug("No duplicate resource subscriptions detected.")
            return

        # Compare the resource URI of the new subscription to parent's
        # subscription resource URIs
        for sub_name, sub_row in subscriber_subscriptions.iteritems():
            # Skip if the subscription row is the current one that is
            # being validated
            if sub_row == subscription_row:
                continue

            curr_resource_uri = get_column_data_from_row(
                sub_row, SUBSCRIPTION_URI)

            if curr_resource_uri == resource_uri:
                app_log.debug("Duplicate resource URI detected")
                details = "Subscriber: %s. " % subscriber_name
                details += "URI %s already exists" % resource_uri
                raise ValidationError(error.DUPLICATE_RESOURCE, details)
示例#2
0
    def validate_modification(self, validation_args):
        option_name = None
        option_number = None
        match_tags = None
        DHCPSrv_Option_row = validation_args.resource_row

        if hasattr(DHCPSrv_Option_row, "option_name"):
            option_name = get_column_data_from_row(DHCPSrv_Option_row,
                                                   "option_name")
        if (option_name is not None):
            for name in option_name:
                if (not dhcptftpservervalidations.is_valid_tag(name)):
                    details = "%s is invalid." % (name)
                    raise ValidationError(error.VERIFICATION_FAILED, details)

        if hasattr(DHCPSrv_Option_row, "match_tags"):
            match_tags = get_column_data_from_row(DHCPSrv_Option_row,
                                                  "match_tags")
        if (match_tags is not None) and \
           (not dhcptftpservervalidations.is_valid_tags(match_tags)):
            details = "%s is invalid." % (match_tags)
            raise ValidationError(error.VERIFICATION_FAILED, details)

        if hasattr(DHCPSrv_Option_row, "option_number"):
            option_number = get_column_data_from_row(DHCPSrv_Option_row,
                                                     "option_number")
        if (option_number is not None):
            for number in option_number:
                if (not dhcptftpservervalidations.is_valid_option_number(
                        number)):
                    details = "%s is invalid." % (number)
                    raise ValidationError(error.VERIFICATION_FAILED, details)
示例#3
0
 def validate_deletion(self, validation_args):
     intf_row = validation_args.resource_row
     intf_type = get_column_data_from_row(intf_row, "type")
     intf_name = get_column_data_from_row(intf_row, "name")
     if intf_type == 'system':
         details = "Physical interfaces cannot be deleted"
         raise ValidationError(error.VERIFICATION_FAILED, details)
     if intf_type == 'internal' and intf_name == 'bridge_normal':
         details = "Bridge_normal interface cannot be deleted"
         raise ValidationError(error.VERIFICATION_FAILED, details)
示例#4
0
    def validate_apply_global_profiles_contain_same_queues(self, system_row):
        q_profile = utils.get_column_data_from_row(system_row, "q_profile")
        if not q_profile:
            return

        schedule_profile = utils.get_column_data_from_row(system_row, "qos")
        if not schedule_profile:
            return

        qos_utils.validate_profiles_contain_same_queues(
            q_profile[0], schedule_profile[0])
示例#5
0
    def validate_apply_global_profiles_contain_same_queues(self, system_row):
        q_profile = utils.get_column_data_from_row(system_row, "q_profile")
        if not q_profile:
            return

        schedule_profile = utils.get_column_data_from_row(system_row, "qos")
        if not schedule_profile:
            return

        qos_utils.validate_profiles_contain_same_queues(
            q_profile[0], schedule_profile[0])
示例#6
0
 def validate_sflow_config_supported(self, port_row):
     interface_rows = utils.get_column_data_from_row(port_row, "interfaces")
     if len(interface_rows) == 0:
         # No interfaces associated with port entry
         return
     for interface_row in interface_rows:
         interface_type = utils.get_column_data_from_row(
             interface_row, "type")
         if interface_type != "system":
             details = "sFlow configuration is only supported on "\
                       "physical interfaces"
             raise ValidationError(error.VERIFICATION_FAILED, details)
示例#7
0
 def validate_modification(self, validation_args):
     system_row = validation_args.resource_row
     if hasattr(system_row, "timezone"):
         timezone = get_column_data_from_row(system_row, "timezone")[0]
         if (check_valid_timezone(timezone) is False):
             details = "Invalid timezone %s." % (timezone)
             raise ValidationError(error.VERIFICATION_FAILED, details)
示例#8
0
def schedule_profile_has_queue_num(schedule_profile, queue_num):
    schedule_profile_entries = utils.get_column_data_from_row(
        schedule_profile, "queues")
    for profile_queue_num in schedule_profile_entries.keys():
        if queue_num == profile_queue_num:
            return True
    return False
示例#9
0
def validate_schedule_profile_has_same_algorithm_on_all_queues(
        schedule_profile):
    # The profile named 'strict' is exempt, since it is a special case. #
    if schedule_profile.name == QOS_STRICT:
        return

    queues = utils.get_column_data_from_row(schedule_profile, "queues")

    if len(queues) == 0:
        details = "The schedule profile must have at least one queue."
        raise ValidationError(error.VERIFICATION_FAILED, details)

    max_queue_num = get_max_queue_num(schedule_profile)

    algorithm = ""
    for queue_entry in queues.items():
        queue_num = queue_entry[0]
        schedule_profile_entry = queue_entry[1]

        schedule_profile_entry_algorithm = schedule_profile_entry.algorithm[0]

        # If it's the max and it's strict, then skip it. #
        if max_queue_num == queue_num and \
                schedule_profile_entry_algorithm == QOS_STRICT:
            continue

        if algorithm == "":
            algorithm = schedule_profile_entry_algorithm

        if schedule_profile_entry_algorithm != algorithm:
            details = "The schedule profile must have " + \
                "the same algorithm on all queues."
            raise ValidationError(error.VERIFICATION_FAILED, details)
示例#10
0
    def profile_has_local_priority(self, q_profile, local_priority):
        q_profile_entries = utils.get_column_data_from_row(
            q_profile, "q_profile_entries")
        for q_profile_entry in q_profile_entries.values():
            if self.queue_has_local_priority(q_profile_entry, local_priority):
                return True

        return False
示例#11
0
    def queue_has_local_priority(self, q_profile_entry, local_priority):
        local_priorities = utils.get_column_data_from_row(
            q_profile_entry, "local_priorities")
        for local_priority_from_row in local_priorities:
            if local_priority_from_row == local_priority:
                return True

        return False
示例#12
0
    def validate_apply_global_s_p_has_same_algorithm_on_all_queues(
            self, system_row):
        schedule_profile = utils.get_column_data_from_row(system_row, "qos")
        if not schedule_profile:
            return

        qos_utils.validate_schedule_profile_has_same_algorithm_on_all_queues(
            schedule_profile[0])
示例#13
0
    def queue_has_local_priority(self, q_profile_entry, local_priority):
        local_priorities = utils.get_column_data_from_row(
            q_profile_entry, "local_priorities")
        for local_priority_from_row in local_priorities:
            if local_priority_from_row == local_priority:
                return True

        return False
示例#14
0
    def profile_has_local_priority(self, q_profile, local_priority):
        q_profile_entries = utils.get_column_data_from_row(
            q_profile, "q_profile_entries")
        for q_profile_entry in q_profile_entries.values():
            if self.queue_has_local_priority(q_profile_entry, local_priority):
                return True

        return False
示例#15
0
    def validate_apply_port_queue_profile_is_null(self, port_row):
        if not hasattr(port_row, 'q_profile'):
            return

        q_profile = utils.get_column_data_from_row(port_row, "q_profile")
        if q_profile != []:
            details = "Port-level queue profile is not supported."
            raise ValidationError(error.VERIFICATION_FAILED, details)
示例#16
0
 def validate_modification(self, validation_args):
     ntp_association_row = validation_args.resource_row
     if hasattr(ntp_association_row, "address"):
         ip_address = get_column_data_from_row(ntp_association_row,
                                               "address")
         if (not ipaddress.is_valid_ip_address(ip_address)):
             details = "Invalid IP address %s." % (ip_address)
             raise ValidationError(error.VERIFICATION_FAILED, details)
示例#17
0
    def validate_apply_global_s_p_has_same_algorithm_on_all_queues(
            self, system_row):
        schedule_profile = utils.get_column_data_from_row(system_row, "qos")
        if not schedule_profile:
            return

        qos_utils.validate_schedule_profile_has_same_algorithm_on_all_queues(
            schedule_profile[0])
示例#18
0
    def validate_apply_global_q_p_has_no_duplicate_local_priorities(
            self, system_row):
        found_local_priorities = []

        q_profile = utils.get_column_data_from_row(system_row, "q_profile")
        if not q_profile:
            return

        q_profile_entries = utils.get_column_data_from_row(
            q_profile[0], "q_profile_entries")
        for q_profile_entry in q_profile_entries.values():
            local_priorities = q_profile_entry.local_priorities
            for local_priority in local_priorities:
                if local_priority in found_local_priorities:
                    details = "The queue profile has local priority " + \
                        str(local_priority) + " assigned more than once."
                    raise ValidationError(error.VERIFICATION_FAILED, details)
                found_local_priorities.append(local_priority)
示例#19
0
 def validate_modification(self, validation_args):
     dhcp_server_row = validation_args.resource_row
     if hasattr(dhcp_server_row, "bootp"):
         bootp = get_column_data_from_row(dhcp_server_row, "bootp")
         tag_value = bootp.get("match tag", None)
         if (tag_value is not None) and \
            (not dhcptftpservervalidations.is_valid_tag(tag_value)):
             details = "%s is invalid." % (tag_value)
             raise ValidationError(error.VERIFICATION_FAILED, details)
示例#20
0
    def validate_apply_global_q_p_has_no_duplicate_local_priorities(
            self, system_row):
        found_local_priorities = []

        q_profile = utils.get_column_data_from_row(system_row, "q_profile")
        if not q_profile:
            return

        q_profile_entries = utils.get_column_data_from_row(
            q_profile[0], "q_profile_entries")
        for q_profile_entry in q_profile_entries.values():
            local_priorities = q_profile_entry.local_priorities
            for local_priority in local_priorities:
                if local_priority in found_local_priorities:
                    details = "The queue profile has local priority " + \
                        str(local_priority) + " assigned more than once."
                    raise ValidationError(error.VERIFICATION_FAILED, details)
                found_local_priorities.append(local_priority)
示例#21
0
    def validate_apply_port_profiles_contain_same_queues(
            self, port_row, system_row):
        if not hasattr(port_row, 'qos'):
            return

        schedule_profile = utils.get_column_data_from_row(port_row, "qos")
        if schedule_profile == []:
            return

        if not hasattr(system_row, 'q_profile'):
            return

        queue_profile = utils.get_column_data_from_row(system_row, "q_profile")
        if queue_profile == []:
            return

        qos_utils.validate_profiles_contain_same_queues(
            queue_profile[0], schedule_profile[0])
示例#22
0
    def validate_deletion(self, validation_args):
        app_log.debug("Verifying if the subscriber can be deleted..")
        subscriber_row = validation_args.resource_row
        subscriber_name = get_column_data_from_row(subscriber_row,
                                                   SUBSCRIBER_NAME)

        if self._is_websocket_subscriber(subscriber_row):
            details = "Subscriber: %s. " % subscriber_name
            details += "Cannot explicitly delete WebSocket based subscriber"
            raise ValidationError(error.METHOD_PROHIBITED, details)
示例#23
0
def validate_profiles_contain_same_queues(q_profile, schedule_profile):
    # The profile named 'strict' is exempt, since it is a special case. #
    if schedule_profile.name == QOS_STRICT:
        return

    queues = utils.get_column_data_from_row(schedule_profile, "queues")
    for queue_num in queues.keys():
        if not queue_profile_has_queue_num(q_profile, queue_num):
            details = "The queue profile must contain " + \
                "all of the schedule profile queue numbers."
            raise ValidationError(error.VERIFICATION_FAILED, details)

    q_profile_entries = utils.get_column_data_from_row(
        q_profile, "q_profile_entries")
    for queue_num in q_profile_entries.keys():
        if not schedule_profile_has_queue_num(schedule_profile, queue_num):
            details = "The schedule profile must contain " + \
                "all of the queue profile queue numbers."
            raise ValidationError(error.VERIFICATION_FAILED, details)
示例#24
0
    def validate_apply_port_s_p_has_all_same_algorithm_on_all_queues(
            self, port_row):
        if not hasattr(port_row, 'qos'):
            return

        schedule_profile = utils.get_column_data_from_row(port_row, "qos")
        if schedule_profile == []:
            return

        qos_utils.validate_schedule_profile_has_same_algorithm_on_all_queues(
            schedule_profile[0])
示例#25
0
    def qos_trust_port_get_value(self, port_row, system_row):
        qos_trust_name = qos_utils.QOS_TRUST_NONE_STRING

        if system_row is not None:
            if hasattr(system_row, 'qos_config'):
                qos_config = utils.get_column_data_from_row(system_row,
                                                            "qos_config")
                system_value = qos_config.get(qos_utils.QOS_TRUST_KEY, None)
                if system_value is not None:
                    qos_trust_name = system_value

        if port_row is not None:
            if hasattr(port_row, 'qos_config'):
                qos_config = utils.get_column_data_from_row(port_row,
                                                            "qos_config")
                port_value = qos_config.get(qos_utils.QOS_TRUST_KEY, None)
                if port_value is not None:
                    qos_trust_name = port_value

        return qos_trust_name
示例#26
0
 def validate_modification(self, validation_args):
     system_row = validation_args.resource_row
     if hasattr(system_row, "other_config"):
         other_config = get_column_data_from_row(system_row, "other_config")
         tftp_server_path_value = other_config.get("tftp_server_path", None)
         if (tftp_server_path_value is not None) and \
            (not self.is_valid_tftp_server_path(tftp_server_path_value)):
             details = "The directory %s does not exist. " \
                       "Please configure a valid absolute path." \
                       % (tftp_server_path_value)
             raise ValidationError(error.VERIFICATION_FAILED, details)
示例#27
0
    def validate_apply_port_profiles_contain_same_queues(
            self, system_row, validation_args):
        idl = validation_args.idl

        q_profile = utils.get_column_data_from_row(system_row, "q_profile")
        if not q_profile:
            return

        for port_row in idl.tables["Port"].rows.itervalues():
            if len(port_row.qos) != 0:
                qos_utils.validate_profiles_contain_same_queues(
                    q_profile[0], port_row.qos[0])
示例#28
0
    def validate_apply_global_queue_profile_has_all_local_priorities(
            self, system_row):
        q_profile = utils.get_column_data_from_row(system_row, "q_profile")
        if not q_profile:
            return

        for local_priority in range(0, qos_utils.QOS_MAX_LOCAL_PRIORITY + 1):
            if not self.profile_has_local_priority(q_profile[0],
                                                   local_priority):
                details = "The queue profile is missing local priority " + \
                    str(local_priority) + "."
                raise ValidationError(error.VERIFICATION_FAILED, details)
示例#29
0
    def validate_apply_global_queue_profile_has_all_local_priorities(
            self, system_row):
        q_profile = utils.get_column_data_from_row(system_row, "q_profile")
        if not q_profile:
            return

        for local_priority in range(0, qos_utils.QOS_MAX_LOCAL_PRIORITY + 1):
            if not self.profile_has_local_priority(
                    q_profile[0], local_priority):
                details = "The queue profile is missing local priority " + \
                    str(local_priority) + "."
                raise ValidationError(error.VERIFICATION_FAILED, details)
示例#30
0
    def validate_apply_port_profiles_contain_same_queues(
            self, system_row, validation_args):
        idl = validation_args.idl

        q_profile = utils.get_column_data_from_row(system_row, "q_profile")
        if not q_profile:
            return

        for port_row in idl.tables["Port"].rows.itervalues():
            if len(port_row.qos) != 0:
                qos_utils.validate_profiles_contain_same_queues(
                    q_profile[0], port_row.qos[0])
    def validate_modification(self, validation_args):
        if validation_args.is_new:
            schema = validation_args.schema
            idl = validation_args.idl
            subscriber_row = validation_args.p_resource_row
            subscription_row = validation_args.resource_row
            subscription_schema = validation_args.resource_schema

            subscriber_name = get_column_data_from_row(subscriber_row,
                                                       SUBSCRIBER_NAME)
            resource_uri = get_column_data_from_row(subscription_row,
                                                    SUBSCRIPTION_URI)

            app_log.debug("Verifying if subscription can be added for "
                          "subscriber %s" % subscriber_name)

            self._verify_duplicate_subscription(subscriber_name,
                                                subscriber_row,
                                                subscription_row,
                                                subscription_schema,
                                                resource_uri)

            self._verify_valid_resource_uri(subscriber_name, subscription_row,
                                            resource_uri, schema, idl)
示例#32
0
    def subscription_changes_check_callback(self, manager, idl):
        """
        Callback method invoked by manager of the IDL used for detecting
        notification subscription changes.
        """
        table_changes = \
            notifutils.get_table_changes_from_idl(consts.SUBSCRIPTION_TABLE,
                                                  idl)

        for sub_uuid, sub_changes in table_changes.iteritems():
            seqno = manager.curr_seqno

            if notifutils.is_resource_added(sub_changes, seqno):
                subscription_row = \
                    idl.tables[consts.SUBSCRIPTION_TABLE].rows[sub_uuid]

                subscription_name = \
                    utils.get_table_key(subscription_row,
                                        consts.SUBSCRIPTION_TABLE,
                                        self._schema, idl)

                # Only one key, so grab the first index
                subscription_name = subscription_name[0]

                app_log.debug("Subscription added for: \"%s\"" %
                              subscription_name)

                resource_uri = \
                    utils.get_column_data_from_row(subscription_row,
                                                   consts.SUBSCRIPTION_URI)

                try:
                    subscription = \
                        yield self.create_subscription(subscription_name,
                                                       subscription_row,
                                                       resource_uri,
                                                       idl)

                    yield self.get_initial_values_and_notify(idl, subscription)
                    self.add_subscription(sub_uuid, subscription)
                except Exception as e:
                    app_log.error("Error while creating subscription: %s" % e)

            elif notifutils.is_resource_deleted(sub_changes, seqno):
                app_log.debug("Subscription was deleted.")
                self.remove_subscription(sub_uuid)
示例#33
0
    def validate_port_override_has_port_trust_mode_none(
            self, port_row, system_row, qos_config_key, display_string):
        if not hasattr(port_row, 'qos_config'):
            return

        qos_config = utils.get_column_data_from_row(port_row, "qos_config")

        qos_override = qos_config.get(qos_config_key, None)
        if qos_override is None:
            return

        # Cos override is not supported for dill.
        if qos_config_key == qos_utils.QOS_COS_OVERRIDE_KEY:
            details = "QoS " + display_string + \
                " override is not currently supported."
            raise ValidationError(error.VERIFICATION_FAILED, details)

        qos_trust_value = self.qos_trust_port_get_value(port_row, system_row)
        if qos_trust_value is None or \
                qos_trust_value != qos_utils.QOS_TRUST_NONE_STRING:
            details = "QoS " + display_string + \
                " override is only allowed if the trust mode is 'none'."
            raise ValidationError(error.VERIFICATION_FAILED, details)
示例#34
0
    def validate_modification(self, validation_args):
        lease_duration = None
        start_ip_address = None
        end_ip_address = None
        name = None
        set_tag = None
        match_tags = None
        netmask = None
        broadcast = None
        prefix_len = None
        net_mask = None
        end_ip = None
        broad_cast = None
        prefixlen = None

        DHCPSrv_Range_row = validation_args.resource_row
        name = get_column_data_from_row(DHCPSrv_Range_row, "name")
        if not dhcptftpservervalidations.is_valid_tag(name):
            details = "%s is invalid." % (name)
            raise ValidationError(error.VERIFICATION_FAILED, details)

        start_ip_address = get_column_data_from_row(DHCPSrv_Range_row,
                                                    "start_ip_address")

        if not ipaddress.is_valid_ip_address(start_ip_address):
            details = "%s is invalid." % (start_ip_address)
            raise ValidationError(error.VERIFICATION_FAILED, details)

        if hasattr(DHCPSrv_Range_row, "end_ip_address"):
            end_ip_address = get_column_data_from_row(DHCPSrv_Range_row,
                                                      "end_ip_address")

        if (end_ip_address is not None):
            for ip in end_ip_address:
                end_ip = ip
                if (not ipaddress.is_valid_ip_address(ip)):
                    details = "%s is invalid." % (ip)
                    raise ValidationError(error.VERIFICATION_FAILED, details)

        if hasattr(DHCPSrv_Range_row, "lease_duration"):
            lease_duration = get_column_data_from_row(DHCPSrv_Range_row,
                                                      "lease_duration")

        if (lease_duration is not None):
            for duration in lease_duration:
                if (not dhcptftpservervalidations.is_valid_lease_duration(
                        duration)):
                    details = "Lease duration should be 0 for infinite or " \
                              "between 2-65535."
                    raise ValidationError(error.VERIFICATION_FAILED, details)

        if (start_ip_address is not None) and \
           (end_ip is not None) and \
           (ipaddress.ip_type(start_ip_address) != ipaddress.ip_type(end_ip)):
            details = "Invalid IP address range"
            raise ValidationError(error.VERIFICATION_FAILED, details)

        if hasattr(DHCPSrv_Range_row, "set_tag"):
            set_tag = get_column_data_from_row(DHCPSrv_Range_row, "set_tag")

        if (set_tag is not None):
            for tag in set_tag:
                if (not dhcptftpservervalidations.is_valid_tag(tag)):
                    details = "%s is invalid." % (tag)
                    raise ValidationError(error.VERIFICATION_FAILED, details)

        if hasattr(DHCPSrv_Range_row, "match_tags"):
            match_tags = get_column_data_from_row(DHCPSrv_Range_row,
                                                  "match_tags")

        if (match_tags is not None) and \
           (not dhcptftpservervalidations.is_valid_tags(match_tags)):
            details = "%s is invalid." % (match_tags)
            raise ValidationError(error.VERIFICATION_FAILED, details)

        if hasattr(DHCPSrv_Range_row, "netmask"):
            netmask = get_column_data_from_row(DHCPSrv_Range_row, "netmask")

        if (netmask is not None):
            for mask in netmask:
                net_mask = mask
                if (not ipaddress.is_valid_netmask(mask)):
                    details = "%s is invalid." % (mask)
                    raise ValidationError(error.VERIFICATION_FAILED, details)

        if (start_ip_address is not None) and \
           (end_ip is not None) and \
           (net_mask is not None) and \
           (ipaddress.ip_type(start_ip_address) == 0) and \
           (not ipaddress.is_valid_net(start_ip_address, end_ip, net_mask)):
            details = "Invalid IP address range."
            raise ValidationError(error.VERIFICATION_FAILED, details)

        if (start_ip_address is not None) and \
           (ipaddress.ip_type(start_ip_address) == 1) and \
           (net_mask is not None):
            details = "Error : netmask configuration not allowed for IPv6"
            raise ValidationError(error.VERIFICATION_FAILED, details)

        if hasattr(DHCPSrv_Range_row, "broadcast"):
            broadcast = get_column_data_from_row(DHCPSrv_Range_row,
                                                 "broadcast")

        if broadcast is not None:
            for b in broadcast:
                broad_cast = b

        if (start_ip_address is not None) and \
           (ipaddress.ip_type(start_ip_address) == 0) and \
           (net_mask is not None) and \
           (broad_cast is not None) and \
           (not ipaddress.is_valid_broadcast_addr(start_ip_address,
                                                  net_mask,
                                                  broad_cast)):
            details = "%s is invalid." % (broad_cast)
            raise ValidationError(error.VERIFICATION_FAILED, details)

        if (start_ip_address is not None) and \
           (broad_cast is not None) and \
           (net_mask is None):
            details = "Error : netmask must be specified before broadcast " \
                      "address"
            raise ValidationError(error.VERIFICATION_FAILED, details)

        if (start_ip_address is not None) and \
           (net_mask is not None) and \
           (broad_cast is not None) and \
           (ipaddress.ip_type(start_ip_address) == 1):
            details = "Error : broadcast address not allowed for IPv6"
            raise ValidationError(error.VERIFICATION_FAILED, details)

        if hasattr(DHCPSrv_Range_row, "prefix_len"):
            prefix_len = get_column_data_from_row(DHCPSrv_Range_row,
                                                  "prefix_len")

        if prefix_len is not None:
            for p in prefix_len:
                prefixlen = p

        if (start_ip_address is not None) and \
           (end_ip is not None) and \
           (prefixlen is not None) and \
           (ipaddress.ip_type(start_ip_address) != 1):
            details = "Error: prefix length configuration not allowed for IPv4"
            raise ValidationError(error.VERIFICATION_FAILED, details)
示例#35
0
 def _get_subscriber_name(self, subscriber_row, idl):
     return utils.get_column_data_from_row(subscriber_row,
                                           consts.SUBSCRIBER_NAME)
示例#36
0
 def validate_trust_global_is_not_empty(self, system_row):
     qos_config = utils.get_column_data_from_row(system_row, "qos_config")
     qos_trust_value = qos_config.get(qos_utils.QOS_TRUST_KEY, None)
     if qos_trust_value is None:
         details = "The qos trust value cannot be empty."
         raise ValidationError(error.VERIFICATION_FAILED, details)
    def validate_modification(self, validation_args):
        mac_addresses = None
        set_tags = None
        client_id = None
        client_hostname = None
        lease_duration = None

        DHCPSrv_Static_Host = validation_args.resource_row
        ip_address = get_column_data_from_row(DHCPSrv_Static_Host,
                                              "ip_address")

        if not ipaddress.is_valid_ip_address(ip_address):
            details = "%s is an invalid IP address." % (ip_address)
            raise ValidationError(error.VERIFICATION_FAILED, details)

        if hasattr(DHCPSrv_Static_Host, "mac_addresses"):
            mac_addresses = get_column_data_from_row(DHCPSrv_Static_Host,
                                                     "mac_addresses")
        if (mac_addresses is not None) and \
           (not dhcptftpservervalidations.is_valid_mac_addresses(
                mac_addresses)):
            details = "Invalid MAC addresses."
            raise ValidationError(error.VERIFICATION_FAILED, details)

        if hasattr(DHCPSrv_Static_Host, "set_tags"):
            set_tags = get_column_data_from_row(DHCPSrv_Static_Host,
                                                "set_tags")

        if (set_tags is not None) and \
           (not dhcptftpservervalidations.is_valid_tags(set_tags)):
            details = "%s is invalid." % (set_tags)
            raise ValidationError(error.VERIFICATION_FAILED, details)

        if hasattr(DHCPSrv_Static_Host, "client_hostname"):
            client_hostname = get_column_data_from_row(DHCPSrv_Static_Host,
                                                       "client_hostname")

        if (client_hostname is not None):
            for hostname in client_hostname:
                if (not dhcptftpservervalidations.is_valid_tag(hostname)):
                    details = "%s is invalid." % (hostname)
                    raise ValidationError(error.VERIFICATION_FAILED, details)

        if hasattr(DHCPSrv_Static_Host, "client_id"):
            client_id = get_column_data_from_row(DHCPSrv_Static_Host,
                                                 "client_id")

        if (client_id is not None):
            for c_id in client_id:
                if (not dhcptftpservervalidations.is_valid_tag(c_id)):
                    details = "%s is invalid." % (c_id)
                    raise ValidationError(error.VERIFICATION_FAILED, details)

        if (mac_addresses is None) and (client_hostname is None) and \
           (client_id is None):
            details = "Any one of MAC address or hostname or client-id" \
                      " must be specified"
            raise ValidationError(error.VERIFICATION_FAILED, details)

        if hasattr(DHCPSrv_Static_Host, "lease_duration"):
            lease_duration = get_column_data_from_row(DHCPSrv_Static_Host,
                                                      "lease_duration")

        if (lease_duration is not None):
            for duration in lease_duration:
                if (not dhcptftpservervalidations.is_valid_lease_duration(
                        duration)):
                    details = "Lease duration should be 0 for infinite or" \
                              " between 2-65535."
                    raise ValidationError(error.VERIFICATION_FAILED, details)
示例#38
0
 def validate_trust_global_is_not_empty(self, system_row):
     qos_config = utils.get_column_data_from_row(system_row, "qos_config")
     qos_trust_value = qos_config.get(qos_utils.QOS_TRUST_KEY, None)
     if qos_trust_value is None:
         details = "The qos trust value cannot be empty."
         raise ValidationError(error.VERIFICATION_FAILED, details)
示例#39
0
 def validate_deletion(self, validation_args):
     vrf_row = validation_args.resource_row
     vrf_name = get_column_data_from_row(vrf_row, "name")
     if vrf_name == 'vrf_default':
         details = "Default vrf cannot be deleted"
         raise ValidationError(error.VERIFICATION_FAILED, details)
示例#40
0
 def _is_websocket_subscriber(self, subscriber_row):
     subscriber_type = get_column_data_from_row(subscriber_row,
                                                SUBSCRIBER_TYPE)
     return subscriber_type == SUBSCRIBER_TYPE_WS
示例#41
0
 def validate_deletion(self, validation_args):
     bridge_row = validation_args.resource_row
     bridge_name = get_column_data_from_row(bridge_row, "name")
     if bridge_name == 'bridge_normal':
         details = "Default bridge cannot be deleted"
         raise ValidationError(error.VERIFICATION_FAILED, details)