question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

netmiko enable() should be configurable

See original GitHub issue

Hi,

I’ve run in to an issue where my routers cannot be configured with netmiko due to the enable() function run in networking.netmiko_send_config

In my particular case, I’m configuring Alcatel SROS devices that do not have a dedicated enable (admin) password configured, thus failing because of this with the following:

ValueError: Failed to enter enable mode. Please ensure you pass the 'secret' argument to ConnectHandler.

May I suggest you make this configurable some how? As a workaround I’ve made my own netmiko_send_config function with just the line referenced below commented out.

The problematic line is this: https://github.com/nornir-automation/nornir/blob/f5a51269f8faffa3f078d14cadd81695419bfa76/nornir/plugins/tasks/networking/netmiko_send_config.py#L25

Thank you!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:23

github_iconTop GitHub Comments

1reaction
ktbyerscommented, Jan 7, 2021

So let’s do this–near term fix it in Nornir by adding an argument. Longer term potentially fix in Netmiko to allow some way to avoid this issue.

I will create an issue in Netmiko to track the longer term issue.

I am worried that we will just run into this problem elsewhere where Netmiko + other tool is being used (which is why the longer term fix is probably a good idea).

1reaction
helltcommented, Jan 7, 2021

sorry @ktbyers for unnecessarily eating your time

My memory failed me and the current sros.enable() code is indeed seems to assume that enable actions happen on SR OS regardless if it is configured or not.

check_enable method only checks if the SR OS node is in admin mode, but if it is not it doesn’t mean it has enable mode configured, that leads to the issue in the super.enable() https://github.com/ktbyers/netmiko/blob/8bbe607a8fbf2a00deeefe2fa7f17c918792949d/netmiko/nokia/nokia_sros_ssh.py#L89-L99

I think the code of nokia.enable() might be enhanced to first detect if admin mode is configured on the device and only if it is, it must go through the super.enable() routine.

Now I recall why that was not an issue with bare netmiko - because in bare netmiko a user decides if he needs to call enable() and user knows if this mode is configured on the device upfront.

So I see two possible solutions:

  1. make nornir-netmiko plugin less opinionated on the need of enable()
  2. or enhance sros.enable() to check if the enable mode is configured on the device, if it is - perform enable. If it doesn’t - pass the function.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Netmiko - Enter configuration terminal mode - Stack Overflow
There is a configure terminal mode in netmiko , using conn.config_mode() sends configure terminal to the remote device. However, you can use ...
Read more >
SSH Configuration with Netmiko - YouTube
Your browser can 't play this video. ... you'll learn how to configure a Secure Shell (SSH) connection using Netmiko.
Read more >
netmiko.cisco_base_connection API documentation
CiscoBaseConnection is netmiko SSH class for Cisco and Cisco-like platforms. ... You can enable this if you want to record both channel reads...
Read more >
How to Enable Netmiko Logging - Packet Coders
To enable logging for all connections to a file, we can import and use the logging module, as shown below. In this example,...
Read more >
Netmiko Library - Python for Network Engineers
You can find the library at https://github.com/ktbyers/netmiko and the latest released ... Simplify the execution of configuration commands.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found