CiscoTestAutomation / genieparser

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

ShowMplsL2TransportDetail - "show mpls l2transport vc detail" Parser Fails on ASR920 Running IOS-XE 17.06.03 #889

Open ZacharyPuls opened 2 days ago

ZacharyPuls commented 2 days ago

When parsing the output of "show mpls l2transport vc detail" on an ASR-920 running IOS-XE 17.06.03, Genie fails with the following error:

Issue with the parser show mpls l2transport vc detail

Traceback (most recent call last):
  File "src/genie/cli/commands/parser.py", line 339, in genie.cli.commands.parser.ParserCommand.parse
  File "src/genie/conf/base/device.py", line 535, in genie.conf.base.device.Device.parse
  File "src/genie/conf/base/device.py", line 574, in genie.conf.base.device.Device._get_parser_output
  File "src/genie/conf/base/device.py", line 572, 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/zpuls/pyats-tests/.venv/lib/python3.10/site-packages/genie/libs/parser/iosxe/show_mpls.py", line 2561, in cli
    new_final_dict = final_dict.setdefault('destination_address', {}).\
UnboundLocalError: local variable 'final_dict' referenced before assignment

Configuration:

interface GigabitEthernet0/0/2
 description [REDACTED]
 mtu 9000
 no ip address
 negotiation auto
 no keepalive
 service instance 29 ethernet [REDACTED]
  description [REDACTED]
  encapsulation default
  l2protocol forward cdp stp vtp pagp dot1x lldp lacp udld loam esmc elmi ptppd R4 R5 R6 R8 R9 RA RB RC RD RF
  service-policy input 1000M-DIA-EPL-INGRESS
  service-policy output 1000M-DIA-EPL-EGRESS
  xconnect 10.9.1.26 5000029 encapsulation mpls pw-class PWC-5000029
  cfm mep domain OPERATOR mpid 2
 !

"show platform"/"show version":

KCBBASR31#show platform
Chassis type: ASR-920-24SZ-M

Slot      Type                State                 Insert time (ago) 
--------- ------------------- --------------------- ----------------- 
 0/0      24xGE-4x10GE-FIXED-Sok                    1y18w         
R0        ASR-920-24SZ-M      ok, active            1y18w         
F0                            ok, active            1y18w         
P0        ASR920-PSU0         ok                    1y18w         
P1        ASR920-PSU1         ok                    1y18w         
P2        ASR920-FAN          ok                    1y18w         

Slot      CPLD Version        Firmware Version                        
--------- ------------------- --------------------------------------- 
R0        2101121B            15.6(48r)S                          
F0        2101121B            15.6(48r)S                          

KCBBASR31#show version
Cisco IOS XE Software, Version 17.06.03
Cisco IOS Software [Bengaluru], ASR920 Software (PPC_LINUX_IOSD-UNIVERSALK9_NPE-M), Version 17.6.3, RELEASE SOFTWARE (fc4)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2022 by Cisco Systems, Inc.
Compiled Wed 30-Mar-22 20:29 by mcpre

Cisco IOS-XE software, Copyright (c) 2005-2022 by cisco Systems, Inc.
All rights reserved.  Certain components of Cisco IOS-XE software are
licensed under the GNU General Public License ("GPL") Version 2.0.  The
software code licensed under GPL Version 2.0 is free software that comes
with ABSOLUTELY NO WARRANTY.  You can redistribute and/or modify such
GPL code under the terms of GPL Version 2.0.  For more details, see the
documentation or "License Notice" file accompanying the IOS-XE software,
or the applicable URL provided on the flyer accompanying the IOS-XE
software.

ROM: IOS-XE ROMMON

