diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f9cdf168..ca2f3efd9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ v2.4.8 (FUTURE) * [#2558](https://github.com/digitalocean/netbox/issues/2558) - Filter on all tags when multiple are passed * [#2565](https://github.com/digitalocean/netbox/issues/2565) - Improved rendering of Markdown tables * [#2575](https://github.com/digitalocean/netbox/issues/2575) - Correct model specified for rack roles table +* [#2588](https://github.com/digitalocean/netbox/issues/2588) - Catch all exceptions from failed NAPALM API Calls --- diff --git a/netbox/dcim/api/views.py b/netbox/dcim/api/views.py index 2159661ef..fd4d37096 100644 --- a/netbox/dcim/api/views.py +++ b/netbox/dcim/api/views.py @@ -263,9 +263,9 @@ class DeviceViewSet(CustomFieldModelViewSet): # Check that NAPALM is installed try: import napalm + from napalm.base.exceptions import ModuleImportError except ImportError: raise ServiceUnavailable("NAPALM is not installed. Please see the documentation for instructions.") - from napalm.base.exceptions import ModuleImportError # Validate the configured driver try: @@ -309,7 +309,9 @@ class DeviceViewSet(CustomFieldModelViewSet): try: response[method] = getattr(d, method)() 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() return Response(response)