ktbyers / netmiko

Multi-vendor library to simplify Paramiko SSH connections to network devices
MIT License
3.63k stars 1.31k forks source link

Extreme 4950 extreme_telnet Pattern not detected: '[>\\#]' in output. #3344

Open Tabak-nsk opened 1 year ago

Tabak-nsk commented 1 year ago

Hi, When I try to connect to extreme ers 4950 with device_type = extreme_telnet, pattern > is not found, but it is there.

Netmiko version

netmiko==4.3.0

Netmiko device_type (if relevant to the issue)

extreme_telnet

Steps to Reproduce the Issue

Authentication is not configured on the device, connection via telnet

Error Traceback

Connecting to 172.21.154.254 MainThread netmiko DEBUG: read_channel:

4950GTS-415-C> MainThread netmiko DEBUG: write_channel: b'\r\n' MainThread netmiko DEBUG: read_channel: MainThread netmiko DEBUG: read_channel: MainThread netmiko DEBUG: read_channel:

removed duplicate lines

MainThread netmiko DEBUG: read_channel: MainThread netmiko DEBUG: read_channel: MainThread netmiko DEBUG: write_channel: b'exit\r\n' Traceback (most recent call last): File "E:\scripts\python\itinet-monitoring\get_network_device_from_ise\get_radius_server_status_avaya_debug.py", line 28, in connect_to_switch('172.21.154.254', command) File "E:\scripts\python\itinet-monitoring\get_network_device_from_ise\get_radius_server_status_avaya_debug.py", line 18, in connect_to_switch net_connect = ConnectHandler(switch) ^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\someuser\AppData\Local\Programs\Python\Python311\Lib\site-packages\netmiko\ssh_dispatcher.py", line 399, in ConnectHandler return ConnectionClass(*args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\someuser\AppData\Local\Programs\Python\Python311\Lib\site-packages\netmiko\extreme\extreme_exos.py", line 79, in init super().init(args, kwargs) File "C:\Users\someuser\AppData\Local\Programs\Python\Python311\Lib\site-packages\netmiko\base_connection.py", line 488, in init self._open() File "C:\Users\someuser\AppData\Local\Programs\Python\Python311\Lib\site-packages\netmiko\base_connection.py", line 494, in _open self._try_session_preparation() File "C:\Users\someuser\AppData\Local\Programs\Python\Python311\Lib\site-packages\netmiko\base_connection.py", line 988, in _try_session_preparation self.session_preparation() File "C:\Users\someuser\AppData\Local\Programs\Python\Python311\Lib\site-packages\netmiko\extreme\extreme_exos.py", line 18, in session_preparation self._test_channel_read(pattern=r"[>#]") File "C:\Users\someuser\AppData\Local\Programs\Python\Python311\Lib\site-packages\netmiko\base_connection.py", line 1235, in _test_channel_read return self.read_until_pattern(pattern=pattern, read_timeout=20) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\someuser\AppData\Local\Programs\Python\Python311\Lib\site-packages\netmiko\base_connection.py", line 746, in read_until_pattern raise ReadTimeout(msg) netmiko.exceptions.ReadTimeout:

Pattern not detected: '[>\#]' in output.

Things you might try to fix this:

  1. Adjust the regex pattern to better identify the terminating string. Note, in many situations the pattern is automatically based on the network device's prompt.
  2. Increase the read_timeout to a larger value.

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

Relevant Python code

def connect_to_switch(ip, comms): print(f"Connecting to {ip}") switch = { 'device_type': 'extreme_telnet', 'host': ip, "global_delay_factor": 2 } net_connect = ConnectHandler(**switch)

v = net_connect.send_command(comms)
print(v)
net_connect.disconnect()

if name == "main":

Commands to sent

command = 'show radius-server'  
connect_to_switch('172.21.154.254', command)
ktbyers commented 1 year ago

Try adding an argument named fast_cli=False to the switch dictionary (and then if that doesn't work, try a global_delay_factor of 4).

Tabak-nsk commented 12 months ago

Good afternoon. Thanks for the advice, but it didn't help. Nothing has changed - I get the same exception.

apepelis-extremenetwork commented 9 months ago

@Tabak-nsk can you log into your device manually and print the prompt? I don't see it here. It might need the prompt regex to be: [>#=] or [=#]

Tabak-nsk commented 9 months ago

Good afternoon. When copy-pasting, it is not visible that there are many line breaks(22) before the hostname output. [login@server ~]$ telnet 172.21.154.254 Trying 172.21.154.254... Connected to 172.21.154.254. Escape character is '^]'.

4950GTS-415-C>

apepelis-extremenetwork commented 9 months ago

4950GTS-415-C>

TU, I just saw that in your original post. It's different from the issue that I'm looking at with a new prompt. Just put a break point at that line 1235 and step in. I would guess that something isn't set right and it's not returning anything to from the channel read.

This: _MainThread netmiko DEBUG: write_channel: b'\r\n' MainThread netmiko DEBUG: read_channel: MainThread netmiko DEBUG: read_channel: MainThread netmiko DEBUG: readchannel:

I would think would look like: _MainThread netmiko DEBUG: write_channel: b'\r\n' MainThread netmiko DEBUG: read_channel: MainThread netmiko DEBUG: read_channel: 4950GT MainThread netmiko DEBUG: readchannel:S-415-C>

but it doesn't look like it's echoing back to you at all. Since this is telnet, do a wireshark on it and you can look at the data going back and forth. It's possible that it didn't auto negotiate the telnet options to echo. But your telnet client does. https://www.omnisecu.com/tcpip/telnet-negotiation.php

ktbyers commented 9 months ago

Yeah, the error is Netmiko expecting to see the > prompt after sending an <enter> and it never does (within the relevant timeouts which we tried to adjust above with global_delay_factor and fast_cli=False above).