Browse Source

Fixes #1696: Fix for NAPALM v2.0+

Jeremy Stretch 7 years ago
parent
commit
9d50b78b69
1 changed files with 9 additions and 2 deletions
  1. 9 2
      netbox/dcim/api/views.py

+ 9 - 2
netbox/dcim/api/views.py

@@ -258,12 +258,19 @@ class DeviceViewSet(WritableSerializerMixin, CustomFieldModelViewSet):
                 device.platform
             ))
 
-        # Check that NAPALM is installed and verify the configured driver
+        # Check that NAPALM is installed
         try:
             import napalm
-            from napalm_base.exceptions import ConnectAuthError, ModuleImportError
         except ImportError:
             raise ServiceUnavailable("NAPALM is not installed. Please see the documentation for instructions.")
+
+        # TODO: Remove support for NAPALM < 2.0
+        try:
+            from napalm.base.exceptions import ConnectAuthError, ModuleImportError
+        except ImportError:
+            from napalm_base.exceptions import ConnectAuthError, ModuleImportError
+
+        # Validate the configured driver
         try:
             driver = napalm.get_network_driver(device.platform.napalm_driver)
         except ModuleImportError: