Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

napalm-opengear incompatible with NAPALM 4.x / Netmiko 4.x #11

Open
mirceaulinic opened this issue Jul 21, 2022 · 4 comments
Open

napalm-opengear incompatible with NAPALM 4.x / Netmiko 4.x #11

mirceaulinic opened this issue Jul 21, 2022 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@mirceaulinic
Copy link
Member

With NAPALM 4.0.0 recently released, there's a requirement for Netmiko to be on a newer version. 4.x has introduced some backwards incompatible changes that are causing the following error in napalm-opengear:

  File "/usr/local/lib/python3.9/site-packages/napalm_opengear/opengear.py", line 61, in open
    self.device.enable()
  File "/usr/local/lib/python3.9/site-packages/netmiko/linux/linux_ssh.py", line 147, in enable
    raise ValueError(msg)
ValueError:
Netmiko failed to elevate privileges.
Please ensure you pass the sudo password into ConnectHandler
using the 'secret' argument and that the user has sudo
permissions.
@mirceaulinic mirceaulinic added the bug Something isn't working label Jul 21, 2022
@mirceaulinic mirceaulinic self-assigned this Jul 21, 2022
@mirceaulinic
Copy link
Member Author

In fact, this seems a little deeper, caused by ktbyers/netmiko#2866. Keeping this issue open in the meantime.

mirceaulinic added a commit that referenced this issue Jul 26, 2022
Until there will be a more permanent solution in Netmiko, in order to
have this driver usable with version 4.x, we need to "help" Netmiko when
it fails to detect the prompt. Strictly speaking, as discussed under
ktbyers/netmiko#2866 Netmiko works as
designed, the ``base_prompt`` attribute is what we'd expect to be, but
when OpenGear doesn't set anything on the prompt other than ``$`` or ``#``
depending on the user elevation, then Netmiko fails to properly read
(more specifically, won't know when to stop).

I also took this chance to change the behaviour in ``open()`` to only
invoke ``enable()`` when the user is not root -- this saves one
unnecessary operation when we use the root user.
@mirceaulinic
Copy link
Member Author

Temporary workaround: #12.

mirceaulinic added a commit that referenced this issue Jul 26, 2022
Working around #11 until the next Netmiko release
@FragmentedPacket
Copy link

Are we able to add support for the force_no_enable option?

We have an account that has "sudo" privs on opengear already that does not prompt for a password as the code in #12 changed.

        if not self.device.base_prompt:
            # If Netmiko fails to detect the prompt due to OpenGear not setting
            # anything before the pound sign, we set the base_prompt attribute
            # so Netmiko is able to read (either # when the username is root, or
            # $ for anything else)
            self.base_prompt = "#" if self.username == "root" else "$"
        if self.username != "root" and not self.force_no_enable:
            self.device.enable()

@tyler-8
Copy link

tyler-8 commented Dec 27, 2024

Presumably this was fixed in netmiko with ktbyers/netmiko#2891

I was able to use several getters with the following setup:

napalm==5.0.0
napalm-opengear==0.3.6
netmiko==4.5.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants