From: Dan Mick Date: Mon, 27 Oct 2014 22:06:01 +0000 (-0700) Subject: lock.py: update keys for any owned VMs, even if none mentioned on CLI X-Git-Tag: 1.1.0~1095^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F348%2Fhead;p=teuthology.git lock.py: update keys for any owned VMs, even if none mentioned on CLI 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 --- diff --git a/teuthology/lock.py b/teuthology/lock.py index aebbd044..d5f21986 100644 --- a/teuthology/lock.py +++ b/teuthology/lock.py @@ -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: