示例#1
0
    def validate_bgp_rib_list(value):
        if not isinstance(value, list):
            raise SchemaTypeError('bgp-rib is not a list')
        bgp_rib_schema = Schema({
            Optional("accepted-external-prefix-count"): str,
            Optional("accepted-internal-prefix-count"): str,
            Optional("accepted-prefix-count"): str,
            Optional("active-external-prefix-count"): str,
            Optional("active-internal-prefix-count"): str,
            "active-prefix-count": str,
            Optional("bgp-rib-state"): str,
            "damped-prefix-count": str,
            "history-prefix-count": str,
            "name": str,
            "pending-prefix-count": str,
            Optional("received-prefix-count"): str,
            Optional("suppressed-external-prefix-count"): str,
            Optional("suppressed-internal-prefix-count"): str,
            "suppressed-prefix-count": str,
            Optional("total-external-prefix-count"): str,
            Optional("total-internal-prefix-count"): str,
            "total-prefix-count": str
        })

        for item in value:
            bgp_rib_schema.validate(item)
        return value
示例#2
0
 def validate_route_table_data(value):
     if not isinstance(value, list):
         raise SchemaTypeError('validate_route_table_data is not a list')
     entry_schema = Schema({'index': str, 'routes': str, 'size': str})
     # Validate each dictionary in list
     for item in value:
         entry_schema.validate(item)
     return value
示例#3
0
 def validate_package_information_list(value):
     # Pass ospf3-interface list as value
     if not isinstance(value, list):
         raise SchemaTypeError('package_information is not a list')
     package_information_schema = Schema({"comment": str, "name": str})
     # Validate each dictionary in list
     for item in value:
         package_information_schema.validate(item)
     return value
示例#4
0
    def validate_bgp_group_list(value):
        if not isinstance(value, list):
            raise SchemaTypeError('bgp-rib is not a list')

        def validate_bgp_rib(value):
            if not isinstance(value, list):
                raise SchemaTypeError('bgp-rib is not a list')
            bgp_rib_schema = Schema({
                'accepted-prefix-count': str,
                'active-prefix-count': str,
                'advertised-prefix-count': str,
                'name': str,
                'received-prefix-count': str,
                Optional('suppressed-prefix-count'): str
            })
            for item in value:
                bgp_rib_schema.validate(item)
            return value

        bgp_group_list_schema = Schema({
            Optional('bgp-option-information'): {
                'bgp-options': str,
                'bgp-options-extended': str,
                'export-policy': str,
                'gshut-recv-local-preference': str,
                'holdtime': str
            },
            Optional('bgp-rib'):
            Use(validate_bgp_rib),
            'established-count':
            str,
            'name':
            str,
            Optional('flap-count'):
            str,
            Optional('group-flags'):
            str,
            Optional('group-index'):
            str,
            Optional('local-as'):
            str,
            Optional('peer-address'):
            list,
            Optional('peer-as'):
            str,
            'peer-count':
            str,
            'type':
            str,
            Optional('route-queue'): {
                'state': str,
                'timer': str,
            }
        })
        for item in value:
            bgp_group_list_schema.validate(item)
        return value
示例#5
0
    def validate_package_info_list(value):
        if not isinstance(value, list):
            raise SchemaTypeError('package infomation is not a list')
        package_info_schema = Schema({
            "comment": str,
            "name": str,
        })

        for item in value:
            package_info_schema.validate(item)
        return value
示例#6
0
 def validate_physical_interface_list(value):
     if not isinstance(value, list):
         raise SchemaTypeError('physical-interface is not a list')
     entry_schema = Schema({
         "admin-status": str,
         "description": str,
         "name": str,
         "oper-status": str
     })
     for item in value:
         entry_schema.validate(item)
     return value
示例#7
0
 def validate_krt_queue_list(value):
     # Pass ospf3-interface list as value
     if not isinstance(value, list):
         raise SchemaTypeError('ospf-interface is not a list')
     krt_queue_schema = Schema({
             "krtq-queue-length": str,
             "krtq-type": str
         })
     # Validate each dictionary in list
     for item in value:
         krt_queue_schema.validate(item)
     return value
示例#8
0
 def validate_snmp_object_list(value):
     if not isinstance(value, list):
         raise SchemaTypeError('snmp-object is not a list')
     snmp_object_schema = Schema({
         "name": str,
         "object-value": str,
         Optional("object-value-type"): str,
         Optional("oid"): str
     })
     # Validate each dictionary in list
     for item in value:
         snmp_object_schema.validate(item)
     return value
