From fff9626f2862bc3ff378129f9ff0b5b06a400344 Mon Sep 17 00:00:00 2001 From: Dan Mick Date: Mon, 27 Oct 2014 15:06:01 -0700 Subject: [PATCH] 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 --- teuthology/lock.py | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/teuthology/lock.py b/teuthology/lock.py index aebbd04407..d5f219867b 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: -- 2.39.5