From: Andrew Schoen Date: Fri, 6 Feb 2015 21:43:34 +0000 (-0600) Subject: Adds a machine_type property to orchestra.remote.Remote X-Git-Tag: 1.1.0~1013^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=d2d6852444ed6a0e7aa5d2017723b5c1256f8138;p=teuthology.git Adds a machine_type property to orchestra.remote.Remote Signed-off-by: Andrew Schoen --- diff --git a/teuthology/lockstatus.py b/teuthology/lockstatus.py index 4000b32ced..109b113458 100644 --- a/teuthology/lockstatus.py +++ b/teuthology/lockstatus.py @@ -1,8 +1,11 @@ import requests import os +import logging from .config import config from .misc import canonicalize_hostname +log = logging.getLogger(__name__) + def get_status(name): name = canonicalize_hostname(name, user=None) @@ -11,4 +14,6 @@ def get_status(name): success = response.ok if success: return response.json() + log.warning( + "Failed to query lock server for status of {name}".format(name=name)) return None diff --git a/teuthology/orchestra/remote.py b/teuthology/orchestra/remote.py index 15ef022e06..10c5a2f508 100644 --- a/teuthology/orchestra/remote.py +++ b/teuthology/orchestra/remote.py @@ -81,6 +81,15 @@ class Remote(object): self._hostname = proc.stdout.getvalue().strip() return self._hostname + @property + def machine_type(self): + if not getattr(self, '_machine_type', None): + remote_info = ls.get_status(self.hostname) + if not remote_info: + return None + self._machine_type = remote_info.get("machine_type", None) + return self._machine_type + @property def shortname(self): if self._shortname is None: diff --git a/teuthology/task/tests/test_locking.py b/teuthology/task/tests/test_locking.py index aa395e71ae..23d7cf1727 100644 --- a/teuthology/task/tests/test_locking.py +++ b/teuthology/task/tests/test_locking.py @@ -1,5 +1,4 @@ import pytest -import re class TestLocking(object): @@ -21,7 +20,4 @@ class TestLocking(object): def test_correct_machine_type(self, ctx, config): machine_type = ctx.machine_type for remote in ctx.cluster.remotes.iterkeys(): - # gotta be a better way to get machine_type - # if not, should we move this to Remote? - remote_type = re.sub("[0-9]", "", remote.shortname) - assert remote_type in machine_type + assert remote.machine_type in machine_type