Skip to content

Update show_alarm.py #892

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
--------------------------------------------------------------------------------
Fix
--------------------------------------------------------------------------------
* IOSXE
* Modified ShowFacilityAlarmStatusSchema:
* Update schema to include optional 'syslog_string'.
* Modified ShowFacilityAlarmStatus:
* Update 'show facility-alarm status', add two new patterns to match table format including "Syslog String".
24 changes: 24 additions & 0 deletions src/genie/libs/parser/iosxe/show_alarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ class ShowFacilityAlarmStatusSchema(MetaParser):
Any() : {
Optional('severity'): str,
Optional('description'): str,
Optional('syslog_string'): str,
Optional('relay'): str,
Optional('time'): str,
Optional('index'): int,
Expand Down Expand Up @@ -330,6 +331,14 @@ def cli(self, output=None):
# xcvr container 0/0/3 Jan 21 2024 19:15:56 CRITICAL Transceiver Missing - Link Down [1]
p4 = re.compile(r'^(?P<source>([\w\/\d\-\_ ]+))\s\s+()?(?P<time>([\w\d\s\:]+))\s\s+(?P<severity>([A-Z]+))\s\s+(?P<description>([\w\s\d\/\/\-]+))\s+(\[(?P<index>(\d+))\])$')

# Source Time Severity Syslog String Description [Index]
p5 = re.compile(r'^Source(\s+Time)\s+Severity\s+Syslog(\s+String)\s+Description(\s+\[Index])$')

# Power Supply Module 1 Sep 11 2023 08:06:40 CRITICAL PSU_FAILURE Power Supply Failure [0]
# 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]
p6 = re.compile(r'^(?P<source>([\w\/\d\-\_ ]+))\s\s+()?(?P<time>([\w\d\s\:]+))\s\s+(?P<severity>([A-Z]+))\s\s+(?P<syslog_string>([\w\/\d\-\_ ]+))\s\s+(?P<description>([\w\s\d\/\/\-]+))\s+(\[(?P<index>(\d+))\])$')

for line in out.splitlines():
line = line.strip()

Expand Down Expand Up @@ -361,6 +370,21 @@ def cli(self, output=None):
alarm_dict = root_dict.setdefault(group['source'].strip().replace(" ","_").lower() , {})
alarm_dict.update({'severity' : group['severity'].strip() , 'description':group['description'].strip(), 'index' : int(group['index'].strip()), 'time' : group['time'].strip() })

# Source Time Severity Syslog String Description [Index]
m = p5.match(line)
if m:
root_dict = ret_dict.setdefault('alarms', {})
continue

# Power Supply Module 1 Sep 11 2023 08:06:40 CRITICAL PSU_FAILURE Power Supply Failure [0]
# 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]
m = p6.match(line)
if m:
group = m.groupdict()
alarm_dict = root_dict.setdefault(group['source'].strip().replace(" ","_").lower() , {})
alarm_dict.update({'severity' : group['severity'].strip() , 'description':group['description'].strip(), 'syslog_string': group['syslog_string'].strip(),'index' : int(group['index'].strip()), 'time' : group['time'].strip() })

return ret_dict