-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to interact with a specific Ubiquiti Edge Switch - Others are fine. #3471
Comments
You might want to check the Basically Netmiko is saying it never saw the prompt get returned on the |
Thanks for the recommendation, with that being said, it looks like the command runs but the output isn't finished before it times out. I'm guessing the read timeout needs to be higher than the time it takes for the command to finish on the switch itself, is that correct in your eyes? |
Yeah, if |
Just logged onto the switch, ran the show run command and it outputted probably one of the smallest configs of all of the devices I'm working through without issue. Set read timeout to 300s and still getting the same error. Any other suggestions at all please? Can't see it being the switch at fault here as it's responsive when I SSH Directly? |
Have you looked at the session log or the Netmiko debug log? |
I'm still looking at the session log. This time it took the full 300 seconds to output the below, less than it did without the read timeout: | || | __ _ ___ (c) 2010-2018 Welcome to EdgeSwitch By logging in, accessing or using the Ubiquiti (UBNT) product, you (UBNT EdgeSwitch) > (UBNT EdgeSwitch) # (UBNT EdgeSwitch) # I'm just looking at getting debug logging on my test file. |
Just adding the debug log, and it's getting stuck after the first portion of the output. It is showing pattern found though, starting off the show run, then has 2000 lines of DEBUG:netmiko:read_channel: DEBUG:netmiko:Pattern found: (#|>) DEBUG:netmiko:write_channel: b'terminal length 0\n' (UBNT EdgeSwitch) # !Current Configuration: network protocol none network mgmt_vlan |
Debug basically is showing that your device stops outputting data for some reason. I.E. Netmiko keeps looking for the next part of the show run output and it is not showing up. How long does the |
Thought so. Less than 15 seconds when directly logged in, that includes hitting space bar to get to the end of the output also. |
I would try: import time
# other imports
switch = {
'device_type': 'ubiquiti_edgeswitch',
'host': 'ip address would be here',
'username': username,
'password': password,
'secret': password,
}
net_connect = ConnectHandler(**switch)
output = net_connect.find_prompt()
print(output)
# sleep for a few seconds
time.sleep(4)
output = net_connect.send_command('show run', expect_string="#", read_timeout=30)
print(output)
net_connect.disconnect() |
Just tried the above, output in console: Pattern not detected: '#' in output. Things you might try to fix this: Explicitly set your pattern using the expect_string argument. Debug now stops after the 'show run': DEBUG:netmiko:read_channel: Session log producing: Welcome to EdgeSwitch By logging in, accessing or using the Ubiquiti (UBNT) product, you (UBNT EdgeSwitch) > (UBNT EdgeSwitch) # (UBNT EdgeSwitch) # I cant make sense as to why Netmiko can't see the output of the command but can see the prompt and the command being entered. |
What do you see in your log/session_log if you try this?
Rest of the code can be the same. |
Session log shows the same as before unfortunately: | || | __ _ ___ (c) 2010-2018 Welcome to EdgeSwitch By logging in, accessing or using the Ubiquiti (UBNT) product, you (UBNT EdgeSwitch) > (UBNT EdgeSwitch) # (UBNT EdgeSwitch) # The script finished earlier though and debug log reflects that also: (UBNT EdgeSwitch) # I also believe there's about that many lines in the actual full config, just obviously isn't displaying the result in each line. |
What about? import time
# other imports
switch = {
'device_type': 'ubiquiti_edgeswitch',
'host': 'ip address would be here',
'username': username,
'password': password,
'secret': password,
'default_enter': "\r\n", # ADDED THIS
}
net_connect = ConnectHandler(**switch)
output = net_connect.find_prompt()
print(output)
# sleep for a few seconds
time.sleep(4)
output = net_connect.send_command('show run', expect_string="#", read_timeout=30)
print(output)
net_connect.disconnect() |
Note I added the |
I get a syntax error doing this: switch = { Error: 'default_enter': "\r\n", |
Your dictionary needs commas after every key-value pair (your session_log doesn't have one): switch = {
'device_type': 'ubiquiti_edgeswitch',
'host': '...',
'username': username,
'password': password,
'secret': password,
'session_log': file_name, # Needs a comma
'default_enter': "\r\n",
} |
Of course it does, I deleted that by accident, apologies. It printed the full output the first time, when I ran it again I'm now back at square one with the error: Pattern not detected: '#' in output. Things you might try to fix this:
You can also look at the Netmiko session_log or debug log for more information. |
If you run it a few more times (the code that worked once), does it work some of the time? |
Sorry for delayed response - I've been tweaking this today now that I've had some sleep, and managed to get it reliably working in the below format: switch = { net_connect = ConnectHandler(**switch) It seems 'default_enter': "\r\n" is the deciding factor here. For future reference, what is it that this argument is doing that would change the outcome of what's being displayed/picked up by netmiko? I'm a little out of my depth here I think. |
Description of Issue/Question
Issue connecting to a specific Ubiquiti Edgeswitch advising Pattern not detected, despite find prompt showing the exact pattern the error is asking for.
I'm fairly new to this so I apologise in advance if I've missed something basic.
Please could you advise, as I've tried a few of the ubiquiti_edge* options and they all seem to do the same thing.
Setup
Windows 11, python 3.12.4, Microsoft Visual Studio Code 1.91.1
(UBNT EdgeSwitch) >show version
Switch: 1
System Description............................. EdgePoint Switch 16-Port, 1.6.0.4900860, Linux 3.6.5-f4a26ed5, 1.0.0.4857129
Machine Type................................... EdgePoint Switch 16-Port
Machine Model.................................. EP-S16
Software Version............................... 1.6.0.4900860
Netmiko version
(Paste verbatim output from
pip freeze | grep netmiko
between quotes below)I'm using windows so grep is not usable:
netmiko==4.4.0
Netmiko device_type (if relevant to the issue)
(Paste
device_type
between quotes below)Steps to Reproduce the Issue
connect to device using netmiko.
Try to run command show run
Error Traceback
(Paste the complete traceback of the exception between quotes below)
Relevant Python code
(Please try to essentialize your Python code to the minimum code needed to reproduce the issue)
(Paste the code between the quotes below)
The text was updated successfully, but these errors were encountered: