Пример #1
0
    def validate_ports_are_system_ports(self, mirror_row):
        ports = []

        if hasattr(mirror_row, 'select_src_port'):
            ports.extend(mirror_row.select_src_port)

        if hasattr(mirror_row, 'select_dst_port'):
            ports.extend(mirror_row.select_dst_port)

        if hasattr(mirror_row, 'output_port'):
            ports.extend(mirror_row.output_port)

        for port in ports:
            if not hasattr(port, 'interfaces') or \
                    port.interfaces == []:
                details = "Port " + port.name + " must contain at " \
                    "least one interface."
                raise ValidationError(error.VERIFICATION_FAILED, details)

            for interface in port.interfaces:
                if hasattr(interface, 'type') and \
                        interface.type != "system":
                    details = "The mirror can only contain interfaces " + \
                        "of type system."
                    raise ValidationError(error.VERIFICATION_FAILED, 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_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)
Пример #4
0
 def validate_priority_code_point_is_empty(
         self, qos_dscp_map_entry_row):
     # Cos (priority_code_point) is not supported for dill.
     if qos_dscp_map_entry_row.priority_code_point != []:
         details = "The priority_code_point field " + \
             "is not currently supported."
         raise ValidationError(error.VERIFICATION_FAILED, details)
Пример #5
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)
Пример #6
0
    def validate_modification(self, validation_args):
        if validation_args.is_new:
            details = "COS Map Entries cannot be created."
            raise ValidationError(error.VERIFICATION_FAILED, details)

        qos_cos_map_entry_row = validation_args.resource_row
        self.validate_cos_map_description_contains_valid_chars(
            qos_cos_map_entry_row)
Пример #7
0
 def validate_selects_are_not_empty(self, mirror_row):
     if (not hasattr(mirror_row, 'select_src_port') or \
             mirror_row.select_src_port == []) and \
             (not hasattr(mirror_row, 'select_dst_port') or \
              mirror_row.select_dst_port == []):
         details = "The select src port and select dst port " \
             "cannot both be empty."
         raise ValidationError(error.VERIFICATION_FAILED, details)
Пример #8
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)
Пример #9
0
    def validate_select_dst_port_is_not_output_port(self, mirror_row,
                                                    other_mirror_row):
        if not hasattr(mirror_row, 'select_dst_port'):
            return

        if not hasattr(other_mirror_row, 'output_port'):
            return

        if other_mirror_row.output_port[0] in mirror_row.select_dst_port:
            details = "A select dst port cannot be an " + \
                "output port of another active mirror row."
            raise ValidationError(error.VERIFICATION_FAILED, details)
Пример #10
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)
Пример #11
0
    def validate_modification(self, validation_args):
        if validation_args.is_new:
            details = "DSCP Map Entries cannot be created."
            raise ValidationError(error.VERIFICATION_FAILED, details)

        qos_dscp_map_entry_row = validation_args.resource_row
        self.validate_dscp_map_description_contains_valid_chars(
            qos_dscp_map_entry_row)

        # Cos (priority_code_point) is not supported for dill.
        self.validate_priority_code_point_is_empty(
            qos_dscp_map_entry_row)
Пример #12
0
    def validate_modification(self, validation_args):
        is_new = validation_args.is_new
        vrf_row = validation_args.p_resource_row

        if is_new:
            bgp_routers = utils.get_column_data_from_row(
                vrf_row, "bgp_routers")

            # Since working on the IDL that already has the reflective change,
            # the total number of bgp_routers in parent table can be used
            # to validate allowed bgp_routers.
            if bgp_routers is not None:
                if len(bgp_routers) > 1:
                    details = "Only one BGP router can be created"
                    raise ValidationError(error.RESOURCES_EXCEEDED, details)

        app_log.debug('Validation Successful')
