]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
lock: Added a --locked flag to teuthology-lock.
authorMark Nelson <mark.nelson@dreamhost.com>
Wed, 7 Mar 2012 17:02:39 +0000 (09:02 -0800)
committerMark Nelson <mark.nelson@dreamhost.com>
Wed, 7 Mar 2012 20:55:33 +0000 (12:55 -0800)
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

index e953376beb5b1ec1446a912e415c12d2e4922540..ec277260597022e9d944983bc87725c1dd5eee18 100644 (file)
@@ -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: