From: Zack Cerza Date: Tue, 23 Sep 2014 15:50:40 +0000 (-0600) Subject: Move default os_type to misc.get_distro() X-Git-Tag: 1.1.0~1153 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=3675a2e25c5d9a370922b714871492f31ed1783d;p=teuthology.git Move default os_type to misc.get_distro() Signed-off-by: Zack Cerza --- diff --git a/scripts/lock.py b/scripts/lock.py index 964f79b82c..f4fb52c9e4 100644 --- a/scripts/lock.py +++ b/scripts/lock.py @@ -150,7 +150,6 @@ def parse_args(): ) parser.add_argument( '--os-type', - default='ubuntu', help='OS type (distro)', ) parser.add_argument( diff --git a/teuthology/misc.py b/teuthology/misc.py index 080e47e381..d0885bac61 100644 --- a/teuthology/misc.py +++ b/teuthology/misc.py @@ -1118,17 +1118,16 @@ def get_distro(ctx): """ Get the name of the distro that we are using (usually the os_type). """ - 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: + if hasattr(ctx, 'os_type') and ctx.os_type is not None: 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): """ diff --git a/teuthology/test/test_get_distro.py b/teuthology/test/test_get_distro.py index 3ade547e05..d5136c86e6 100644 --- a/teuthology/test/test_get_distro.py +++ b/teuthology/test/test_get_distro.py @@ -1,13 +1,14 @@ from .. import misc as teuthology -class Mock: pass -class TestGetDistro(object): +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) @@ -24,6 +25,6 @@ class TestGetDistro(object): 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'