From fac88a40965c9412fe634e8aabde22f2762e40ed Mon Sep 17 00:00:00 2001 From: Dan Mick Date: Tue, 5 Jun 2012 18:33:36 -0700 Subject: [PATCH] More shortnames fixes: - Allow shortnames in teuthology-updatekeys as well - Use list comprehensions instead of map() --- teuthology/lock.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/teuthology/lock.py b/teuthology/lock.py index 94fb7b0f93715..40c5d671bdad0 100644 --- a/teuthology/lock.py +++ b/teuthology/lock.py @@ -95,6 +95,11 @@ def _positive_int(string): '{string} is not positive'.format(string=string)) return value +def canonicalize_hostname(s): + if re.match('ubuntu@.*\.front\.sepia\.ceph\.com', s) is None: + s = 'ubuntu@' + s + '.front.sepia.ceph.com' + return s + def main(): parser = argparse.ArgumentParser(description=""" Lock, unlock, or query lock status of machines. @@ -204,15 +209,9 @@ Lock, unlock, or query lock status of machines. ret = 0 user = ctx.owner - machines = ctx.machines + machines = [canonicalize_hostname(m) for m in ctx.machines] machines_to_update = [] - def canonicalize_hostname(s): - if re.match('ubuntu@.*\.front\.sepia\.ceph\.com', s) is None: - s = 'ubuntu@' + s + '.front.sepia.ceph.com' - return s - machines = map(canonicalize_hostname, machines) - if ctx.targets: try: with file(ctx.targets) as f: @@ -353,7 +352,7 @@ to run on, or use -a to check all of them automatically. assert not ctx.targets and not ctx.machines, \ 'You can\'t specify machines with the --all option' - machines = ctx.machines + machines = [canonicalize_hostname(m) for m in ctx.machines] if ctx.targets: try: -- 2.39.5