Skip to content

Commit 5865734

Browse files
committed
Fixes onboarding_extensions_map issue
The onboarding_extensions_map setting (specified in netbox_onboarding/__init__.py or overridden in configuration.py) is used to map napalm driver names to a custom class which extends the driver, allowing extensibility. Currently, when a mapping doesn't exist for a napalm driver, the NetdevKeepr class's get_onboarding_facts() method fails. This causes the rq-worker to be unable to run the onbaord_device() function to onboard a device. The changes in this commit fix the issue.
1 parent 2874352 commit 5865734

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

netbox_onboarding/netdev_keeper.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,11 @@ def get_onboarding_facts(self):
268268

269269
try:
270270
module_name = PLUGIN_SETTINGS["onboarding_extensions_map"].get(self.napalm_driver)
271-
module = importlib.import_module(module_name)
272-
driver_addon_class = module.OnboardingDriverExtensions(napalm_device=napalm_device)
273-
self.onboarding_class = driver_addon_class.onboarding_class
274-
self.driver_addon_result = driver_addon_class.ext_result
271+
if module_name:
272+
module = importlib.import_module(module_name)
273+
driver_addon_class = module.OnboardingDriverExtensions(napalm_device=napalm_device)
274+
self.onboarding_class = driver_addon_class.onboarding_class
275+
self.driver_addon_result = driver_addon_class.ext_result
275276
except ImportError as exc:
276277
logger.info("No onboarding extension found for driver %s", self.napalm_driver)
277278

0 commit comments

Comments
 (0)