示例#9
0
 def validate_lag_lacp_protocol_list(value):
     if not isinstance(value, list):
         raise SchemaTypeError('lag-lacp-protocol is not a list')
     entry_schema = Schema({
         "lacp-mux-state": str,
         "lacp-receive-state": str,
         "lacp-transmit-state": str,
         "name": str
     })
     # Validate each dictionary in list
     for item in value:
         entry_schema.validate(item)
     return value
示例#10
0
 def validate_neighbor_list(value):
     if not isinstance(value, list):
         raise SchemaTypeError('ospf-neighbor is not a list')
     neighbor_schema = Schema({
         'neighbor-address': str,
         'interface-name': str,
         'ospf-neighbor-state': str,
         'neighbor-id': str,
         'neighbor-priority': str,
         'activity-timer': str
     })
     for item in value:
         neighbor_schema.validate(item)
     return value
示例#11
0
 def validate_bgp_rib(value):
     if not isinstance(value, list):
         raise SchemaTypeError('bgp-rib is not a list')
     bgp_rib_schema = Schema({
         'accepted-prefix-count': str,
         'active-prefix-count': str,
         'advertised-prefix-count': str,
         'name': str,
         'received-prefix-count': str,
         Optional('suppressed-prefix-count'): str
     })
     for item in value:
         bgp_rib_schema.validate(item)
     return value
示例#12
0
 def validate_hops_list(value):
     # Pass hops list of dict in value
     if not isinstance(value, list):
         raise SchemaTypeError('hops is not a list')
     # Create hop Schema
     hop_schema = Schema({
         "hop-number": str,
         Optional("router-name"): str,
         "address": str,
         "round-trip-time": str
     })
     # Validate each dictionary in list
     for item in value:
         hop_schema.validate(item)
     return value
示例#13
0
 def validate_filter_information_list(value):
     if not isinstance(value, list):
         raise SchemaTypeError('filter-information is not a list')
     filter_schema = Schema({
             Optional("counter"): Use(ShowFirewall.validate_counter_list),
             "filter-name": str,
             Optional("policer"): {
                 "byte-count": str,
                 "packet-count": str,
                 "policer-name": str
             }
     })
     for item in value:
         filter_schema.validate(item)
     return value
示例#14
0
 def validate_arp_table_entry_list(value):
     # Pass arp-entry list of dict in value
     if not isinstance(value, list):
         raise SchemaTypeError('arp-table-entry is not a list')
     # Create Arp Entry Schema
     entry_schema = Schema({
         "arp-table-entry-flags": str,
         "interface-name": str,
         "ip-address": str,
         "mac-address": str
     })
     # Validate each dictionary in list
     for item in value:
         entry_schema.validate(item)
     return value
示例#15
0
 def validate_ospf3_interface_list(value):
     # Pass ospf3-interface list as value
     if not isinstance(value, list):
         raise SchemaTypeError('ospf-interface is not a list')
     ospf3_interface_schema = Schema({
         "bdr-id": str,
         "dr-id": str,
         "interface-name": str,
         "neighbor-count": str,
         "ospf-area": str,
         "ospf-interface-state": str
     })
     # Validate each dictionary in list
     for item in value:
         ospf3_interface_schema.validate(item)
     return value
示例#16
0
    def validate_bgp_peer_list(value):
        if not isinstance(value, list):
            raise SchemaTypeError('bgp-peer is not a list')

        def validate_bgp_peer_rib_list(value):
            if not isinstance(value, list):
                raise SchemaTypeError('bgp-rib of bgp-peer is not a list')
            bgp_peer_rib_schema = Schema({
                'accepted-prefix-count': str,
                'active-prefix-count': str,
                'name': str,
                'received-prefix-count': str,
                'suppressed-prefix-count': str
            })

            for item in value:
                bgp_peer_rib_schema.validate(item)
            return value

        bgp_peer_schema = Schema({
            Optional('bgp-rib'):
            Use(validate_bgp_peer_rib_list),
            Optional("description"):
            str,
            "elapsed-time": {
                "#text": str,
                Optional("@junos:seconds"): str,
            },
            "flap-count":
            str,
            "input-messages":
            str,
            "output-messages":
            str,
            "peer-address":
            str,
            "peer-as":
            str,
            "peer-state":
            str,
            "route-queue-count":
            str,
        })
        for item in value:
            bgp_peer_schema.validate(item)
        return value
