nornir-automation / nornir_napalm

NAPALM's plugins for nornir
Apache License 2.0
63 stars 21 forks source link

Connections to IOS XR via Netconf driver fail due to ssh_config_file argument #63

Open 991jo opened 9 months ago

991jo commented 9 months ago

When I am running nornir_napalm with the iosxr_netconf driver the connection fails, because nornir_napalm adds a argument called ssh_config_file that is passed on to ncclient in NAPALM, which does not expect that argument.

Versions used:

napalm==4.1.0
ncclient==0.6.15
nornir==3.4.1
nornir-napalm==0.4.0
nornir-utils==0.2.0

Here is my code:

from nornir import InitNornir
from nornir_utils.plugins.functions import print_result
from nornir.core.plugins.connections import ConnectionPluginRegister
from nornir_napalm.plugins.connections import Napalm
from nornir_napalm.plugins.tasks import napalm_get

ConnectionPluginRegister.register("nornir-napalm", Napalm)

nr = InitNornir(config_file="config.yaml")

result = nr.run(task=napalm_get, getters=["get_config"])
print_result(result)

With this config:

inventory:
  plugin: SimpleInventory
  options:
    host_file: "inventory/hosts.yaml"
    group_file: "inventory/groups.yaml"
    defaults_file: "inventory/defaults.yaml"

runner:
  plugin: threaded
  options:
    num_workers: 20 

And this inventory:

p-1:
  hostname: clab-isis-p-1
  platform: iosxr_netconf

This results in this error:

SSHSession.connect() got an unexpected keyword argument 'ssh_config_file'
napalm_get**********************************************************************
* p-1 ** changed : False *******************************************************
vvvv napalm_get ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv ERROR
Traceback (most recent call last):
  File "/home/jo/projects/isis-tests/nornir/venv/lib/python3.11/site-packages/napalm/iosxr_netconf/iosxr_netconf.py", line 83, in open
    self.device = manager.connect(
                  ^^^^^^^^^^^^^^^^
  File "/home/jo/projects/isis-tests/nornir/venv/lib/python3.11/site-packages/ncclient/manager.py", line 187, in connect
    return connect_ssh(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jo/projects/isis-tests/nornir/venv/lib/python3.11/site-packages/ncclient/manager.py", line 139, in connect_ssh
    session.connect(*args, **kwds)
TypeError: SSHSession.connect() got an unexpected keyword argument 'ssh_config_file'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/jo/projects/isis-tests/nornir/venv/lib/python3.11/site-packages/nornir/core/task.py", line 99, in start
    r = self.task(self, **self.params)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jo/projects/isis-tests/nornir/venv/lib/python3.11/site-packages/nornir_napalm/plugins/tasks/napalm_get.py", line 32, in napalm_get
    device = task.host.get_connection(CONNECTION_NAME, task.nornir.config)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jo/projects/isis-tests/nornir/venv/lib/python3.11/site-packages/nornir/core/inventory.py", line 494, in get_connection
    self.open_connection(
  File "/home/jo/projects/isis-tests/nornir/venv/lib/python3.11/site-packages/nornir/core/inventory.py", line 546, in open_connection
    conn_obj.open(
  File "/home/jo/projects/isis-tests/nornir/venv/lib/python3.11/site-packages/nornir_napalm/plugins/connections/__init__.py", line 57, in open
    connection.open()
  File "/home/jo/projects/isis-tests/nornir/venv/lib/python3.11/site-packages/napalm/iosxr_netconf/iosxr_netconf.py", line 97, in open
    raise ConnectionException(conn_err.args[0])
napalm.base.exceptions.ConnectionException: SSHSession.connect() got an unexpected keyword argument 'ssh_config_file'