]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Revert "Move default os_type to misc.get_distro()"
authorZack Cerza <zack.cerza@inktank.com>
Thu, 25 Sep 2014 21:22:06 +0000 (15:22 -0600)
committerZack Cerza <zack.cerza@inktank.com>
Thu, 25 Sep 2014 21:22:06 +0000 (15:22 -0600)
This reverts commit 3675a2e25c5d9a370922b714871492f31ed1783d.

scripts/lock.py
teuthology/misc.py
teuthology/test/test_get_distro.py

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