Skip to content
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

Merged
merged 7 commits into from
Dec 23, 2018

Conversation

tstoner
Copy link
Contributor

@tstoner tstoner commented Dec 19, 2018

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().

@coveralls
Copy link

coveralls commented Dec 19, 2018

Coverage Status

Coverage decreased (-0.02%) to 80.194% when pulling b40c081 on tstoner:develop into 6b6de47 on napalm-automation:develop.

try:
vlan = int(mac_entry.get('disp_vlan'))
except ValueError:
vlan = '-'
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@mirceaulinic mirceaulinic added this to the 2.3.6 milestone Dec 20, 2018
@ktbyers ktbyers merged commit 13ee5c6 into napalm-automation:develop Dec 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants