]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
lock.py: update keys for any owned VMs, even if none mentioned on CLI 348/head
authorDan Mick <dan.mick@redhat.com>
Mon, 27 Oct 2014 22:06:01 +0000 (15:06 -0700)
committerDan Mick <dan.mick@redhat.com>
Tue, 28 Oct 2014 17:00:15 +0000 (10:00 -0700)
teuthology-lock to create new VMs followed by "--list-targets" was
returning the old hostkeys.  The code rightly avoids fetching keys
for all hosts; this change makes it update keys owned by the
current querying user.

Fixes: #9871
Signed-off-by: Dan Mick <dan.mick@redhat.com>
teuthology/lock.py

index aebbd044078f283a6d99bd780805d4392963dadd..d5f219867b86505f22c3bb814234bed9e935b1ee 100644 (file)
@@ -161,18 +161,26 @@ def main(ctx):
         else:
             statuses = list_locks()
         vmachines = []
-
-        for vmachine in statuses:
-            if vmachine['vm_host']:
-                if vmachine['locked']:
-                    vmachines.append(vmachine['name'])
+        my_vmachines = []
+
+        for machine in statuses:
+            if machine['is_vm'] and machine['locked']:
+                vmachines.append(machine['name'])
+                # keep track of which are ours, so that if we don't
+                # specify machines, the update_keys below can only try
+                # ours
+                if machine['locked_by'] == user:
+                    my_vmachines.append(machine['name'])
         if vmachines:
             # Avoid ssh-keyscans for everybody when listing all machines
-            # Listing specific machines will update the keys.
-            if machines:
-                do_update_keys(vmachines)
-                statuses = [get_status(machine)
-                            for machine in machines]
+            # Listing specific machines will update the keys, and if none
+            # are specified, my_vmachines will also be updated (if any)
+            if machines or not ctx.all:
+                if my_vmachines:
+                    do_update_keys(my_vmachines)
+                if machines:
+                    statuses = [get_status(machine)
+                                for machine in machines]
             else:
                 statuses = list_locks()
         if statuses: