This should make usage in other labs easier.
Signed-off-by: Zack Cerza <zack@cerza.org>
'archive_base': '/var/lib/teuthworker/archive',
'automated_scheduling': False,
'ceph_git_base_url': 'https://github.com/ceph/',
+ 'lab_domain': 'front.sepia.ceph.com',
'lock_server': 'http://paddles.front.sepia.ceph.com/',
'max_job_time': 259200, # 3 days
'results_server': 'http://paddles.front.sepia.ceph.com/',
is_arm = lambda x: x.startswith('tala') or x.startswith(
'ubuntu@tala') or x.startswith('saya') or x.startswith('ubuntu@saya')
-hostname_expr = '(?P<user>.*@)?(?P<shortname>.*)\.front\.sepia\.ceph\.com'
+hostname_expr_templ = '(?P<user>.*@)?(?P<shortname>.*)\.{lab_domain}'
def canonicalize_hostname(hostname, user='ubuntu'):
+ hostname_expr = hostname_expr_templ.format(
+ lab_domain=config.lab_domain.replace('.', '\.'))
match = re.match(hostname_expr, hostname)
if match:
match_d = match.groupdict()
user_at = user_.strip('@') + '@' if user_ else ''
- ret = '{user_at}{short}.front.sepia.ceph.com'.format(
+ ret = '{user_at}{short}.{lab_domain}'.format(
user_at=user_at,
- short=shortname)
+ short=shortname,
+ lab_domain=config.lab_domain,
+ )
return ret
def decanonicalize_hostname(hostname):
+ hostname_expr = hostname_expr_templ.format(
+ lab_domain=config.lab_domain.replace('.', '\.'))
match = re.match(hostname_expr, hostname)
if match:
hostname = match.groupdict()['shortname']
class TestHostnames(object):
+ def setup(self):
+ self.old_lab_domain = config.lab_domain
+
+ def teardown(self):
+ config.lab_domain = self.old_lab_domain
def test_canonicalize_hostname(self):
host_base = 'box1'
host = 'box1.front.sepia.ceph.com'
result = misc.decanonicalize_hostname(host)
assert result == 'box1'
+
+ def test_canonicalize_hostname_otherlab(self):
+ config.lab_domain = 'example.com'
+ host_base = 'box1'
+ result = misc.canonicalize_hostname(host_base)
+ assert result == 'ubuntu@box1.example.com'
+
+ def test_decanonicalize_hostname(self):
+ config.lab_domain = 'example.com'
+ host = 'ubuntu@box1.example.com'
+ result = misc.decanonicalize_hostname(host)
+ assert result == 'box1'