CiscoTestAutomation / pyats

Cisco DevNet pyATS Test Framework Bug Tracker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

learn STP crashes with error UnboundLocalError: local variable 'inst_dict' referenced before assignment

geertn444 opened this issue · comments

Crash happens in line 720 of /usr/local/lib/python3.9/site-packages/genie/libs/parser/iosxe/show_spanning_tree.py
I traced the error to match condition p1

initial regexp pattern

    p1 = re.compile(r'^\#+ +MST(?P<inst>\d+) +'
                    r'vlans +mapped: +(?P<vlan>[\d\-\,\s]+)$')

it only matches digits and numbers, like

##### MST0 vlans mapped: 1-9,11-99,101-4094

However, it is possible that MST0 matches not a single VLAN. In that case, the switch returns:

MST0 vlans mapped: none

when this happens, script crashes

quick fix:

p1 = re.compile(r'^\#+ +MST(?P<inst>\d+) +'
                    r'vlans +mapped: +(?P<vlan>[\d\-\,\s\bnone\b]+)$')

Hello @geertn444,

I will be working on your ticket. Thanks for providing quick fix as well. I'll get back to you once I have any update on it.

Hello @geertn444,

Would you like to make these changes yourself that you suggested and make a contribution to the genieparser repo?

A guide for writing, testing, and contributing parser can be found here
https://pubhub.devnetcloud.com/media/pyats-development-guide/docs/writeparser/writeparser.html.

or Please provide the full device output with command used.

Hello @geertn444,

Kindly provide me full device output along with the command used.

Hello @geertn444,

You are not responding, hence I am closing this ticket, but If you are still facing the same issue, kindly let me know, I'll re-open the ticket.