diff --git a/changelog/undistributed/changelog_show_isis_20251215190817.rst b/changelog/undistributed/changelog_show_isis_20251215190817.rst new file mode 100644 index 0000000000..20189e6fd8 --- /dev/null +++ b/changelog/undistributed/changelog_show_isis_20251215190817.rst @@ -0,0 +1,11 @@ +-------------------------------------------------------------------------------- + Fix +-------------------------------------------------------------------------------- +* iosxr + * Modified ShowIsis: + * Changed Instance from schema to Optional + * Fixed uninitialized variable 'vrf_dict' in r5 when no informations about Instance ar given in Output + + * Modified ShowIsisStatistics: + * Changed psnp_cache, csnp_cache, lsp, upd, snp, transmit_time, process_time, ispf_calculation, arrival_time_throttled, flooding_duplicates from schema to Optional + * Updated regex pattern r1, r16, r18, r20, r23, r24, r25, r26, r27, r28 to accommodate various outputs. diff --git a/src/genie/libs/parser/iosxr/show_isis.py b/src/genie/libs/parser/iosxr/show_isis.py index 8c3ba9526c..4445f7a065 100644 --- a/src/genie/libs/parser/iosxr/show_isis.py +++ b/src/genie/libs/parser/iosxr/show_isis.py @@ -472,7 +472,7 @@ class ShowIsisSchema(MetaParser): 'instance': { Any(): { 'process_id': str, - 'instance': str, + Optional('instance'): str, 'vrf': { Any(): { 'system_id': str, @@ -684,6 +684,11 @@ def cli(self, output=None): if result: group = result.groupdict() is_levels = group['is_levels'] + if 'vrf_dict' not in locals(): + vrf_dict = instance_dict\ + .setdefault('vrf', {})\ + .setdefault(vrf, {}) + vrf_dict['system_id'] = system_id vrf_dict['is_levels'] = is_levels continue @@ -1037,27 +1042,27 @@ class ShowIsisStatisticsSchema(MetaParser): schema = { 'isis': { Any(): { - 'psnp_cache': { + Optional('psnp_cache'): { 'hits': int, 'tries': int, }, - 'csnp_cache': { + Optional('csnp_cache'): { 'hits': int, 'tries': int, 'updates': int, }, - 'lsp': { + Optional('lsp'): { 'checksum_errors_received': int, 'dropped': int, }, - 'upd': { + Optional('upd'): { 'max_queue_size': int, Optional('queue_size'): int, }, - 'snp': { + Optional('snp'): { 'dropped': int }, - 'transmit_time': { + Optional('transmit_time'): { 'hello': { 'rate_per_sec': int, 'average_transmit_time_sec': int, @@ -1079,7 +1084,7 @@ class ShowIsisStatisticsSchema(MetaParser): Optional('average_transmit_time_nsec'): int, }, }, - 'process_time': { + Optional('process_time'): { 'hello': { 'rate_per_sec': int, 'average_process_time_sec': int, @@ -1111,7 +1116,7 @@ class ShowIsisStatisticsSchema(MetaParser): Any(): { 'total_spf_calculation': int, 'full_spf_calculation': int, - 'ispf_calculation': int, + Optional('ispf_calculation'): int, 'next_hop_calculation': int, 'partial_route_calculation': int, 'periodic_spf_calculation': int, @@ -1126,8 +1131,8 @@ class ShowIsisStatisticsSchema(MetaParser): Optional('lsps_sourced'): { 'sent': int, 'received': int, - 'arrival_time_throttled': int, - 'flooding_duplicates': int, + Optional('arrival_time_throttled'): int, + Optional('flooding_duplicates'): int, }, Optional('csnp'): { 'sent': int, @@ -1166,7 +1171,9 @@ def cli(self, output=None): output = self.device.execute(self.cli_command) # IS-IS test statistics: - r1 = re.compile(r'IS\-IS\s+(?P.+)\s+statistics\:') + # IS-IS 1 Packet and Event Statistics + r1 = re.compile(r'IS\-IS\s+(?P.+)\s+' + r'(statistics\:|Packet and Event Statistics)') # Fast PSNP cache (hits/tries): 21/118 r2 = re.compile(r'Fast\s+PSNP\s+cache\s*\(hits/tries\): ' @@ -1226,7 +1233,8 @@ def cli(self, output=None): r'\d+)\s*\w+\,)?\s+(?P\d+)/\w+') # Level-1: - r16 = re.compile(r'Level\-(?P\d+):') + # Level-2 + r16 = re.compile(r'Level\-(?P\d+)(:)?$') # LSPs sourced (new/refresh): 11/15 # LSPs sourced (new/refresh): 13/11 @@ -1235,14 +1243,18 @@ def cli(self, output=None): # IPv4 Unicast # IPv6 Unicast - r18 = re.compile(r'(?P(IPv4|IPv6) Unicast)') + # IPv4 Unicast Total: 17912 + # IPv6 Unicast Total: 17901 + r18 = re.compile(r'(?P(IPv4\s+Unicast|IPv6\s+Unicast))' + r'(?: Total:?\s*(?P\d+))?') # Total SPF calculations : 23 r19 = re.compile(r'Total\s+SPF\s+calculations\s*:\s*' r'(?P\d+)') # Full SPF calculations : 16 - r20 = re.compile(r'Full\s+SPF\s+calculations\s*:\s*' + # Full SPF Calculations: 17832 + r20 = re.compile(r'Full\s+SPF\s+[Cc]alculations\s*:\s*' r'(?P\d+)') # ISPF calculations : 0 @@ -1254,29 +1266,46 @@ def cli(self, output=None): r'(?P\d+)') # Partial Route Calculations : 2 - r23 = re.compile(r'Partial\s+Route\s+Calculations\s*:\s*' + # Partial Route Calc: 61 + r23 = re.compile(r'Partial\s+Route\s+Calc.*:\s*' r'(?P\d+)') # Periodic SPF calculations : 3 - r24 = re.compile(r'Periodic\s+SPF\s+calculations\s*:\s*' + # Periodic: 17747 + r24 = re.compile(r'Periodic.*:\s*' r'(?P\d+)') # Interface Loopback0: # Interface GigabitEthernet0/0/0/1: - r25 = re.compile(r'Interface\s+(?P\S+):') + #r25 = re.compile(r'Interface\s+(?P\S+):') + r25 = re.compile(r'(?:Interface )?' + r'(?P(' + r'Loopback|' + r'GigabitEthernet|' + r'TenGigE|' + r'TwentyFiveGigE|' + r'FortyGigE|' + r'HundredGigE|' + r'Bundle-Ether' + r')' + r'+[0-9|/|\.]*)' + r'(?::)?') # Level-1 LSPs (sent/rcvd) : 0/0 # Level-2 LSPs (sent/rcvd) : 0/0 - r26 = re.compile(r'Level\-(?P\d+)\s+LSPs\s+\(sent\/rcvd\)\s*:' - r'\s*(?P\d+)/(?P\d+)') + # LSPs (sent/rcvd): 9/27 + r26 = re.compile(r'(?:Level\-(?P\d+)\s+)?LSPs\s+\(sent\/rcvd\)\s*:' + r'\s*(?P\d+)\/(?P\d+)') # Level-2 CSNPs (sent/rcvd) : 0/0 # Level-1 CSNPs (sent/rcvd) : 339/0 - r27 = re.compile(r'Level\-(?P\d+)\s+CSNPs\s+\(sent\/rcvd\)\s*:' + # CSNPs (sent/rcvd): 1/1826825 + r27 = re.compile(r'(?:Level\-(?P\d+)\s+)?CSNPs\s+\(sent\/rcvd\)\s*:' r'\s*(?P\d+)/(?P\d+)') # Level-1 PSNPs (sent/rcvd) : 0/0 - r28 = re.compile(r'Level\-(?P\d+)\s+PSNPs\s+\(sent/rcvd\)\s*:' + # PSNPs (sent/rcvd): 92/20 + r28 = re.compile(r'(?:Level\-(?P\d+)\s+)?PSNPs\s+\(sent/rcvd\)\s*:' r'\s*(?P\d+)\/(?P\d+)') # Level-1 LSP Flooding Duplicates : 51 @@ -1299,11 +1328,15 @@ def cli(self, output=None): parsed_dict = {} vrf = 'default' + level = 0 + level_dict = {} + interface_dict = {} for line in output.splitlines(): line = line.strip() # IS-IS test statistics: + # IS-IS 1 Packet and Event Statistics result = r1.match(line) if result: group = result.groupdict() @@ -1464,6 +1497,7 @@ def cli(self, output=None): continue # Level-1: + # Level-2 result = r16.match(line) if result: group = result.groupdict() @@ -1487,6 +1521,8 @@ def cli(self, output=None): # IPv4 Unicast # IPv6 Unicast + # IPv4 Unicast Total: 17899 + # IPv6 Unicast Total: 17888 result = r18.match(line) if result: group = result.groupdict() @@ -1494,6 +1530,9 @@ def cli(self, output=None): address_family_dict = level_dict\ .setdefault('address_family', {})\ .setdefault(address_family, {}) + if 'total_spf_calculation' in group and group['total_spf_calculation'] is not None: + total_spf_calculation = int(group['total_spf_calculation']) + address_family_dict['total_spf_calculation'] = total_spf_calculation continue @@ -1553,6 +1592,10 @@ def cli(self, output=None): # Interface Loopback0: # Interface GigabitEthernet0/0/0/1: + # Loopback0 + # GigabitEthernet0/0/0/0 + # TenGigE0/0/0/14 + # HundredGigE0/0/1/0 result = r25.match(line) if result: group = result.groupdict() @@ -1564,10 +1607,12 @@ def cli(self, output=None): # Level-1 LSPs (sent/rcvd) : 0/0 # Level-2 LSPs (sent/rcvd) : 0/0 + # LSPs (sent/rcvd): 2350/277 result = r26.match(line) if result: group = result.groupdict() - level = int(group['level']) + if group['level'] is not None: + level = int(group['level']) lsp_sent = int(group['lsp_sent']) lsp_received = int(group['lsp_received']) lsp_interface_dict = interface_dict\ @@ -1581,12 +1626,15 @@ def cli(self, output=None): # Level-2 CSNPs (sent/rcvd) : 0/0 # Level-1 CSNPs (sent/rcvd) : 339/0 + # CSNPs (sent/rcvd): 1/1828150 result = r27.match(line) if result: group = result.groupdict() - level = int(group['level']) + if group['level'] is not None: + level = int(group['level']) csnp_sent = int(group['csnp_sent']) csnp_received = int(group['csnp_received']) + print(f"addding csnp dict to interface dict with line: {line}") csnp_interface_dict = interface_dict\ .setdefault('level', {})\ .setdefault(level, {})\ @@ -1597,10 +1645,12 @@ def cli(self, output=None): continue # Level-1 PSNPs (sent/rcvd) : 0/0 + # PSNPs (sent/rcvd): 266/2250 result = r28.match(line) if result: group = result.groupdict() - level = int(group['level']) + if group['level'] is not None: + level = int(group['level']) psnp_sent = int(group['psnp_sent']) psnp_received = int(group['psnp_received']) psnp_interface_dict = interface_dict\ diff --git a/src/genie/libs/parser/iosxr/tests/ShowIsis/cli/equal/golden_output_4_expected.py b/src/genie/libs/parser/iosxr/tests/ShowIsis/cli/equal/golden_output_4_expected.py new file mode 100644 index 0000000000..ec4dd80592 --- /dev/null +++ b/src/genie/libs/parser/iosxr/tests/ShowIsis/cli/equal/golden_output_4_expected.py @@ -0,0 +1,83 @@ +expected_output = { + "instance": { + "1": { + "process_id": "1", + "vrf": { + "default": { + "system_id": "fc20.2400.06fd", + "is_levels": "level-2-only", + "manual_area_address": [ + "49.0000" + ], + "routing_area_address": [ + "49.0000" + ], + "non_stop_forwarding": "Disabled", + "most_recent_startup_mode": "Cold Restart", + "te_connection_status": "Up", + "topology": { + "IPv4 Unicast": { + "vrf": { + "default": { + "level": { + 2: { + "generate_style": "Wide", + "accept_style": "Wide", + "metric": 10 + } + }, + "redistributing": [ + "Connected" + ], + "protocols_redistributed": True, + "distance": 115, + "adv_passive_only": False + } + } + }, + "IPv6 Unicast": { + "vrf": { + "default": { + "level": { + 2: { + "metric": 10 + } + }, + "protocols_redistributed": False, + "distance": 115, + "adv_passive_only": False + } + } + } + }, + "interfaces": { + "Loopback0": { + "running_state": "running passively", + "configuration_state": "passive in configuration" + }, + "GigabitEthernet0/0/0/0": { + "running_state": "running actively", + "configuration_state": "active in configuration" + }, + "TenGigE0/0/0/14": { + "running_state": "running actively", + "configuration_state": "active in configuration" + }, + "TenGigE0/0/0/15": { + "running_state": "disabled", + "configuration_state": "active in configuration" + }, + "TenGigE0/0/0/16": { + "running_state": "disabled", + "configuration_state": "active in configuration" + }, + "TenGigE0/0/0/17": { + "running_state": "disabled", + "configuration_state": "active in configuration" + } + } + } + } + } + } +} \ No newline at end of file diff --git a/src/genie/libs/parser/iosxr/tests/ShowIsis/cli/equal/golden_output_4_output.txt b/src/genie/libs/parser/iosxr/tests/ShowIsis/cli/equal/golden_output_4_output.txt new file mode 100644 index 0000000000..fcd3b2a04c --- /dev/null +++ b/src/genie/libs/parser/iosxr/tests/ShowIsis/cli/equal/golden_output_4_output.txt @@ -0,0 +1,55 @@ +show isis +Mon Dec 15 08:17:44.848 CET + +IS-IS Router: 1 + System Id: fc20.2400.06fd + Hostname: PE3 + IS Levels: level-2-only + Manual area address(es): + 49.0000 + Routing for area address(es): + 49.0000 + Multi-Instance Id: 0 + Job Id: 1005 + PID: 7263 + Respawn count: 1 + Started: Tue Jun 10 08:56:24 2025 + Null0 ready: Tue Jun 10 08:56:24 2025 + LSP MTU: 1492 + LSP Full: level-1: No, level-2: No + Non-stop forwarding: Disabled + Most recent startup mode: Cold Restart + TE connection status: Up + XTC connection status: Up + Overload Bit Level-2: configured, clear + interarea prefixes suppressed, external prefixes suppressed + on startup for 300 seconds + clear since Jun 10 2025 09:01:25.384 CEST + Maximum Metric: not configured + Topologies supported by IS-IS: + IPv4 Unicast + Rib connected + Level-2 + Metric style (generate/accept): Wide/Wide + Metric: 10 + Redistributing: + Connected + Distance: 115 + Advertise Passive Interface Prefixes Only: No + IPv6 Unicast + Rib connected + Level-2 + Metric: 10 + No protocols redistributed + Distance: 115 + Advertise Passive Interface Prefixes Only: No + SRv6: + Configured locators: + MAIN (Active) + Interfaces supported by IS-IS 1: + Loopback0 is running passively (passive in configuration) + GigabitEthernet0/0/0/0 is running actively (active in configuration) + TenGigE0/0/0/14 is running actively (active in configuration) + TenGigE0/0/0/15 is disabled (active in configuration) + TenGigE0/0/0/16 is disabled (active in configuration) + TenGigE0/0/0/17 is disabled (active in configuration) \ No newline at end of file diff --git a/src/genie/libs/parser/iosxr/tests/ShowIsisStatistics/cli/equal/golden_output_4_expected.py b/src/genie/libs/parser/iosxr/tests/ShowIsisStatistics/cli/equal/golden_output_4_expected.py new file mode 100644 index 0000000000..6c7a851f15 --- /dev/null +++ b/src/genie/libs/parser/iosxr/tests/ShowIsisStatistics/cli/equal/golden_output_4_expected.py @@ -0,0 +1,123 @@ +expected_output = { + "isis": { + "1": { + "level": { + 2: { + "lsp": { + "new": 37, + "refresh": 252 + }, + "address_family": { + "IPv4 Unicast": { + "total_spf_calculation": 18182, + "full_spf_calculation": 18115, + "periodic_spf_calculation": 18030, + "partial_route_calculation": 61, + "next_hop_calculation": 6 + }, + "IPv6 Unicast": { + "total_spf_calculation": 18171, + "full_spf_calculation": 18119, + "periodic_spf_calculation": 18029, + "partial_route_calculation": 48, + "next_hop_calculation": 4 + } + } + } + }, + "interface": { + "Loopback0": {}, + "GigabitEthernet0/0/0/0": { + "level": { + 2: { + "lsps_sourced": { + "sent": 2387, + "received": 281 + }, + "csnp": { + "sent": 1, + "received": 1855866 + }, + "psnp": { + "sent": 270, + "received": 2287 + } + } + } + }, + "TenGigE0/0/0/14": { + "level": { + 2: { + "lsps_sourced": { + "sent": 48, + "received": 146 + }, + "csnp": { + "sent": 2, + "received": 2 + }, + "psnp": { + "sent": 125, + "received": 28 + } + } + } + }, + "TenGigE0/0/0/15": { + "level": { + 2: { + "lsps_sourced": { + "sent": 26, + "received": 17 + }, + "csnp": { + "sent": 2, + "received": 2 + }, + "psnp": { + "sent": 7, + "received": 6 + } + } + } + }, + "TenGigE0/0/0/16": { + "level": { + 2: { + "lsps_sourced": { + "sent": 9, + "received": 27 + }, + "csnp": { + "sent": 1, + "received": 1 + }, + "psnp": { + "sent": 25, + "received": 8 + } + } + } + }, + "TenGigE0/0/0/17": { + "level": { + 2: { + "lsps_sourced": { + "sent": 1912, + "received": 1933 + }, + "csnp": { + "sent": 1, + "received": 1 + }, + "psnp": { + "sent": 1866, + "received": 1855 + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/src/genie/libs/parser/iosxr/tests/ShowIsisStatistics/cli/equal/golden_output_4_output.txt b/src/genie/libs/parser/iosxr/tests/ShowIsisStatistics/cli/equal/golden_output_4_output.txt new file mode 100644 index 0000000000..63e24cee11 --- /dev/null +++ b/src/genie/libs/parser/iosxr/tests/ShowIsisStatistics/cli/equal/golden_output_4_output.txt @@ -0,0 +1,79 @@ +show isis statistics +Mon Dec 15 08:17:45.399 CET + +IS-IS 1 Packet and Event Statistics + Dropped Dropped + Total PDUs Sent Received On Input By Update + Hello: 5441144 5440051 0 - + CSNP: 8 1855873 - 0 + PSNP: 4172 5157 0 0 + LSP: 5356 4343 0 0 + + LSP Retransmissions: 20 + LSP Checksum Errors: 0 + + IS-IS Update Queue: 0/3455 + High Water Mark: 11 + Total Traffic: 1865373 + Drops: 0 + IS-IS Input Queue: 0/6400 + High Water Mark: 11 + Total Traffic: 7305425 + Drops: 0 + + Level-2 + LSPs sourced (new/refresh): 37/252 + Route Calculations: + IPv4 Unicast Total: 18182 + Full SPF Calculations: 18115 + Periodic: 18030 + Partial Route Calc: 61 + Next Hop Calculations: 6 + IPv6 Unicast Total: 18171 + Full SPF Calculations: 18119 + Periodic: 18029 + Partial Route Calc: 48 + Next Hop Calculations: 4 + +Loopback0 + Passive + +GigabitEthernet0/0/0/0 + PTP Hellos (sent/rcvd): 1856417/1855630 + LSP Retransmissions: 0 + Level-2 + LSPs (sent/rcvd): 2387/281 + CSNPs (sent/rcvd): 1/1855866 + PSNPs (sent/rcvd): 270/2287 + +TenGigE0/0/0/14 + PTP Hellos (sent/rcvd): 97436/97375 + LSP Retransmissions: 10 + Level-2 + LSPs (sent/rcvd): 48/146 + CSNPs (sent/rcvd): 2/2 + PSNPs (sent/rcvd): 125/28 + +TenGigE0/0/0/15 + PTP Hellos (sent/rcvd): 3140/3111 + LSP Retransmissions: 10 + Level-2 + LSPs (sent/rcvd): 26/17 + CSNPs (sent/rcvd): 2/2 + PSNPs (sent/rcvd): 7/6 + +TenGigE0/0/0/16 + PTP Hellos (sent/rcvd): 17765/17762 + LSP Retransmissions: 0 + Level-2 + LSPs (sent/rcvd): 9/27 + CSNPs (sent/rcvd): 1/1 + PSNPs (sent/rcvd): 25/8 + +TenGigE0/0/0/17 + PTP Hellos (sent/rcvd): 1729305/1729144 + LSP Retransmissions: 0 + Level-2 + LSPs (sent/rcvd): 1912/1933 + CSNPs (sent/rcvd): 1/1 + PSNPs (sent/rcvd): 1866/1855