01-04-2023 02:55 PM
I have NX-OS 9.3(7) (in EVE-NG) device to whcih pyATS can connect and parse all commands except thsi one command:
show bgp vrf all all neighbors
This command returns follwoing error:
Issue with the parser show bgp vrf all all neighbors
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 531, in genie.conf.base.device.Device.parse
File "src/genie/conf/base/device.py", line 570, in genie.conf.base.device.Device._get_parser_output
File "src/genie/conf/base/device.py", line 568, in genie.conf.base.device.Device._get_parser_output
File "src/genie/metaparser/_metaparser.py", line 308, in genie.metaparser._metaparser.MetaParser.parse
File "/usr/local/lib/python3.10/dist-packages/genie/libs/parser/nxos/show_bgp.py", line 2971, in cli
[address_family]['session_state'] = session_state.lower()
UnboundLocalError: local variable 'session_state' referenced before assignment
This only happnes on this partiuclar commandon this paritucla deivce, I have exact same image on seprate node (in EVE-NG) and it works fine on that node. What could be the issue here?
01-21-2023 07:23 AM
Please see this external blog post about someone having an error from the same command, and notice the comment with a link to the documentation about Writing your own pyATS parser:
https://issueantenna.com/repo/CiscoTestAutomation/genieparser/issues/700
I hope thus helps!
02-05-2023 09:20 PM
The "UnboundLocalError: local variable referenced before assignment" error occurs in Python when you try to access a local variable before it has been assigned a value. This is typically caused by a typo, or by using the same name for a local variable and a global variable in the same scope or when you forget to assign a value to a local variable before using it.
x = x + 1
print(x) // This code will result in the error
to solve this....
x = 0 //assign a value to the local variable
x = x + 1
print(x)
To resolve the "UnboundLocalError: local variable referenced before assignment" error, you need to assign a value to the local variable before you use it. Another way to resolve this error is to use the global keyword to access the global variable with the same name.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide