CiscoTestAutomation / genieparser

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

ShowFacilityAlarmStatus - "show facility-alarm status" Parser Fails on ASR920 Running IOS-XE 17.06.03 #891

Open ZacharyPuls opened 3 days ago

ZacharyPuls commented 3 days ago

When parsing the output of "show facility-alarm status" on an ASR-920 running IOS-XE 17.06.03, Genie fails with the following error:

Issue with the parser show facility-alarm status

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_alarm.py", line 361, in cli
    alarm_dict = root_dict.setdefault(group['source'].strip().replace(" ","_").lower() , {})
UnboundLocalError: local variable 'root_dict' referenced before assignment

"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:

Source                     Time                   Severity      Syslog String                  Description [Index]
------                     ------                 --------      -------------                  -------------------
GigabitEthernet0           May 11 2023 02:55:45   INFO          ETHERNET_PORT_ADMIN_DOWN       Physical Port Administrative State Down [2]
xcvr container 0/0/6       May 11 2023 02:57:56   INFO          XCVR_MISSING                   Transceiver Missing [0]
xcvr container 0/0/7       May 11 2023 02:57:56   INFO          XCVR_MISSING                   Transceiver Missing [0]
GigabitEthernet0/0/8       May 11 2023 02:57:56   INFO          ETHERNET_PORT_ADMIN_DOWN       Physical Port Administrative State Down [2]
xcvr container 0/0/9       May 11 2023 02:57:56   INFO          XCVR_MISSING                   Transceiver Missing [0]
GigabitEthernet0/0/11      May 11 2023 02:57:57   INFO          ETHERNET_PORT_ADMIN_DOWN       Physical Port Administrative State Down [2]
xcvr container 0/0/12      May 11 2023 02:57:56   INFO          XCVR_MISSING                   Transceiver Missing [0]
xcvr container 0/0/13      May 11 2023 02:57:56   INFO          XCVR_MISSING                   Transceiver Missing [0]
xcvr container 0/0/14      May 11 2023 02:57:56   INFO          XCVR_MISSING                   Transceiver Missing [0]
xcvr container 0/0/15      May 11 2023 02:57:56   INFO          XCVR_MISSING                   Transceiver Missing [0]
xcvr container 0/0/16      May 11 2023 02:57:56   INFO          XCVR_MISSING                   Transceiver Missing [0]
GigabitEthernet0/0/17      May 11 2023 02:57:56   INFO          ETHERNET_PORT_ADMIN_DOWN       Physical Port Administrative State Down [2]
xcvr container 0/0/18      May 11 2023 02:57:56   INFO          XCVR_MISSING                   Transceiver Missing [0]
xcvr container 0/0/19      May 11 2023 02:57:56   INFO          XCVR_MISSING                   Transceiver Missing [0]
GigabitEthernet0/0/20      May 11 2023 02:57:57   INFO          ETHERNET_PORT_ADMIN_DOWN       Physical Port Administrative State Down [2]
GigabitEthernet0/0/23      Jan 16 2024 08:51:32   INFO          ETHERNET_PORT_ADMIN_DOWN       Physical Port Administrative State Down [2]
TenGigabitEthernet0/0/26   May 11 2023 02:57:57   INFO          ETHERNET_PORT_ADMIN_DOWN       Physical Port Administrative State Down [2]
System Totals  Critical: 0  Major: 0  Minor: 0 Info: 17

The issue appears to be not matching the "Syslog String" column of the output.

SohanTirpude commented 2 days 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.