-
Notifications
You must be signed in to change notification settings - Fork 152
Description
Hi,
I have just tried to test with a Python script ParallelSSHClient and run_command with approximately 50 hosts behind a proxy host.
I've realized that if you had one host in your host list which didn't boot correctly but you still establish a blocking TCP connexion the run_command return the output after bit more two minutes (eg. raise exception Connect Failed). So I decided to pass timeout option to the client with 10 seconds but the behaviour is the same and I must wait two minutes. So I pushed my script on the proxy host and launch ParallelSSHClient without proxy_host option and the output is returned after 10 seconds with an exception as expected (eg. timed out) .
Can you confirm me this behaviour and how I should apply a timeout for my hosts list SSH connection when I specify a proxy_host ? Indeed I don't want to wait two minutes in the case of all hosts boot correctly except one.
You can see below my script and the result of the tests with one host.
Thanks in advance for your help
NOTE1 : If I want a timeout of 10 seconds I must specify .10 (with 10 I must wait 40 seconds).
NOTE2 : I notice in your documentation that you have a timeout=120 in ParallelSSHClient method and a typo in docstring with "Defaults to 10".
script
#!/usr/bin/env python
from __future__ import print_function
import sys
import time
from pssh import ParallelSSHClient
def main(args):
start_time = time.time()
if len(args) > 1:
client = ParallelSSHClient([args[0]],
user='root',
proxy_host=args[1],
proxy_user=args[2],
timeout=.10,
channel_timeout=.10)
else:
client = ParallelSSHClient(args,
user='root',
timeout=.10,
channel_timeout=.10)
output = client.run_command("uptime", stop_on_errors=False)
end_time = time.time() - start_time
print('run_command duration : %d seconds' % end_time)
print(output)
if __name__ == '__main__':
main(sys.argv[1:])
with_proxy : script launch on my computer
my_computer:~$ time ssh -o ConnectTimeout=10 -o "ProxyCommand=ssh grenoble.iot-lab.info -W %h:%p" root@node-a8-111
Connection timed out during banner exchange
real 0m10.021s
user 0m0.012s
sys 0m0.000s
my_computer:~$ ./test_pssh.py node-a8-111 grenoble.iot-lab.info <proxy_user>
run_command duration : 127 seconds
{'node-a8-111':
host=node-a8-111
cmd=<Greenlet at 0x7f2db08a39b0>
channel=None
stdout=None
stderr=None
stdin=None
exception=("Error connecting to host '%s:%s' - %s", 'node-a8-111', 22, 'Connect failed')
}
without_proxy: script launch on the proxy host
proxy_host:~$ time ssh -o ConnectTimeout=10 root@node-a8-111
ssh: connect to host node-a8-111 port 22: Connection timed out
real 0m10.022s
user 0m0.004s
sys 0m0.004s
proxy_host:~$ ./test_pssh.py node-a8-111
run_command duration : 10 seconds
{'node-a8-111':
host=node-a8-111
cmd=<Greenlet at 0x7f2429667050>
channel=None
stdout=None
stderr=None
stdin=None
exception=("Error connecting to host '%s:%s' - %s - retry %s/%s", 'node-a8-111', 22, 'timed out', 3, 3)
}