]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Adds a machine_type property to orchestra.remote.Remote 429/head
authorAndrew Schoen <aschoen@redhat.com>
Fri, 6 Feb 2015 21:43:34 +0000 (15:43 -0600)
committerAndrew Schoen <aschoen@redhat.com>
Mon, 9 Feb 2015 18:49:41 +0000 (12:49 -0600)
Signed-off-by: Andrew Schoen <aschoen@redhat.com>
teuthology/lockstatus.py
teuthology/orchestra/remote.py
teuthology/task/tests/test_locking.py

index 4000b32ced78ffd388158b5ded72e17bb7dffba1..109b1134587ac8822864dd25250dcd72760fefa0 100644 (file)
@@ -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
index 15ef022e0617661b2df3a912160ce52b86d61fa7..10c5a2f5082bfaee38aabf3730dd982b3992c416 100644 (file)
@@ -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:
index aa395e71ae68c8785dc35a35f3f40b5c1c4605a6..23d7cf1727f7c8e3d94dd9e16435830afa12a09f 100644 (file)
@@ -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