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)
success = response.ok
if success:
return response.json()
+ log.warning(
+ "Failed to query lock server for status of {name}".format(name=name))
return None
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:
import pytest
-import re
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