示例#17
0
 def validate_counter_list(value):
     # Pass firmware list as value
     if not isinstance(value, list):
         raise SchemaTypeError('counter is not a list')
     counter_inner_schema = Schema(
                     {
                         "byte-count": str,
                         "counter-name": str,
                         "packet-count": str
                     
                     }
                 
     )
     # Validate each dictionary in list
     for item in value:
         counter_inner_schema.validate(item)
     return value
示例#18
0
 def validate_ping_result_list(value):
     # Pass ping result list of dict in value
     if not isinstance(value, list):
         raise SchemaTypeError('ping result is not a list')
     # Create Arp Entry Schema
     ping_result_schema = Schema({
                 'bytes': int,
                 'from': str,
                 'icmp-seq': int,
                 Optional('hlim'): int,
                 Optional('ttl'): int,
                 'time': str,
             })
     # Validate each dictionary in list
     for item in value:
         ping_result_schema.validate(item)
     return value
 def validate_ipv6_entry_list(value):
     # Pass arp-entry list of dict in value
     if not isinstance(value, list):
         raise SchemaTypeError('ipv6-entry is not a list')
     # Create Arp Entry Schema
     entry_schema = Schema({
         "ipv6-nd-expire": str,
         "ipv6-nd-interface-name": str,
         "ipv6-nd-isrouter": str,
         "ipv6-nd-issecure": str,
         "ipv6-nd-neighbor-address": str,
         "ipv6-nd-neighbor-l2-address": str,
         "ipv6-nd-state": str
     })
     # Validate each dictionary in list
     for item in value:
         entry_schema.validate(item)
     return value
示例#20
0
 def validate_lag_lacp_state_list(value):
     if not isinstance(value, list):
         raise SchemaTypeError('lag-lacp-state is not a list')
     entry_schema = Schema({
         "lacp-activity": str,
         "lacp-aggregation": str,
         "lacp-collecting": str,
         "lacp-defaulted": str,
         "lacp-distributing": str,
         "lacp-expired": str,
         "lacp-role": str,
         "lacp-synchronization": str,
         "lacp-timeout": str,
         "name": str
     })
     # Validate each dictionary in list
     for item in value:
         entry_schema.validate(item)
     return value
示例#21
0
 def validate_version_information_list(value):
     # Pass ospf3-interface list as value
     if not isinstance(value, list):
         raise SchemaTypeError('version_information is not a list')
     version_information_schema = Schema({
         "build-date": str,
         Optional("build-number"): str,
         "builder": str,
         "component": str,
         Optional("major"): str,
         Optional("minor"): str,
         "release": str,
         Optional("release-category"): str,
         Optional("spin"): str
     })
     # Validate each dictionary in list
     for item in value:
         version_information_schema.validate(item)
     return value
示例#22
0
 def validate_bgp_info_bgp_rib_list(value):
     if not isinstance(value, list):
         raise SchemaTypeError('bgp-information bgp-rib is not a list')
     bgp_rib_list_schema = Schema({
         'active-prefix-count':
         str,
         Optional('damped-prefix-count'):
         str,
         Optional('history-prefix-count'):
         str,
         'name':
         str,
         Optional('pending-prefix-count'):
         str,
         'suppressed-prefix-count':
         str,
         Optional('total-prefix-count'):
         str,
         Optional('active-external-prefix-count'):
         str,
         Optional('active-internal-prefix-count'):
         str,
         Optional('suppressed-external-prefix-count'):
         str,
         Optional('accepted-prefix-count'):
         str,
         Optional('total-internal-prefix-count'):
         str,
         Optional('received-prefix-count'):
         str,
         Optional('total-external-prefix-count'):
         str,
         Optional('suppressed-internal-prefix-count'):
         str,
         Optional('bgp-rib-state'):
         str,
     })
     for item in value:
         bgp_rib_list_schema.validate(item)
     return value
示例#23
0
 def validate_file_information_list(value):
     # Pass file-information of dict in value
     if not isinstance(value, list):
         raise SchemaTypeError('file-information is not a list')
     # Create protocols Schema
     file_information_schema = Schema({
         "file-date": {
             Optional("#text"): str,
             Optional("@junos:format"): str
         },
         "file-group": str,
         "file-links": str,
         "file-name": str,
         "file-owner": str,
         "file-permissions": {
             Optional("#text"): str,
             Optional("@junos:format"): str
         },
         "file-size": str
     })
     # Validate each dictionary in list
     for item in value:
         file_information_schema.validate(item)
     return value