1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Closes #1374: Added NAPALM_ARGS and NAPALM_TIMEOUT configiuration parameters

This commit is contained in:
Jeremy Stretch
2017-07-26 11:47:59 -04:00
parent d2c6d79589
commit 65a633f42d
4 changed files with 46 additions and 3 deletions

View File

@@ -273,14 +273,16 @@ class DeviceViewSet(WritableSerializerMixin, CustomFieldModelViewSet):
d = driver(
hostname=ip_address,
username=settings.NAPALM_USERNAME,
password=settings.NAPALM_PASSWORD
password=settings.NAPALM_PASSWORD,
timeout=settings.NAPALM_TIMEOUT,
optional_args=settings.NAPALM_ARGS
)
try:
d.open()
for method in napalm_methods:
response[method] = getattr(d, method)()
except Exception as e:
raise ServiceUnavailable("Error connecting to the device: {}".format(e))
raise ServiceUnavailable("Error connecting to the device at {}: {}".format(ip_address, e))
d.close()
return Response(response)