]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Update SSH keys when creating VMs
authorZack Cerza <zack@redhat.com>
Fri, 6 Jan 2017 20:47:59 +0000 (13:47 -0700)
committerZack Cerza <zack@redhat.com>
Fri, 24 Feb 2017 16:03:33 +0000 (09:03 -0700)
Signed-off-by: Zack Cerza <zack@redhat.com>
teuthology/lock/cli.py
teuthology/lock/keys.py
teuthology/lock/ops.py
teuthology/task/internal/lock_machines.py

index 75869871b81e2df13b99c9f5fb44eca533371f1f..66702d3aeef06861ae79f3b07b95c74ed0f6df2f 100644 (file)
@@ -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['<machine>']:
+    machines = []
+    if args['<machine>']:
         machines = [misc.canonicalize_hostname(m, user=None)
                     for m in args['<machine>']]
     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]
index b6fe58ec2db46518cc716c6170ecf127490a54eb..c59bdb71977852bcf03b770af06a9ec31270fe23 100644 (file)
@@ -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
index ccd77540359940f5a6328956671b438af705e8ba..41a2d1cb58777eed4003f027b58406f90979bcf6 100644 (file)
@@ -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:
index a44f9d2301ad44ff927eafb41e7d62d8ba8c9013..96b5eec632c0f77f8f4fa4a3ec978a7074041cc9 100644 (file)
@@ -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():