|
@@ -263,9 +263,9 @@ class DeviceViewSet(CustomFieldModelViewSet):
|
|
|
# Check that NAPALM is installed
|
|
# Check that NAPALM is installed
|
|
|
try:
|
|
try:
|
|
|
import napalm
|
|
import napalm
|
|
|
|
|
+ from napalm.base.exceptions import ModuleImportError
|
|
|
except ImportError:
|
|
except ImportError:
|
|
|
raise ServiceUnavailable("NAPALM is not installed. Please see the documentation for instructions.")
|
|
raise ServiceUnavailable("NAPALM is not installed. Please see the documentation for instructions.")
|
|
|
- from napalm.base.exceptions import ModuleImportError
|
|
|
|
|
|
|
|
|
|
# Validate the configured driver
|
|
# Validate the configured driver
|
|
|
try:
|
|
try:
|
|
@@ -309,7 +309,9 @@ class DeviceViewSet(CustomFieldModelViewSet):
|
|
|
try:
|
|
try:
|
|
|
response[method] = getattr(d, method)()
|
|
response[method] = getattr(d, method)()
|
|
|
except NotImplementedError:
|
|
except NotImplementedError:
|
|
|
- response[method] = {'error': 'Method not implemented for NAPALM driver {}'.format(driver)}
|
|
|
|
|
|
|
+ response[method] = {'error': 'Method {} not implemented for NAPALM driver {}'.format(method, driver)}
|
|
|
|
|
+ except Exception as e:
|
|
|
|
|
+ response[method] = {'error': 'Method {} failed: {}'.format(method, e)}
|
|
|
d.close()
|
|
d.close()
|
|
|
|
|
|
|
|
return Response(response)
|
|
return Response(response)
|