ciscotestautomation / genieparser Goto Github PK
View Code? Open in Web Editor NEWsub-component of Genie that parse the device output into structured datastructure
License: Apache License 2.0
sub-component of Genie that parse the device output into structured datastructure
License: Apache License 2.0
Parser "show interfaces trunk" raises an exception when an interface in the list is in an STP alternate/blocking state.
It appears this regular expression does not account for "none" in the "Vlans in spanning tree forwarding state and not pruned" as shown in this example output:
SW3#show interfaces trunk
Port Mode Encapsulation Status Native vlan
Et0/0 auto 802.1q trunking 1
Et0/1 auto 802.1q trunking 1
Port Vlans allowed on trunk
Et0/0 1-4094
Et0/1 1-4094
Port Vlans allowed and active in management domain
Et0/0 1,5,7-10,22,43,58,67,79,123,146
Et0/1 1,5,7-10,22,43,58,67,79,123,146
Port Vlans in spanning tree forwarding state and not pruned
Et0/0 1
Et0/1 none
Spanning-tree:
SW3#show spanning-tree interface Ethernet0/1
Vlan Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
VLAN0001 Altn BLK 100 128.2 Shr
VLAN0005 Altn BLK 100 128.2 Shr
VLAN0007 Altn BLK 100 128.2 Shr
VLAN0008 Altn BLK 100 128.2 Shr
VLAN0009 Altn BLK 100 128.2 Shr
VLAN0010 Altn BLK 100 128.2 Shr
VLAN0022 Altn BLK 100 128.2 Shr
VLAN0043 Altn BLK 100 128.2 Shr
VLAN0058 Altn BLK 100 128.2 Shr
VLAN0067 Altn BLK 100 128.2 Shr
VLAN0079 Altn BLK 100 128.2 Shr
VLAN0123 Altn BLK 100 128.2 Shr
VLAN0146 Altn BLK 100 128.2 Shr
Stack trace:
2019-08-22T10:16:38: %AETEST-ERROR: Caught exception during execution:
2019-08-22T10:16:38: %AETEST-ERROR: Traceback (most recent call last):
2019-08-22T10:16:38: %AETEST-ERROR: File "/Users/jvoss/python/pyats/test.py", line 81, in prune_eligible_list
2019-08-22T10:16:38: %AETEST-ERROR: output = device.parse("show interfaces trunk")
2019-08-22T10:16:38: %AETEST-ERROR: File "src/genie/conf/base/device.py", line 498, in genie.conf.base.device.Device.parse
2019-08-22T10:16:38: %AETEST-ERROR: File "src/genie/metaparser/_metaparser.py", line 302, in genie.metaparser._metaparser.MetaParser.parse
2019-08-22T10:16:38: %AETEST-ERROR: File "src/genie/metaparser/_metaparser.py", line 284, in genie.metaparser._metaparser.MetaParser.parse
2019-08-22T10:16:38: %AETEST-ERROR: File "src/genie/metaparser/util/schemaengine.py", line 392, in genie.metaparser.util.schemaengine.Schema.validate
2019-08-22T10:16:38: %AETEST-ERROR: genie.metaparser.util.exceptions.SchemaMissingKeyError: Missing keys: [['interface', 'Ethernet0/1', 'vlans_in_stp_forwarding_not_pruned']]
Simular to issue #25
i user version
Requirement already up-to-date: genie.libs.parser in /usr/local/lib/python3.7/site-packages (19.8)
Requirement already satisfied, skipping upgrade: xmltodict in /usr/lib/python3.7/site-packages (from genie.libs.parser) (0.12.0)
In [4]: jkg.parse("show vtp status")
[2019-09-10 06:19:14,422] +++ jkgipswi001: executing command 'show vtp status' +++
show vtp status
VTP Version capable : 1 to 3
VTP version running : 3
VTP Domain Name : JKGv2
VTP Pruning Mode : Disabled
VTP Traps Generation : Disabled
Device ID : 885a.92d1.ae80
Feature VLAN:
--------------
VTP Operating Mode : Primary Server
Number of existing VLANs : 40
Number of existing extended VLANs : 0
Maximum VLANs supported locally : 2048
Configuration Revision : 25
Primary ID : 885a.92d1.ae80
Primary Description : jkgipswi001
MD5 digest : 0x3D 0x05 0xEE 0x1F 0x35 0xCC 0x7C 0x74
0x41 0x7A 0xB2 0x1F 0xE9 0x77 0x9A 0xCD
Feature MST:
--------------
VTP Operating Mode : Transparent
Feature UNKNOWN:
--------------
VTP Operating Mode : Transparent
jkgipswi001#
---------------------------------------------------------------------------
SchemaMissingKeyError Traceback (most recent call last)
<ipython-input-4-9698d17a0444> in <module>
----> 1 jkg.parse("show vtp status")
/usr/local/lib64/python3.7/site-packages/genie/conf/base/device.cpython-37m-x86_64-linux-gnu.so in genie.conf.base.device.Device.parse()
/usr/local/lib64/python3.7/site-packages/genie/metaparser/_metaparser.cpython-37m-x86_64-linux-gnu.so in genie.metaparser._metaparser.MetaParser.parse()
/usr/local/lib64/python3.7/site-packages/genie/metaparser/_metaparser.cpython-37m-x86_64-linux-gnu.so in genie.metaparser._metaparser.MetaParser.parse()
/usr/local/lib64/python3.7/site-packages/genie/metaparser/util/schemaengine.cpython-37m-x86_64-linux-gnu.so in genie.metaparser.util.schemaengine.Schema.validate()
SchemaMissingKeyError: Missing keys: [['vtp', 'feature', 'mst', 'configuration_revision'], ['vtp', 'feature', 'mst', 'primary_id']]
I have - > EAP Method = (13)
Dot1x Info for GigabitEthernet1/6
-----------------------------------
PAE = AUTHENTICATOR
QuietPeriod = 3
ServerTimeout = 0
SuppTimeout = 15
ReAuthMax = 2
MaxReq = 1
TxPeriod = 1
Dot1x Authenticator Client List
-------------------------------
EAP Method = (13)
Supplicant = 6451.065c.f902
Session ID = 0A90740B0000A7FD44A5F6A8
Auth SM State = AUTHENTICATED
Auth BEND SM State = IDLE
Running the parser for show ip protocols on a ASR920; IOS-XE 16.09.2.
Running from either ipyats or a robot file hitting the following error. Can this be set to ignore 'ospf' commands during run?
In [1]: from genie.libs.parser.iosxe.show_protocols import ShowIpProtocols
In [2]:
In [2]:
In [2]:
In [2]: lab920 = testbed.devices['LAB-ASR920-24SZ-2']
In [3]: lab920.connect()
[2019-02-27 18:41:19,597] +++ LAB-ASR920-24SZ-2 logfile /tmp/LAB-ASR920-24SZ-2-cli-20190227T184119596.log +++
[2019-02-27 18:41:19,598] +++ Unicon plugin iosxe +++
[2019-02-27 18:41:19,603] +++ connection to spawn: ssh -l dduser 10.50.15.11 -p 22, id: 139862119761960 +++
[2019-02-27 18:41:19,605] connection to LAB-ASR920-24SZ-2
[2019-02-27 18:41:19,609] ssh -l dduser 10.50.15.11 -p 22
<<logs ommited from connect>>
Out[3]: '[2019-02-27 18:41:19,609] ssh -l dduser 10.50.15.11 -p 22\r\n\r\r\n*******************************************************************************\r\r\n\r\r\n This is a private computer system. It is for authorized use only. Users\r\r\n (authorized or unauthorized) have no explicit or implicit expectation of\r\r\n privacy.\r\r\n\r\r\n Any or all uses of this system and all files on this system may be\r\r\n intercepted, monitored, recorded, copied, audited, inspected, and\r\r\n disclosed to authorized site, law enforcement personnel, as well as\r\r\n authorized officials of other agencies. By using this system, the user\r\r\n consents to such interception, monitoring, recording, copying, auditing,\r\r\n inspection, and disclosure at the discretion of authorized site personnel.\r\r\n\r\r\n Unauthorized or improper use of this system may result in administrative\r\r\n disciplinary action and civil and criminal penalties. By continuing to\r\r\n use this system you indicate your awareness of and consent to these terms\r\r\n and conditions of use. LOG OFF IMMEDIATELY if you do not agree to the\r\r\n conditions stated in this warning. Have a nice day.\r\r\n\r\r\n*******************************************************************************\r\r\npassword: \r\n\r\n*******************************************************************************\r\n Description: Nsight Corporate 470 Lab ASR920-24SZ-IM 2\r\n Hostname: CC4CORPLBB12.eng.nsight.com\r\n Machine Type: Cisco ASR920-24SZ-IM\r\n Loc ID: 70871\r\n Location: Nsight Crop 470 Lab A3, Green Bay, WI\r\n*******************************************************************************\r\n\r\nLAB-ASR920-24SZ-2#'
In [4]:
In [4]:
In [4]: ShowIpProtocols(lab920)
In [5]: proto = ShowIpProtocols(lab920)
In [7]: proto.parse()
[2019-02-27 18:42:34,631] +++ LAB-ASR920-24SZ-2: executing command 'show ip protocols' +++
show ip protocols
*** IP Routing is NSF aware ***
Routing Protocol is "application"
Sending updates every 0 seconds
Invalid after 0 seconds, hold down 0, flushed after 0
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
Maximum path: 32
Routing for Networks:
Routing Information Sources:
Gateway Distance Last Update
Distance: (default is 4)
Routing Protocol is "isis network_mpls"
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
Redistributing: isis network_mpls
Address Summarization:
None
Maximum path: 4
Routing for Networks:
TenGigabitEthernet0/0/26
TenGigabitEthernet0/0/27
Passive Interface(s):
Loopback0
Routing Information Sources:
Gateway Distance Last Update
10.239.6.3 115 05:56:34
10.239.6.2 115 05:56:34
10.239.6.4 115 05:56:34
10.239.6.9 115 05:56:34
Distance: (default is 115)
Routing Protocol is "bgp 9999"
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
IGP synchronization is disabled
Automatic route summarization is disabled
Maximum path: 1
Routing Information Sources:
Gateway Distance Last Update
10.239.6.3 200 12w5d
10.239.6.2 200 14w4d
Distance: external 20 internal 200 local 200
LAB-ASR920-24SZ-2#
---------------------------------------------------------------------------
UnboundLocalError Traceback (most recent call last)
~/pyats_dev/sandbox/lib64/python3.6/site-packages/ipyats/main.py in <module>
----> 1 proto.parse()
~/pyats_dev/sandbox/lib64/python3.6/site-packages/genie/metaparser/_metaparser.cpython-36m-x86_64-linux-gnu.so in genie.metaparser._metaparser.MetaParser.parse()
~/pyats_dev/sandbox/lib64/python3.6/site-packages/genie/libs/parser/iosxe/show_protocols.py in cli(self, output)
394 elif passive_interfaces is not None:
395 passive_interfaces.append(str(m.groupdict()['interface']))
--> 396 ospf_dict['passive_interfaces'] = passive_interfaces
397 continue
398
UnboundLocalError: local variable 'ospf_dict' referenced before assignment
It's silly, but this looks like a copy/paste error in this docstring.
Docstring says the filename is show_spanning_tree.py
, should be show_lldp.py
.
Using the genie parser for "show access-lists" against any ACL that contains object-group references will generate incomplete output, insofar as any line with an object-group is simply omitted from the output dictionary. For instance, parsing the following:
Extended IP access list Public_Trust
10 permit icmp any any echo
20 permit icmp any any echo-reply (198 matches)
40 permit icmp any any unreachable
50 permit icmp any any packet-too-big
60 deny icmp any any
70 permit ip object-group grt-interface-nets object-group grt-interface-nets
80 permit udp any host 224.0.0.102 eq 1985
90 permit esp object-group vpn-endpoints-dummydpd host 1.1.1.4 (14 matches)
100 permit ahp object-group vpn-endpoints-dummydpd host 1.1.1.4
110 permit udp object-group vpn-endpoints-dummydpd host 1.1.1.4 eq isakmp (122 matches)
Only produces a dictionary with items 10-80 present, 90-110 do not appear at all. The obvious worst case:
Extended IP access list worstcase-acl
10 permit ip object-group grt-interface-nets any
Output:
$ genie parse "show access-lists worstcase-acl" --testbed-file gns3.yml --devices rtr-ipsec-vlab1-a
{
"worstcase-acl": {
"name": "worstcase-acl",
"type": "ipv4-acl-type"
}
}
I don't know if this is an explicit schema limitation of the greater framework, but not being able to check for these items or read their statistics is a serious problem if the environment makes extensive use of this syntax.
This is listed as Open Source, but lacks a license file.
Someone made an issue on my Ansible parse_genie module, but I think they may have found a parse issue in the genie parser. Here is the original issue.
It looks like System Description
data in show lldp neighbor detail
is possibly failing to parse therefore system_description
is not in the parsed output.
See this for more info.
Is it possible to add parer for show auth session commnad?
would be grate to have for validating dot1x config and for finding failing dot1x devices.
Looking for parser compatible with the IOS platform, i believe the output is similar from other platforms.
more related commands can be find hear. ->
https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/security/s1/sec-s1-xe-3se-3850-cr-book/sec-s1-xe-3se-3850-cr-book_chapter_01.html#wp3404908137
example commnad.
show authentication sessions
show authentication sessions int gi 1/0/11
show authentication sessions interface GigabitEthernet3/0/2 details
I have an idea!
way not use the command show logging | exclude Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec
to extract the meta data for the logging setting on the IOS device.
full output example:
fspsw002#show log | exclude Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec
Syslog logging: enabled (0 messages dropped, 0 messages rate-limited, 0 flushes, 0 overruns, xml disabled, filtering disabled)
No Active Message Discriminator.
No Inactive Message Discriminator.
Console logging: disabled
Monitor logging: level debugging, 13 messages logged, xml disabled,
filtering disabled
Buffer logging: level debugging, 1566 messages logged, xml disabled,
filtering disabled
Exception Logging: size (4096 bytes)
Count and timestamp logging messages: disabled
File logging: disabled
Persistent logging: disabled
No active filter modules.
Trap logging: level informational, 1570 message lines logged
Logging to 192.168.1.3 (tcp port 1514, audit disabled,
link down),
787 message lines logged,
0 message lines rate-limited,
0 message lines dropped-by-MD,
xml disabled, sequence number disabled
filtering disabled
Logging to 1.22.33.4 (udp port 888, audit disabled,
link down),
0 message lines logged,
0 message lines rate-limited,
0 message lines dropped-by-MD,
xml disabled, sequence number disabled
filtering disabled
Logging Source-Interface: VRF Name:
Vlan200
Log Buffer (32000 bytes):
Receiving error: genie.metaparser.util.exceptions.SchemaMissingKeyError: Missing keys:
when using parse "show authentication sessions interface gigabitEthernet 1/12 details"
from genie cli.
IOSXE Traceback:
Traceback (most recent call last):
File "src/genie/cli/commands/parser.py", line 276, in genie.cli.commands.parser.ParserCommand.parse
File "src/genie/conf/base/device.py", line 498, in genie.conf.base.device.Device.parse
File "src/genie/metaparser/_metaparser.py", line 302, in genie.metaparser._metaparser.MetaParser.parse
File "src/genie/metaparser/_metaparser.py", line 284, in genie.metaparser._metaparser.MetaParser.parse
File "src/genie/metaparser/util/schemaengine.py", line 392, in genie.metaparser.util.schemaengine.Schema.validate
genie.metaparser.util.exceptions.SchemaMissingKeyError: Missing keys: [['interfaces', 'gigabitEthernet 2/20', 'local_policies'], ['interfaces', 'gigabitEthernet 2/20', 'iif_id'], ['interfaces', 'gigabitEthernet 2/20', 'session_timeout']]
Log files will be sent to PYATS support email.
- name: Testing PyATS
tasks:
- name: Read in parse_genie role
include_role:
name: clay584.parse_genie
- name: show interfaces
ios_command:
commands:
- show interfaces
register: interfaces
- name: Set Fact Genie Filter
set_fact:
pyats_interfaces: "{{ interfaces['stdout'][0] | parse_genie(command='show interfaces', os='iosxe') }}"
- name: Debug
debug:
var: pyats_interfaces.GigabitEthernet0/0
"ansible_facts": {
"pyats_interfaces": {
"GigabitEthernet0/0": {
"arp_timeout": "04:00:00",
"arp_type": "arpa",
"auto_negotiate": true,
"bandwidth": 1000000,
"counters": {
"in_broadcast_pkts": 0,
"in_crc_errors": 0,
"in_errors": 0,
"in_frame": 0,
"in_giants": 0, etc.
"pyats_interfaces.GigabitEthernet0/0": "VARIABLE IS NOT DEFINED!: 'dict object' has no attribute 'GigabitEthernet0'"
It appears it's being treated as an escape character.
Hi,
I think there is an issue with the VTP parser.
I'm running a test script, connected to a single IOS switch. I can successfully connect to the device, and parse 'show version', 'show interface' and 'show vlan'. However, the parser for 'show vtp staus' throws an error:
a.parse("show vtp status")
[2019-07-25 11:30:58,310] +++ <>: executing command 'show vtp status' +++
show vtp status
VTP Version : running VTP1 (VTP2 capable)
Configuration Revision : 0
Maximum VLANs supported locally : 1005
Number of existing VLANs : 131
VTP Operating Mode : Transparent
VTP Domain Name : <>
VTP Pruning Mode : Enabled
VTP V2 Mode : Disabled
VTP Traps Generation : Enabled
MD5 digest : 0x55 0xC8 0xE5 0x71 0x48 0x6A 0xB7 0x97
Configuration last modified by 0.0.0.0 at 0-0-00 00:00:00
<>#
Traceback (most recent call last):
File "", line 1, in
File "src/genie/conf/base/device.py", line 498, in genie.conf.base.device.Device.parse
File "src/genie/metaparser/_metaparser.py", line 271, in genie.metaparser._metaparser.MetaParser.parse
File "/home/ubuntu/environments/stpaul/lib/python3.5/site-packages/genie/libs/parser/iosxe/show_vtp.py", line 204, in cli
ret_dict['vtp']['configuration_revision'] = int(m.groupdict()['val'])
KeyError: 'vtp'
As reported by user Arpit in PyATS Community Teams room.
anybody able to help with genie learn interface NXOS
I am trying to get the duplex_mode
value but not all the interfaces have that value
I just want to get all the duplex value for all the interface
the โopsโ file created doesnโt have that so not able to parse json but console.txt does have that
but ios_xe devices have that and works perfectly fine
The "show vtp status" parser throws an error when the device is running VTP version 3. This is caused by the conf_last_modified_by
and conf_last_modified_time
keys being empty due to a difference in the output between versions 1/2 and 3.
Version [1|2]:
SW1#show vtp status
VTP Version capable : 1 to 3
VTP version running : 2
VTP Domain Name : TEST
VTP Pruning Mode : Enabled
VTP Traps Generation : Disabled
Device ID : 3820.5622.a580
Configuration last modified by 0.0.0.0 at 8-22-19 03:33:22
Feature VLAN:
--------------
VTP Operating Mode : Client
Maximum VLANs supported locally : 1005
Number of existing VLANs : 17
Configuration Revision : 4
MD5 digest : 0x8B 0x41 0x52 0x2B 0x33 0x5E 0x91 0x68
0xEF 0x95 0x70 0xE8 0xAA 0xEC 0x85 0xFF
Version 3:
SW2#show vtp status
VTP Version capable : 1 to 3
VTP version running : 3
VTP Domain Name : TEST
VTP Pruning Mode : Enabled
VTP Traps Generation : Disabled
Device ID : 3820.5622.a580
Feature VLAN:
--------------
VTP Operating Mode : Primary Server
Number of existing VLANs : 18
Number of existing extended VLANs : 0
Maximum VLANs supported locally : 4096
Configuration Revision : 2
Primary ID : 3820.5622.a580
Primary Description : SW2
MD5 digest : 0xC2 0x3C 0x1A 0x2C 0x1C 0x48 0x7D 0xFC
0x6B 0x17 0x15 0x87 0x92 0xC7 0x70 0x25
Feature MST:
--------------
VTP Operating Mode : Server
Configuration Revision : 0
Primary ID : 0000.0000.0000
Primary Description :
MD5 digest :
Feature UNKNOWN:
--------------
VTP Operating Mode : Transparent
Stack trace:
2019-08-23T07:24:41: %AETEST-ERROR: Caught exception during execution:
2019-08-23T07:24:41: %AETEST-ERROR: Traceback (most recent call last):
2019-08-23T07:24:41: %AETEST-ERROR: File "/Users/jvoss/python/pyats/test.py", line 47, in vtp_version
2019-08-23T07:24:41: %AETEST-ERROR: output = device.parse("show vtp status")
2019-08-23T07:24:41: %AETEST-ERROR: File "src/genie/conf/base/device.py", line 498, in genie.conf.base.device.Device.parse
2019-08-23T07:24:41: %AETEST-ERROR: File "src/genie/metaparser/_metaparser.py", line 302, in genie.metaparser._metaparser.MetaParser.parse
2019-08-23T07:24:41: %AETEST-ERROR: File "src/genie/metaparser/_metaparser.py", line 284, in genie.metaparser._metaparser.MetaParser.parse
2019-08-23T07:24:41: %AETEST-ERROR: File "src/genie/metaparser/util/schemaengine.py", line 392, in genie.metaparser.util.schemaengine.Schema.validate
2019-08-23T07:24:41: %AETEST-ERROR: genie.metaparser.util.exceptions.SchemaMissingKeyError: Missing keys: [['vtp', 'conf_last_modified_by'], ['vtp', 'conf_last_modified_time']]
Resolution:
Making the two keys conf_last_modified_by
and conf_last_modified_time
optional does not cause the parser to fail on version 3 output. However, the information is not necessarily accurate as similar output (such as VTP Operating Mode
and Configuration Revision
) from other features overwrites itself as they match additional lines.
Proposal:
Since VTP version 3 also contains discrete sets of information per feature (VLAN, MST, and Unknown), I propose the following change to the schema:
schema = {'vtp': {
Optional('version_capable'): list,
'version': str,
Optional('domain_name'): str,
'pruning_mode': bool,
'traps_generation': bool,
Optional('device_id'): str,
Optional('conf_last_modified_by'): str,
Optional('conf_last_modified_time'): str,
Optional('updater_id'): str,
Optional('updater_interface'): str,
Optional('updater_reason'): str,
Optional('operating_mode'): str,
Optional('enabled'): bool,
Optional('maximum_vlans'): int,
Optional('existing_vlans'): int,
Optional('configuration_revision'): int,
Optional('md5_digest'): str,
Optional('feature'): {
'vlan': {
'enabled': bool,
'operating_mode': str,
'maximum_vlans': int,
'existing_vlans': int,
'existing_extended_vlans': int,
'configuration_revision': int,
'primary_id': str,
Optional('primary_description'): str,
'md5_digest': str,
},
'mst': {
'enabled': bool,
'operating_mode': str,
'configuration_revision': int,
'primary_id': str,
Optional('primary_description'): str,
Optional('md5_digest'): str,
},
'unknown': {
'enabled': bool,
'operating_mode': str,
}
},
}
}
This schema returns exactly the same way for versions 1 and 2 as it does currently. However, with version 3, attributes are appropriately contained within a feature key.
While trying to parse the output of the "show policy-map interface output" command the following error gets generated:
File "src/genie/conf/base/device.py", line 498, in genie.conf.base.device.Device.parse
File "src/genie/metaparser/_metaparser.py", line 271, in genie.metaparser._metaparser.MetaParser.parse
File "/home/mike/.local/lib/python3.6/site-packages/genie/libs/parser/iosxe/show_policy_map.py", line 1271, in cli
return super().cli(output=show_output)
File "/home/mike/.local/lib/python3.6/site-packages/genie/libs/parser/iosxe/show_policy_map.py", line 941, in cli
class_map_dict['queue_limit_packets'] = m.groupdict()['queue_limit']
UnboundLocalError: local variable 'class_map_dict' referenced before assignment
The error is generated by the following data:
TenGigabitEthernet0/1/0
Service-policy output: xxxx
queue stats for all priority classes:
Queueing
queue limit 512 packets
(queue depth/total drops/no-buffer drops) 0/0/0
(pkts output/bytes output) 0/0
Class-map: yyyyyy (match-any)
Looking at the source I found that the problem seems to be that the schema is expecting the stats for all classes to be under a class.
I verified this by replacing "queue stats for all priority classes:" with "Class-map: all_priority_classes (match-any)\nMatch: any" after which, the command output was parsed.
I had to add the Match: any for it to work. It would be nice for these stats to be parsed without mapping them to a class.
Find a bug in the parser "show interfaces switchport"
If the vlan name 99 contians a hifen sign (-) i dont get the
Access Mode VLAN: 99 (Falback-Data)
output from switch
Name: Gi1/0/19
Switchport: Enabled
Administrative Mode: static access
Operational Mode: down
Administrative Trunking Encapsulation: dot1q
Negotiation of Trunking: Off
Access Mode VLAN: 99 (Falback-Data)
Trunking Native Mode VLAN: 1 (default)
Administrative Native VLAN tagging: enabled
Voice VLAN: 98 (Fallback-Voice)
Administrative private-vlan host-association: none
Administrative private-vlan mapping: none
Administrative private-vlan trunk native VLAN: none
Administrative private-vlan trunk Native VLAN tagging: enabled
Administrative private-vlan trunk encapsulation: dot1q
Administrative private-vlan trunk normal VLANs: none
Administrative private-vlan trunk associations: none
Administrative private-vlan trunk mappings: none
Operational private-vlan: none
Trunking VLANs Enabled: ALL
Pruning VLANs Enabled: 2-1001
Capture Mode Disabled
Capture VLANs Allowed: ALL
Protected: false
Unknown unicast blocked: disabled
Unknown multicast blocked: disabled
Appliance trust: none
No key 'access_vlan'
{'switchport_enable': True,
'switchport_mode': 'static access',
'operational_mode': 'down',
'encapsulation': {'administrative_encapsulation': 'dot1q',
'native_vlan': '1'},
'negotiation_of_trunk': False,
'native_vlan_tagging': True,
'private_vlan': {'native_vlan_tagging': True, 'encapsulation': 'dot1q'},
'trunk_vlans': 'all',
'pruning_vlans': '2-1001',
'capture_mode': False,
'capture_vlans': 'all',
'unknown_unicast_blocked': False,
'unknown_multicast_blocked': False}
I renamed the vlan
output from switch
Name: Gi1/0/19
Switchport: Enabled
Administrative Mode: static access
Operational Mode: down
Administrative Trunking Encapsulation: dot1q
Negotiation of Trunking: Off
Access Mode VLAN: 99 (Falback)
Trunking Native Mode VLAN: 1 (default)
Administrative Native VLAN tagging: enabled
Voice VLAN: 98 (Fallback-Voice)
Administrative private-vlan host-association: none
Administrative private-vlan mapping: none
Administrative private-vlan trunk native VLAN: none
Administrative private-vlan trunk Native VLAN tagging: enabled
Administrative private-vlan trunk encapsulation: dot1q
Administrative private-vlan trunk normal VLANs: none
Administrative private-vlan trunk associations: none
Administrative private-vlan trunk mappings: none
Operational private-vlan: none
Trunking VLANs Enabled: ALL
Pruning VLANs Enabled: 2-1001
Capture Mode Disabled
Capture VLANs Allowed: ALL
Protected: false
Unknown unicast blocked: disabled
Unknown multicast blocked: disabled
Appliance trust: none
i have the key 'access_vlan' :)
{'switchport_enable': True,
'switchport_mode': 'static access',
'operational_mode': 'down',
'encapsulation': {'administrative_encapsulation': 'dot1q',
'native_vlan': '1'},
'negotiation_of_trunk': False,
'access_vlan': '99',
'native_vlan_tagging': True,
'private_vlan': {'native_vlan_tagging': True, 'encapsulation': 'dot1q'},
'trunk_vlans': 'all',
'pruning_vlans': '2-1001',
'capture_mode': False,
'capture_vlans': 'all',
'unknown_unicast_blocked': False,
'unknown_multicast_blocked': False}
Traceback (most recent call last):
File "/Users/XX/PycharmProjects/test_folder/vpc_parser_test.py", line 102, in
after = device.parse('show vpc', output=vpc_plus)
File "src/genie/conf/base/device.py", line 536, in genie.conf.base.device.Device.parse
File "/Users/XX/miniconda3/envs/pyats/lib/python3.6/site-packages/genie/libs/parser/nxos/show_vpc.py", line 499, in cli
vpc_dict.update({'up_vlan_bitset': up_vlan_bitset})
UnboundLocalError: local variable 'vpc_dict' referenced before assignment
Example output for show vpc is:
Switch1# show vpc
Legend:
(*) - local vPC is down, forwarding via vPC peer-link
vPC domain id : 312
vPC+ switch id : 312
Peer status : peer adjacency formed ok
vPC keep-alive status : peer is alive
vPC fabricpath status : peer is reachable through fabricpath
Configuration consistency status : success
Per-vlan consistency status : success
Type-2 consistency status : success
vPC role : primary
Number of vPCs configured : 8
Peer Gateway : Disabled
Dual-active excluded VLANs : -
Graceful Consistency Check : Enabled
Auto-recovery status : Enabled (timeout = 300 seconds)
id Port Status Active vlans
1 Po1 up 1,10-28,30-54,56-82,138,530,2587
id Port Status Consistency Reason Active vlans vPC+ Attrib
11 Po11 up success success 1,10-28,30-5 DF: Partial,
4,56-82,138, FP MAC:
530,2587 312.0.0
It's not matching p19 regex.
Hi Thai,
Sorry to bother again...Not sure should I open a new issue/request or
continue from here....
See...I have this c3850 running IOS 03.07.05E...This IOS version don't have
the "show authentication sessions interface xxx details"...It's
equivalent is "show access-session interface xxxx details" (see below CLI
output)...
But seems that the genie parser don't have a parser for "show
access-session interface xxx" (it only have "show access-session").
Are we able to create one for " show access-session interface xxxx details"?
Thanks
NAC_SW_375#sh ver | in Cisco IOS
Cisco IOS Software, IOS-XE Software, Catalyst L3 Switch Software
(CAT3K_CAA-UNIVERSALK9-M), Version 03.07.05E RELEASE SOFTWARE (fc1)
Cisco IOS-XE software, Copyright (c) 2005-2015 by cisco Systems, Inc.
All rights reserved. Certain components of Cisco IOS-XE software are
NAC_SW_375#
NAC_SW_375#
NAC_SW_375#show authen
NAC_SW_375#show authen?
% Unrecognized command
NAC_SW_375#show access?
access-lists access-session
NAC_SW_375#show access-session ?
cache Shows Auth Manager cache info
database only show data stored in session database
fqdn FQDN Display Config commands
handle The context handle
history Show historic information
interface Client interface
mac The client MAC address
method The name of the Authentication method
registrations Shows Auth Manager registrations
session-id The client session ID
| Output modifiers
NAC_SW_375#show access-session interf
NAC_SW_375#show access-session interface Gi1/0/21 ?
details Show detailed information
policy Show policies applied on the interface
| Output modifiers
NAC_SW_375#show access-session interface Gi1/0/21 det
NAC_SW_375#show access-session interface Gi1/0/21 details
Interface: GigabitEthernet1/0/21
IIF-ID: 0x105B0C0000005F5
MAC Address: 0800.37c8.2dbc
IPv6 Address: Unknown
IPv4 Address: 10.10.10.1
User-Name: 08-00-37-C8-2D-BC
Status: Authorized
Domain: DATA
Oper host mode: multi-auth
Oper control dir: both
Session timeout: N/A
Restart timeout: N/A
Common Session ID: 0A7820020000413CCCE37640
Acct Session ID: 0x00007EAF
Handle: 0x7100056D
Current Policy: Test_DOT1X-DEFAULT_V1
Server Policies:
ACS ACL: xACSACLx-IP-Test_ACL_XeroxPrinters_v1-597a95c4
Method status list:
Method State
dot1x Stopped
mab Authc Success
On Thu, Nov 14, 2019 at 12:57 PM THAI NGUYEN [email protected]
wrote:
โ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/CiscoTestAutomation/genieparser/issues/24?email_source=notifications&email_token=ADDEDRDAAFAC6UB7DVO6E5LQTSWBFA5CNFSM4IFLNCP2YY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOU263WKI#event-2797452073,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ADDEDRFUW5WCQOQAOJ4HLVTQTSWBFANCNFSM4IFLNCPQ
.
Originally posted by @micyew in #24 (comment)
I'm seeing this for an interface on which VLANs are defined and policies are applied on those VLANs. Not sure if that is why the interface name appears even though it has no policy configuration applied to it directly.
The error generated is:
File "src/genie/conf/base/device.py", line 498, in genie.conf.base.device.Device.parse
File "src/genie/metaparser/_metaparser.py", line 302, in genie.metaparser._metaparser.MetaParser.parse
File "src/genie/metaparser/_metaparser.py", line 284, in genie.metaparser._metaparser.MetaParser.parse
File "src/genie/metaparser/util/schemaengine.py", line 392, in genie.metaparser.util.schemaengine.Schema.validate
genie.metaparser.util.exceptions.SchemaMissingKeyError: Missing keys: [['TenGigabitEthernet0/3/0', 'service_policy']]
The command output that generates the error is:
TenGigabitEthernet0/3/0
TenGigabitEthernet0/3/0.nnnn
Service-policy output: xxxxx
If TenGigabitEthernet0/3/0 is removed from the command output, the output is parsed correctly.
Running nxos9000v on ViRL, and get error for "show running-config vrf | sec '^vrf'" parser:
Command:
genie parse "show running-config vrf test-vrf | sec '^vrf'" --testbed-file testbed.yaml --devices device1 --output output/
Error:
Issue with the parser show running-config vrf test-vrf | sec '^vrf'
Traceback (most recent call last):
File "src/genie/cli/commands/parser.py", line 276, in genie.cli.commands.parser.ParserCommand.parse
File "src/genie/conf/base/device.py", line 498, in genie.conf.base.device.Device.parse
File "src/genie/metaparser/_metaparser.py", line 271, in genie.metaparser._metaparser.MetaParser.parse
TypeError: cli() got an unexpected keyword argument 'feature'
And in python:
from genie.conf import Genie
vrf_name = 'test-vrf'
vrf_parser = f"show running-config vrf {vrf_name} | sec '^vrf'"
testbed = Genie.init('testbed.yaml')
device = testbed.devices['device1']
device.connect()
running_config = device.parse(vrf_parser)
print(json.dumps(running_config, indent=4))
Error:
running_config = device.parse(vrf_parser)
File "src/genie/conf/base/device.py", line 498, in genie.conf.base.device.Device.parse
File "src/genie/metaparser/_metaparser.py", line 271, in genie.metaparser._metaparser.MetaParser.parse
TypeError: cli() got an unexpected keyword argument 'feature'
testbed.yaml:
testbed:
name: testbed
devices:
device1:
os: nxos
type: nxosv
connections:
defaults:
class: unicon.Unicon
telnet:
protocol: telnet
ip: 172.16.1.191
username: "cisco"
password: "cisco"
custom:
abstraction:
order: [os, type]
hello
when i do a learn_all, the 'platform' feature not work, since update genie-metaparser
Successfully installed MarkupSafe-1.1.1 aiohttp-3.6.2 async-timeout-3.0.1 attrs-19.2.0 chardet-3.0.4 dill-0.3.1.1 distro-1.4.0 genie.libs.parser-19.9 genie.metaparser-19.9 idna-2.8 jinja2-2.10.3 junit-xml-1.8 multidict-4.5.2 pathspec-0.6.0 psutil-5.6.3 pyats-19.9.2 pyats.aereport-19.9 pyats.aetest-19.9.1 pyats.async-19.9 pyats.connections-19.9 pyats.datastructures-19.9 pyats.easypy-19.9.3 pyats.kleenex-19.9.1 pyats.log-19.9.1 pyats.reporter-19.9.1 pyats.results-19.9 pyats.tcl-19.9 pyats.topology-19.9 pyats.utils-19.9 pyyaml-5.1.2 requests-2.22.0 setproctitle-1.1.10 six-1.12.0 unicon-19.9 urllib3-1.25.6 wheel-0.33.6 xmltodict-0.12.0 yamllint-1.17.0 yarl-1.3.0
my testbed:
testbed:
name: TESTBED
devices:
R1:
os: ios
type: iouxe
connections:
console:
protocol: telnet
ip: 192.168.248.174
port: 32769
my test code:
_from genie.conf import Genie
import pprint
import os
eve='/Users/cedric/Devops/RecetteTechnique/testbed.yaml'
testbed=Genie.init(eve)
pprint.pprint (testbed.devices)
rtr = testbed.devices["R1"]
rtr.connect()
Cannot read termcap database;
using dumb terminal settings.
{'R1': <Device R1 at 0x110c78eb8>,
'R2': <Device R2 at 0x110d3e8d0>}
[2019-10-14 14:14:10,905] +++ R1 logfile /tmp/R1-cli-20191014T141410905.log +++
[2019-10-14 14:14:10,906] +++ Unicon plugin ios +++
Trying 192.168.248.174...
[2019-10-14 14:14:10,940] +++ connection to spawn: telnet 192.168.248.174 32769, id: 4578089000 +++
[2019-10-14 14:14:10,940] connection to R1
Connected to 192.168.248.174.
Escape character is '^]'.
๏ฟฝ]0;R1๏ฟฝ
R1#
[2019-10-14 14:14:11,752] +++ initializing handle +++
[2019-10-14 14:14:11,753] +++ R1: executing command 'term length 0' +++
term length 0
R1#
[2019-10-14 14:14:11,949] +++ R1: executing command 'term width 0' +++
term width 0
R1#
[2019-10-14 14:14:12,182] +++ R1: executing command 'show version' +++
show version
Cisco IOS Software, Solaris Software (I86BI_LINUXL2-ADVENTERPRISE-M), Experimental Version 15.1(20131216:211730) [mmen 106]
Copyright (c) 1986-2013 by Cisco Systems, Inc.
Compiled Mon 16-Dec-13 13:50 by mmen
ROM: Bootstrap program is Linux
R1 uptime is 1 day, 9 minutes
System returned to ROM by reload at 0
System image file is "unix:/opt/unetlab/addons/iol/bin/i86bi-linux-l2-adventerprise-15.1b.b"
Last reload reason: Unknown reason
Linux Unix (Intel-x86) processor with 981578K bytes of memory.
Processor board ID 67108880
4 Ethernet interfaces
1 Virtual Ethernet interface
1024K bytes of NVRAM.
Configuration register is 0x0
R1#
[2019-10-14 14:14:12,408] +++ R1: config +++
config term
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#no logging console
R1(config)#line console 0
R1(config-line)#exec-timeout 0
R1(config-line)#end
R1#
info_all=rtr._learn_all()
import pprint
pprint.pprint(info_all)
{'acl': <Acl object at 0x1112761d0>,
'arp': <Arp object at 0x111276160>,
'bgp': <Bgp object at 0x1106ff208>,
'config': {'errored': LookupError('Could not find genie.libs.ops.config.config.Config for device R1',)},
'dot1x': <Dot1X object at 0x11073ea90>,
'eigrp': <Eigrp object at 0x1107cb9e8>,
'fdb': <Fdb object at 0x1107b4cc0>,
'hsrp': <Hsrp object at 0x1107b4908>,
'igmp': <Igmp object at 0x1107d9e10>,
'interface': {'errored': TypeError("cli() got an unexpected keyword argument 'intf'",)},
'lag': <Lag object at 0x1106f08d0>,
'lisp': <Lisp object at 0x11073e6d8>,
'lldp': <Lldp object at 0x110805828>,
'mcast': <Mcast object at 0x110771550>,
'mld': {'errored': TypeError("'NoneType' object is not iterable",)},
'msdp': <Msdp object at 0x110805b00>,
'nd': {'errored': NotImplementedError()},
'ntp': <Ntp object at 0x11082a5f8>,
'ospf': <Ospf object at 0x111f8bba8>,
'pim': <Pim object at 0x112097278>,
'platform': {'errored': NotImplementedError()},
'prefix_list': <PrefixList object at 0x1120cc9e8>,
'rip': <Rip object at 0x1120a1e10>,
'route_policy': <RoutePolicy object at 0x1120a2668>,
'routing': <Routing object at 0x1120a20f0>,
'static_routing': <StaticRouting object at 0x1121065f8>,
'stp': <Stp object at 0x112058400>,
'vlan': <Vlan object at 0x112071518>,
'vrf': <Vrf object at 0x1120eb630>,
'vxlan': {'errored': NotImplementedError()}}
>>> print(info_all["platform"].version)
Traceback (most recent call last):
File "", line 1, in
AttributeError: 'dict' object has no attribute 'version'
>>> print(info_all["platform"])
{'errored': NotImplementedError()}_
Cedric
I'm trying to run genie learn today. It's worked in the past, but it's not working at the moment with the following output:
(genie_lab_router) [gporter@fwdnetcent01 genie_lab_router]$ genie learn Traceback (most recent call last): File "/home/gporter/genie_lab_router/bin/genie", line 6, in <module> from genie.cli.__main__ import main File "src/genie/cli/__main__.py", line 8, in init genie.cli.__main__ File "src/genie/cli/commands/learn.py", line 6, in init genie.cli.commands.learn ImportError: cannot import name get_ops_exclude
I get the error "msg": "genie_parse: local variable 'cmd' referenced before assignment - Failed to parse command output." when trying to use this parser on an IOSXE device.
PLAY [Gather IOSXE BGP outputs] *******************************************************************************************************
TASK [SYS >> Read in parse_genie role] ************************************************************************************************
TASK [NET >> Get IOSXE BGP output] ****************************************************************************************************
ok: [dc1-csr-xnet1]
TASK [SYS >> Parse NXOS BGP output] ***************************************************************************************************
fatal: [dc1-csr-xnet1]: FAILED! => {"msg": "genie_parse: local variable 'cmd' referenced before assignment - Failed to parse command output."}
PLAY RECAP ****************************************************************************************************************************
dc1-csr-xnet1 : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
The playbook works fine with other cmds such as "show bgp all", also confirmed that the parser works fine using "genie parse "show bgp all summary" --testbed-file testbed.yaml --devices "DC1-CSR-XNET1"" against the same device.
Ansible version and playbook book:
ansible 2.8.4
config file = /home/ste/playbooks/chk_device_states/ansible.cfg
configured module search path = ['/home/ste/virt/ansible_2.8.4/lib/python3.6/site-packages/napalm_ansible/modules']
ansible python module location = /home/ste/virt/ansible_2.8.4/lib/python3.6/site-packages/ansible
executable location = /home/ste/virt/ansible_2.8.4/bin/ansible
python version = 3.6.8 (default, Jan 14 2019, 11:02:34) [GCC 8.0.1 20180414 (experimental) [trunk revision 259383]]
- name: "Gather IOSXE BGP outputs"
hosts: dc1-csr-xnet1
connection: local
tasks:
- name: SYS >> Read in parse_genie role
include_role:
name: clay584.parse_genie
- name: NET >> Get IOSXE BGP output
ios_command:
commands:
- show bgp all summary
register: bgp_output
- name: SYS >> Parse NXOS BGP output
set_fact:
pyats_bgp: "{{ bgp_output['stdout'][0] | parse_genie(command='show bgp all summary', os='iosxe') }}"
Device output, is on a CSR1000v version 16.06.02:
DC1-CSR-XNET1#show bgp all summary
For address family: VPNv4 Unicast
BGP router identifier 10.10.108.17, local AS number 65002
BGP table version is 6, main routing table version 6
5 network entries using 1280 bytes of memory
5 path entries using 680 bytes of memory
3/3 BGP path/bestpath attribute entries using 888 bytes of memory
2 BGP AS-PATH entries using 48 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
BGP using 2896 total bytes of memory
BGP activity 5/0 prefixes, 5/0 paths, scan interval 60 secs
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
172.16.101.2 4 901 7199 7269 6 0 0 06:12:04 1
172.16.201.2 4 12076 7199 7269 6 0 0 06:12:06 3
192.168.12.6 4 65001 7422 7267 6 0 0 06:11:55 0
192.168.12.10 4 65001 7396 7242 6 0 0 06:10:36 0
Thanks
Hello,
It looks like a bug for pyats_parser Ansible filter for directly conneced routes
OS is IOSXE
Here is output for sh ip route 10.20.100.10
TASK [debug] *************************************************************************************************************************************************
ok:[firewall] => {
"device_output": "Routing entry for 10.20.100.0/24\n Known via "connected", distance 0, metric 0 (connected, via interface)\n Redistributing via eigrp 100, ospf 4\n Routing Descriptor Blocks:\n * directly connected, via Port-channel2.60\n Route metric is 0, traffic share count is 1"
}
TASK [Parsing device output] *********************************************************************************************************************************
fatal: [firewall]: FAILED! => {
"msg": "Unable to parse output for command 'show ip route' (local variable 'path_dict' referenced before assignment)"
}
CSR-DEV#sh run vrf
Building configuration...
Current configuration : 143 bytes
vrf definition Mgmt
!
address-family ipv4
exit-address-family
!
address-family ipv6
exit-address-family
!
!
!
vrf definition VRF1
!
end
interfaces = abstract.ops.interface.interface.Interface(csr_dev)
interfaces.learn()
Result:
CSR-DEV#---------------------------------------------------------------------------
SchemaMissingKeyError Traceback (most recent call last)
<ipython-input-2-90b4adbe4fe0> in <module>()
4 # lookup = Lookup(device.os, device.context)
5 interfaces = abstract.ops.interface.interface.Interface(csr_dev)
----> 6 interfaces.learn()
~/projects/my/public/network-programmability-stream/.venv-py36/lib/python3.6/site-packages/genie/libs/ops/interface/iosxe/interface.py in learn(self, custom)
48
49 # make to write in cache
---> 50 self.make()
51
52 # mapping vrf to interface from ShowVrfDetail
~/projects/my/public/network-programmability-stream/.venv-py36/lib/python3.6/site-packages/genie/ops/base/base.cpython-36m-darwin.so in genie.ops.base.base.Base.make()
~/projects/my/public/network-programmability-stream/.venv-py36/lib/python3.6/site-packages/genie/ops/base/maker.cpython-36m-darwin.so in genie.ops.base.maker.Maker.make()
~/projects/my/public/network-programmability-stream/.venv-py36/lib/python3.6/site-packages/genie/ops/base/maker.cpython-36m-darwin.so in genie.ops.base.maker.Maker._call_parser()
~/projects/my/public/network-programmability-stream/.venv-py36/lib/python3.6/site-packages/genie/metaparser/_metaparser.cpython-36m-darwin.so in genie.metaparser._metaparser.MetaParser.parse()
~/projects/my/public/network-programmability-stream/.venv-py36/lib/python3.6/site-packages/genie/metaparser/_metaparser.cpython-36m-darwin.so in genie.metaparser._metaparser.MetaParser.parse()
~/projects/my/public/network-programmability-stream/.venv-py36/lib/python3.6/site-packages/genie/metaparser/util/schemaengine.cpython-36m-darwin.so in genie.metaparser.util.schemaengine.Schema.validate()
SchemaMissingKeyError: Missing keys: [['VRF1', 'address_family']]
genie parse "show vlan" --testbed-file dc.yml --output /dc_vlan
the file _console.txt includes vlan with underscore in the name
27 0027_192.168.1.0/24 active Po1, Po3, Po4, Po5, Po7, Po9
Po11, Po12, Po13, Po15, Eth1/1
Eth1/2, Eth1/3, Eth1/4, Eth1/6
Eth1/7, Eth1/9, Eth1/10, Eth1/11
Eth1/15, Eth1/41, Eth1/43
Eth1/44, Eth1/45, Eth1/46
Eth2/1, Eth2/2, Eth122/1/21
Eth122/1/22
28 0028_192.168.5.0/24 active Po1, Po3, Po4, Po5, Po7, Po9
Po11, Po12, Po13, Po15, Eth1/1
Eth1/2, Eth1/3, Eth1/4, Eth1/6
Eth1/7, Eth1/9, Eth1/10, Eth1/11
Eth1/15, Eth1/41, Eth1/43
Eth1/44, Eth1/45, Eth1/46
Eth2/1, Eth2/2, Eth122/1/21
Eth122/1/22
but i don't get any vlan 27 or 28 int the parsted file. _parsed.txt
if I remove the _ (undersore) form vlan name it ends upp in the _parsed.txt file
When parsing show ip route
on Catalyst 9300 (IOS-XE, 16.6.5), static routing without outgoing interface like below is not displayed in the parsed dictionary data.
Switch(config)# ip route 10.30.0.0 255.255.255.0 10.2.2.2
Switch#sh ip route
<snip>
S* 0.0.0.0/0 [1/0] via 10.10.20.254
10.0.0.0/8 is variably subnetted, 7 subnets, 2 masks
<snip>
S 10.30.0.0/24 [1/0] via 10.2.2.2
The static routing with outgoing interface seems to have no problem.
Switch(config)# ip route 10.30.20.0 255.255.255.0 Vlan835 10.2.2.2
Switch#sh ip route
<snip>
S 10.30.20.0/24 [1/0] via 10.2.2.2, Vlan835
<snip>
'10.30.20.0/24': {'active': True,
'metric': 0,
'next_hop': {'next_hop_list': {1: {'index': 1,
'next_hop': '10.2.2.2',
'outgoing_interface': 'Vlan835'}}},
'route': '10.30.20.0/24',
'route_preference': 1,
'source_protocol': 'static',
'source_protocol_codes': 'S'}}}}}}}
Hi
I believe the library genie.abstract
should be listed as a requirement since it's used in the file src/genie/libs/parser/__init__.py
from .base import tcl_invoke_ats_cmd,\
tcl_package_require_caas,\
tcl_package_require_caas_parsers,\
tcl_invoke_caas_abstract_parser,\
CaasMetaParser
from genie import abstract
abstract.declare_package(__name__)
I wasn't able to import a parser without installing this library first
Hi
i can do a traceroute, but i don't find any parameters for traceroute with vrf.
how can i do it ?
Thx.
from genie.conf import Genie
eve='/Users/cedric/Devops/RecetteTechnique/testbed.yaml'
testbed=Genie.init(eve)
rtr = testbed.devices["R1"]
rtr.connect()
rtr.traceroute("2.2.2.2\n")
2019-10-29 10:52:52,654] +++ R1: traceroute +++
traceroute
Protocol [ip]:
Target IP address: 2.2.2.2
Source address:
Numeric display [n]:
Timeout in seconds [3]:
Probe count [3]:
Minimum Time to Live [1]:
Maximum Time to Live [30]:
Port Number [33434]:
Loose, Strict, Record, Timestamp, Verbose[none]:
Type escape sequence to abort.
Tracing the route to 2.2.2.2
VRF info: (vrf in name/id, vrf out name/id)
1 10.0.13.3 2 msec 3 msec 0 msec
2 10.0.23.2 2 msec * 2 msec
R1#
'traceroute\r\nProtocol [ip]: \r\nTarget IP address: 2.2.2.2\r\nSource address: \r\nNumeric display [n]: \r\nTimeout in seconds [3]: \r\nProbe count [3]: \r\nMinimum Time to Live [1]: \r\nMaximum Time to Live [30]: \r\nPort Number [33434]: \r\nLoose, Strict, Record, Timestamp, Verbose[none]: \r\nType escape sequence to abort.\r\nTracing the route to 2.2.2.2\r\nVRF info: (vrf in name/id, vrf out name/id)\r\n 1 10.0.13.3 2 msec 3 msec 0 msec\r\n 2 10.0.23.2 2 msec * 2 msec\r\n'
Environment:
Platform: IOS-XR 6.5.3 and 6.6.3
> ansible 2.9.4
> config file = None
> configured module search path = ['/home/ubuntu/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
> ansible python module location = /home/ubuntu/venv/issue/lib/python3.7/site-packages/ansible
> executable location = /home/ubuntu/venv/issue/bin/ansible
> python version = 3.7.6 (default, Jan 24 2020, 07:14:12) [GCC 7.4.0]
pip packages version:
---------------------------- -----------
aiohttp 3.6.2
ansible 2.9.4
async-timeout 3.0.1
attrs 19.3.0
backports.ssl 0.0.9
bcrypt 3.1.7
certifi 2019.11.28
cffi 1.13.2
chardet 3.0.4
cryptography 2.8
dill 0.3.1.1
distro 1.4.0
genie 19.12
genie.abstract 19.12
genie.conf 19.12
genie.harness 19.12
genie.libs.conf 19.12
genie.libs.filetransferutils 19.12
genie.libs.ops 19.12
genie.libs.parser 19.12
genie.libs.sdk 19.12
genie.libs.telemetry 19.12
genie.metaparser 19.12
genie.ops 19.12
genie.parsergen 19.12
genie.predcore 19.12
genie.telemetry 19.12
genie.trafficgen 19.12
genie.utils 19.12
idna 2.8
IxNetwork 9.0.1915.16
Jinja2 2.10.3
jsonpickle 1.2
junit-xml 1.8
MarkupSafe 1.1.1
multidict 4.7.4
netaddr 0.7.19
paramiko 2.7.1
pathspec 0.7.0
pip 20.0.1
prettytable 0.7.2
psutil 5.6.7
pyats 19.12
pyats.aereport 19.12
pyats.aetest 19.12
pyats.async 19.12
pyats.connections 19.12
pyats.datastructures 19.12
pyats.easypy 19.12
pyats.kleenex 19.12
pyats.log 19.12
pyats.reporter 19.12
pyats.results 19.12
pyats.tcl 19.12
pyats.topology 19.12
pyats.utils 19.12
pycparser 2.19
PyNaCl 1.3.0
pyOpenSSL 19.1.0
PyYAML 5.3
requests 2.22.0
setuptools 41.2.0
six 1.14.0
tqdm 4.41.1
unicon 19.12.1
unicon.plugins 19.12.1
urllib3 1.25.8
websocket-client 0.57.0
wheel 0.33.6
xlrd 1.2.0
XlsxWriter 1.2.7
xlwt 1.3.0
xmltodict 0.12.0
yamllint 1.20.0
yarl 1.4.2
Task example:
- name: run "show route ipv6" on remote devices
iosxr_command:
commands: show route ipv6
register: result_show_route_ipv6
- debug:
msg: "{{ result_show_route_ipv6 }}"
- name: get parsed data using pyats_parser for "show route ipv6"
set_fact:
check_sh_route_ipv6: "{{ result_show_route_ipv6.stdout[0] | pyats_parser('show route ipv6', 'iosxr') }}"
- debug:
msg: "{{ check_sh_route_ipv6 }}"
Error:
FAILED! => {"msg": "Unable to parse output for command 'show route ipv6' (local variable 'source_protocol' referenced before assignment)"}
What could be the problem? Two months ago, more or less, I was able to parse "show route ipv6" using the clay584.parse_genie like this:
tasks:
- name: run "show route ipv6" on remote devices
iosxr_command:
commands:
- show route ipv6
register: result_show_route_ipv6
- name: get parsed data using pyats_parser for "show route ipv6"
set_fact:
check_sh_route_ipv6: "{{ result_show_route_ipv6.stdout[0] | parse_genie(command='show route ipv6', os='iosxr') }}"
- debug:
msg: "{{ check_sh_route_ipv6 }}"
but now I have a similar error:
FAILED! => {"msg": "parse_genie: local variable 'source_protocol' referenced before assignment - Failed to parse command output."}
While parsing the output of the following command
show bgp vpnv4 uni vrf vrf1 detail
Got the follwing error
File "src/genie/conf/base/device.py", line 498, in genie.conf.base.device.Device.parse
File "src/genie/metaparser/_metaparser.py", line 271, in genie.metaparser._metaparser.MetaParser.parse
File "/home/mike/.local/lib/python3.6/site-packages/genie/libs/parser/iosxe/show_bgp.py", line 1569, in cli
return super().cli(output=show_output, vrf=vrf, rd=rd,
File "/home/mike/.local/lib/python3.6/site-packages/genie/libs/parser/iosxe/show_bgp.py", line 1100, in cli
['address_family'][address_family]['prefixes'] = {}
UnboundLocalError: local variable 'prefixes' referenced before assignment
Looking at the source code, the local variable does not seem to have been initialized before line 1100 in show_bgp.py.
Use case: there will be a pair of routers with the following ACL present for allowing HSRP broadcast traffic on interfaces:
permit udp any host 224.0.0.102 eq 1985
Attempting to parse the access-lists of these devices will fail with the following traceback:
$ genie parse "show access-lists" --testbed-file gns3.yml --devices rtr-ipsec-vlab1-a
0%| | 0/1 [00:00<?, ?it/s]Issue with the parser show access-lists
Traceback (most recent call last):
File "src/genie/metaparser/_metaparser.py", line 284, in genie.metaparser._metaparser.MetaParser.parse
File "src/genie/metaparser/util/schemaengine.py", line 371, in genie.metaparser.util.schemaengine.Schema.validate
File "src/genie/metaparser/util/schemaengine.py", line 346, in genie.metaparser.util.schemaengine.Schema.validate
File "src/genie/metaparser/util/schemaengine.py", line 371, in genie.metaparser.util.schemaengine.Schema.validate
File "src/genie/metaparser/util/schemaengine.py", line 346, in genie.metaparser.util.schemaengine.Schema.validate
File "src/genie/metaparser/util/schemaengine.py", line 371, in genie.metaparser.util.schemaengine.Schema.validate
File "src/genie/metaparser/util/schemaengine.py", line 346, in genie.metaparser.util.schemaengine.Schema.validate
File "src/genie/metaparser/util/schemaengine.py", line 302, in genie.metaparser.util.schemaengine.Schema.validate
File "src/genie/metaparser/util/schemaengine.py", line 277, in genie.metaparser.util.schemaengine.Schema.validate
File "src/genie/metaparser/util/schemaengine.py", line 371, in genie.metaparser.util.schemaengine.Schema.validate
File "src/genie/metaparser/util/schemaengine.py", line 346, in genie.metaparser.util.schemaengine.Schema.validate
File "src/genie/metaparser/util/schemaengine.py", line 371, in genie.metaparser.util.schemaengine.Schema.validate
File "src/genie/metaparser/util/schemaengine.py", line 346, in genie.metaparser.util.schemaengine.Schema.validate
File "src/genie/metaparser/util/schemaengine.py", line 371, in genie.metaparser.util.schemaengine.Schema.validate
File "src/genie/metaparser/util/schemaengine.py", line 346, in genie.metaparser.util.schemaengine.Schema.validate
File "src/genie/metaparser/util/schemaengine.py", line 371, in genie.metaparser.util.schemaengine.Schema.validate
File "src/genie/metaparser/util/schemaengine.py", line 346, in genie.metaparser.util.schemaengine.Schema.validate
File "src/genie/metaparser/util/schemaengine.py", line 302, in genie.metaparser.util.schemaengine.Schema.validate
File "src/genie/metaparser/util/schemaengine.py", line 277, in genie.metaparser.util.schemaengine.Schema.validate
File "src/genie/metaparser/util/schemaengine.py", line 245, in genie.metaparser.util.schemaengine.Schema.validate
genie.metaparser.util.exceptions.SchemaTypeError: Public_Trust.aces.80.matches.l4.udp.destination_port.range.upper_port: Expected type '<class 'int'>' but got type '(80'(<class 'str'>)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "src/genie/cli/commands/parser.py", line 289, in genie.cli.commands.parser.ParserCommand.parse
File "src/genie/conf/base/device.py", line 549, in genie.conf.base.device.Device.parse
File "src/genie/metaparser/_metaparser.py", line 305, in genie.metaparser._metaparser.MetaParser.parse
Exception: Parser ShowAccessLists schema checking failed
''
The error seems to be due to the parser misinterpreting the number of matches for the rule in the "show access-lists" output:
Extended IP access list dummydpd-intacl
10 permit icmp any any
20 permit udp any host 224.0.0.102 eq 1985 (67 matches)
30 permit ip object-group dummydpd-local object-group dummydpd-remote
IE, the parser seems to assume that the part in parenthesis on line 20 should be the second part of a port range or list of ports. This ACL will parse fine if there are no hits on the item in question, IE, if I turn off the interface on the other router in the HSRP pair so it's no longer generating this traffic and clear the access-list statistics it'll work. I'm able to replicate this with other sorts of udp traffic acls; for instance, having this in the show access-lists output:
30 permit udp any any eq isakmp (12 matches)
Generates the same traceback.
Genie learn command for 'bgp' on ios-xe fails if the following address-families are configured on the router.
['rt_filter', 'mvpnv4_unicast']
Classes: ShowBgpAllNeighborsSchema(MetaParser):
Please add ['rt_filter', 'mvpnv4_unicast'] as part of the optional address families.
Optional('bgp_negotiated_capabilities'):
Issue while building the feature
Traceback (most recent call last):
File "src/genie/cli/commands/learn.py", line 310, in genie.cli.commands.learn.LearnCommand._retrieve_ops
File "/home/tele/pyATS/lib/python3.5/site-packages/genie/libs/ops/bgp/iosxe/bgp.py", line 425, in learn
self.make()
File "src/genie/ops/base/base.py", line 95, in genie.ops.base.base.Base.make
File "src/genie/ops/base/maker.py", line 272, in genie.ops.base.maker.Maker.make
File "src/genie/ops/base/maker.py", line 375, in genie.ops.base.maker.Maker._call_parser
File "src/genie/metaparser/_metaparser.py", line 289, in genie.metaparser._metaparser.MetaParser.parse
File "src/genie/metaparser/_metaparser.py", line 284, in genie.metaparser._metaparser.MetaParser.parse
File "src/genie/metaparser/util/schemaengine.py", line 302, in genie.metaparser.util.schemaengine.Schema.validate
File "src/genie/metaparser/util/schemaengine.py", line 277, in genie.metaparser.util.schemaengine.Schema.validate
File "src/genie/metaparser/util/schemaengine.py", line 371, in genie.metaparser.util.schemaengine.Schema.validate
File "src/genie/metaparser/util/schemaengine.py", line 346, in genie.metaparser.util.schemaengine.Schema.validate
File "src/genie/metaparser/util/schemaengine.py", line 302, in genie.metaparser.util.schemaengine.Schema.validate
File "src/genie/metaparser/util/schemaengine.py", line 277, in genie.metaparser.util.schemaengine.Schema.validate
File "src/genie/metaparser/util/schemaengine.py", line 371, in genie.metaparser.util.schemaengine.Schema.validate
File "src/genie/metaparser/util/schemaengine.py", line 346, in genie.metaparser.util.schemaengine.Schema.validate
File "src/genie/metaparser/util/schemaengine.py", line 371, in genie.metaparser.util.schemaengine.Schema.validate
File "src/genie/metaparser/util/schemaengine.py", line 346, in genie.metaparser.util.schemaengine.Schema.validate
File "src/genie/metaparser/util/schemaengine.py", line 403, in genie.metaparser.util.schemaengine.Schema.validate
genie.metaparser.util.exceptions.SchemaUnsupportedKeyError: vrf.default.neighbor.10.239.6.3.bgp_negotiated_capabilities: Unsupported keys: ['rt_filter', 'mvpnv4_unicast']
Hello
i have a problem when i want parse show interface description:
from genie.conf import Genie
import os
eve='/Users/cedric/Devops/RecetteTechnique/testbed.yaml'
testbed=Genie.init(eve)
rtr = testbed.devices["R1"]
rtr.connect()
out=rtr.execute("show interfaces description")
out=rtr.parse("show interfaces description")
[2019-10-14 11:27:15,352] +++ R1: executing command 'show interfaces description' +++
show interfaces description
Interface Status Protocol Description
Et0/0 up up
Et0/1 up up
Et0/2 up up
Et0/3 up up
Lo0 up up
Vl1 up up
R1#
Traceback (most recent call last):
File "", line 1, in
File "src/genie/conf/base/device.py", line 517, in genie.conf.base.device.Device.parse
File "src/genie/metaparser/_metaparser.py", line 289, in genie.metaparser._metaparser.MetaParser.parse
File "src/genie/metaparser/_metaparser.py", line 284, in genie.metaparser._metaparser.MetaParser.parse
File "src/genie/metaparser/util/schemaengine.py", line 223, in genie.metaparser.util.schemaengine.Schema.validate
genie.metaparser.util.exceptions.SchemaEmptyParserError: Parser Output is empty
my version : Successfully installed genie.libs.parser-19.9.1b3
my yaml:
testbed:
name: TESTBED
devices:
R1:
os: ios
type: iou
connections:
console:
protocol: telnet
ip: 192.168.248.174
port: 32769
Cedric.
As a creator of genie parsers, I would like to be able to define my own/private python packages that contain parsers, and then dynamically load them into the genie framework using the setuptools entry_point mechanism (described here). I would like the behavior to operate as follows:
The entry point values should point to user defined function(s) within their private package. Genie will call these functions during the initial loading of the framework, at the same time (immediately after) the parser definitions are loaded from the JSON file (stored in the genie distribution). These user defined functions will be responsible for returning a dictionary of data containing the parser classes to load into the genie framework.
# setup.py
# example private package is called idreamofgenie
entry_points={
"genie.libs.parser": [
"idreamofgenie": idreamofgenie:load_my_parsers"
]
}
The above example represents that the idreamofgenie
package has a function called load_my_parsers
.
# file: idreamofgenie.__init__.py
# import private parser modules
from idreamofgenie.parsers import iosxe, nxos
def load_my_parsers():
"""
This function is called during the genie.libs.parser startup to dynamically load
parsers defined in the this private package.
Returns
-------
dict[list]
key: <str> - OS name, for example "nxos"
value: list[class<MetaParser>] - list of parser classes
"""
return {
'iosxe': [
iosxe.show_interface_transceiver.ShowInterfaceTransceiver
],
'nxos': [
nxos.show_interface_transceiver.ShowInterfaceTransceiver
]
}
In [7]: sw2.parse("show module")
[2019-08-21 10:48:21,959] +++ tstipswi002: executing command 'show module' +++
show module
Chassis Type : WS-C4507R+E
Power consumed by backplane : 40 Watts
Mod Ports Card Type Model Serial No.
---+-----+--------------------------------------+------------------+-----------
1 48 10/100/1000BaseT Premium POE E Series WS-X4648-RJ45V+E JAE1747099J
3 6 Sup 7L-E 10GE (SFP+), 1000BaseX (SFP) WS-X45-SUP7L-E CAT1745L39S
6 48 10/100/1000BaseT Premium POE E Series WS-X4648-RJ45V+E JAE201200M0
7 48 10/100/1000BaseT Premium POE E Series WS-X4648-RJ45V+E JAE180604R8
M MAC addresses Hw Fw Sw Status
--+--------------------------------+---+------------+----------------+---------
1 24e9.b312.de30 to 24e9.b312.de5f 3.1 Ok
3 885a.92d1.aac0 to 885a.92d1.aac5 3.0 15.0(1r)SG10 03.06.07.E Ok
6 00f2.8b92.bf4e to 00f2.8b92.bf7d 3.1 Ok
7 b838.6144.4420 to b838.6144.444f 3.1 Ok
Mod Redundancy role Operating mode Redundancy status
----+-------------------+-------------------+----------------------------------
3 Active Supervisor RPR Active
System Failures:
----------------
Power Supply: bad/off (see 'show power')
tstipswi002#
---------------------------------------------------------------------------
SchemaEmptyParserError Traceback (most recent call last)
<ipython-input-7-3c6a369ace5a> in <module>
----> 1 sw2.parse("show module")
/usr/local/lib64/python3.7/site-packages/genie/conf/base/device.cpython-37m-x86_64-linux-gnu.so in genie.conf.base.device.Device.parse()
/usr/local/lib64/python3.7/site-packages/genie/metaparser/_metaparser.cpython-37m-x86_64-linux-gnu.so in genie.metaparser._metaparser.MetaParser.parse()
/usr/local/lib64/python3.7/site-packages/genie/metaparser/_metaparser.cpython-37m-x86_64-linux-gnu.so in genie.metaparser._metaparser.MetaParser.parse()
/usr/local/lib64/python3.7/site-packages/genie/metaparser/util/schemaengine.cpython-37m-x86_64-linux-gnu.so in genie.metaparser.util.schemaengine.Schema.validate()
SchemaEmptyParserError: Parser Output is empty
genie parse "show mac address-table" --testbed-file git/testbed.yml --output git/macadress-table/
C6880-X-LE
Version 15.1(02)SY01 [ Rel 1.1]
Getting following error message:
Issue with the parser show mac address-table
Traceback (most recent call last):
File "src/genie/cli/commands/parser.py", line 272, in genie.cli.commands.parser.ParserCommand.parse
File "src/genie/conf/base/device.py", line 498, in genie.conf.base.device.Device.parse
File "src/genie/metaparser/_metaparser.py", line 302, in genie.metaparser._metaparser.MetaParser.parse
File "src/genie/metaparser/_metaparser.py", line 284, in genie.metaparser._metaparser.MetaParser.parse
File "src/genie/metaparser/util/schemaengine.py", line 398, in genie.metaparser.util.schemaengine.Schema.validate
genie.metaparser.util.exceptions.SchemaMissingKeyError: Missing keys: [['total_mac_addresses']]
Using the playbook below
- hosts: localhost
gather_facts: no
vars:
contents: |
!Command: show running-config interface Ethernet1/1
!Running configuration last done at: Sun Aug 18 23:22:42 2019
!Time: Tue Sep 3 23:25:59 2019
version 7.0(3)I7(6) Bios:version 08.35
interface Ethernet1/1
description *** Peer Link ***
switchport
switchport mode trunk
switchport trunk allowed vlan 1-99,101-199,201-1399,1401-4094
channel-group 1 mode active
no shutdown
tasks:
- debug: msg="the value of contents is {{ contents }}"
- name: Read in parse_genie role
include_role:
name: clay584.parse_genie
- name: Debug Genie Filter
debug:
msg: "{{ contents | parse_genie(command='show running-config interface', os='nxos') }}"
I get this output
ansible-playbook -i my_hosts ./parse_show_run_interface.yml
PLAY [localhost] ***********************************************************************************************************************************************************************************************************************************************************************************************************************************************
TASK [debug] ***************************************************************************************************************************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
"msg": "the value of pattern.txt is !Command: show running-config interface Ethernet1/1\n!Running configuration last done at: Sun Aug 18 23:22:42 2019\n!Time: Tue Sep 3 23:25:59 2019\n\nversion 7.0(3)I7(6) Bios:version 08.35\n\ninterface Ethernet1/1\n description *** VPC PEER LINK PO1 to JER-LAB-N95KSW2 1/1-2 ***\n switchport\n switchport mode trunk\n switchport trunk allowed vlan 1-99,101-199,201-1399,1401-4094\n channel-group 1 mode active\n no shutdown\n"
}
TASK [Read in parse_genie role] ********************************************************************************************************************************************************************************************************************************************************************************************************************************
TASK [Debug Genie Filter] **************************************************************************************************************************************************************************************************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"msg": "parse_genie: cli() got an unexpected keyword argument 'output' - Failed to parse command output."}
PLAY RECAP *****************************************************************************************************************************************************************************************************************************************************************************************************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
Could you have a look at this, please?
After upgrade calatyst 4500 switch to
Software (cat4500e-UNIVERSALK9-M), Version 03.11.00.E RELEASE SOFTWARE (fc3)
the parser for "show vtp status" fails.
In [3]: tst2.parse("show vtp status")
[2019-11-06 08:48:03,608] +++ sw002: executing command 'show vtp status' +++
show vtp status
VTP Version capable : 1 to 3
VTP version running : 3
VTP Domain Name : MIGRA
VTP Pruning Mode : Disabled
VTP Traps Generation : Disabled
Device ID : 885a.92d1.aac0
Feature VLAN:
--------------
VTP Operating Mode : Client
Number of existing VLANs : 47
Number of existing extended VLANs : 0
Maximum VLANs supported locally : 2048
Configuration Revision : 15
Primary ID : 501c.bf9d.0c80
Primary Description : sw001
MD5 digest : 0xD9 0xAA 0x42 0x1D 0xD7 0xD6 0xA7 0x23
0xE8 0xBE 0xA0 0xB3 0x33 0xB1 0x7A 0x62
Feature MST:
--------------
VTP Operating Mode : Transparent
tstipswi002#
---------------------------------------------------------------------------
SchemaMissingKeyError Traceback (most recent call last)
<ipython-input-3-613aeb9cd548> in <module>
----> 1 tst2.parse("show vtp status")
/usr/local/lib64/python3.7/site-packages/genie/conf/base/device.cpython-37m-x86_64-linux-gnu.so in genie.conf.base.device.Device.parse()
/usr/local/lib64/python3.7/site-packages/genie/metaparser/_metaparser.cpython-37m-x86_64-linux-gnu.so in genie.metaparser._metaparser.MetaParser.parse()
/usr/local/lib64/python3.7/site-packages/genie/metaparser/_metaparser.cpython-37m-x86_64-linux-gnu.so in genie.metaparser._metaparser.MetaParser.parse()
/usr/local/lib64/python3.7/site-packages/genie/metaparser/util/schemaengine.cpython-37m-x86_64-linux-gnu.so in genie.metaparser.util.schemaengine.Schema.validate()
SchemaMissingKeyError: Missing keys: [['vtp', 'feature', 'unknown', 'enabled'], ['vtp', 'feature', 'unknown', 'operating_mode']]
Aloha,
The "show inventory" parser fails, if the description field is empty:
CLI Output:
NAME: "module 0/0/0", DESCR: "ASR 9000 20-port 1GE Modular Port Adapter"
PID: A9K-MPA-20X1GE, VID: V03, SN: FOC19286666
NAME: "module mau 0/0/0/0", DESCR: ""
PID: N/A, VID: N/A, SN: FNS66661UTW
Parser output:
"module 0/0/0": {
"descr": "ASR 9000 20-port 1GE Modular Port Adapter",
"pid": "N/A",
"vid": "N/A",
"sn": "FNS66661UTW"
},
This fix helped:
in: show_platform.py
line 746:
' +DESCR: +\"(?P<descr>[\w\-\.\:\/\s,&]+)\"$')"
change the + with *
' +DESCR: +\"(?P<descr>[\w\-\.\:\/\s,&]*)\"$')
Then it works:
"module 0/0/0": {
"descr": "ASR 9000 20-port 1GE Modular Port Adapter",
"pid": "A9K-MPA-20X1GE",
"vid": "V03",
"sn": "FOC196666"
},
"module mau 0/0/0/0": {
"descr": "",
"pid": "N/A",
"vid": "N/A",
"sn": "FNS66661UTW"
},
Im just learning programming and this is my first issue report in Github.
So forgive me, if I missed anything
Cheers
Marcel
Hello,
I've found a wrong regexp expression under the VRF RD match in the Genie parser lib show_vrf.py
for IOS-XR.
In case the RD has a format of ip_address:number
(e.g.: 172.16.0.1:1009
) , then there is no match.
My proposed solution is to add \.
to the regexp:
Current regexp:
...
# VRF VRF1; RD 200:1; VPN ID not set
p1 = re.compile(r'^VRF +(?P<vrf>[\w\-]+); +'
'RD +(?P<rd>[\w\s\:\<\>]+); +'
'VPN +ID +(?P<vpn_id>[\w\s\:]+)$')
...
New regexp:
...
# VRF VRF1; RD 200:1; VPN ID not set
p1 = re.compile(r'^VRF +(?P<vrf>[\w\-]+); +'
'RD +(?P<rd>[\w\s\:\<\>\.]+); +'
'VPN +ID +(?P<vpn_id>[\w\s\:]+)$')
...
The title is error massage which has output when I try "Learn multiple features" on this DEVNET webpage (https://developer.cisco.com/docs/pyats-getting-started/) because of a script "genie/libs/parser/iosxe/show_eigrp.py" is wrong.
This script has a class 'ShowEigrpIpv6NeighborsDetail' at the end of a script file but this class name shoud be the name 'ShowIpv6EigrpNeighborsDetail'.
After I fix this the error message has gone so may I ask the DEVNET team to fix it on git if what I'm mentioning is correct?
Thanks!
This documentation does not appear to match the actual schema definition for the ShowLldpEntrySchema class.
In [20]: foo = sw.parse("show interfaces status")
[2019-11-29 13:25:12,766] +++ jkgipswi001: executing command 'show interfaces status' +++
show interfaces status
Port Name Status Vlan Duplex Speed Type
Gi1/1 To Minet notconnect 1 auto auto 10/100/1000-TX
Gi1/2 TelenorVOIP notconnect 125 full 100 10/100/1000-TX
Gi1/3 DP connected 132 a-full a-1000 10/100/1000-TX
Gi1/4 DP notconnect 132 auto auto 10/100/1000-TX
Gi1/5 DP connected 132 a-full a-1000 10/100/1000-TX
Gi1/6 connected 100 a-full a-1000 10/100/1000-TX
Gi1/7 notconnect 99 auto auto 10/100/1000-TX
Gi1/8 notconnect 99 auto auto 10/100/1000-TX
Gi1/9 notconnect 99 auto auto 10/100/1000-TX
Gi1/10 To swi002 connected trunk a-full a-1000 10/100/1000-TX
Gi1/11 connected 136 a-full a-1000 10/100/1000-TX
Gi1/12 connected 99 a-full a-100 10/100/1000-TX
Gi1/13 connected 100 a-full a-1000 10/100/1000-TX
Gi1/14 connected 99 a-full a-1000 10/100/1000-TX
Gi1/15 notconnect 99 auto auto 10/100/1000-TX
Gi1/16 connected 100 a-full a-1000 10/100/1000-TX
Gi1/17 connected 100 a-full a-1000 10/100/1000-TX
Gi1/18 notconnect 99 auto auto 10/100/1000-TX
Gi1/19 connected 100 a-full a-1000 10/100/1000-TX
Gi1/20 notconnect 99 auto auto 10/100/1000-TX
Gi1/21 connected 100 a-full a-1000 10/100/1000-TX
Gi1/22 notconnect 99 auto auto 10/100/1000-TX
Gi1/23 notconnect 99 auto auto 10/100/1000-TX
Gi1/24 connected 100 a-full a-1000 10/100/1000-TX
Gi1/25 connected 250 a-full a-1000 10/100/1000-TX
Gi1/26 notconnect 99 auto auto 10/100/1000-TX
Gi1/27 connected 99 a-full a-1000 10/100/1000-TX
Gi1/28 notconnect 99 auto auto 10/100/1000-TX
Gi1/29 notconnect 99 auto auto 10/100/1000-TX
Gi1/30 connected 140 a-full a-100 10/100/1000-TX
Gi1/31 connected 99 a-full a-1000 10/100/1000-TX
Gi1/32 notconnect 99 auto auto 10/100/1000-TX
Gi1/33 notconnect 99 auto auto 10/100/1000-TX
Gi1/34 connected 100 a-full a-1000 10/100/1000-TX
Gi1/35 connected 99 a-full a-1000 10/100/1000-TX
Gi1/36 connected 100 a-full a-1000 10/100/1000-TX
Gi1/37 CAPWAP connected trunk a-full a-1000 10/100/1000-TX
Gi1/38 connected 100 a-full a-1000 10/100/1000-TX
Gi1/39 connected 100 a-full a-1000 10/100/1000-TX
Gi1/40 notconnect 99 auto auto 10/100/1000-TX
Gi1/41 connected 99 a-full a-10 10/100/1000-TX
Gi1/42 connected 99 a-full a-100 10/100/1000-TX
Gi1/43 CAPWAP connected trunk a-full a-1000 10/100/1000-TX
Gi1/44 connected 550 a-full a-1000 10/100/1000-TX
Gi1/45 CAPWAP connected trunk a-full a-1000 10/100/1000-TX
Gi1/46 notconnect 99 auto auto 10/100/1000-TX
Gi1/47 connected 99 a-full a-1000 10/100/1000-TX
Gi1/48 notconnect 99 auto auto 10/100/1000-TX
Gi2/1 notconnect 99 auto auto 10/100/1000-TX
Gi2/2 connected 100 a-full a-1000 10/100/1000-TX
Gi2/3 notconnect 99 auto auto 10/100/1000-TX
Gi2/4 connected 99 a-full a-10 10/100/1000-TX
Gi2/5 connected 99 a-full a-1000 10/100/1000-TX
Gi2/6 notconnect 99 auto auto 10/100/1000-TX
Gi2/7 notconnect 99 auto auto 10/100/1000-TX
Gi2/8 connected 99 a-full a-10 10/100/1000-TX
Gi2/9 connected 100 a-full a-1000 10/100/1000-TX
Gi2/10 notconnect 99 auto auto 10/100/1000-TX
Gi2/11 DEPLOY connected 136 a-full a-1000 10/100/1000-TX
Gi2/12 notconnect 99 auto auto 10/100/1000-TX
Gi2/13 connected 100 a-full a-1000 10/100/1000-TX
Gi2/14 notconnect 99 auto auto 10/100/1000-TX
Gi2/15 connected 99 a-full a-10 10/100/1000-TX
Gi2/16 connected 100 a-full a-1000 10/100/1000-TX
Gi2/17 notconnect 99 auto auto 10/100/1000-TX
Gi2/18 connected 99 a-full a-10 10/100/1000-TX
Gi2/19 connected 140 a-full a-1000 10/100/1000-TX
Gi2/20 connected 100 a-full a-1000 10/100/1000-TX
Gi2/21 connected 550 a-full a-1000 10/100/1000-TX
Gi2/22 DEPLOY notconnect 136 auto auto 10/100/1000-TX
Gi2/23 connected 140 a-full a-100 10/100/1000-TX
Gi2/24 CAPWAP connected trunk a-full a-1000 10/100/1000-TX
Gi2/25 CAPWAP connected trunk a-full a-1000 10/100/1000-TX
Gi2/26 CAPWAP connected trunk a-full a-1000 10/100/1000-TX
Gi2/27 connected 100 a-full a-1000 10/100/1000-TX
Gi2/28 connected 99 a-full a-10 10/100/1000-TX
Gi2/29 connected 99 a-full a-10 10/100/1000-TX
Gi2/30 connected 250 a-full a-1000 10/100/1000-TX
Gi2/31 connected 100 a-full a-1000 10/100/1000-TX
Gi2/32 connected 99 a-full a-10 10/100/1000-TX
Gi2/33 notconnect 99 auto auto 10/100/1000-TX
Gi2/34 connected 99 a-full a-10 10/100/1000-TX
Gi2/35 notconnect 99 auto auto 10/100/1000-TX
Gi2/36 connected 100 a-full a-1000 10/100/1000-TX
Gi2/37 connected 100 a-full a-1000 10/100/1000-TX
Gi2/38 notconnect 99 auto auto 10/100/1000-TX
Gi2/39 connected 100 a-full a-1000 10/100/1000-TX
Gi2/40 notconnect 99 auto auto 10/100/1000-TX
Gi2/41 connected 100 a-full a-1000 10/100/1000-TX
Gi2/42 notconnect 99 auto auto 10/100/1000-TX
Gi2/43 notconnect 99 auto auto 10/100/1000-TX
Gi2/44 notconnect 99 auto auto 10/100/1000-TX
Gi2/45 connected 100 a-full a-1000 10/100/1000-TX
Gi2/46 connected 100 a-full a-1000 10/100/1000-TX
Gi2/47 notconnect 99 auto auto 10/100/1000-TX
Gi2/48 connected 100 a-full a-1000 10/100/1000-TX
Te3/1 inactive 1 full auto No XCVR
Te3/2 inactive 1 full auto No XCVR
Gi3/3 notconnect 99 full 1000 No Gbic
Gi3/4 notconnect 99 full 1000 No Gbic
Gi3/5 To jkgipswi004 connected trunk full 1000 1000BaseSX
Gi3/6 To jkgipswi003 connected trunk full 1000 1000BaseSX
Gi5/1 connected 100 a-full a-1000 10/100/1000-TX
Gi5/2 connected 100 a-full a-1000 10/100/1000-TX
Gi5/3 connected 100 a-full a-1000 10/100/1000-TX
Gi5/4 connected 99 a-full a-10 10/100/1000-TX
Gi5/5 notconnect 99 auto auto 10/100/1000-TX
Gi5/6 connected 99 a-full a-10 10/100/1000-TX
Gi5/7 notconnect 99 auto auto 10/100/1000-TX
Gi5/8 notconnect 99 auto auto 10/100/1000-TX
Gi5/9 notconnect 99 auto auto 10/100/1000-TX
Gi5/10 notconnect 99 auto auto 10/100/1000-TX
Gi5/11 notconnect 99 auto auto 10/100/1000-TX
Gi5/12 connected 99 a-full a-1000 10/100/1000-TX
Gi5/13 connected 99 a-full a-10 10/100/1000-TX
Gi5/14 CAPWAP connected trunk a-full a-1000 10/100/1000-TX
Gi5/15 CAPWAP connected trunk a-full a-1000 10/100/1000-TX
Gi5/16 connected 100 a-full a-1000 10/100/1000-TX
Gi5/17 notconnect 99 auto auto 10/100/1000-TX
Gi5/18 connected 100 a-full a-1000 10/100/1000-TX
Gi5/19 connected 140 a-full a-100 10/100/1000-TX
Gi5/20 connected 99 a-full a-10 10/100/1000-TX
Gi5/21 connected 140 a-full a-100 10/100/1000-TX
Gi5/22 connected 99 a-full a-10 10/100/1000-TX
Gi5/23 notconnect 99 auto auto 10/100/1000-TX
Gi5/24 connected 100 a-full a-1000 10/100/1000-TX
Gi5/25 notconnect 99 auto auto 10/100/1000-TX
Gi5/26 connected 136 a-full a-1000 10/100/1000-TX
Gi5/27 connected 140 a-full a-100 10/100/1000-TX
Gi5/28 connected 99 a-full a-10 10/100/1000-TX
Gi5/29 notconnect 99 auto auto 10/100/1000-TX
Gi5/30 connected 100 a-full a-1000 10/100/1000-TX
Gi5/31 notconnect 99 auto auto 10/100/1000-TX
Gi5/32 connected 99 a-full a-10 10/100/1000-TX
Gi5/33 notconnect 99 auto auto 10/100/1000-TX
Gi5/34 connected 99 a-full a-10 10/100/1000-TX
Gi5/35 notconnect 99 auto auto 10/100/1000-TX
Gi5/36 notconnect 99 auto auto 10/100/1000-TX
Gi5/37 connected 140 a-full a-100 10/100/1000-TX
Gi5/38 connected 140 a-full a-100 10/100/1000-TX
Gi5/39 connected 99 a-full a-10 10/100/1000-TX
Gi5/40 connected 140 a-full a-100 10/100/1000-TX
Gi5/41 notconnect 99 auto auto 10/100/1000-TX
Gi5/42 connected 99 a-full a-10 10/100/1000-TX
Gi5/43 notconnect 99 auto auto 10/100/1000-TX
Gi5/44 notconnect 99 auto auto 10/100/1000-TX
Gi5/45 notconnect 99 auto auto 10/100/1000-TX
Gi5/46 notconnect 99 auto auto 10/100/1000-TX
Gi5/47 notconnect 99 auto auto 10/100/1000-TX
Gi5/48 notconnect 99 auto auto 10/100/1000-TX
switch1#
---------------------------------------------------------------------------
SchemaEmptyParserError Traceback (most recent call last)
<ipython-input-20-159ae12c0e93> in <module>
----> 1 foo = sw.parse("show interfaces status")
/pyats/lib/python3.6/site-packages/genie/conf/base/device.cpython-36m-x86_64-linux-gnu.so in genie.conf.base.device.Device.parse()
/pyats/lib/python3.6/site-packages/genie/metaparser/_metaparser.cpython-36m-x86_64-linux-gnu.so in genie.metaparser._metaparser.MetaParser.parse()
/pyats/lib/python3.6/site-packages/genie/metaparser/_metaparser.cpython-36m-x86_64-linux-gnu.so in genie.metaparser._metaparser.MetaParser.parse()
/pyats/lib/python3.6/site-packages/genie/metaparser/util/schemaengine.cpython-36m-x86_64-linux-gnu.so in genie.metaparser.util.schemaengine.Schema.validate()
SchemaEmptyParserError: Parser Output is empty
I am using version....
l# pip freeze | grep genie
genie==19.11
genie.abstract==19.11
genie.conf==19.11
genie.harness==19.11
genie.libs.conf==19.11
genie.libs.filetransferutils==19.11
genie.libs.ops==19.11
genie.libs.parser==19.11
genie.libs.sdk==19.11
genie.libs.telemetry==19.11
genie.metaparser==19.11
genie.ops==19.11
genie.parsergen==19.11
genie.predcore==19.11
genie.telemetry==19.11
genie.trafficgen==19.11
genie.utils==19.11
Hi, tried quite a few times to run this command in the last two versions (19.9 and 19.10) with the same result.
Command:
genie parse "show bgp sessions" --testbed-file base2.yaml
Error:
Parsed command 'show bgp sessions' but it returned empty
Python:
from genie.conf import Genie
testbed = Genie.init('base2.yaml')
device = testbed.device['PE-02']
device.connect()
bgp = device.parse('show bgp sessions')
Error:
SchemaEmptyParserError Traceback (most recent call last)
<ipython-input-7-11dda00aa363> in <module>
----> 1 bgp = device.parse('show bgp sessions')
~/PycharmProjects/test-genie/venv/lib/python3.7/site-packages/genie/conf/base/device.cpython-37m-darwin.so in genie.conf.base.device.Device.parse()
~/PycharmProjects/test-genie/venv/lib/python3.7/site-packages/genie/metaparser/_metaparser.cpython-37m-darwin.so in genie.metaparser._metaparser.MetaParser.parse()
~/PycharmProjects/test-genie/venv/lib/python3.7/site-packages/genie/metaparser/_metaparser.cpython-37m-darwin.so in genie.metaparser._metaparser.MetaParser.parse()
~/PycharmProjects/test-genie/venv/lib/python3.7/site-packages/genie/metaparser/util/schemaengine.cpython-37m-darwin.so in genie.metaparser.util.schemaengine.Schema.validate()
SchemaEmptyParserError: Parser Output is empty
Attempting to parse an access-list that reads as follows in "show access-lists":
Extended IP access list Public_Trust
10 permit icmp any any echo
20 permit icmp any any echo-reply (1195 matches)
30 permit icmp any any ttl-exceeded
40 permit icmp any any unreachable
50 permit icmp any any packet-too-big
60 deny icmp any any
70 permit ip object-group grt-interface-nets object-group grt-interface-nets
80 permit udp any host 224.0.0.102 eq 1985
Generates the following error:
$ genie parse "show access-lists" --testbed-file gns3.yml --devices rtr-ipsec-vlab1-a
0%| | 0/1 [00:00<?, ?it/s]Issue with the parser show access-lists
Traceback (most recent call last):
File "src/genie/cli/commands/parser.py", line 289, in genie.cli.commands.parser.ParserCommand.parse
File "src/genie/conf/base/device.py", line 549, in genie.conf.base.device.Device.parse
File "src/genie/metaparser/_metaparser.py", line 271, in genie.metaparser._metaparser.MetaParser.parse
File "/Users/josiemer/configs/Automation/pyATS/venv/lib/python3.7/site-packages/genie/libs/parser/iosxe/show_acl.py", line 478, in cli
l3_dict['ttl_operator'] = ttl_group.groups()[0]
AttributeError: 'NoneType' object has no attribute 'groups'
I initially thought this error was related to the access-list containing object-groups, but the actual cause seems to be this line:
permit icmp any any ttl-exceeded
Looking at the code it appears the parser is attempting to make some kind of sense of whatever text might follow "ttl" in this part of an ACL and failing. Removing this line of the ACL will allow it to be processed.
When trying to use your role with Cisco ASA's I get the following error
FAILED! => {"msg": "The network OS provided (ASA) to the parse_genie filter is not a supported OS in Genie."}
AND
FAILED! => {"msg": "The network OS provided (asa) to the parse_genie filter is not a supported OS in Genie."}
Adding 'asa' to your
supported_oses = ["ios", "iosxe", "iosxr", "junos", "nxos"]
seems to fix the issue.
You also need to update your error message to link to the correct parser list
https://pubhub.devnetcloud.com/media/pyats-packages/docs/genie/genie_libs/#/parsers
is not valid.
thanks!
Receiving KeyError when using Genie learn bgp. Genie output files will be sent to [email protected]
The parsing of the VRF name in the show route ipv4 vrf all command on IOS-XR router is not working as expected. In case the VRF name is not standard and the name have any special character like (:_) the VRF name is returned as 'default'.
Below is an Example
RP/0/RP0/CPU0:xrv_rtr1#sh route vrf L:192
Thu Feb 6 00:29:44.865 UTC
Codes: C - connected, S - static, R - RIP, B - BGP, (>) - Diversion path
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, E - EGP
i - ISIS, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, su - IS-IS summary null, * - candidate default
U - per-user static route, o - ODR, L - local, G - DAGR, l - LISP
A - access/subscriber, a - Application route
M - mobile route, r - RPL, t - Traffic Engineering, (!) - FRR Backup path
Gateway of last resort is not set
S 10.2.2.2/32 is directly connected, 00:06:36, Null0
"default": {
"address_family": {
"ipv4": {
"routes": {
"10.2.2.2/32": {
"active": true,
"next_hop": {
"outgoing_interface": {
"Null0": {
"outgoing_interface": "Null0",
"updated": "00:00:25"
}
}
},
"route": "10.2.2.2/32",
"source_protocol": "static",
"source_protocol_codes": "S"
}
}
}
}
},
I think that the problem is in the parsing of the VRF name since you are matching only on (\w).
If this is modified this will solve the problem.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.