Cisco SG350-10 - Not much working....
See original GitHub issueBeen trying to use netmiko to write a script for a Cisco SG350-10 and not having much luck. All the videos on YouTube made it look so simple haha.
from netmiko import Netmiko
from getpass import getpass
cisco_switch = {
"host": "192.168.1.17", # input("Host: "),
"username": "damien", # input("Username: "),
"password": "Cisco12345", # getpass(),
"device_type": "cisco_ios"
}
connection = Netmiko(**cisco_switch)
prompt = connection.find_prompt()
print(prompt)
output = connection.send_command("show vlan")
print(output)
connection.disconnect()
This outputs:
[Running] py -u "c:\Users\Damien Butt\Norgate AV Dropbox\Damien Butt\Resources\Crestron\Cisco NVX Setup\cisco_nvx_setup.py"
[Kswitch28798b#
Traceback (most recent call last):
File "c:\Users\Damien Butt\Norgate AV Dropbox\Damien Butt\Resources\Crestron\Cisco NVX Setup\cisco_nvx_setup.py", line 33, in <module>
output = connection.send_command("show vlan")
File "C:\Users\Damien Butt\AppData\Local\Programs\Python\Python38\lib\site-packages\netmiko\base_connection.py", line 1405, in send_command
raise IOError(
OSError: Search pattern never detected in send_command_expect: \[Kswitch28798b\#
[Done] exited with code=1 in 111.877 seconds
It seems to find the prompt fairly quickly, although it has some extra chars at the start. Then it hangs for a long time before the exception is thrown. I think it’s something to do with those extra chars in the prompt perhaps. They shouldn’t be there.
I’ve also tried using the send_config_set method and that also throws exceptions.
However, if I use the send_command method and specify the “expect_string” parameter as follows:
output = connection.send_command("show vlan", expect_string=r"#"))
That works and outputs:
[Running] py -u "c:\Users\Damien Butt\Norgate AV Dropbox\Damien Butt\Resources\Crestron\Cisco NVX Setup\cisco_nvx_setup.py"
[Kswitch28798b#
Created by: D-Default, S-Static, G-GVRP, R-Radius Assigned VLAN, V-Voice VLAN
Vlan Name Tagged Ports UnTagged Ports Created by
---- ----------------- ------------------ ------------------ ----------------
1 1 gi1-10,Po1-8 DV
switch28798b#
[Done] exited with code=0 in 8.329 seconds
Ideally, I need to use the send_config_set method as I have a bunch of commands to send.
Any ideas what the problem could be?
Thanks in advance.
Damien
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (4 by maintainers)
Top GitHub Comments
@ktbyers That’s exactly the issue, it’s missing from the dict. I’d try making a PR for this during the weekend.
@gaby Did you check if it is supported by ssh_autodetect? If not, someone would need to add that support.