From 01cf78567d7c26900a581b13f8c0ef752eb56582 Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Mon, 25 Aug 2014 13:50:38 -0600 Subject: [PATCH] Fix canonicalize_hostname() Signed-off-by: Zack Cerza --- teuthology/misc.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/teuthology/misc.py b/teuthology/misc.py index 6bddc86e36..2ffc0f4e1e 100644 --- a/teuthology/misc.py +++ b/teuthology/misc.py @@ -39,12 +39,20 @@ hostname_expr = '(?P.*@)?(?P.*)\.front\.sepia\.ceph\.com' def canonicalize_hostname(hostname, user='ubuntu'): match = re.match(hostname_expr, hostname) - if match is None: - user_at = user + '@' if user else '' - hostname = '{user_at}{short}.front.sepia.ceph.com'.format( - user_at=user_at, - short=hostname) - return hostname + if match: + match_d = match.groupdict() + shortname = match_d['shortname'] + user_ = match_d.get('user') or user + else: + shortname = hostname.split('.')[0] + user_ = user + + user_at = user_ + '@' if user_ else '' + + ret = '{user_at}{short}.front.sepia.ceph.com'.format( + user_at=user_at, + short=shortname) + return ret def decanonicalize_hostname(hostname): -- 2.39.5