Skip to content
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

No handlers could be found for logger "paramiko.transport" #35

Open
opnine opened this issue May 10, 2018 · 32 comments
Open

No handlers could be found for logger "paramiko.transport" #35

opnine opened this issue May 10, 2018 · 32 comments

Comments

@opnine
Copy link

opnine commented May 10, 2018

Paramiko version = paramiko (2.4.1)

./netmiko-show --cmd "show ip int brief" cisco

I get the error in the subject.

@ktbyers
Copy link
Owner

ktbyers commented May 10, 2018

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

@opnine
Copy link
Author

opnine commented May 10, 2018

it stays there with that output, and I don't get any type of information. I have to manually cancel the task.

@ktbyers
Copy link
Owner

ktbyers commented May 10, 2018

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

@opnine
Copy link
Author

opnine commented May 12, 2018

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.

@ktbyers
Copy link
Owner

ktbyers commented May 12, 2018

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

@ktbyers
Copy link
Owner

ktbyers commented May 12, 2018

My bad, I thought this was a straight Netmiko issue, not netmiko_tools.

@ktbyers
Copy link
Owner

ktbyers commented May 12, 2018

@opnine How long are you waiting for the timeout. You probably have to wait at least two minutes (in certain contexts).

@opnine
Copy link
Author

opnine commented May 14, 2018

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
sys.exit(main(sys.argv[1:]))
File "./maxson-show", line 164, in main
grepx(my_files, pattern, grep_options)
File "./maxson-show", line 48, in grepx
proc.communicate()
File "/usr/lib/python2.7/subprocess.py", line 480, in communicate
self.wait()
File "/usr/lib/python2.7/subprocess.py", line 1099, in wait
pid, sts = _eintr_retry_call(os.waitpid, self.pid, 0)
File "/usr/lib/python2.7/subprocess.py", line 125, in _eintr_retry_call
return func(*args)
KeyboardInterrupt

@ktbyers
Copy link
Owner

ktbyers commented May 14, 2018

What operating system are you on?

What is the path to grep?

Did files get created in ~/.netmiko/tmp?

Kirk

@collin-clark
Copy link

collin-clark commented Feb 20, 2019

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

@ktbyers
Copy link
Owner

ktbyers commented Feb 20, 2019

@collin-clark What does the output of this show:

$ netmiko-grep --list-devices

@collin-clark
Copy link

collin-clark commented Feb 20, 2019

root@srvnet01 netmiko_tools]# ./netmiko-grep --list-devices

Devices:
----------------------------------------
test                         (cisco_ios)


Groups:
----------------------------------------
all

@ktbyers
Copy link
Owner

ktbyers commented Feb 20, 2019

@collin-clark FYI, you can wrap it in triple backtick:

my output

@ktbyers
Copy link
Owner

ktbyers commented Feb 20, 2019

@collin-clark Does this user:

mmessier

Have privilege level 15 (i.e. it needs to be able to do 'show run')?

@collin-clark
Copy link

Yes, he does.

@collin-clark
Copy link

The router (10.0.0.63) never shows a login attempt.

@ktbyers
Copy link
Owner

ktbyers commented Feb 20, 2019

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).

@ktbyers
Copy link
Owner

ktbyers commented Feb 20, 2019

Try to execute that with the correct password and see what occurs.

@collin-clark
Copy link

That works. I see the 'show run'.

@ktbyers
Copy link
Owner

ktbyers commented Feb 20, 2019

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.

@ktbyers
Copy link
Owner

ktbyers commented Feb 20, 2019

This way, hopefully, we can see the actual exception.

@collin-clark
Copy link

collin-clark commented Feb 20, 2019

[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.

@ktbyers
Copy link
Owner

ktbyers commented Feb 20, 2019

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})

@collin-clark
Copy link

{'username': mmessier, 'ip': '10.0.0.63', 'password': '********', 'port': 22, 'device_type': 'cisco_ios'}

That seems to look good.

@ktbyers
Copy link
Owner

ktbyers commented Feb 20, 2019

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?

@collin-clark
Copy link

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

@ktbyers
Copy link
Owner

ktbyers commented Feb 20, 2019

Okay, that would lead me to believe that it can't reach that IP address on port 22 (from that machine).

@collin-clark
Copy link

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'}

@ktbyers
Copy link
Owner

ktbyers commented Feb 20, 2019

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

@collin-clark
Copy link

I quoted it in my YAML file, but in the print statement, its still showing without any quotes.

@collin-clark
Copy link

I'm sorry, I am incorrect. When quoting in the YAML it IS working. Verified on Ubuntu 18.04 and CentOS 7.4.

@ktbyers
Copy link
Owner

ktbyers commented Feb 20, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants