From: Zack Cerza Date: Thu, 25 Sep 2014 21:22:06 +0000 (-0600) Subject: Revert "Move default os_type to misc.get_distro()" X-Git-Tag: 1.1.0~1148 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=a5eed69d1a55a2f0df8d02a9dfd02380469ef5d4;p=teuthology.git Revert "Move default os_type to misc.get_distro()" This reverts commit 3675a2e25c5d9a370922b714871492f31ed1783d. --- diff --git a/scripts/lock.py b/scripts/lock.py index f4fb52c9e4..964f79b82c 100644 --- a/scripts/lock.py +++ b/scripts/lock.py @@ -150,6 +150,7 @@ 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 d0885bac61..080e47e381 100644 --- a/teuthology/misc.py +++ b/teuthology/misc.py @@ -1118,16 +1118,17 @@ def get_distro(ctx): """ 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): """ diff --git a/teuthology/test/test_get_distro.py b/teuthology/test/test_get_distro.py index d5136c86e6..3ade547e05 100644 --- a/teuthology/test/test_get_distro.py +++ b/teuthology/test/test_get_distro.py @@ -1,14 +1,13 @@ 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) @@ -25,6 +24,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'