From 05a07dda7d153b5d04dfab34d46bf5acdb115224 Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Wed, 7 Mar 2012 09:02:39 -0800 Subject: [PATCH] lock: Added a --locked flag to teuthology-lock. Can be used to restrict searches based on lock status, e.g. 'teuthology-lock --list -a --locked false --status up' shows available nodes. --- teuthology/lock.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/teuthology/lock.py b/teuthology/lock.py index e953376beb5b1..ec27726059702 100644 --- a/teuthology/lock.py +++ b/teuthology/lock.py @@ -106,13 +106,13 @@ Lock, unlock, or query lock status of machines. '--list', action='store_true', default=False, - help='Show lock info for machines owned by you, or only machines specified. Can be restricted by --owner and --status.', + help='Show lock info for machines owned by you, or only machines specified. Can be restricted by --owner, --status, and --locked.', ) group.add_argument( '--list-targets', action='store_true', default=False, - help='Show lock info for all machines, or only machines specified, in targets: yaml format. Can be restricted by --owner and --status.', + help='Show lock info for all machines, or only machines specified, in targets: yaml format. Can be restricted by --owner, --status, and --locked.', ) group.add_argument( '--lock', @@ -166,6 +166,12 @@ Lock, unlock, or query lock status of machines. choices=['up', 'down'], help='whether a machine is usable for testing', ) + parser.add_argument( + '--locked', + default=None, + choices=['true', 'false'], + help='whether a machine is locked', + ) parser.add_argument( '-t', '--targets', dest='targets', @@ -242,6 +248,9 @@ Lock, unlock, or query lock status of machines. if ctx.status is not None: statuses = [status for status in statuses \ if status['up'] == (ctx.status == 'up')] + if ctx.locked is not None: + statuses = [status for status in statuses \ + if status['locked'] == (ctx.locked == 'true')] if ctx.list: print json.dumps(statuses, indent=4) else: -- 2.39.5