"""
Get the name of the distro that we are using (usually the os_type).
"""
- if hasattr(ctx, 'os_type') and ctx.os_type is not None:
+ 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
+ except AttributeError:
return ctx.os_type
- default_os_type = 'ubuntu'
- if hasattr(ctx, 'config'):
- os_type = ctx.config.get('os_type', default_os_type)
- return ctx.config.get('downburst', dict()).get('distro', os_type)
-
- return default_os_type
-
def get_distro_version(ctx):
"""
from .. import misc as teuthology
-
-class Mock:
- pass
-
+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 == 'fedora'
def test_teuth_config_downburst(self):
- self.fake_ctx.config = {'downburst': {'distro': 'sles'}}
+ self.fake_ctx.config = {'downburst' : {'distro': 'sles'}}
distro = teuthology.get_distro(self.fake_ctx)
assert distro == 'sles'