Telnet Connection Unsuccessful - Exception? #2299
-
I am attempting to determine if a telnet connection was unsuccessful due to the host being offline or unreachable so I can attempt a ping afterwards. I am using the generic_telnet device type to connect to Windows XP systems. For systems that are reachable, the connection is not being established automatically so I am having to use find_prompt() and write_channel() to detect the prompt and send the username and password, which is working fine. However, if a system is offline, it fails to connect, but doesn't return any exception. Is there a way to determine if the connection was unsuccessful? Neither the NetmikoAuthenticationException nor the NetmikoTimeoutException are being thrown. I have the same issue with version 3.3.3 and 3.4. Thank you, |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 10 replies
-
Have you tried passing in a lower timeout, maybe |
Beta Was this translation helpful? Give feedback.
-
@rgourleypython If you do the telnet manually to one of these systems what does the login process look like? On quick glance, I think the issue is probably that you are using |
Beta Was this translation helpful? Give feedback.
-
I would try this:
BaseConnection.telnet_login(self.net_connect) You will have to import BaseConnection into your code i.e.
Let me know if that improves things at all? |
Beta Was this translation helpful? Give feedback.
-
Exceptions work for me as long as I specify the timeout. This is for a system that doesn't have telnet enabled: from netmiko import ConnectHandler, BaseConnection
from getpass import getpass
import logging
host = "cisco.domain.io"
username = "admin"
password = getpass()
net_connect = ConnectHandler(
host=host, username=username, password=password, device_type="generic_telnet", timeout=5
)
BaseConnection.telnet_login(net_connect)
print("-------")
print(net_connect.find_prompt())
print("-------")
|
Beta Was this translation helpful? Give feedback.
Exceptions work for me as long as I specify the timeout. This is for a system that doesn't have telnet enabled: