From: Loic Dachary Date: Sun, 19 Jul 2015 07:02:02 +0000 (+0200) Subject: ssh_keyscan_wait: blocking version of ssh_keysscan X-Git-Tag: 1.1.0~864^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F577%2Fhead;p=teuthology.git ssh_keyscan_wait: blocking version of ssh_keysscan ssh_keyscan is designed to return almost immediately if there is no connection (the timeout is 1 second). ssh_keyscan_wait will wait up to 10 minutes and report progress every 6 seconds. Signed-off-by: Loic Dachary --- diff --git a/teuthology/misc.py b/teuthology/misc.py index 2ced9f4d..5ae39425 100644 --- a/teuthology/misc.py +++ b/teuthology/misc.py @@ -1147,6 +1147,23 @@ def ssh_keyscan(hostnames): return keys_dict +def ssh_keyscan_wait(hostname): + """ + Run ssh-keyscan against a host, return True if it succeeds, + False otherwise. Try again if ssh-keyscan timesout. + :param hostname: on which ssh-keyscan is run + """ + with safe_while(sleep=6, tries=100, + action="ssh_keyscan_wait " + hostname) as proceed: + success = False + while proceed(): + keys_dict = ssh_keyscan([hostname]) + if len(keys_dict) == 1: + success = True + break + log.info("try ssh_keyscan again for " + str(hostname)) + return success + def stop_daemons_of_type(ctx, type_): """ :param type_: type of daemons to be stopped.