CiscoTestAutomation / genieparser

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

IOS-XR show route vrf {vrf} ipv4 {route} UnboundLocalError #123

Closed vishnuo-lab closed 4 years ago

vishnuo-lab commented 4 years ago

I am getting a UnboundLocalError sometimes when running this parser. Seems to happen for BGP external routes but not 100% sure. This is on iosxr ASR 9912 v6.5.3.

[2020-04-22 16:38:25,219] +++ LABASR9912: executing command 'show route vrf HIPTV ipv4 172.25.254.37/32' +++ show route vrf HIPTV ipv4 172.25.254.37/32 Wed Apr 22 16:38:25.274 EDT

Routing entry for 172.25.254.37/32 Known via "bgp 7992", distance 20, metric 0 Tag 65525, type external Installed Feb 6 13:12:22.999 for 10w6d Routing Descriptor Blocks 172.25.253.121, from 172.25.253.121, BGP external Route metric is 0 No advertising protos. RP/0/RP0/CPU0:LABASR9912# Traceback (most recent call last): File "IP_Checks.py", line 99, in main() File "IP_Checks.py", line 93, in main ipv4_address_check(ipv4_address_subnet, vrf, provider_edge_router, genie_dict_of_obj, circuit_type) File "IP_Checks.py", line 79, in ipv4_address_check show_route_output = ipv4_address_check_on_pe(str(ipv4_address_obj.network), vrf, provider_edge_router, genie_dict_of_obj, circuit_type) File "IP_Checks.py", line 25, in ipv4_address_check_on_pe provider_edge_router, genie_command) File "/home/vnathan/Automation/packages/Genie_Func.py", line 159, in genie_parse_func output = device_obj.parse(genie_command) File "src/genie/conf/base/device.py", line 548, in genie.conf.base.device.Device.parse File "src/genie/metaparser/_metaparser.py", line 271, in genie.metaparser._metaparser.MetaParser.parse File "/home/vnathan/Automation/.venv/lib/python3.7/site-packages/genie/libs/parser/iosxr/show_routing.py", line 486, in cli outgoing_interface_dict.update({'metric': metric}) UnboundLocalError: local variable 'outgoing_interface_dict' referenced before assignment

xiaoxinz-cisco commented 4 years ago

Hi @vishnuo-lab ,

We fixed the issue and a new package has been released with the fix. https://github.com/CiscoTestAutomation/genieparser/blob/master/src/genie/libs/parser/iosxr/show_routing.py#L231

Could you please run the following command and try again to see if it works?

Please try and let's know if there is an issue.

Thanks, Irene

vishnuo-lab commented 4 years ago

Now getting some other unbound local error:

parser command is "show route vrf NCS_TEST ipv4 4.4.4.0/24"

[2020-04-30 09:19:24,551] +++ LABASR9912: executing command 'show route vrf NCS_TEST ipv4 4.4.4.0/24' +++ show route vrf NCS_TEST ipv4 4.4.4.0/24 Thu Apr 30 09:19:24.615 EDT

Routing entry for 4.4.4.0/24 Known via "bgp 7992", distance 20, metric 0 Tag 65512, type external Installed Apr 22 15:20:23.790 for 1w0d Routing Descriptor Blocks 10.92.0.251, from 10.92.0.238, BGP external Nexthop in Vrf: "default", Table: "default", IPv4 Unicast, Table Id: 0xe0000000 Route metric is 0 No advertising protos. RP/0/RP0/CPU0:LABASR9912# Traceback (most recent call last): File "Genie_Func.py", line 318, in main() File "Genie_Func.py", line 308, in main output = genie_obj.genie_parse_func('LABASR9912','show route vrf NCS_TEST ipv4 4.4.4.0/24') File "Genie_Func.py", line 159, in genie_parse_func output = device_obj.parse(genie_command) File "src/genie/conf/base/device.py", line 548, in genie.conf.base.device.Device.parse File "src/genie/metaparser/_metaparser.py", line 271, in genie.metaparser._metaparser.MetaParser.parse File "/home/vnathan/Automation/.venv/lib/python3.7/site-packages/genie/libs/parser/iosxr/show_routing.py", line 486, in cli outgoing_interface_dict.update({'metric': metric}) UnboundLocalError: local variable 'outgoing_interface_dict' referenced before assignment

vishnuo-lab commented 4 years ago

had to upgrade Genie as well and now it is working. Thanks