Пример #13
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)
Пример #14
0
    def validate_modification(self, validation_args):
        is_new = validation_args.is_new
        port_row = validation_args.resource_row
        idl = validation_args.idl
        is_sec = False
        ip_type = "ipv4"
        port_ip4 = None
        port_ip4_sec = None
        port_ip6 = None
        port_ip6_sec = None
        port_dict = {}
        if '_changes' in port_row.__dict__:
            port_dict = port_row.__dict__['_changes']

        if "ip4_address" in port_dict:
            port_ip4 = \
                utils.get_column_data_from_row(port_row,
                                               "ip4_address")
            if port_ip4:
                for port_ip in port_ip4:
                    if not is_ip4_valid(port_ip):
                        details =\
                            "ip[%s] is not valid" % (port_ip)
                        raise ValidationError(error.VERIFICATION_FAILED,
                                              details)
        if "ip4_address_secondary" in port_dict:
            port_ip4_sec = \
                utils.get_column_data_from_row(port_row,
                                               "ip4_address_secondary")
            if port_ip4_sec:
                for port_ip in port_ip4_sec:
                    if not is_ip4_valid(port_ip):
                        details =\
                            "ip[%s] is not valid" % (port_ip)
                        raise ValidationError(error.VERIFICATION_FAILED,
                                              details)
        if "ip6_address" in port_dict:
            port_ip6 = \
                utils.get_column_data_from_row(port_row,
                                               "ip6_address")
            if port_ip6:
                for port_ip in port_ip6:
                    if not is_ip6_valid(port_ip):
                        details =\
                            "ip[%s] is not valid" % (port_ip)
                        raise ValidationError(error.VERIFICATION_FAILED,
                                              details)
        if "ip6_address_secondary" in port_dict:
            port_ip6_sec = \
                utils.get_column_data_from_row(port_row,
                                               "ip6_address_secondary")
            if port_ip6_sec:
                for port_ip in port_ip6_sec:
                    if not is_ip6_valid(port_ip):
                        details =\
                            "ip[%s] is not valid" % (port_ip)
                        raise ValidationError(error.VERIFICATION_FAILED,
                                              details)

        port_name = utils.get_column_data_from_row(port_row, "name")
        vrf_row_ports = get_vrf_row_for_port(idl, port_name)

        if not vrf_row_ports:
            return

        if port_ip4:
            for port_ip in port_ip4:
                for port in vrf_row_ports:
                    if is_ip_overlapping(port_ip, "ipv4", port_name, False,
                                         port):
                        details =\
                            "ip[%s] overlap in port:%s" % (port_ip,
                                                           port.name)
                        raise ValidationError(error.VERIFICATION_FAILED,
                                              details)
        if port_ip4_sec:
            for port_ip in port_ip4_sec:
                for port in vrf_row_ports:
                    if is_ip_overlapping(port_ip, "ipv4", port_name, True,
                                         port):
                        details = \
                            "secondary ip[%s] overlap in port:%s" % (port_ip,
                                                                     port.name)
                        raise ValidationError(error.VERIFICATION_FAILED,
                                              details)
        if port_ip6:
            for port_ip in port_ip6:
                for port in vrf_row_ports:
                    if is_ip_overlapping(port_ip, "ipv6", port_name, False,
                                         port):
                        details =\
                            "ip[%s] overlap in port:%s" % (port_ip,
                                                           port.name)
                        raise ValidationError(error.VERIFICATION_FAILED,
                                              details)
        if port_ip6_sec:
            for port_ip in port_ip6_sec:
                for port in vrf_row_ports:
                    if is_ip_overlapping(port_ip, "ipv6", port_name, True,
                                         port):
                        details =\
                            "secondary ip[%s] overlap in port:%s" % (port_ip,
                                                                     port.name)
                        raise ValidationError(error.VERIFICATION_FAILED,
                                              details)

        app_log.debug('Port Validation Successful')
Пример #15
0
 def validate_output_port_is_not_this_select_src_port(self, mirror_row):
     if hasattr(mirror_row, 'select_src_port') and \
             hasattr(mirror_row, 'output_port') and \
             mirror_row.output_port[0] in mirror_row.select_src_port:
         details = "The output port cannot also be a select src port."
         raise ValidationError(error.VERIFICATION_FAILED, details)
Пример #16
0
 def validate_output_port_is_not_empty(self, mirror_row):
     if not hasattr(mirror_row, 'output_port') or \
             mirror_row.output_port == []:
         details = "The output port cannot be empty."
         raise ValidationError(error.VERIFICATION_FAILED, details)
Пример #17
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)