]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Move default os_type to misc.get_distro()
authorZack Cerza <zack.cerza@inktank.com>
Tue, 23 Sep 2014 15:50:40 +0000 (09:50 -0600)
committerZack Cerza <zack.cerza@inktank.com>
Thu, 25 Sep 2014 15:46:07 +0000 (09:46 -0600)
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
scripts/lock.py
teuthology/misc.py
teuthology/test/test_get_distro.py

index 964f79b82cfde55275fc4c70eb052ef2de27d610..f4fb52c9e45d5e2f20e4d4b19fbb81cbc773f4b9 100644 (file)
@@ -150,7 +150,6 @@ def parse_args():
     )
     parser.add_argument(
         '--os-type',
-        default='ubuntu',
         help='OS type (distro)',
     )
     parser.add_argument(
index 080e47e381200d82dd08dae4143f71acbfc2596d..d0885bac610a6356661259aecf281cf679d402c7 100644 (file)
@@ -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):
     """
index 3ade547e05864dd84ae13d4c2a75b20f5c753798..d5136c86e6035243cb246d72c81121856542292a 100644 (file)
@@ -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'