Skip to content

Commit

Permalink
Merge pull request #51801 from misch42/fix_netbox_import
Browse files Browse the repository at this point in the history
Suggestion to fix issue #51795
  • Loading branch information
dwoz authored Jan 6, 2020
2 parents 1f83336 + 2725fa1 commit 90a8cb8
Showing 1 changed file with 4 additions and 5 deletions.
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

0 comments on commit 90a8cb8

Please sign in to comment.