From cd0442354157bf26ea3ef03814a1aaeaca9b00d9 Mon Sep 17 00:00:00 2001 From: Josh Durgin Date: Tue, 2 Aug 2011 15:53:37 -0700 Subject: [PATCH] teuthology-lock: allow list of locks to be filtered by owner and status --- teuthology/lock.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/teuthology/lock.py b/teuthology/lock.py index 566783fb686bf..f9cc34af9b397 100644 --- a/teuthology/lock.py +++ b/teuthology/lock.py @@ -207,9 +207,7 @@ Lock, unlock, or query lock status of machines. 'machines must be specified for that operation' if ctx.list: - assert ctx.status is None and ctx.desc is None, \ - '--status and --desc do nothing with --list' - assert ctx.owner is None, 'the owner option does nothing with --list' + assert ctx.desc is None, '--desc does nothing with --list' if machines: statuses = [get_status(ctx, machine) for machine in machines] @@ -217,6 +215,12 @@ Lock, unlock, or query lock status of machines. statuses = list_locks(ctx) if statuses: + if ctx.owner is not None: + statuses = [status for status in statuses \ + if status['locked_by'] == ctx.owner] + if ctx.status is not None: + statuses = [status for status in statuses \ + if status['up'] == (ctx.status == 'up')] print json.dumps(statuses, indent=4) else: log.error('error retrieving lock statuses') -- 2.39.5