Open opnine opened 6 years ago
That is just a Paramiko warning (which doesn't matter); there is likely a separate error.
Can you post the entire output of what you received?
Kirk
it stays there with that output, and I don't get any type of information. I have to manually cancel the task.
Can you post your code and the output you see on the screen?
How long are you waiting before break out of the task?
Kirk
I never get a any timeout , but I found that the issue starts when I have to add the static route to access that devices. If I remove the route I only get a timeout, but if I add the route to access , i get the error.
Okay, please post your code and the output you see when you execute your code. The paramiko logging message is an unimportant logging warning so that is a side-effect of some other issue.
Kirk
My bad, I thought this was a straight Netmiko issue, not netmiko_tools.
@opnine How long are you waiting for the timeout. You probably have to wait at least two minutes (in certain contexts).
I neve get the time out .
No handlers could be found for logger "paramiko.transport"
^CTraceback (most recent call last):
File "./maxson-show", line 181, in
What operating system are you on?
What is the path to grep
?
Did files get created in ~/.netmiko/tmp?
Kirk
I get this same error. I've tried both installs (git and download tar), doesn't seem to make a difference. I've tried it on Ubuntu 16.04, Ubuntu 18.04 and CentOS 7.4. The files do get created, however all they have in them is %%%failed%%%. I have let it run for ~45 minutes and the only way out is to CTRL-C.
Command: ./netmiko-grep 'zone' all
I have verified that Paramiko, Netmiko, grep and netmiko-grep are all in my PATH.
On the hosts I've installed the full netmiko toolset, I've tried netmiko-show and netmiko-cfg with the same results.
My inventory file [.netmiko.yml] is in the same directory as netmiko-grep and it is below. I also tried it in my home dir and get the same results.
test: device_type: cisco_ios ip: 10.0.0.63 username: mmessier password: LeTsGoRaNgErS port: 22
@collin-clark What does the output of this show:
$ netmiko-grep --list-devices
root@srvnet01 netmiko_tools]# ./netmiko-grep --list-devices
Devices:
----------------------------------------
test (cisco_ios)
Groups:
----------------------------------------
all
@collin-clark FYI, you can wrap it in triple backtick:
my output
@collin-clark Does this user:
mmessier
Have privilege level 15 (i.e. it needs to be able to do 'show run')?
Yes, he does.
The router (10.0.0.63) never shows a login attempt.
Okay, I would take it out of netmiko-tools and try it directly in Netmiko:
from netmiko import ConnectHandler
my_device = {
"device_type" : "cisco_ios",
"ip": "10.0.0.63",
"username": "mmessier",
"password": "password",
"port": 22,
}
net_connect = ConnectHandler(**my_device)
output = net_connect.send_command("show run")
print(output)
And see what happens (note, I changed the password, but everything else should be identical).
Try to execute that with the correct password and see what occurs.
That works. I see the 'show run'.
Okay, it would be interesting if in the netmiko-grep executable, you commented these two lines out:
def ssh_conn(device_name, a_device, cli_command, output_q):
# try:
net_connect = ConnectHandler(**a_device)
net_connect.enable()
output = net_connect.send_command_expect(cli_command)
net_connect.disconnect()
# except Exception:
# output = ERROR_PATTERN
output_q.put({device_name: output})
In other words, comment out the try/except so that the exception just happens. You might have to fix the indentation also.
This way, hopefully, we can see the actual exception.
[root@srvnet01 netmiko_tools]# ./netmiko-grep 'zone' all
No handlers could be found for logger "paramiko.transport"
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib64/python2.7/threading.py", line 812, in __bootstrap_inner
self.run()
File "/usr/lib64/python2.7/threading.py", line 765, in run
self.__target(*self.__args, **self.__kwargs)
File "./netmiko-grep", line 55, in ssh_conn
net_connect = ConnectHandler(**a_device)
File "/usr/lib/python2.7/site-packages/netmiko/ssh_dispatcher.py", line 218, in ConnectHandler
return ConnectionClass(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/netmiko/base_connection.py", line 270, in __init__
self.establish_connection()
File "/usr/lib/python2.7/site-packages/netmiko/base_connection.py", line 782, in establish_connection
self.remote_conn_pre.connect(**ssh_connect_params)
File "/usr/lib/python2.7/site-packages/paramiko/client.py", line 437, in connect
passphrase,
File "/usr/lib/python2.7/site-packages/paramiko/client.py", line 736, in _auth
self._transport.auth_password(username, password)
File "/usr/lib/python2.7/site-packages/paramiko/transport.py", line 1436, in auth_password
return self.auth_handler.wait_for_response(my_event)
File "/usr/lib/python2.7/site-packages/paramiko/auth_handler.py", line 236, in wait_for_response
raise e
TypeError: object of type 'int' has no len()
It just hangs there, no more output.
What do you see if you add a print statement here?
def ssh_conn(device_name, a_device, cli_command, output_q):
# try:
print(a_device)
net_connect = ConnectHandler(**a_device)
net_connect.enable()
output = net_connect.send_command_expect(cli_command)
net_connect.disconnect()
# except Exception:
# output = ERROR_PATTERN
output_q.put({device_name: output})
{'username': mmessier, 'ip': '10.0.0.63', 'password': '********', 'port': 22, 'device_type': 'cisco_ios'}
That seems to look good.
I assume you tested the netmiko script and netmiko-tools from the same exact machine using the same exact virtual environment?
I am not really seeing any difference between those two from a code perspective, but in the netmiko_tools case it doesn't look like the traffic is exiting your machine. You don't have any firewall or or SE-linux that would be blocking it in this case?
I jumped over to my Ubuntu box and made the same changes as we did on the CentOS box (verified no firewall/SE). It however has a larger inventory. I ran it and I get the same results, however there is a a couple of new additional traceback that may be helpful.
Exception in thread Thread-17:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "./netmiko-grep", line 56, in ssh_conn
net_connect = ConnectHandler(**a_device)
File "/home/ubuntu/netmiko_tools/venv/lib/python2.7/site-packages/netmiko/ssh_dispatcher.py", line 218, in ConnectHandler
return ConnectionClass(*args, **kwargs)
File "/home/ubuntu/netmiko_tools/venv/lib/python2.7/site-packages/netmiko/base_connection.py", line 270, in __init__
self.establish_connection()
File "/home/ubuntu/netmiko_tools/venv/lib/python2.7/site-packages/netmiko/base_connection.py", line 787, in establish_connection
raise NetMikoTimeoutException(msg)
NetMikoTimeoutException: Connection to device timed-out: cisco_ios 10.130.60.3:22
Okay, that would lead me to believe that it can't reach that IP address on port 22 (from that machine).
Ahhh, old device, sorry about that. In digging a little deeper I noticed that the info from the print statement we added, that the username is not in single-quotes. Does that matter?
{'username': mmessier, 'ip': '10.0.0.63', 'password': '********', 'port': 22, 'device_type': 'cisco_ios'}
Yes, the username should be quoted in the print output. I would quote it in your source YAML file and re-test:
test:
device_type: cisco_ios
ip: 10.0.0.63
username: "mmessier"
password: passw
port: 22
I quoted it in my YAML file, but in the print statement, its still showing without any quotes.
I'm sorry, I am incorrect. When quoting in the YAML it IS working. Verified on Ubuntu 18.04 and CentOS 7.4.
Ugly...weird. I wonder if there is a hidden character in your YAML file.
You could try to print(repr(a_device['username']))
But it looks like you have it working.
But anyways looks like it is fixed.
Paramiko version = paramiko (2.4.1)
./netmiko-show --cmd "show ip int brief" cisco
I get the error in the subject.