我无法使用connectHandler运行netmiko代码

时间:2019-05-10 16:02:36

标签: python-3.x python-2.7 networking sdn

我能够ping通此IP 192.168.122.40的交换机,但是我无法运行此代码。请对此提供帮助

我无法运行此代码,请对此提供帮助

from Netmiko import ConnectHandler
cisco_881 = {
    'device_type': 'cisco_ios',
    'ip':   '192.168.122.40',
    'username': 'nani',
    'password': 'cisco',
}
net_connect = ConnectHandler(**cisco_881)
output = net_connect.send_command('show ip int brief')
print(output)enter code here

after running this code I am getting below output


python file name ( netmio_script.py)


root@NetworkAutomation-1:~# python netmio_script.py
Traceback (most recent call last):
  File "netmio_script.py", line 9, in <module>
    net_connect = ConnectHandler(**cisco_881)
  File "/usr/local/lib/python2.7/dist-packages/netmiko/ssh_dispatcher.py", line 218, in ConnectHandler
    return ConnectionClass(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/netmiko/base_connection.py", line 270, in __init__
    self.establish_connection()
  File "/usr/local/lib/python2.7/dist-packages/netmiko/base_connection.py", line 787, in establish_connection
    raise NetMikoTimeoutException(msg)
netmiko.ssh_exception.NetMikoTimeoutException: Connection to device timed-out: cisco_ios 192.168.122.40:22
root@NetworkAutomation-1:~# python netmio_script.py
Traceback (most recent call last):
  File "netmio_script.py", line 9, in <module>
    net_connect = ConnectHandler(**cisco_881)
  File "/usr/local/lib/python2.7/dist-packages/netmiko/ssh_dispatcher.py", line 218, in ConnectHandler
    return ConnectionClass(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/netmiko/base_connection.py", line 270, in __init__
    self.establish_connection()
  File "/usr/local/lib/python2.7/dist-packages/netmiko/base_connection.py", line 787, in establish_connection
    raise NetMikoTimeoutException(msg)
netmiko.ssh_exception.NetMikoTimeoutException: Connection to device timed-out: cisco_ios 192.168.122.40:22

0 个答案:

没有答案