phys_host = status_info['vpshost']
if not phys_host:
return False
- try:
- os_type = ctx.config['os_type']
- except KeyError:
- try:
- os_type = ctx.os_type
- except AttributeError:
- os_type = 'ubuntu'
+ from teuthology.misc import get_distro
+ os_type = get_distro(ctx)
os_version = dict(
ubuntu="12.04",
fedora="18",
log.exception('Saw exception from %s.%s', daemon.role, daemon.id_)
if exc_info != (None, None, None):
raise exc_info[0], exc_info[1], exc_info[2]
+
+def get_distro(ctx):
+ try:
+ os_type = ctx.config.get('os_type', ctx.os_type)
+ except AttributeError:
+ os_type = 'ubuntu'
+ try:
+ return ctx.config['downburst'].get('distro', os_type)
+ except KeyError:
+ return os_type
{'internal.vm_setup': None},
])
if 'kernel' in ctx.config:
- try:
- distro = ctx.config['downburst'].get('distro')
- if distro is None:
- distro = 'ubuntu'
- except:
- distro = 'ubuntu'
+ from teuthology.misc import get_distro
+ distro = get_distro(ctx)
if distro == 'ubuntu':
init_tasks.append({'kernel': ctx.config['kernel']})
init_tasks.extend([
--- /dev/null
+from .. import misc as teuthology
+
+class Mock: pass
+
+class TestGetDistro(object):
+
+ def setup(self):
+ self.fake_ctx = Mock()
+ self.fake_ctx.config = {}
+ self.fake_ctx.os_type = 'ubuntu'
+
+ def test_default_distro(self):
+ distro = teuthology.get_distro(self.fake_ctx)
+ assert distro == 'ubuntu'
+
+ def test_argument(self):
+ self.fake_ctx.os_type = 'centos'
+ distro = teuthology.get_distro(self.fake_ctx)
+ assert distro == 'centos'
+
+ def test_teuth_config(self):
+ self.fake_ctx.config = {'os_type': 'fedora'}
+ distro = teuthology.get_distro(self.fake_ctx)
+ assert distro == 'fedora'
+
+ def test_teuth_config_downburst(self):
+ self.fake_ctx.config = {'downburst' : {'distro': 'sles'}}
+ distro = teuthology.get_distro(self.fake_ctx)
+ assert distro == 'sles'