-
Notifications
You must be signed in to change notification settings - Fork 555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Catch ValueError exception when vlan is not set to an integer. #889
Conversation
napalm/nxos/nxos.py
Outdated
try: | ||
vlan = int(mac_entry.get('disp_vlan')) | ||
except ValueError: | ||
vlan = '-' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VLAN always needs to be an integer...so you should change the vlan assignment in the exception clause to:
except ValueError:
vlan = 0
Also change the quotes around 'disp_vlan' to be double quotes: "disp_vlan" (so that it is compliant with python-black-formatting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review & guidance.
o Double quotes around disp_vlan o Changed default vlan value to 0 in exception clause
When vlan is not set to an integer it is set to '-' which causes int() to throw a ValueError exception. Adding try/except around int().