CiscoTestAutomation / genieparser

sub-component of Genie that parse the device output into structured datastructure
Apache License 2.0
249 stars 386 forks source link

NX-OS parsing of 'show l2route' commands fail on version 22.7 #697

Closed deep-blue-pulsar closed 2 years ago

deep-blue-pulsar commented 2 years ago

Parsing the commands below fail with the following exceptions: dev.parse("show l2route mac-ip all detail")

Traceback (most recent call last):
  File "/home/xxxxxx/myvenv/pyats_test.py", line 10, in <module>
    cmd = dev.parse("show l2route mac-ip all detail")
  File "src/genie/conf/base/device.py", line 528, in genie.conf.base.device.Device.parse
  File "src/genie/conf/base/device.py", line 567, in genie.conf.base.device.Device._get_parser_output
  File "src/genie/conf/base/device.py", line 565, in genie.conf.base.device.Device._get_parser_output
  File "src/genie/metaparser/_metaparser.py", line 308, in genie.metaparser._metaparser.MetaParser.parse
  File "/home/[REDACTED]/myvenv/lib/python3.9/site-packages/genie/libs/parser/nxos/show_vxlan.py", line 1579, in cli
    topo_dict.update({k:int(v) for k,v in group.items() })
  UnboundLocalError: local variable 'topo_dict' referenced before assignment

dev.parse("show l2route evpn mac-ip all")

Traceback (most recent call last):
  File "/home/xxxxxx/myvenv/pyats_test.py", line 10, in <module>
    cmd = dev.parse("show l2route evpn mac-ip all")
  File "src/genie/conf/base/device.py", line 528, in genie.conf.base.device.Device.parse
  File "src/genie/conf/base/device.py", line 567, in genie.conf.base.device.Device._get_parser_output
  File "src/genie/conf/base/device.py", line 565, in genie.conf.base.device.Device._get_parser_output
  File "src/genie/metaparser/_metaparser.py", line 329, in genie.metaparser._metaparser.MetaParser.parse
  File "src/genie/metaparser/_metaparser.py", line 322, in genie.metaparser._metaparser.MetaParser.parse
  File "src/genie/metaparser/util/schemaengine.py", line 233, in genie.metaparser.util.schemaengine.Schema.validate
genie.metaparser.util.exceptions.SchemaEmptyParserError: Parser Output is empty
Taarini commented 2 years ago

Hi

Thanks for reporting.

Could you please share the device output which caused the above issues.

Please share the os and platform along with it.

deep-blue-pulsar commented 2 years ago

Hi

Thanks for reporting.

Could you please share the device output which caused the above issues.

Please share the os and platform along with it.

Hi @Taarini,

Of course, here you go:

2022-08-29 10:34:58,148: %UNICON-INFO: +++ initializing handle +++

2022-08-29 10:34:59,028: %UNICON-INFO: +++ LEAF1 with via 'cli': executing command 'show l2route evpn mac-ip all' +++
show l2route evpn mac-ip all
Flags -(Rmac):Router MAC (Stt):Static (L):Local (R):Remote (V):vPC link
(Dup):Duplicate (Spl):Split (Rcv):Recv(D):Del Pending (S):Stale (C):Clear
(Ps):Peer Sync (Ro):Re-Originated (Orp):Orphan
Topology    Mac Address    Host IP                                 Prod   Flags
        Seq No     Next-Hops
----------- -------------- --------------------------------------- ------ ------
---- ---------- ---------------------------------------
10          0050.7966.6805 10.10.0.10                              HMM    L,
        0         Local
20          0050.7966.6808 10.20.0.120                             BGP    --
        0         10.0.0.4 (Label: 20)
LEAF1#
Traceback (most recent call last):
  File "/home/[redacted]/myvenv/pyats_test.py", line 10, in <module>
    cmd = dev.parse("show l2route evpn mac-ip all")
  File "src/genie/conf/base/device.py", line 528, in genie.conf.base.device.Device.parse
  File "src/genie/conf/base/device.py", line 567, in genie.conf.base.device.Device._get_parser_output
  File "src/genie/conf/base/device.py", line 565, in genie.conf.base.device.Device._get_parser_output
  File "src/genie/metaparser/_metaparser.py", line 329, in genie.metaparser._metaparser.MetaParser.parse
  File "src/genie/metaparser/_metaparser.py", line 322, in genie.metaparser._metaparser.MetaParser.parse
  File "src/genie/metaparser/util/schemaengine.py", line 233, in genie.metaparser.util.schemaengine.Schema.validate
genie.metaparser.util.exceptions.SchemaEmptyParserError: Parser Output is empty
Software
  BIOS: version
 NXOS: version 9.3(6)
  BIOS compile time:
  NXOS image file is: bootflash:///nxos.9.3.6.bin
  NXOS compile time:  11/9/2020 23:00:00 [11/10/2020 11:00:21]

Hardware
  cisco Nexus9000 C9300v Chassis
Taarini commented 2 years ago

Hi,

The reason you are getting "Parser Output is empty" because the regex pattern didn't match your output.

Sharing the example link of how we are currently parsing, https://github.com/CiscoTestAutomation/genieparser/blob/master/src/genie/libs/parser/nxos/tests/ShowL2routeMacIpAllDetail/cli/equal/golden_output1_output.txt

pyATS parser is community driven.

Please consider contributing to pyATS genie parser library.

Below is a link with instructions on how to write a parser: https://pubhub.devnetcloud.com/media/pyats-development-guide/docs/writeparser/writeparser.html

If you need any help, please let me know by creating a pull request for the above issue

Taarini commented 2 years ago

The issue will be closed within 3 business days if there is no reply

deep-blue-pulsar commented 2 years ago

I thought any parser listed here was already in a working state?

https://pubhub.devnetcloud.com/media/genie-feature-browser/docs/#/parsers

The "Parser Output is empty" results from the "show l2route evpn mac-ip all". The "detail" version of the command fails with the exception UnboundLocalError: local variable 'topo_dict' referenced before assignment.

Taarini commented 2 years ago

Yeah it is, but device output varies from devices which you use.

Taarini commented 2 years ago

No reply from user hence closing