nornir-automation / nornir

Pluggable multi-threaded framework with inventory management to help operate collections of devices
https://nornir.readthedocs.io/
Apache License 2.0
1.4k stars 237 forks source link

Nornir scrapli-netconf #684

Closed marcinkrzyzynski closed 3 years ago

marcinkrzyzynski commented 3 years ago

Hi Guys,

Can you help me investigate what is/or may be wrong?

I am trying to use nornir-scrapli to read some device configuration :

------------------------------------------------------------------------------

#!/usr/bin/env/python3

from nornir import InitNornir
from nornir_scrapli.tasks import ( netconf_capabilities,netconf_get_config,netconf_get)
from nornir_utils.plugins.functions import print_result

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

FILTER = '''

 <ifm xmlns="urn:huawei:yang:huawei-ifm"> 

            <interfaces>
           <interface>
            </interface> 
            </interfaces>
            </ifm>
'''

config_result = nr.run(task=netconf_get,filter_=FILTER)
print_result(config_result)

-----------------------------------------------------------------------------------

but it's failed with traceback :


Host 'R3': task 'netconf_get' failed with traceback:
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/scrapli/transport/plugins/system/ptyprocess.py", line 424, in read
    s = self.fileobj.read1(size)
OSError: [Errno 5] Input/output error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/scrapli/transport/plugins/system/transport.py", line 126, in read
    buf = self.session.read(65535)
  File "/usr/local/lib/python3.7/dist-packages/scrapli/transport/plugins/system/ptyprocess.py", line 429, in read
    raise EOFError("End Of File (EOF). Exception style platform.")
EOFError: End Of File (EOF). Exception style platform.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/nornir/core/task.py", line 99, in start
    r = self.task(self, **self.params)
  File "/usr/local/lib/python3.7/dist-packages/nornir_scrapli/tasks/netconf_get.py", line 28, in netconf_get
    scrapli_response = scrapli_conn.get(filter_=filter_, filter_type=filter_type)
  File "/usr/local/lib/python3.7/dist-packages/scrapli_netconf/driver/sync_driver.py", line 137, in get
    raw_response = self.channel.send_input_netconf(response.channel_input)
  File "/usr/local/lib/python3.7/dist-packages/scrapli_netconf/channel/sync_channel.py", line 325, in send_input_netconf
    buf = self._read_until_prompt(buf=buf)
  File "/usr/local/lib/python3.7/dist-packages/scrapli/channel/sync_channel.py", line 131, in _read_until_prompt
    buf += self.read()
  File "/usr/local/lib/python3.7/dist-packages/scrapli/channel/sync_channel.py", line 68, in read
    buf = self.transport.read()
  File "/usr/local/lib/python3.7/dist-packages/scrapli/decorators.py", line 97, in decorate
    kwargs=kwargs,
  File "/usr/local/lib/python3.7/dist-packages/scrapli/decorators.py", line 172, in _multiprocessing_timeout
    return future.result()
  File "/usr/lib/python3.7/concurrent/futures/_base.py", line 425, in result
    return self.__get_result()
  File "/usr/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result
    raise self._exception
  File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.7/dist-packages/scrapli/transport/plugins/system/transport.py", line 133, in read
    raise ScrapliConnectionError(msg) from exc
scrapli.exceptions.ScrapliConnectionError: encountered EOF reading from transport; typically means the device closed the connection

netconf_get*********************************************************************
* R3 ** changed : False ********************************************************
vvvv netconf_get ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv ERROR
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/scrapli/transport/plugins/system/ptyprocess.py", line 424, in read
    s = self.fileobj.read1(size)
OSError: [Errno 5] Input/output error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/scrapli/transport/plugins/system/transport.py", line 126, in read
    buf = self.session.read(65535)
  File "/usr/local/lib/python3.7/dist-packages/scrapli/transport/plugins/system/ptyprocess.py", line 429, in read
    raise EOFError("End Of File (EOF). Exception style platform.")
EOFError: End Of File (EOF). Exception style platform.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/nornir/core/task.py", line 99, in start
    r = self.task(self, **self.params)
  File "/usr/local/lib/python3.7/dist-packages/nornir_scrapli/tasks/netconf_get.py", line 28, in netconf_get
    scrapli_response = scrapli_conn.get(filter_=filter_, filter_type=filter_type)
  File "/usr/local/lib/python3.7/dist-packages/scrapli_netconf/driver/sync_driver.py", line 137, in get
    raw_response = self.channel.send_input_netconf(response.channel_input)
  File "/usr/local/lib/python3.7/dist-packages/scrapli_netconf/channel/sync_channel.py", line 325, in send_input_netconf
    buf = self._read_until_prompt(buf=buf)
  File "/usr/local/lib/python3.7/dist-packages/scrapli/channel/sync_channel.py", line 131, in _read_until_prompt
    buf += self.read()
  File "/usr/local/lib/python3.7/dist-packages/scrapli/channel/sync_channel.py", line 68, in read
    buf = self.transport.read()
  File "/usr/local/lib/python3.7/dist-packages/scrapli/decorators.py", line 97, in decorate
    kwargs=kwargs,
  File "/usr/local/lib/python3.7/dist-packages/scrapli/decorators.py", line 172, in _multiprocessing_timeout
    return future.result()
  File "/usr/lib/python3.7/concurrent/futures/_base.py", line 425, in result
    return self.__get_result()
  File "/usr/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result
    raise self._exception
  File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.7/dist-packages/scrapli/transport/plugins/system/transport.py", line 133, in read
    raise ScrapliConnectionError(msg) from exc
scrapli.exceptions.ScrapliConnectionError: encountered EOF reading from transport; typically means the device closed the connection 
ktbyers commented 3 years ago

Probably should ask this in the nornir_scrapli GitHub issues page.

Kani999 commented 3 years ago

@marcinkrzyzynski I've encountered the same error, did you solve the problem?