class ShowLacpInterfacesInterfaceSchema(MetaParser): """ Schema for: * show lacp interfaces {interface} """ def validate_lag_lacp_state_list(value): if not isinstance(value, list): raise SchemaError('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 def validate_lag_lacp_protocol_list(value): if not isinstance(value, list): raise SchemaError('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 schema = { "lacp-interface-information-list": { "lacp-interface-information": { "lag-lacp-header": { "aggregate-name": str }, "lag-lacp-protocol": Use(validate_lag_lacp_protocol_list), "lag-lacp-state": Use(validate_lag_lacp_state_list) } } }
class ShowSystemCommitSchema(MetaParser): """ Schema for: * show sysyem commit """ # Sub Schema commit-history def validate_commit_history_list(value): # Pass commit-history list as value if not isinstance(value, list): raise SchemaTypeError('commit-history is not a list') commit_history_schema = Schema({ "client": str, "date-time": { "#text": str }, "sequence-number": str, "user": str }) # Validate each dictionary in list for item in value: commit_history_schema.validate(item) return value schema = { "commit-information": { "commit-history": Use(validate_commit_history_list) } }
class ShowOspfNeighborSchema(MetaParser): ''' schema = { 'ospf-neighbor-information': { 'ospf-neighbor': [{ 'neighbor-address': str, 'interface-name': str, 'ospf-neighbor-state': str, 'neighbor-id': str, 'neighbor-priority': str, 'activity-timer': str }] } } ''' 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 schema = { 'ospf-neighbor-information': { 'ospf-neighbor': Use(validate_neighbor_list) } }
class ShowRSVPNeighborSchema(MetaParser): """ Schema for: * show rsvp neighbor """ def validate_neighbor_list(value): if not isinstance(value, list): raise SchemaError('RSVP Neighbor not a list') rsvp_neighbor_list = Schema({ "rsvp-neighbor-address": str, "neighbor-idle": str, "neighbor-up-count": str, "neighbor-down-count": str, "last-changed-time": str, "hello-interval": str, "hellos-sent": str, "hellos-received": str, "messages-received": str, }) for item in value: rsvp_neighbor_list.validate(item) return value schema = { "rsvp-neighbor-information": { "rsvp-neighbor-count": str, "rsvp-neighbor": Use(validate_neighbor_list) } }
class ShowSnmpMibWalkSystemSchema(MetaParser): """ Schema for: * show snmp mib walk system """ # Sub Schema snmp-object 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 schema = { "snmp-object-information": { "snmp-object": Use(validate_snmp_object_list), } }
class ShowConfigurationProtocolsMplsPathSchema(MetaParser): """ Schema for: show configuration protocols mpls path {path} """ def validate_path_list_schema(value): if not isinstance(value, list): raise SchemaError('path list schema is not a list') path_list_schema = Schema({ 'name': str, 'type': str, }) for item in value: path_list_schema.validate(item) return value schema = { "configuration": { "protocols": { "mpls": { "path": { "path-list": Use(validate_path_list_schema) } } } } }
class ShowBFDSessionSchema(MetaParser): """ Schema for * show bfd session """ def validate_bfd_session(value): if not isinstance(value, list): raise SchemaError('BFD Session not a list') bfd_session = Schema({ "session-neighbor": str, "session-state": str, Optional("session-interface"): str, "session-detection-time": str, "session-transmission-interval": str, "session-adaptive-multiplier": str, }) for item in value: bfd_session.validate(item) return value schema = { "bfd-session-information": { Optional("bfd-session"): Use(validate_bfd_session), "clients": str, "cumulative-reception-rate": str, "cumulative-transmission-rate": str, "sessions": str } }
class ShowServicesAccountingStatusSchema(MetaParser): """ Schema for: * show services accounting status """ def validate_status_information(value): if not isinstance(value, list): raise SchemaError('Status information is not a list') status_information = Schema({ "interface-name": str, "status-export-format": str, "status-route-record-count": str, "status-ifl-snmp-map-count": str, "status-as-count": str, "status-monitor-config-set": str, "status-monitor-route-record-set": str, "status-monitor-ifl-snmp-set": str, }) for item in value: status_information.validate(item) return value schema = { "services-accounting-information": { "status-information": Use(validate_status_information), } }
class ShowConfigurationSystemNtpSchema(MetaParser): """Schema for: show configuration system ntp """ def validate_server_list(value): # Pass server list of dict in value if not isinstance(value, list): raise SchemaError('server list is not a list') # Create server list Schema servers = Schema({ 'name': str, }) # Validate each dictionary in list for item in value: servers.validate(item) return value schema = { "configuration": { "system": { "ntp": { Optional("server"): Use(validate_server_list), Optional("source-address"): { "name": str } } } } }
class ShowServicesAccountingErrorsSchema(MetaParser): """ Schema for: * show services accounting errors """ def validate_error_information(value): if not isinstance(value, list): raise SchemaError('Error information is not a list') error_information = Schema({ "interface-name": str, "service-set-dropped": str, "active-timeout-failures": str, "export-packet-failures": str, "flow-creation-failures": str, "memory-overload": str, }) for item in value: error_information.validate(item) return value schema = { "services-accounting-information": { "v9-error-information": Use(validate_error_information), } }
class ShowServicesAccountingMemorySchema(MetaParser): """ Schema for: * show services accounting memory """ def validate_memory_information(value): if not isinstance(value, list): raise SchemaError('Memory information is not a list') memory_information = Schema({ "interface-name": str, "allocation-count": str, "free-count": str, "allocations-per-second": str, "frees-per-second": str, "memory-used": str, "memory-free": str, "v9-memory-used": str, }) for item in value: memory_information.validate(item) return value schema = { "services-accounting-information": { "memory-information": Use(validate_memory_information), } }
class ShowServicesAccountingUsageSchema(MetaParser): """ Schema for: * show services accounting usage """ def validate_usage_information(value): if not isinstance(value, list): raise SchemaError('Usage information is not a list') usage_information = Schema({ "interface-name": str, "uptime": str, "inttime": str, "five-second-load": str, "one-minute-load": str, }) for item in value: usage_information.validate(item) return value schema = { "services-accounting-information": { "usage-information": Use(validate_usage_information), } }
def validate_community_list(value): if not isinstance(value, list): raise SchemaError('snmp community is not a list') def validate_clients_list(value): if not isinstance(value, list): raise SchemaError('snmp clients is not a list') snmp_clients_schema = Schema({ "name": str, Optional("restrict"): bool }) # Validate each dictionary in list for item in value: snmp_clients_schema.validate(item) return value snmp_community_schema = Schema({ "name": str, "authorization": str, "clients": Use(validate_clients_list), }) # Validate each dictionary in list for item in value: snmp_community_schema.validate(item) return value
class ShowLDPSessionSchema(MetaParser): """ Schema for * show ldp session """ def validate_ldp_session(value): if not isinstance(value, list): raise SchemaTypeError('LDP Session not a list') ldp_session = Schema({ "ldp-neighbor-address": str, "ldp-session-state": str, "ldp-connection-state": str, "ldp-remaining-time": str, Optional("ldp-session-adv-mode"): str, }) for item in value: ldp_session.validate(item) return value schema = { "ldp-session-information": { "ldp-session": Use(validate_ldp_session) } }
class ShowKrtQueueSchema(MetaParser): '''schema = { "krt-queue-information": { "krt-queue": [ { "krtq-queue-length": str, "krtq-type": str } ] } }''' # Sub Schema def validate_krt_queue_list(value): # Pass ospf3-interface list as value if not isinstance(value, list): raise SchemaError('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 # Main Schema schema = { "krt-queue-information": { "krt-queue": Use(validate_krt_queue_list) } }
class ShowServicesAccountingFlowSchema(MetaParser): """ Schema for: * show services accounting flow """ def validate_flow_information(value): if not isinstance(value, list): raise SchemaError('Flow information is not a list') flow_information = Schema({ "interface-name": str, "local-ifd-index": str, "flow-packets": str, "flow-bytes": str, "flow-packets-ten-second-rate": str, "flow-bytes-ten-second-rate": str, "active-flows": str, "flows": str, "flows-exported": str, "flow-packets-exported": str, "flows-expired": str, "flows-aged": str, }) for item in value: flow_information.validate(item) return value schema = { "services-accounting-information": { "flow-information": Use(validate_flow_information), } }
class ShowLdpDatabaseSessionIpaddressSchema(MetaParser): """ Schema for: * show ldp database session ipaddress """ '''schema = { "ldp-database-information": { "ldp-database": [ { "ldp-binding": [ { "ldp-label": str, "ldp-prefix": str } ], "ldp-database-type": str, "ldp-label-received": str, "ldp-label-advertised": str, "ldp-session-id": str } ] } }''' def validate_ldp_binding(value): if not isinstance(value, list): raise SchemaError('LDP binding is not a list') ldp_binding = Schema({"ldp-label": str, "ldp-prefix": str}) for item in value: ldp_binding.validate(item) return value def validate_ldp_database(value): if not isinstance(value, list): raise SchemaError('LDP database is not a list') ldp_database = Schema({ "ldp-binding": Use(ShowLdpDatabaseSessionIpaddress.validate_ldp_binding), "ldp-database-type": str, Optional("ldp-label-received"): str, Optional("ldp-label-advertised"): str, "ldp-session-id": str }) for item in value: ldp_database.validate(item) return value schema = { "ldp-database-information": { "ldp-database": Use(validate_ldp_database) } }
class ShowSystemStorageSchema(MetaParser): """ Schema for: * show system storage """ """ schema = { "system-storage-information": { "filesystem": [ { "available-blocks": { "#text": str }, "filesystem-name": str, "mounted-on": str, "total-blocks": { "#text": str }, "used-blocks": { "#text": str }, "used-percent": str } ] } } """ # Sub Schema filesystem def validate_filesystem_list(value): # Pass filesystem list as value if not isinstance(value, list): raise SchemaTypeError('filesystem is not a list') filesystem_schema = Schema({ "available-blocks": { "junos:format": str }, "filesystem-name": str, "mounted-on": str, "total-blocks": { Optional("#text"): str, "junos:format": str }, "used-blocks": { "junos:format": str }, "used-percent": str }) # Validate each dictionary in list for item in value: filesystem_schema.validate(item) return value schema = { "system-storage-information": { "filesystem": Use(validate_filesystem_list) } }
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
class ShowIpv6NeighborsSchema(MetaParser): """ Schema for: * show ipv6 neighbors """ """schema = { Optional("@xmlns:junos"): str, "ipv6-nd-information": { Optional("@junos:style"): str, Optional("@xmlns"): str, "ipv6-nd-entry": [ { "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 } ], "ipv6-nd-total": str } }""" def validate_ipv6_entry_list(value): # Pass arp-entry list of dict in value if not isinstance(value, list): raise SchemaError('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 # Main Schema schema = { Optional("@xmlns:junos"): str, "ipv6-nd-information": { Optional("@junos:style"): str, Optional("@xmlns"): str, "ipv6-nd-entry": Use(validate_ipv6_entry_list), "ipv6-nd-total": str } }
class ShowRSVPSessionSchema(MetaParser): """ Schema for: * show rsvp session * show rsvp session transit """ def validate_session_data_list(value): if not isinstance(value, list): raise SchemaError('RSVP session data not a list') def validate_session_list(value): if not isinstance(value, list): raise SchemaError('RSVP session not a list') rsvp_session_list = Schema({ "destination-address": str, "source-address": str, "lsp-state": str, "route-count": str, "rsb-count": str, "resv-style": str, "label-in": str, "label-out": str, "name": str, }) for item in value: rsvp_session_list.validate(item) return value rsvp_session_data_list = Schema({ "session-type": str, "count": str, Optional("rsvp-session"): Use(validate_session_list), "display-count": str, "up-count": str, "down-count": str, }) for item in value: rsvp_session_data_list.validate(item) return value schema = { "rsvp-session-information": { "rsvp-session-data": Use(validate_session_data_list) } }
class ShowLacpStatisticsInterfacesInterfaceSchema(MetaParser): """ Schema for: * show lacp statistics interfaces {interface} """ """ schema = { Optional("@xmlns:junos"): str, "lacp-interface-statistics-list": { Optional("@xmlns"): str, "lacp-interface-statistics": { Optional("@xmlns"): str, "lag-lacp-header": { "aggregate-name": str }, "lag-lacp-statistics": [ { "illegal-rx-packets": str, "lacp-rx-packets": str, "lacp-tx-packets": str, "name": str, "unknown-rx-packets": str } ] } } } """ def lag_lacp_statistics_list(value): if not isinstance(value, list): raise SchemaError('lag-lacp-statistics is not a list') entry_schema = Schema({ "illegal-rx-packets": str, "lacp-rx-packets": str, "lacp-tx-packets": str, "name": str, "unknown-rx-packets": str, }) # Validate each dictionary in list for item in value: entry_schema.validate(item) return value schema = { "lacp-interface-statistics-list": { "lacp-interface-statistics": { "lag-lacp-header": { "aggregate-name": str }, "lag-lacp-statistics": Use(lag_lacp_statistics_list), } } }
class ShowVersionInvokeOnAllRoutingEnginesSchema(MetaParser): """ schema = { Optional("@xmlns:junos"): str, "multi-routing-engine-results": { "multi-routing-engine-item": { "re-name": str, "software-information": { "host-name": str, "junos-version": str, "package-information": [ { "comment": str, "name": str } ], "product-model": str, "product-name": str } } } } """ def validate_package_information_list(value): # Pass ospf3-interface list as value if not isinstance(value, list): raise SchemaError('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 # Main Schema schema = { Optional("@xmlns:junos"): str, "multi-routing-engine-results": { "multi-routing-engine-item": { "re-name": str, "software-information": { "host-name": str, "junos-version": str, "package-information": Use(validate_package_information_list), "product-model": str, Optional("product-name"): str } } } }
class TracerouteNoResolveSchema(MetaParser): """ Schema for: * traceroute {ipaddress} no-resolve * traceroute {ipaddress} source {ipaddress2} no-resolve """ """schema = { "traceroute": { "to": { "domain": str, "address": str }, "max-hops": str, "packet-size": str, "hops": [ { "hop-number": str, Optional("router-name"): str, "address": str, "round-trip-time": str } ] } } """ def validate_hops_list(value): # Pass hops list of dict in value if not isinstance(value, list): raise SchemaError('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 # Main Schema schema = { "traceroute": { "to": { "domain": str, "address": str }, "max-hops": str, "packet-size": str, Optional("hops"): Use(validate_hops_list) } }
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
def validate_ldp_database(value): if not isinstance(value, list): raise SchemaTypeError('LDP database is not a list') ldp_database = Schema({ "ldp-binding": Use(ShowLdpDatabaseSessionIpaddress.validate_ldp_binding), "ldp-database-type": str, Optional("ldp-label-received"): str, Optional("ldp-label-advertised"): str, "ldp-session-id": str }) for item in value: ldp_database.validate(item) return value
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
class ShowRSVPNeighborDetailSchema(MetaParser): """ Schema for * show rsvp neighbor detail """ def validate_neighbor_list(value): if not isinstance(value, list): raise SchemaError('RSVP Neighbor not a list') rsvp_neighbor_list = Schema({ "rsvp-neighbor-address": str, Optional("rsvp-neighbor-interface"): str, "rsvp-neighbor-status": str, Optional("rsvp-neighbor-node"): bool, "last-changed-time": str, "neighbor-idle": str, "neighbor-up-count": str, "neighbor-down-count": str, "messages-received": str, "hello-interval": str, "hellos-sent": str, "hellos-received": str, "rsvp-neighbor-remote-instance": str, "rsvp-neighbor-local-instance": str, "rsvp-refresh-reduct-status": str, "rsvp-refresh-reduct-remote-status": str, "rsvp-refresh-reduct-ack-status": str, "rsvp-nbr-enh-local-protection": { "rsvp-nbr-enh-lp-status": str, Optional("rsvp-nbr-enh-lp-total-lsp-count"): str, Optional("rsvp-nbr-enh-lp-phop-lsp-count"): str, Optional("rsvp-nbr-enh-lp-pphop-lsp-count"): str, Optional("rsvp-nbr-enh-lp-nhop-lsp-count"): str, Optional("rsvp-nbr-enh-lp-nnhop-lsp-count"): str, } }) for item in value: rsvp_neighbor_list.validate(item) return value schema = { "rsvp-neighbor-information": { "rsvp-neighbor-count": str, "rsvp-neighbor": Use(validate_neighbor_list) } }
class ShowFirewallLogSchema(MetaParser): """ Schema for: * show firewall log """ """schema = { "firewall-log-information": { "log-information": [ { "action-name": str, "destination-address": str, "filter-name": str, "interface-name": str, "protocol-name": str, "source-address": str, "time": str } ] } }""" def validate_log_information_list(value): if not isinstance(value, list): raise SchemaError('log-information is not a list') log_schema = Schema({ "action-name": str, "destination-address": str, "filter-name": str, "interface-name": str, "protocol-name": str, "source-address": str, "time": str }) for item in value: log_schema.validate(item) return value schema = { "firewall-log-information": { "log-information": Use(validate_log_information_list) } }
class ShowArpSchema(MetaParser): """ Schema for: * show arp * show arp | no-more """ """schema = { "arp-table-information": { "arp-entry-count": str, "arp-table-entry": [ { "arp-table-entry-flags": str, "hostname": str, "interface-name": str, "ip-address": str, "mac-address": str } ] } }""" 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, "hostname": 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 # Main Schema schema = { "arp-table-information": { "arp-entry-count": str, "arp-table-entry": Use(validate_arp_table_entry_list) } }