napalm-automation-community / napalm-s350

NAPALM driver for Cisco SMB switches (SF3xx, SF5xx, SG3xx, SG5xx).
Apache License 2.0
16 stars 13 forks source link

get_config not working under napalm==4.0.0 but works under 3.4.1 #81

Closed davama closed 2 years ago

davama commented 2 years ago

Environment

Python version ('python3 --version'): Python 3.9.7

Steps to Reproduce

driver = get_network_driver("s350")
device = driver(device_name,'username','password')
device.open()
output = device.get_config()

Expected Behavior

The dict output of the config.

Observed Behavior

Under v3.4.1 (pip install napalm==3.4.1) I have no issues getting the output of get_config function. WIth napalm==4.0.0 the following results:

Traceback (most recent call last):
  File "/home/user/dave-dev-environment/my-napalm-s350-test.py", line 34, in <module>
    output = device.get_config()
  File "/home/user/dave-dev-environment/lib64/python3.9/site-packages/napalm_s350/s350.py", line 209, in get_config
    startup = self._send_command("show startup-config")
  File "/home/user/dave-dev-environment/lib64/python3.9/site-packages/napalm_s350/s350.py", line 143, in _send_command
    output = self.device.send_command(command)
  File "/home/user/dave-dev-environment/lib64/python3.9/site-packages/netmiko/utilities.py", line 592, in wrapper_decorator
    return func(self, *args, **kwargs)
  File "/home/user/dave-dev-environment/lib64/python3.9/site-packages/netmiko/base_connection.py", line 1721, in send_command
    raise ReadTimeout(msg)
netmiko.exceptions.ReadTimeout: 
Pattern not detected: 'H\\-TXA\\-2WDM\\-SW\\-1\\#' in output.

Things you might try to fix this:
1. Explicitly set your pattern using the expect_string argument.
2. Increase the read_timeout to a larger value.

You can also look at the Netmiko session_log or debug log for more information.

I can see in the netmiko debug log that it runs the commands as expected (show startup-config) but as the config is being spit out, I eventually get Patter not detected error

DEBUG:netmiko:read_channel: 
DEBUG:netmiko:read_channel: show
DEBUG:netmiko:read_channel:  startup-config
...
...
...
DEBUG:netmiko:read_channel: !

DEBUG:netmiko:read_channel: 
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:read_channel: interface gigabitethernet2
 description H-TXA-2W-SW-1(A17)
 storm-control broadcast enable
 storm-control broadcast level kbps 3500
DEBUG:netmiko:read_channel: 
 storm-control include-multicast unknown-unicast
DEBUG:netmiko:read_channel: 

DEBUG:netmiko:read_channel: 
DEBUG:netmiko:read_channel:  switchport trunk allowed vlan add 63,224,663,824,1063,1224,2063
 switchport forbidden default-vlan

#### there is still just 10 more lines left for the whole config to finish, but it errors out here

Please let me know if need more information from me. First time posting here. Hope I did this right.

Thank you, Dave

davama commented 2 years ago

Found the issue. It was technically not napalm but netmiko. With the latest netmiko version they added a read_timeout=10.0 to the _send_command function under netmiko.base_connection.

i basically copied over the s350 napalm _send_command into custom_napalm.s350 (which replaces the original function) and added read_timeout=20 to the netmiko call in self.device._send_command(bla, read_timeout=20)

qaxi commented 2 years ago

Sooo , what is conclusion. Is the issue specific for your environment ?

davama commented 2 years ago

Well the default netmiko read_timeout=10.0 setting is not specific, but my device taking more than 10 seconds to spit the config is.