From 48357d666cfcff19c250908c39f0023ca6538f83 Mon Sep 17 00:00:00 2001 From: Sandon Van Ness Date: Thu, 1 Aug 2013 17:04:04 -0700 Subject: [PATCH] Fix for #5836 (--lock-many with vms) This makes --lock-many work when --machine-type vps is passed. Before it wasn't handled correctly and guests were not created. Now it creates and gives the back the user the list-targets for said guests. teuthology-lock --lock-many 4 --machine-type vps --os-type centos This fixes issue #5836 Signed-off-by: Sandon Van Ness Reviewed-by: Alfredo Deza --- teuthology/lock.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/teuthology/lock.py b/teuthology/lock.py index b0e0f62c8cfab..65d1fcf796211 100644 --- a/teuthology/lock.py +++ b/teuthology/lock.py @@ -28,6 +28,9 @@ def lock_many(ctx, num, machinetype, user=None, description=None): if success: machines = json.loads(content) log.debug('locked {machines}'.format(machines=', '.join(machines.keys()))) + if ctx.machine_type == 'vps': + for machine in machines: + create_if_vm(ctx, machine) return machines if status == 503: log.error('Insufficient nodes available to lock %d nodes.', num) @@ -366,9 +369,10 @@ Lock, unlock, or query lock status of machines. else: machines_to_update = result.keys() if ctx.machine_type == 'vps': - print "Locks successful" - print "Unable to display keys at this time (virtual machines are rebooting)." - print "Please run teuthology-lock --list-targets once these machines come up." + shortnames = ' '.join([name.split('@')[1].split('.')[0] for name in result.keys()]) + print "Successfully Locked:\n%s\n" % shortnames + print "Unable to display keys at this time (virtual machines are booting)." + print "Please run teuthology-lock --list-targets %s once these machines come up." % shortnames else: print yaml.safe_dump(dict(targets=result), default_flow_style=False) elif ctx.update: -- 2.39.5