Implement "optional_args" parameter for NAPALM integration #1128

Closed
opened 2025-12-29 16:29:15 +01:00 by adam · 3 comments
Owner

Originally created by @bdlamprecht on GitHub (Jul 26, 2017).

Issue type:

Bug Report

Python version:
2.7.12
NetBox version:
2.1.0

First off, let me state that your work with integrating NAPALM into NetBox is outstanding. From what I've found so far, it works perfectly with Juniper devices. However, in my envrionment, when I try to use this new functionality with my IOS devices, I get the following error:

Error connecting to the device: Failed to enter enable mode

As mentioned in the NetworkToCode Slack channel, I encountered this problem previously and was able to solve it by supplying the optional_args dict which contained the parameter secret=[PASSWORD] to the NAPALM driver for the device (see http://napalm.readthedocs.io/en/latest/base.html for details).

I tried to test a solution myself in the /netbox/netbox/dcim/api/views.py file of v2.1.0, but was unsuccessful (most likely due to not understanding in depth how the integration took place).

My solution is something as simple as this in the views.py file mentioned above (in pseudo-code):

d = driver(
     hostname=ip_address,
     username=settings.NETBOX_USERNAME,
     password=settings.NETBOX_PASSWORD,
     optional_args.secret=settings.NETBOX_PASSWORD,

I'm assuming this is a simple fix due to the great work done by the team developing NAPALM, but if you need help testing a solution, I'd be happy to help.

Originally created by @bdlamprecht on GitHub (Jul 26, 2017). ### Issue type: Bug Report **Python version:** 2.7.12 **NetBox version:** 2.1.0 First off, let me state that your work with integrating NAPALM into NetBox is outstanding. From what I've found so far, it works perfectly with Juniper devices. However, in my envrionment, when I try to use this new functionality with my IOS devices, I get the following error: ``` Error connecting to the device: Failed to enter enable mode ``` As mentioned in the NetworkToCode Slack channel, I encountered this problem previously and was able to solve it by supplying the `optional_args` dict which contained the parameter `secret=[PASSWORD]` to the NAPALM driver for the device (see http://napalm.readthedocs.io/en/latest/base.html for details). I tried to test a solution myself in the `/netbox/netbox/dcim/api/views.py` file of v2.1.0, but was unsuccessful (most likely due to not understanding in depth how the integration took place). My solution is something as simple as this in the `views.py` file mentioned above (in _pseudo-code_): ``` d = driver( hostname=ip_address, username=settings.NETBOX_USERNAME, password=settings.NETBOX_PASSWORD, optional_args.secret=settings.NETBOX_PASSWORD, ``` I'm assuming this is a simple fix due to the great work done by the team developing NAPALM, but if you need help testing a solution, I'd be happy to help.
adam added the type: feature label 2025-12-29 16:29:15 +01:00
adam closed this issue 2025-12-29 16:29:15 +01:00
Author
Owner

@jeremystretch commented on GitHub (Jul 26, 2017):

NAPALM optional args for reference.

I think it makes sense to introduce a NAPALM_ARGS configuration parameter to hold a dictionary of these arguments, and pass it on every instantiation of a NetworkDriver. Seems that any args not recognized by a driver are ignored, so it should be safe to apply the same arguments to all drivers/platforms.

While we're at it, we should add a NAPALM_TIMEOUT setting (the default is 60 seconds).

@jeremystretch commented on GitHub (Jul 26, 2017): [NAPALM optional args](http://napalm.readthedocs.io/en/latest/support/#list-of-supported-optional-arguments) for reference. I think it makes sense to introduce a `NAPALM_ARGS` configuration parameter to hold a dictionary of these arguments, and pass it on every instantiation of a NetworkDriver. Seems that any args not recognized by a driver are ignored, so it should be safe to apply the same arguments to all drivers/platforms. While we're at it, we should add a `NAPALM_TIMEOUT` setting (the default is 60 seconds).
Author
Owner

@bdlamprecht commented on GitHub (Jul 26, 2017):

That works for me. Oddly enough, I don't see the secret argument in the link you referenced, perhaps the developers of NAPALM need to update their documentation.

@bdlamprecht commented on GitHub (Jul 26, 2017): That works for me. Oddly enough, I don't see the `secret` argument in the link you referenced, perhaps the developers of NAPALM need to update their documentation.
Author
Owner

@bdlamprecht commented on GitHub (Jul 26, 2017):

Sorry, I pressed the wrong "comment" button. 😉

@bdlamprecht commented on GitHub (Jul 26, 2017): Sorry, I pressed the wrong "comment" button. :wink:
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#1128