CiscoTestAutomation / genieparser

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

ios-xr parser issue - "show ospf interface" and "show ospf interface {interface_name}" #659

Open lukasnbm opened 2 years ago

lukasnbm commented 2 years ago

Hi Team,

I have an issues with ios-xr parser

  1. show ospf interface - parser result doesn't catch the md5 authentication even though the interface on the router has ospf authentication enabled.
  2. show ospf interface {interface_name} parser it gives me the error below:
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "src/genie/conf/base/device.py", line 527, in genie.conf.base.device.Device.parse
    File "src/genie/conf/base/device.py", line 563, in genie.conf.base.device.Device._get_parser_output
    File "src/genie/conf/base/device.py", line 561, in genie.conf.base.device.Device._get_parser_output
    File "src/genie/metaparser/_metaparser.py", line 279, in genie.metaparser._metaparser.MetaParser.parse
    File "/home/ubuntu/.local/lib/python3.8/site-packages/genie/libs/parser/iosxr/show_ospf.py", line 6105, in cli
    interfaces_dict = ospf_dict.setdefault('interfaces', {})
    UnboundLocalError: local variable 'ospf_dict' referenced before assignment 

    For extra information, I tried the ios-xe parser with the same command and it all works fine, it shows the ospf md5 authentication and doesn't give error.

I have attached two supporting files to replicate the issue. Please let me know if you need another file.

Thank you for the support.

XR_ShowOspfInterface.txt XR_ShowOspfInterfaceIfaceName.txt

Taarini commented 2 years ago

Can you please clarify, what you mean by md5 authentication. If possible can you highlight the line in the device output.

Also, iosxe doesn't have the "show ospf interface", but it has "show ip ospf interface".

lukasnbm commented 2 years ago

Yes, for the IOS-XE the command should be show ip ospf interface. In this example I try to sample with interface G0/3/7.

The device output related to md5 configuration (bold) on ios-xe is:

GigabitEthernet0/3/7 is up, line protocol is up 
  Internet Address 172.20.153.89/30, Interface ID 38, Area 0
  Attached via Network Statement
  Process ID 5, Router ID 221.132.196.25, Network Type POINT_TO_POINT, Cost: 100
  Topology-MTID    Cost    Disabled    Shutdown      Topology Name
        0           100       no          no            Base
  Transmit Delay is 1 sec, State POINT_TO_POINT, BFD enabled
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    oob-resync timeout 40
    Hello due in 00:00:00
  Supports Link-local Signaling (LLS)
  Cisco NSF helper support enabled
  IETF NSF helper support enabled
  Can be protected by per-prefix Loop-Free FastReroute
  Can be used for per-prefix Loop-Free FastReroute repair paths
  Not Protected by per-prefix TI-LFA
  Index 1/8/8, flood queue length 0
  Next 0x0(0)/0x0(0)/0x0(0)
  Last flood scan length is 1, maximum is 4
  Last flood scan time is 0 msec, maximum is 16 msec
  Neighbor Count is 1, Adjacent neighbor count is 1 
    Adjacent with neighbor 221.132.196.59
  Suppress hello for 0 neighbor(s)
  **Cryptographic authentication enabled**
    **Youngest key id is 1**

and the parser result for ios-xe is:

--Snipped--
 'GigabitEthernet0/3/7': {'attached': 'network '
                                     'statement',
                         **'authentication': {'auth_trailer_key': {'crypto_algorithm': 'md5',**
                                                                 **'youngest_key_id': 1}}**,
--Snipped--

You can see the parser gives the MD5 authentication crypto algorithm (bold).

For IOS-XR parser with show ospf interface I try to sample with Te0/5/0/34, the device output would be:

TenGigE0/5/0/34 is up, line protocol is up 
  Internet Address 172.20.208.198/30, Area 0, SID 0, Strict-SPF SID 0
  Label stack Primary label 1 Backup label 3 SRTE label 10
  auto path capability supported
  Process ID 8, Router ID 221.132.247.124, Network Type POINT_TO_POINT, Cost: 90
  LDP Sync Enabled, Sync Status: Achieved
  Transmit Delay is 1 sec, State POINT_TO_POINT, MTU 9000, MaxPktSz 9000
  Forward reference No, Unnumbered no,  Bandwidth 10000000 
  RIB LC sync Yes
  BFD enabled, BFD interval 300 msec, BFD multiplier 3, Mode: Default
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
  Non-Stop Forwarding (NSF) enabled
    Hello due in 00:00:04:303
  Index 10/10, flood queue length 0
  Next 0(0)/0(0)
  Last flood scan length is 2, maximum is 10
  Last flood scan time is 0 msec, maximum is 0 msec
  LS Ack List: current length 0, high water mark 2
  Neighbor Count is 1, Adjacent neighbor count is 1
    Adjacent with neighbor 221.132.247.132
  Suppress hello for 0 neighbor(s)
  **Message digest authentication enabled**
    **Youngest key id is 1**
  Multi-area interface Count is 0

You can see the MD5 authentication information is there (bold).

but the parser have no information related to MD5 authentication at all:

'TenGigE0/5/0/34': {'area': '0',
                                                                                                       'bandwidth': 10000000,
                                                                                                       'bfd': {'enable': True,
                                                                                                               'interval': 300,
                                                                                                               'mode': 'Default',
                                                                                                               'multiplier': 3},
                                                                                                       'cost': 90,
                                                                                                       'dead_interval': 40,
                                                                                                       'demand_circuit': False,
                                                                                                       'enable': True,
                                                                                                       'flood_queue_length': 0,
                                                                                                       'forward_reference': 'No',
                                                                                                       'hello_interval': 10,
                                                                                                       'hello_timer': '00:00:05:577',
                                                                                                       'high_water_mark': 2,
                                                                                                       'index': '10/10',
                                                                                                       'interface_type': 'POINT_TO_POINT',
                                                                                                       'ip_address': '172.20.208.198/30',
                                                                                                       'label_stack': {'backup_label': '3',
                                                                                                                       'primary_label': '1',
                                                                                                                       'srte_label': '10'},
                                                                                                       'last_flood_scan_length': 1,
                                                                                                       'last_flood_scan_time_msec': 0,
                                                                                                       'line_protocol': True,
                                                                                                       'ls_ack_list': 'current',
                                                                                                       'ls_ack_list_length': 0,
                                                                                                       'max_flood_scan_length': 10,
                                                                                                       'max_flood_scan_time_msec': 0,
                                                                                                       'max_pkt_sz': 9000,
                                                                                                       'mtu': 9000,
                                                                                                       'name': 'TenGigE0/5/0/34',
                                                                                                       'neighbors': {'221.132.247.132': {'router_id': '221.132.247.132'}},
                                                                                                       'next': '0(0)/0(0)',
                                                                                                       'nsf_enabled': True,
                                                                                                       'process_id': '8',
                                                                                                       'retransmit_interval': 5,
                                                                                                       'router_id': '221.132.247.124',
                                                                                                       'sid': '0',
                                                                                                       'state': 'POINT_TO_POINT',
                                                                                                       'statistics': {'adj_nbr_count': 1,
                                                                                                                      'multi_area_intf_count': 0,
                                                                                                                      'nbr_count': 1,
                                                                                                                      'num_nbrs_suppress_hello': 0},
                                                                                                       'strict_spf_sid': '0',
                                                                                                       'transmit_delay': 1,
                                                                                                       'unnumbered': False,
                                                                                                       'wait_interval': 40}}}}}}}}}
Taarini commented 2 years ago

Thank you for the detailed response. Will keep you posted and let you know once it is fixed.

lukasnbm commented 2 years ago

Thank you very much for the support @Taarini, I really appreciate it. Can't wait for the fixed version.

Taarini commented 2 years ago

Hi @lukasnbm, The issue is fixed and will be available in the next release.

lukasnbm commented 2 years ago

Hi @Taarini, thank you very much for the support and the update. Looking forward to it