From bf25efb197a7640578b5920648958c7ee3e98a36 Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Fri, 6 Jan 2017 13:47:59 -0700 Subject: [PATCH] Update SSH keys when creating VMs Signed-off-by: Zack Cerza --- teuthology/lock/cli.py | 8 ++++---- teuthology/lock/keys.py | 4 ++-- teuthology/lock/ops.py | 1 + teuthology/task/internal/lock_machines.py | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/teuthology/lock/cli.py b/teuthology/lock/cli.py index 75869871b8..66702d3aee 100644 --- a/teuthology/lock/cli.py +++ b/teuthology/lock/cli.py @@ -215,6 +215,7 @@ def main(ctx): return ret + def do_summary(ctx): lockd = collections.defaultdict(lambda: [0, 0, 'unknown']) if ctx.machine_type: @@ -251,9 +252,8 @@ def updatekeys(args): level=loglevel, ) all_ = args['--all'] - if all_: - machines = [] - elif args['']: + machines = [] + if args['']: machines = [misc.canonicalize_hostname(m, user=None) for m in args['']] elif args['--targets']: @@ -263,4 +263,4 @@ def updatekeys(args): for doc in docs: machines = [n for n in doc.get('targets', dict()).iterkeys()] - return keys.do_update_keys(machines, all_) \ No newline at end of file + return keys.do_update_keys(machines, all_)[0] diff --git a/teuthology/lock/keys.py b/teuthology/lock/keys.py index b6fe58ec2d..c59bdb7197 100644 --- a/teuthology/lock/keys.py +++ b/teuthology/lock/keys.py @@ -12,7 +12,7 @@ def do_update_keys(machines, all_=False): if all_: machines = reference.keys() keys_dict = misc.ssh_keyscan(machines) - return push_new_keys(keys_dict, reference) + return push_new_keys(keys_dict, reference), keys_dict def push_new_keys(keys_dict, reference): @@ -24,4 +24,4 @@ def push_new_keys(keys_dict, reference): if not ops.update_lock(hostname, ssh_pub_key=pubkey): log.error('failed to update %s!', hostname) ret = 1 - return ret \ No newline at end of file + return ret diff --git a/teuthology/lock/ops.py b/teuthology/lock/ops.py index ccd7754035..41a2d1cb58 100644 --- a/teuthology/lock/ops.py +++ b/teuthology/lock/ops.py @@ -104,6 +104,7 @@ def lock_many(ctx, num, machine_type, user=None, description=None, log.error('Unable to create virtual machine: %s', machine) unlock_one(ctx, machine, user) + ok_machs = keys.do_update_keys(ok_machs.keys())[1] return ok_machs return machines elif response.status_code == 503: diff --git a/teuthology/task/internal/lock_machines.py b/teuthology/task/internal/lock_machines.py index a44f9d2301..96b5eec632 100644 --- a/teuthology/task/internal/lock_machines.py +++ b/teuthology/task/internal/lock_machines.py @@ -115,7 +115,7 @@ def lock_machines(ctx, config): full_name = misc.canonicalize_hostname(guest) provision.destroy_if_vm(ctx, full_name) provision.create_if_vm(ctx, full_name) - if teuthology.lock.keys.do_update_keys(keys_dict): + if teuthology.lock.keys.do_update_keys(keys_dict)[0]: log.info("Error in virtual machine keys") newscandict = {} for dkey in all_locked.iterkeys(): -- 2.39.5