Unable to learn BGP - UnboundLocalError: local variable 'session_state' referenced before assignment
genie learn bgp --testbed-file testbeds/testbed.yml
Traceback (most recent call last):
File "src/genie/cli/commands/learn.py", line 365, in genie.cli.commands.learn.LearnCommand._retrieve_ops
File "/Users/edgleyl/venv/pyats/lib/python3.9/site-packages/genie/libs/ops/bgp/nxos/bgp.py", line 1110, in learn
self.make()
File "/Users/edgleyl/venv/pyats/lib/python3.9/site-packages/genie/ops/base/base.py", line 103, in make
self.maker.make(*args, **kwargs)
File "src/genie/ops/base/maker.py", line 315, in genie.ops.base.maker.Maker.make
File "src/genie/ops/base/maker.py", line 427, in genie.ops.base.maker.Maker._call_parser
File "src/genie/metaparser/_metaparser.py", line 308, in genie.metaparser._metaparser.MetaParser.parse
File "/Users/edgleyl/venv/pyats/lib/python3.9/site-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
Testbed
devices:
switch001:
connections:
cli:
ip: 10.20.0.1
protocol: ssh
credentials:
default:
password: '%ENC'
username: admin
enable:
password: '%ENC'
os: nxos
type: nxos
Can also share snippets of config/output if necessary.
NXOS: version 9.3(5)
Seems like a workaround/solution is to instansiate the session_state variable, as below
# For address family: VPNv4 Unicast
m = p31.match(line)
if m:
session_state = ''
if 'address_family' not in parsed_dict['neighbor'][neighbor_id]:
parsed_dict['neighbor'][neighbor_id]['address_family'] = {}
address_family = str(m.groupdict()['af']).lower()
if address_family not in parsed_dict['neighbor'][neighbor_id]\
['address_family']:
parsed_dict['neighbor'][neighbor_id]['address_family']\
[address_family] = {}
parsed_dict['neighbor'][neighbor_id]['address_family']\
[address_family]['session_state'] = session_state.lower()
if 'state_reason' in parsed_dict['neighbor'][neighbor_id]:
parsed_dict['neighbor'][neighbor_id]['address_family']\
[address_family]['state_reason'] = \
parsed_dict['neighbor'][neighbor_id]['state_reason']
continue
Hi . Thanks for reaching out piestack support team, I will be looking at your ticket and get back to you .
Hi , Please could you share the complete testbed.yaml file , and also please update your genie package and try it again .
pip install --upgrade genie
make sure that the credentials are correctly defined for the device
credentials:
default:
username: admin
password: 'your_password_here'
enable:
password: 'your_enable_password_here'
Hi , Please can you share the user output and show command to reproduce the issue .
Hi , Please can you share the user output and show command to reproduce the issue .
Hi , Please can you share the user output and show command to reproduce the issue .
Company policy won't allow me to paste the configuration on public GitHub. Happy to raise a TAC, if you can direct me what category to raise it under.
Hi , Please can you share the devices output and show command on external mailer group [email protected] to reproduce the issue .
Hi , Please can you share the devices output and show command on external mail group .