class ShowPlatformSoftwareSchema(MetaParser): ''' Schema for "show Platform software" ''' schema = { Optional('statistics'): {Optional('object-update'): {Optional('pending-issue'):int, Optional('pending-ack'):int, }, Optional('batch-begin'): {Optional('pending-issue'):int, Optional('pending-ack'):int, }, Optional('batch-end'): {Optional('pending-issue'):int, Optional('pending-ack'):int, }, Optional('command'): {Optional('pending-ack'):int, }, Optional('total-objects'):int, Optional('stale-objects'): int, Optional('resolve-objects'): int, Optional('childless-delete-objects'): int, Optional('backplane-objects'): int, Optional('error-objects'): int, Optional('number-of-bundles'): int, Optional('paused-types'): int, }, }
class ShowLoggingSchema(MetaParser): '''Schema for: * 'show logging' * 'show logging | include {include}' * 'show logging | exclude {exclude}' ''' schema = { Optional('logs'): list, Optional('syslog_logging'): { Any(): { # enabled 'counters': { 'messages_dropped': int, 'messages_rate_limited': int, 'flushes': int, 'overruns': int, 'xml': str, # 'disabled' 'filtering': str, # 'disabled' } } }, Optional('message_discriminator'): { Optional(Any()): { # 'Active'|'Inactive' Optional('md_name'): { Optional(Any()): { # 'C' Optional('severity_group'): { 'flag': str, # 'includes'|'drops' 'str': str, # '5' }, Optional('facility'): { 'flag': str, # 'includes'|'drops' 'regexp_str': str, # 'SYS' }, Optional('mnemonics'): { 'flag': str, # 'include'|'drops' 'regexp_str': str, # 'UPDOWN' }, Optional('msg_body'): { 'flag': str, # 'include'|'drops' 'regexp_str': str, # link }, Optional('rate_limit_not_to_exceed'): { 'rate_limit': int, # 100 } } } } }, Optional('logging'): { 'console': { 'status': str, # 'enabled'|'disabled' Optional('level'): str, Optional('messages_logged'): int, Optional('xml'): str, Optional('filtering'): str, }, 'monitor': { 'status': str, # 'enabled'|'disabled' Optional('level'): str, Optional('messages_logged'): int, Optional('xml'): str, Optional('filtering'): str, Optional('discriminator'): str, Optional('messages_rate_limited'): int, Optional('messages_dropped_by_md'): int, Optional('logging_to'): { Any(): { # '10.4.29.222' Or('vty', 'tty'): int, } } }, 'buffer': { 'status': str, # 'enabled'|'disabled' Optional('level'): str, Optional('messages_logged'): int, 'xml': str, # 'enabled'|'disabled' Optional('xml_buffer_count'): int, 'filtering': str, # 'enabled'|'disabled' Optional('buffer_count'): int, Optional('discriminator'): str, Optional('messages_rate_limited'): int, Optional('messages_dropped_by_md'): int }, 'exception': { Optional('status'): str, # 'enabled'|'disabled' Optional('size_bytes'): int, # 4096 }, 'persistent': { Optional('status'): str, # 'enabled'|'disabled' Optional('url'): str, Optional('disk_space_bytes'): int, Optional('file_size_bytes'): int, Optional('batch_size_bytes'): int, # threshold capacity 5 alert , immediate , protected , notify Optional('logging_threshold'): int, Optional('threshold_percent'): int, Optional('threshold_alert'): str, Optional('immediate_write'): str, Optional('notify'): str, Optional('protected'): str }, Optional('file'): { Optional('status'): str, # 'enabled'|'disabled' Optional('file_name'): str, Optional('max_size'): int, Optional('min_size'): int, Optional('level'): str, Optional('messages_logged'): int, }, Optional('count_and_time_stamp_logging_messages'): str, # 'enabled'|'disabled' 'trap': { Optional('status'): str, # 'enabled'|'disabled' Optional('level'): str, # 'informational' Optional('message_lines_logged'): int, # 70 Optional("logging_source_interface"): { Any(): { # Loopback0 Optional("vrf"): str # Mgmt-intf } }, Optional('logging_to'): { Any(): { # '10.4.29.222' 'protocol': str, # 'tcp'|'udp'|'unknown' 'port': int, # 1470 'audit': str, # 'disabled'|'enabled' 'link': str, # 'up'|'down' 'message_lines_logged': int, 'message_lines_rate_limited': int, 'message_lines_dropped_by_md': int, 'xml': str, # 'enabled'|'disabled' 'sequence_number': str, # 'enabled'|'disabled' 'filtering': str, # 'enabled'|'disabled' Optional('vrf'): str, Optional('logging_source_interface'): { Any(): str, # 'Vlan200': <vrf> }, } } } }, Optional('filter_modules'): { Any(): { # url 'cli_args': str, 'invalid': bool, # True|False } }, Optional('tls_profiles'): { Any(): { # 'tls-profile-name 'ciphersuites': list, # rsa-aes-cbc-sha2 ecdhe-rsa-aes-cbc-sha2 'trustpoint': str, # tls-trustpoint 'tls_version': str # TLSv1.1 | TLSv1.2 | Default } }, Optional('log_buffer_bytes'): int, # 32000 }
class ShowL2vpnVfiSchema(MetaParser): """Schema for show l2vpn vfi """ schema = { 'vfi': { Any(): { 'bd_vfi_name': str, Optional('bridge_group'): str, 'state': str, Optional('type'): str, 'signaling': str, 'vpn_id': int, Optional('ve_id'): int, Optional('vpls_id'): str, Optional('ve_range'): int, Optional('rd'): str, Optional('rt'): list, 'bridge_domain': { Any(): { Optional('pseudo_port_interface'): str, Optional('attachment_circuits'): { Optional(Any()): { 'name': str, } }, 'vfi': { Any(): { 'pw_id': { Any(): { Optional('local_label'): int, Optional('ve_id'): int, Optional('vc_id'): int, Optional('remote_label'): int, Optional('split_horizon'): bool, Optional('discovered_router_id'): str, Optional('next_hop'): str, }, } }, } }, } }, } }
class ShowVariablesSystemSchema(MetaParser): """ Schema for show variables system """ schema = { 'paths': { 'path': str, 'loadpath': str, 'ld_library_path': str, Optional('bfm_config_path'): str, 'bgp_path': str, 'configs_path': str, Optional('craft_path'): str, Optional('ctf_path'): str, Optional('dm_rules_path'): str, 'etc_path': str, Optional('fpd_path'): str, 'im_rules_path': str, 'init_startup_path': str, Optional('insthelper_path'): str, Optional('man_path'): str, 'mib_library_path': str, 'mib_path': str, Optional('netio_script_path'): str, 'parser_path': str, 'partitions_path': str, Optional('pkg_path'): str, Optional('placement_path'): str, Optional('qos_path'): str, 'schema_path': str, 'startup_path': str, Optional('ucode_path'): str, Optional('ucode_root_path'): str, Optional('vcm_rules_path'): str, }, Optional('hostname'): str, 'term': list, 'gdb_pdebug': str, Optional('dir_prefix'): str, Optional('tcl_library'): str, 'job_id': int, 'instance_id': int, Optional('sysmgr_tuple'): str, 'sysmgr_node': str, 'exit_status': int, 'sysmgr_restart_reason': int, 'aaa_user': str, 'exec_pid': int, 'taskid_map_size': int, 'home': str, 'tmpdir': str, 'pwd': str, Optional('node_watcher'): int, Optional('tty_uart_driver'): str, Optional('ld_preload'): str, Optional('boot_dir'): str, Optional('dir'): str, Optional('user'): str, Optional('libvirt_default_uri'): str, Optional('iox_disable_startup'): int, Optional('ps1'): str, Optional('iox_disable_sysmgr'): int, Optional('memdbg_blacklist'): str, Optional('shlvl'): int, Optional('terminfo'): str, Optional('connect_dir'): str, Optional('upstart_instance'): str, Optional('memdbg_enable'): int, Optional('upstart_events'): str, Optional('iox'): int, Optional('rlimit'): int, Optional('connect_command'): str, Optional('boot_iox'): int, Optional('upstart_job'): str, Optional('iox_no_config'): int, Optional('confreg'): int, Optional('pcie_debug'): str, Optional('_'): str, Optional('sysmgr_vs_started'): int, Optional('respawn_count'): int, Optional('tty_category'): int, Optional('tty_port'): int }
class ShowIpArpstatisticsVrfAllSchema(MetaParser): """Schema for show ip arp statistics vrf all""" schema = { 'statistics': { 'sent':{ 'total': int, 'requests': int, 'replies': int, 'l2_requests': int, 'l2_replies': int, 'gratuitous': int, 'tunneled': int, 'dropped': int, 'drops_details': { 'mbuf_operation_failed': int, Optional('context_not_created'): int, Optional('invalid_context'): int, Optional('invalid_ifindex'): int, Optional('invalid_src_ip'): int, Optional('invalid_dest_ip'): int, Optional('destnination_is_our_own_ip'): int, Optional('unattached_ip'): int, Optional('adjacency_couldnt_be_added'): int, Optional('null_source_ip'): int, Optional('null_source_mac'): int, Optional('client_enqueue_failed'): int, Optional('dest_not_reachable_for_proxy_arp'): int, Optional('dest_unreachable_for_enhanced_proxy'): int, Optional('destnination_on_l2_port_tracked'): int, Optional('invalid_local_proxy_arp'): int, Optional('invalid_proxy_arp'): int, Optional('vip_is_not_active'): int, Optional('arp_refresh_skipped_over_core_and_flooded'): int, } }, 'received':{ 'total': int, 'requests': int, 'replies': int, 'l2_requests': int, 'l2_replies': int, 'proxy_arp': int, 'local_proxy_arp': int, Optional('enhanced_proxy_arp'): int, Optional('anycast_proxy_arp'): int, Optional('l2_port_track_proxy_arp'): int, 'tunneled': int, Optional('fastpath'): int, Optional('snooped'): int, 'dropped': int, Optional('dropped_server_port'): int, 'drops_details': { 'context_not_created': int, 'invalid_context': int, Optional('invalid_hardwaretype'): int, 'invalid_layer2_address_length': int, 'invalid_source_ip_address': int, 'no_mem_to_create_per_intf_structure': int, 'invalid_layer3_address_length': int, 'source_address_mismatch_with_subnet': int, 'directed_broadcast_source': int, 'invalid_destination_ip_address': int, 'non_local_destination_ip_address': int, 'invalid_source_mac_address': int, 'source_mac_address_is_our_own': int, 'received_before_arp_initialization': int, 'l2_packet_on_untrusted_l2_port': int, 'packet_with_vip_on_standby_fhrp': int, 'requests_came_for_exising_entries': int, 'requests_came_on_a_l2_interface': int, 'l2fm_query_failed_for_a_l2address': int, 'dropping_due_to_tunneling_failures': int, Optional('glean_requests_recv_count'): int, Optional('arp_refresh_requests_received_from_clients'): int, Optional('number_of_signals_received_from_l2rib'): int, 'non_active_fhrp_dest_ip': int, 'grat_arp_received_on_proxy': int, 'invalid_protocol_packet': int, 'appeared_on_a_wrong_interface': int, 'incorrect_length': int, } }, 'adjacency':{ 'adjacency_adds': int, 'adjacency_deletes': int, 'adjacency_timeouts': int, Optional('failed_due_to_limits'): int, } } }
class ShowDot1xAllDetailSchema(MetaParser): """Schema for show dot1x all details""" schema = { Optional('system_auth_control'): bool, Optional('version'): int, Optional('interfaces'): { Any(): { 'pae': str, 'interface': str, Optional('credentials'): str, Optional('port_control'): str, Optional('control_direction'): str, Optional('host_mode'): str, Optional('re_authentication'): bool, Optional('max_reauth_req'): int, Optional('max_req'): int, Optional('max_start'): int, Optional('timeout'): { Optional('server_timeout'): int, Optional('supp_timeout'): int, Optional('quiet_period'): int, Optional('tx_period'): int, Optional('auth_period'): int, Optional('held_period'): int, Optional('ratelimit_period'): int, Optional('start_period'): int, Optional('re_auth_period'): int }, Optional('authenticator'): { 'eap': { 'profile': str, } }, Optional('supplicant'): { 'eap': { 'profile': str, } }, Optional('clients'): { Any(): { 'client': str, 'eap_method': str, Optional('session'): { Any(): { 'session_id': str, 'auth_sm_state': str, 'auth_bend_sm_state': str, } } } } } } }
class ShowSpanningTreeDetailSchema(MetaParser): """Schema for show spanning-tree detail""" schema = { Any(): { # mstp, pvst, rapid_pvst Optional('domain'): str, Optional('pvst_id'): str, Optional('name'): str, Optional('revision'): int, Optional('max_hop'): int, 'hello_time': int, 'max_age': int, 'forwarding_delay': int, Optional('hold_count'): int, Any(): { # mst_instances, vlans Any(): { Optional('mst_id'): int, Optional('vlan'): str, Optional('vlan_id'): int, Optional('hello_time'): int, Optional('max_age'): int, Optional('forwarding_delay'): int, Optional('hold_count'): int, 'bridge_priority': int, 'bridge_sysid': int, 'bridge_address': str, Optional('root_of_spanning_tree'): bool, 'topology_change_flag': bool, 'topology_detected_flag': bool, 'hold_time': int, 'topology_changes': int, 'time_since_topology_change': str, Optional('topology_from_port'): str, 'hello_time': int, 'max_age': int, 'forwarding_delay': int, 'hold_time': int, 'topology_change_times': int, 'notification_times': int, 'hello_timer': int, 'topology_change_timer': int, 'notification_timer': int, Optional('aging_timer'): int, 'interfaces': { Any(): { 'status': str, 'name': str, 'cost': int, 'port_priority': int, 'port_num': int, 'port_identifier': str, 'designated_root_priority': int, 'designated_root_address': str, 'designated_path_cost': int, 'designated_port_id': str, 'designated_bridge_priority': int, 'designated_bridge_address': str, 'number_of_forward_transitions': int, 'message_age': int, 'forward_delay': int, 'hold': int, 'link_type': str, Optional('internal'): bool, Optional('boundary'): str, Optional('peer'): str, Optional('loop_guard'): bool, 'counters': { 'bpdu_sent': int, 'bpdu_received': int, } } } }, }, } }
class ShowIpv6MldInterfaceSchema(MetaParser): """Schema for: show ipv6 mld interface show ipv6 mld interface vrf all show ipv6 mld interface vrf <vrf>""" schema = { 'vrfs': { Any(): { Optional('interface'): { Any(): { 'enable': bool, 'link_status': str, 'oper_status': str, Optional('ipv6'): { Any(): { 'ip': str, 'prefix_length': str, 'status': str, }, }, Optional('link_local'): { 'address': str, 'status': str, Optional('ipv6_address'): str, }, Optional('querier'): str, Optional('querier_version'): int, Optional('next_query_sent_in'): str, Optional('membership_count'): int, Optional('version'): int, Optional('host_version'): int, Optional('query_interval'): int, Optional('configured_query_interval'): int, Optional('query_max_response_time'): int, Optional('configured_query_max_response_time'): int, Optional('startup_query'): { Optional('configured_interval'): int, Optional('interval'): int, Optional('count'): int, }, Optional('last_member'): { Optional('mrt'): int, Optional('query_count'): int, }, Optional('group_timeout'): int, Optional('configured_group_timeout'): int, Optional('querier_timeout'): int, Optional('configured_querier_timeout'): int, Optional('unsolicited_report_interval'): int, Optional('robustness_variable'): int, Optional('configured_robustness_variable'): int, Optional('link_local_groups_reporting'): bool, Optional('immediate_leave'): bool, Optional('enable_refcount'): int, Optional('group_policy'): str, Optional('max_groups'): int, Optional('available_groups'): int, Optional('statistics'): { 'sent': { Any(): int, }, 'received': { Any(): int, } } } }, }, }, }
class ShowMPLSLSPNameDetailSchema(MetaParser): """ Schema for * show mpls lsp name {name} detail """ schema = { "mpls-lsp-information": { "rsvp-session-data": ListOf({ "session-type": str, "count": str, Optional("rsvp-session"): { "destination-address": str, "source-address": str, "lsp-state": str, "route-count": str, "name": str, "lsp-path-type": str, "suggested-label-in": str, "suggested-label-out": str, "recovery-label-in": str, "recovery-label-out": str, "rsb-count": str, "resv-style": str, "label-in": str, "label-out": str, "psb-lifetime": str, "psb-creation-time": str, "sender-tspec": str, "lsp-id": str, "tunnel-id": str, "proto-id": str, "packet-information": ListOf({ "heading": str, Optional("next-hop"): str, Optional("previous-hop"): str, Optional("interface-name"): str, Optional("count"): str, Optional("entropy-label"): str, Optional("in-epoch"): str, Optional("in-message-handle"): str, Optional("in-message-id"): str, Optional("out-epoch"): str, Optional("out-message-state"): str, Optional("out-message-id"): str, }), "adspec": str, "explicit-route": { "explicit-route-element": ListOf({ "address": str, }) }, "record-route": { Optional("record-route-element"): ListOf({ "address": str, }), Optional("address"): list, }, Optional("rsvp-lsp-enh-local-prot-downstream"): { "rsvp-lsp-enh-local-prot-refresh-interval": str, "rsvp-lsp-enh-lp-downstream-status": str }, Optional("rsvp-lsp-enh-local-prot-upstream"): { "rsvp-lsp-enh-local-prot-refresh-interval": str, "rsvp-lsp-enh-lp-upstream-status": str }, }, "display-count": str, "up-count": str, "down-count": str, }) }, }
class ShowFirewallSchema(MetaParser): """ Schema for: * show firewall """ """schema = { Optional("@xmlns:junos"): str, "firewall-information": { Optional("@xmlns"): str, "filter-information": [ { Optional("counter"): { "byte-count": str, "counter-name": str, "packet-count": str }, "filter-name": str, Optional("policer"): { "byte-count": str, "packet-count": str, "policer-name": str } } ] } }""" def validate_counter_list(value): # Pass firmware list as value if not isinstance(value, list): raise SchemaError('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 def validate_filter_information_list(value): if not isinstance(value, list): raise SchemaError('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 schema = { Optional("@xmlns:junos"): str, "firewall-information": { Optional("@xmlns"): str, "filter-information": Use(validate_filter_information_list) } }
class ShowRouteMapAllSchema(MetaParser): """Schema for show route-map all""" schema = { Any(): { Optional('description'): str, 'statements': { Any(): { 'conditions': { Optional('match_med_eq'): int, Optional('match_local_pref_eq'): int, Optional('match_nexthop_in'): list, Optional('match_nexthop_in_v6'): list, Optional('match_level_eq'): str, Optional('match_route_type'): str, Optional('match_community_list'): str, Optional('match_ext_community_list'): str, Optional('match_as_path_list'): str, Optional('match_interface'): str, Optional('match_prefix_list'): str, Optional('match_as_number_list'): str, Optional('match_prefix_list_v6'): str, }, 'actions': { Optional('set_route_origin'): str, Optional('set_distance'): int, Optional('set_local_pref'): int, Optional('set_next_hop'): list, Optional('set_next_hop_v6'): list, Optional('set_next_hop_self'): bool, Optional('set_as_path_prepend'): str, Optional('set_as_path_group'): list, Optional('set_as_path_prepend_repeat_n'): int, Optional('set_community'): str, Optional('match_tag_list'): str, Optional('set_community_additive'): bool, Optional('set_community_no_advertise'): bool, Optional('set_community_no_export'): bool, Optional('set_community_delete'): str, Optional('set_ext_community_rt'): list, Optional('set_ext_community_soo'): str, Optional('set_ext_community_vpn'): str, Optional('set_ext_community_rt_additive'): bool, Optional('set_ext_community_delete'): str, Optional('set_level'): str, Optional('set_weight'): int, Optional('set_metric'): int, Optional('set_ospf_metric_type'): str, Optional('set_metric_type'): str, 'route_disposition': str, Optional('set_tag'): str }, }, }, }, }
class TftpBoot(IOSXETftpBoot): """This stage boots a new image onto your device using the tftp booting method. Stage Schema ------------ tftp_boot: image (list): Image to boot with ip_address (list): Management ip address to configure to reach to the tftp server subnet_mask (str): Management subnet mask gateway (str): Management gateway tftp_server (str): Tftp server that is reachable with management interface recovery_password (str): Enable password for device required after bootup. Defaults to None. recovery_username (str): Enable username for device required after bootup. Defaults to None. save_system_config (bool, optional): Whether or not to save the system config if it was modified. Defaults to True. timeout (int, optional): Max time during which tftp boot must complete. Defaults to 1000 seconds. Example ------- tftp_boot: image: - /auto/some-location/that-this/image/stay-isr-image.bin ip_address: [10.1.7.126, 10.1.7.127] gateway: 10.1.7.1 subnet_mask: 255.255.255.0 tftp_server: 11.1.7.251 recovery_password: nbv_12345 recovery_username: user_123 save_system_config: False timeout: 1000 There is more than one ip address, one for each supervisor. """ # ================= # Argument Defaults # ================= # ================= RECOVERY_PASSWORD = None RECOVERY_USERNAME = None SAVE_SYSTEM_CONFIG = True TIMEOUT = 1000 # ============ # Stage Schema # ============ schema = { 'image': list, 'ip_address': list, 'subnet_mask': str, 'gateway': str, 'tftp_server': str, 'recovery_password': str, 'recovery_username': str, Optional('recovery_en_pasword'): str, Optional('save_system_config'): bool, Optional('timeout'): int, } # ============================== # Execution order of Stage steps # ============================== exec_order = [ 'delete_boot_variables', 'write_memory', 'go_to_rommon', 'tftp_boot', 'reconnect', ] def delete_boot_variables(self, steps, device, timeout=30): # Delete any previously configured boot variables with steps.start("Delete any previously configured boot variables on {}".\ format(device.name)) as step: try: device.configure('no boot system', timeout=timeout) except Exception as e: step.failed( "Failed to delete the boot variables because of {}".format( e))
class PingSchema(MetaParser): """ schema = { 'ping': { 'addrress': str, 'source': str, 'data-bytes': int, 'result': [ { 'bytes': int, 'from': str, 'icmp-seq': int, 'ttl': int, 'hlim': int, 'time': str, } ], 'ping-statistics': { 'send': str, 'received': str, 'loss-rate': str, 'round-trip': { 'min': str, 'avg': str, 'max': str, 'stddev': str, } } } } """ # Main Schema schema = { 'ping': { Optional('address'): str, Optional('source'): str, Optional('data-bytes'): int, Optional('result'): ListOf({ 'bytes': int, 'from': str, Optional('icmp-seq'): int, Optional('hlim'): int, Optional('ttl'): int, Optional('time'): str, Optional('message'): str, Optional('mtu'): int, }), 'statistics': { 'send': int, 'received': int, 'loss-rate': int, Optional('round-trip'): { 'min': str, 'avg': str, 'max': str, 'stddev': str, } } } }
class ShowVersionSchema(MetaParser): """Schema for show version""" schema = { 'version': { Optional('xe_version'): str, 'version_short': str, 'os': str, Optional('code_name'): str, 'platform': str, 'version': str, Optional('label'): str, Optional('build_label'): str, 'image_id': str, 'rom': str, 'bootldr_version': str, 'hostname': str, 'uptime': str, 'uptime_this_cp': str, 'returned_to_rom_by': str, 'system_image': str, 'last_reload_reason': str, 'chassis': str, 'processor_type': str, 'main_mem': str, 'processor_board_id': str, Optional('curr_config_register'): str, 'compiled_date': str, 'compiled_by': str, 'mac_address': str, 'mb_assembly_num': str, 'mb_sn': str, 'model_rev_num': str, 'mb_rev_num': str, 'model_num': str, Optional ('system_sn'): str, Optional('mem_size'): { Any(): str, }, Optional('license_level'): str, Optional('next_reload_license_level'): str, 'smart_licensing_status': str, Optional('number_of_intfs'): { Any(): str, }, Optional('disks'): { Any(): { 'disk_size': str, } }, } }
class ShowRunPolicyMapSchema(MetaParser): schema = { 'policy_map': { Any(): { 'class': { Any(): { Optional('qos_set'): { Optional('ip precedence'): str, Optional('qos-group'): str, }, Optional('police'): { Optional('cir_bps'): str, Optional('pir_bps'): str, Optional('cir_bc_bytes'): str, Optional('cir_be_bytes'): str, Optional('conformed'): str, Optional('exceeded'): str, }, Optional('bandwidth_percent'): str, Optional('priority_level'): str, Optional('target_shape_rate'): str, Optional('service_policy'): str, Optional('service_policy_input'): str, Optional('service_policy_output'): str, }, } }, } }
class ShowIpRouteSchema(MetaParser): """Schema for: show ip route bgp show ip route vrf <WORD> bgp show ipv6 route bgp show ipv6 route vrf <WORD> bgp""" schema = { 'vrf': { Any(): { Optional('address_family'): { Any(): { 'ip': { Any(): { Optional('nexthop'): { Optional(Any()): { Optional('protocol'): { Optional(Any()): { Optional('route_table'): str, Optional('candidate_default'): bool, Optional('uptime'): str, Optional('preference'): str, Optional('metric'): str, Optional('attribute'): str, } }, } }, } }, } }, } }, }
class ShowSpanningTreeMstSchema(MetaParser): schema = { 'mstp': { Any(): { 'mst_instances': { Any(): { 'mst_id': str, Optional('vlan'): str, Optional('this_bridge_is'): str, Optional('bridge_priority'): int, Optional('bridge_address'): str, Optional('bridge_max_age'): int, Optional('bridge_forward_delay'): int, Optional('bridge_max_hops'): int, Optional('bridge_transmit_hold_count'): int, Optional('designated_root_priority'): int, Optional('designated_root_address'): str, Optional('root_cost'): int, Optional('root_max_age'): int, Optional('root_forward_delay'): int, Optional('cist_root_priority'): int, Optional('cist_root_address'): str, Optional('cist_root_cost'): int, Optional('sys_id_ext'): int, 'interfaces': { Any(): { 'name': str, 'cost': int, 'port_priority': int, 'port_num': int, 'role': str, 'port_state': str, Optional('designated_cost'): int, 'designated_bridge_priority': int, 'designated_bridge_address': str, 'designated_port_priority': int, 'designated_port_num': int, } } } } } } }
class ShowEnvironmentAllSchema(MetaParser): """Schema for show environment all""" schema = { 'switch': { Any(): { 'fan': { Any(): { 'state': str, Optional('direction'): str, Optional('speed'): int, }, }, 'power_supply': { Any(): { 'state': str, Optional('pid'): str, Optional('serial_number'): str, 'status': str, Optional('system_power'): str, Optional('poe_power'): str, Optional('watts'): str } }, 'system_temperature_state': str, Optional('inlet_temperature'): { 'value': str, 'state': str, 'yellow_threshold': str, 'red_threshold': str }, Optional('outlet_temperature'): { 'value': str, 'state': str, 'yellow_threshold': str, 'red_threshold': str }, Optional('hotspot_temperature'): { 'value': str, 'state': str, 'yellow_threshold': str, 'red_threshold': str }, Optional('asic_temperature'): { 'value': str, 'state': str, 'yellow_threshold': str, 'red_threshold': str }, }, }, }
class ShowInterfaceDetailSchema(MetaParser): """Schema for * show interface detail """ schema = { 'interfaces': { Any(): { 'link_status': bool, 'line_protocol': bool, Optional('name'): str, Optional('mac_address'): str, Optional('mtu'): int, Optional('ipv4'): { Any(): { Optional('ip'): str, Optional('prefix_length'): str }, }, Optional('subnet'): str, Optional('interface_state'): bool, Optional('config_status'): bool, Optional('config_issue'): str, Optional('traffic_statistics'): { 'packets_input': int, 'bytes_input': int, 'packets_output': int, 'bytes_output': int, 'packets_dropped': int }, Optional('control_point_states'): { 'interface': { 'interface_number': int, 'interface_config_status': str, 'interface_state': str }, Any(): { 'interface_vlan_config_status': str, 'interface_vlan_state': str }, } }, } }
class ShowIpNatStatisticsSchema(MetaParser): """ Schema for command: * show ip nat statistics """ schema = { 'active_translations': { 'total': int, 'static': int, 'dynamic': int, 'extended': int, }, 'interfaces': { Optional('outside'): list, Optional('inside'): list, }, 'hits': int, 'misses': int, Optional('dynamic_mappings'): { Any(): { # 'Inside source' 'id': { Any(): { # 0, 1, 2 or 1, 2, 3 Optional('match'): str, # 'access-list 1 pool poo1' Optional('access_list'): str, Optional('route_map'): str, Optional('refcount'): int, Optional('interface'): str, Optional('pool'): { Any(): { # mypool test-pool 'netmask': str, 'start': str, 'end': str, 'type': str, 'total_addresses': int, 'allocated': int, 'allocated_percentage': int, 'misses': int, Optional('addr_hash'): int, Optional('average_len'): int, Optional('chains'): str, Optional('id'): int, } } } } } }, Optional('nat_limit_statistics'): { 'max_entry': { 'max_allowed': int, 'used': int, 'missed': int, } }, Optional('cef_translated_pkts'): int, Optional('in_to_out_drops'): int, Optional('out_to_in_drops'): int, Optional('cef_punted_pkts'): int, Optional('expired_translations'): int, Optional('pool_stats_drop'): int, Optional('mapping_stats_drop'): int, Optional('port_block_alloc_fail'): int, Optional('ip_alias_add_fail'): int, Optional('limit_entry_add_fail'): int, Optional('queued_pkts'): int, Optional('peak_translations'): int, Optional('occurred'): str, Optional('total_doors'): int, Optional('appl_doors'): int, Optional('normal_doors'): int, }
class ShowSpanningTreeSummarySchema(MetaParser): """Schema for show spanning-tree summary""" schema = { Optional('etherchannel_misconfig_guard'): bool, Optional('extended_system_id'): bool, Optional('portfast_default'): bool, 'bpdu_guard': bool, Optional('bpdu_filter'): bool, Optional('bridge_assurance'): bool, Optional('loop_guard'): bool, 'uplink_fast': bool, 'backbone_fast': bool, Optional('root_bridge_for'): str, Optional('pvst_simulation'): bool, Optional('pvst_simulation_status'): str, Optional('platform_pvst_simulation'): bool, Optional("configured_pathcost"): { 'method': str, Optional('operational_value'): str, }, Optional('mode'): { Any(): { # mstp, pvst, rapid_pvst Any(): { # <mst_domain>, <pvst_id> 'blocking': int, 'listening': int, 'learning': int, 'forwarding': int, 'stp_active': int, } } }, 'total_statistics': { 'blockings': int, 'listenings': int, 'learnings': int, 'forwardings': int, 'stp_actives': int, Optional('num_of_msts'): int, Optional('num_of_vlans'): int, } }
class ShowRouteIpv4Schema(MetaParser): """Schema for show route ipv4""" schema = { 'vrf': { Any(): { 'address_family': { Any(): { Optional('routes'): { Any(): { 'route': str, 'active': bool, Optional('ip'): str, Optional('mask'): str, Optional('route_preference'): int, Optional('metric'): int, Optional('source_protocol'): str, Optional('source_protocol_codes'): str, Optional('known_via'): str, Optional('distance'): int, Optional('type'): str, Optional('tag'): str, Optional('installed'): { 'date': str, 'for': str, }, Optional('redist_advertisers'): { Any(): { 'protoid': int, 'clientid': int, }, }, Optional('next_hop'): { Optional('outgoing_interface'): { Any(): { 'outgoing_interface': str, Optional('updated'): str, Optional('metric'): int, } }, Optional('next_hop_list'): { int: { # index 'index': int, Optional('next_hop'): str, Optional('outgoing_interface'): str, Optional('updated'): str, Optional('metric'): int, Optional('from'): str, Optional('table'): str, Optional('address_family'): str, Optional('table_id'): str, Optional('nexthop_in_vrf'): str, } } } } }, }, }, Optional('last_resort'): { Optional('gateway'): str, Optional('to_network'): str, }, }, } }
class ShowRomvarSchema(MetaParser): """Schema for show romvar.""" schema = { "rommon_variables": { Optional("ps1"): str, Optional("switch_number"): int, Optional("mcp_startup_traceflags"): str, Optional("license_active_level"): str, Optional("license_boot_level"): str, Optional("stack"): str, "boot": list, Optional("switch_priority"): int, Optional("chassis_ha_local_ip"): str, Optional("chassis_ha_remote_ip"): str, Optional("chassis_ha_local_mask"): str, Optional("ret_2_rts"): str, Optional("rmi_interface"): str, Optional("rmi_local_ip"): str, Optional("rmi_remote_ip"): str, "bsi": int, Optional("ret_2_rcalts"): str, "random_num": int, Optional("thrput"): str, Optional("config_file"): str, Optional("bootldr"): str, Optional("crashinfo"): str, Optional("no_console"): int, Optional("boot_device_mode"): str, Optional("boardid"): int, Optional("mac_addr"): str, Optional("manual_boot"): str, Optional("model_num"): str, Optional("model_revision_num"): str, Optional("motherboard_assembly_num"): str, Optional("motherboard_revision_num"): str, Optional("motherboard_serial_num"): str, Optional("rommon_autoboot_attempt"): int, Optional("system_serial_num"): str, Optional("version_id"): str, Optional("device_managed_mode"): str, Optional("default_gateway"): str, Optional("ip_address"): str, Optional("crashinfo"): str, Optional("subnet_mask"): str, Optional("abnormal_reset_count"): int } }
class ShowSnmpSchema(MetaParser): ''' Schema for "show snmp" ''' schema = { "chassis": str, "contact": str, Optional("location"): Optional(str), "snmp_input": { "packet_count": int, "bad_snmp_version_errors": int, "unknown_community_name": int, "illegal_operation_for_community_name_supplied": int, "encoding_errors": int, "number_of_requested_variables": int, "number_of_altered_variables": int, "get_request_pdus": int, "get_next_pdus": int, "set_request_pdus": int, "input_queue_drops": int, "maximum_queue_size": int }, "snmp_output": { "packet_count": int, "too_big_errors": int, "maximum_packet_size": int, "no_such_name_errors": int, "bad_value_errors": int, "general_errors": int, "response_pdus": int, "trap_pdus": int }, Optional("snmp_input_queue"): int, Optional("snmp_global_trap"): str, "snmp_logging" : { "status": str, Optional("endpoints") : { Optional(Any()) : { Optional("port") : int, Optional("queue"): int, Optional("queue_size"): int, Optional("sent"): int, Optional("dropped"): int } } } }
class TracerouteSchema(MetaParser): ''' Schema for: * 'traceroute' ''' schema = { 'traceroute': { Any(): { 'hops': { Any(): { 'paths': { Any(): { 'address': str, Optional('name'): str, Optional('probe_msec'): list, Optional('vrf_in_name'): str, Optional('vrf_out_name'): str, Optional('vrf_in_id'): str, Optional('vrf_out_id'): str, Optional('label_info'): { Optional('label_name'): str, Optional('exp'): int, Optional('MPLS'): { 'label': str, 'exp': int, }, }, Optional('mru'): int, }, }, Optional('code'): str, } }, Optional('timeout_seconds'): int, Optional('name_of_address'): str, 'address': str, Optional('vrf'): str, Optional('mask'): str, }, }, }
class ShowProcessesSchema(MetaParser): ''' Schema for commands: * show processes * show processes {process} ''' schema = { 'job_id': { Any(): { Optional('pid'): int, Optional('process_name'): str, Optional('executable_path'): str, Optional('instance'): str, Optional('version_id'): str, Optional('respawn'): str, Optional('respawn_count'): int, Optional('last_started'): str, Optional('process_state'): str, Optional('package_state'): str, Optional('started_on_config'): str, Optional('process_group'): str, Optional('core'): str, Optional('registered_item'): str, Optional('max_core'): int, Optional('placement'): str, Optional('startup_path'): str, Optional('ready'): str, Optional('available'): str, Optional('process_cpu_time'): { 'user': float, 'kernel': float, 'total': float, }, Optional('tid'): { Any(): { 'stack': str, 'pri': int, 'state': str, 'name': str, 'rt_pri': int, } } } } }
class ShowIpRpfSchema(MetaParser): """Schema for: show ip rpf <mroute address> show ip rpf vrf <vrf> <mroute address> show ipv6 rpf <mroute address> show ipv6 rpf vrf <vrf> <mroute address>""" schema = { 'vrf': { Any(): { 'source_address': str, Optional('source_host'): str, Optional('mofrr'): str, 'path': { Any(): { 'neighbor_address': str, 'interface_name': str, 'table_type': str, Optional('neighbor_host'): str, Optional('admin_distance'): str, Optional('route_mask'): str, Optional('table_feature'): str, Optional('table_feature_instance'): str, Optional('recursion_count'): int, Optional('metric'): int, Optional('distance_preferred_lookup'): bool, Optional('lookup_vrf'): str, Optional('lookup_topology'): str, Optional('originated_topology'): str } }, }, }, }
class ShowRunInterfaceSchema(MetaParser): schema = { 'interfaces': { Any(): { Optional('authentication_control_direction'): str, Optional('authentication_event_fail_action'): str, Optional('authentication_fallback'): str, Optional('authentication_host_mode'): str, Optional('authentication_order'): str, Optional('authentication_periodic'): bool, Optional('authentication_port_control'): str, Optional('authentication_priority'): str, Optional('authentication_timer_inactivity'): str, Optional('authentication_timer_reauthenticate_server'): bool, Optional('authentication_violation'): str, Optional('carrier_delay'): list, Optional('encapsulation_dot1q'): str, Optional('description'): str, Optional('dot1x_pae_authenticator'): bool, Optional('dot1x_timeout_quiet_period'): str, Optional('dot1x_timeout_server_timeout'): str, Optional('dot1x_timeout_tx_period'): str, Optional('ip_arp_inspection_limit_rate'): str, Optional('ip_dhcp_snooping_limit_rate'): str, Optional('ip_ospf'): { Any(): { 'area': str, }, }, Optional('ipv4'): { 'ip': str, 'netmask': str, }, Optional('ipv6'): list, Optional('ipv6_ospf'): { Any(): { 'area': str, }, }, Optional('ipv6_enable'): bool, Optional('ipv6_ospfv3'): { Any(): { 'area': str, }, }, Optional('load_interval'): str, Optional('mab'): bool, Optional('negotiation_auto'): bool, Optional('snmp_trap_link_status'): bool, Optional('snmp_trap_mac_notification_change_added'): bool, Optional('snmp_trap_mac_notification_change_removed'): bool, Optional('spanning_tree_bpduguard'): str, Optional('spanning_tree_portfast'): bool, Optional('switchport_access_vlan'): str, Optional('switchport_mode'): str, Optional('switchport_nonegotiate'): str, Optional('vrf'): str, } } }
class ShowRouteSchema(MetaParser): """Schema for * show route """ schema = { 'vrf': { 'default': { 'address_family': { 'ipv4': { Optional(Or('routes', 'tunneled_routes')): { Any(): { 'candidate_default': bool, Optional('subnet'): str, 'route': str, Optional('active'): bool, Optional('date'): str, Optional('route_preference'): int, Optional('metric'): int, Optional('source_protocol'): str, Optional('source_protocol_codes'): str, Optional('next_hop'): { Optional('outgoing_interface_name'): { Any(): { # context_name for interface if there is no next_hop Optional('outgoing_interface_name'): str }, }, Optional('next_hop_list'): { Any(): { # index Optional('index'): int, Optional('next_hop'): str, Optional('outgoing_interface_name'): str }, }, }, }, }, }, }, }, }, } """ Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2, V - VPN i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2 ia - IS-IS, * - candidate default, U - per-user static route o - ODR, P - periodic downloaded static route, + - replicated route SI - Static InterVRF """ source_protocol_dict = { 'O': 'ospf', 'IA': 'ospf', 'N1': 'ospf', 'N2': 'ospf', 'E1': 'ospf', 'E2': 'ospf', 'o': 'odr', 'i': 'isis', 'su': 'isis', 'L1': 'isis', 'L2': 'isis', 'ia': 'isis', 'D': 'eigrp', 'EX': 'eigrp', 'S': 'static', 'E': 'egp', 'M': 'mobile', 'L': 'local', 'C': 'connected', 'B': 'bgp', 'U': 'per-user static route', 'R': 'rip', 'I': 'igrp', '+': 'replicated route', 'V': 'VPN', 'P': 'periodic downloaded static route', 'SI': 'Static InterVRF', }
class ApplySelfSignedCert(BaseStage): """ This stage configures the self-signed-certificate for the given trustpoint. Stage Schema ------------ apply_self_signed_cert: key_size (int, optional): Key size to be configured. Default is 2048 signature_algorithm (str, optional): Algorithm to be applied. Default is sha256 encryption_type (int, optional): Encryption type to be configured. Default is 0 password (str): Password to be configured for the trustpoint. timeout (int, optional): Execute timeout in seconds. Defaults to 300. Examples: apply_self_signed_cert: key_size:2048 signature_algorithm:sha256 encryption_type:0 password:cisco123 timeout: 150 """ # ================= # Argument Defaults # ================= KEY_SIZE = 2048 SIGNATURE_ALGORITHM = "sha256" ENCRYPTION_TYPE = 0 TIMEOUT = 300 MAX_TIME = 300 CHECK_INTERVAL = 30 # ============ # Stage Schema # ============ schema = { 'password': str, Optional('key_size'): int, Optional('signature_algorithm'): str, Optional('encryption_type'): int, Optional('timeout'): int, } # ============================== # Execution order of Stage steps # ============================== exec_order = ['configure_ssc_trustpoint', 'verify_configured_trustpoint'] def configure_ssc_trustpoint(self, device, steps, password, key_size=KEY_SIZE, signature_algorithm=SIGNATURE_ALGORITHM, encryption_type=ENCRYPTION_TYPE, timeout=TIMEOUT): # Configuring the self signed certificate on the device with steps.start( "Configuring the self-signed certificate on {}".format( device.name)) as step: try: device.api.enable_http_server() device.api.set_clock_calendar() # passing the arguments to configure the SSC device.api.execute_self_signed_certificate_command( key_size=key_size, signature_algorithm=signature_algorithm, encryption_type=encryption_type, password=password, timeout=timeout) except (AttributeError, SubCommandFailure) as e: step.failed("Failed to configure the self-signed certificate", from_exception=e) def verify_configured_trustpoint(self, device, steps, max_time=MAX_TIME, check_interval=CHECK_INTERVAL): # the trustpoint name will always be in the following format of '<dev name>_WLC_TP' as it comes from the device trustpoint_name = device.name + "_WLC_TP" with steps.start( "Verify the self-signed certificate is configured") as step: # verifying if the trustpoint is configured properly result_1 = device.api.verify_wireless_management_trustpoint_name( trustpoint_name=trustpoint_name, max_time=max_time, check_interval=check_interval) result_2 = device.api.verify_pki_trustpoint_state( trustpoint_name=trustpoint_name, max_time=max_time, check_interval=check_interval) if not result_1 or not result_2: step.failed( "Management trustpoint {} is configured incorrectly". format(trustpoint_name))