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

Suggestion to fix issue #51795 #51801

Merged
merged 2 commits into from
Jan 6, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions salt/modules/netbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

try:
import pynetbox
from pynetbox.lib import RequestError
HAS_PYNETBOX = True
except ImportError:
HAS_PYNETBOX = False
Expand Down Expand Up @@ -102,7 +101,7 @@ def _add(app, endpoint, payload):
nb = _nb_obj(auth_required=True)
try:
return getattr(getattr(nb, app), endpoint).create(**payload)
except RequestError as e:
except pynetbox.RequestError as e:
log.error("{}, {}, {}".format(e.req.request.headers, e.request_body, e.error))
return False

Expand Down Expand Up @@ -378,7 +377,7 @@ def create_device(name,
return False

status = {'label': "Active", 'value': 1}
except RequestError as e:
except pynetbox.RequestError as e:
log.error("{}, {}, {}".format(e.req.request.headers, e.request_body, e.error))
return False

Expand Down Expand Up @@ -415,7 +414,7 @@ def update_device(name, **kwargs):
try:
nb_device.save()
return {'dcim': {'devices': kwargs}}
except RequestError as e:
except pynetbox.RequestError as e:
log.error("{}, {}, {}".format(e.req.request.headers, e.request_body, e.error))
return False

Expand Down Expand Up @@ -797,7 +796,7 @@ def update_interface(device_name, interface_name, **kwargs):
try:
nb_interface.save()
return {'dcim': {'interfaces': {nb_interface.id: dict(nb_interface)}}}
except RequestError as e:
except pynetbox.RequestError as e:
log.error("{}, {}, {}".format(e.req.request.headers, e.request_body, e.error))
return False

Expand Down