KCBBASR31 uptime is 1 year, 18 weeks, 3 days, 7 hours, 42 minutes
Uptime for this control processor is 1 year, 18 weeks, 3 days, 7 hours, 48 minutes
System returned to ROM by reload at 02:30:14 CDT Thu May 11 2023
System restarted at 02:54:50 CDT Thu May 11 2023
System image file is "bootflash:asr920-universalk9_npe.17.06.03.SPA.bin"
Last reload reason: Reload Command

This product contains cryptographic features and is subject to United
States and local country laws governing import, export, transfer and
use. Delivery of Cisco cryptographic products does not imply
third-party authority to import, export, distribute or use encryption.
Importers, exporters, distributors and users are responsible for
compliance with U.S. and local country laws. By using this product you
agree to comply with applicable laws and regulations. If you are unable
to comply with U.S. and local laws, return this product immediately.

A summary of U.S. laws governing Cisco cryptographic products may be found at:
http://www.cisco.com/wwl/export/crypto/tool/stqrg.html

If you require further assistance please contact us by sending email to
export@cisco.com.

License Level: advancedmetroipaccess
License Type: Permanent
Next reload license Level: advancedmetroipaccess

Smart Licensing Status: Smart Licensing is DISABLED

cisco ASR-920-24SZ-M (Freescale P2020) processor (revision 1.2 GHz) with 864538K/6147K bytes of memory.
Processor board ID [REDACTED]
24 Gigabit Ethernet interfaces
4 Ten Gigabit Ethernet interfaces
32768K bytes of non-volatile configuration memory.
3670016K bytes of physical memory.
1328927K bytes of eMMC flash at bootflash:.

Configuration register is 0x2102

Show command output:

Local interface: Gi0/0/2 up, line protocol up, Ethernet:29 up
  Destination address: 10.9.1.26, VC ID: 5000029, VC status: up
    Output interface: Te0/0/25, imposed label stack {24172 853}
    Preferred path: not configured  
    Default path: active
    Next hop: 10.9.5.193
  Create time: 1y18w, last status change time: 19w6d
    Last label FSM state change time: 50w4d
  Signaling protocol: LDP, peer 10.9.1.26:0 up
    Targeted Hello: 10.9.1.98(LDP Id) -> 10.9.1.26, LDP is UP
    Graceful restart: configured and enabled
    Non stop routing: configured and not enabled
    Status TLV support (local/remote)   : enabled/supported
      LDP route watch                   : enabled
      Label/status state machine        : established, LruRru
      Last local dataplane   status rcvd: No fault
      Last BFD dataplane     status rcvd: Not sent
      Last BFD peer monitor  status rcvd: No fault
      Last local AC  circuit status rcvd: No fault
      Last local AC  circuit status sent: No fault
      Last local PW i/f circ status rcvd: No fault
      Last local LDP TLV     status sent: No fault
      Last remote LDP TLV    status rcvd: No fault
      Last remote LDP ADJ    status rcvd: No fault
    MPLS VC labels: local 36, remote 853 
    Group ID: local 8, remote 23
    MTU: local 9000, remote 9000
    Remote interface description: [REDACTED]
  Sequencing: receive disabled, send disabled
  Control Word: On
  SSO Descriptor: 10.9.1.26/5000029, local label: 36
  Dataplane:
    SSM segment/switch IDs: 147764/4137 (used), PWID: 4
  VC statistics:
    transit packet totals: receive 8906212980, send 4457131826
    transit byte totals:   receive 5874877490956, send 1822656153028
    transit packet drops:  receive 6, seq error 0, send 0

The issue appears to be in src/genie/libs/parser/iosxe/show_mpls.py on line 2406-2408, the RegEx should also match on the prefix "Ethernet:" as well as "Eth VLAN "

SohanTirpude commented 1 day ago

Hello @ZacharyPuls,

In your PR, unit tests are missing. Kindly follow this documentation: https://pubhub.devnetcloud.com/media/pyats-development-guide/docs/writeparser/writeparser.html#folder-based-testing-asa-ios-and-iosxe to add one or refer any PRs that are already merged.

Thank you.