]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
Support --os-version as argument.
authorSandon Van Ness <sandon@inktank.com>
Sat, 26 Oct 2013 00:48:50 +0000 (17:48 -0700)
committerSandon Van Ness <sandon@inktank.com>
Sat, 26 Oct 2013 00:48:50 +0000 (17:48 -0700)
You can use --os-type as an argument when not running teuthology
tests but instead just using teuthology-lock. This adds the ability
to also use --os-version so you can specify the version of the
distro without having to run an actual test with a yaml like you
normally would have had to do setting os_version in the yaml.

Signed-off-by: Sandon Van Ness <sandon@inktank.com>
scripts/lock.py
scripts/run.py
teuthology/lock.py
teuthology/misc.py
teuthology/test/test_get_distro_version.py [new file with mode: 0644]

index 0751fc4f225cb9869ac98376f7492ff8ab76049b..f94021bf09750515f32643fdc83df4a34c00e369 100644 (file)
@@ -149,7 +149,12 @@ def parse_args():
     parser.add_argument(
         '--os-type',
         default='ubuntu',
-        help='virtual machine type',
+        help='OS type (distro)',
+    )
+    parser.add_argument(
+        '--os-version',
+        default=None,
+        help='OS (distro) version such as "12.10"',
     )
 
     return parser.parse_args()
index a1767e4d8f462922011c8d52ee089ae6bc3f9bff..5eee377216904099f9c8f0cf6ace78af1b745130 100644 (file)
@@ -53,6 +53,11 @@ def parse_args():
         default='ubuntu',
         help='Distro/OS of machine to run test on.',
     )
+    parser.add_argument(
+        '--os-version',
+        default=None,
+        help='Distro/OS version of machine to run test on.',
+    )
     parser.add_argument(
         '--block',
         action='store_true',
index de39f8c63a217eb91e088e2dcc6f9ad57b1d127e..ac1c44de96ceb499d5894c0b42ddd4557e48e811 100644 (file)
@@ -14,6 +14,8 @@ import teuthology
 from .config import config
 from . import lockstatus as ls
 from . import misc
+from teuthology.misc import get_distro
+from teuthology.misc import get_distro_version
 
 log = logging.getLogger(__name__)
 
@@ -436,17 +438,9 @@ def create_if_vm(ctx, machine_name):
     phys_host = status_info['vpshost']
     if not phys_host:
         return False
-    from teuthology.misc import get_distro
     os_type = get_distro(ctx)
-    default_os_version = dict(
-        ubuntu="12.04",
-        fedora="18",
-        centos="6.4",
-        opensuse="12.2",
-        sles="11-sp2",
-        rhel="6.3",
-        debian='6.0'
-    )
+    os_version = get_distro_version(ctx)
+
     createMe = decanonicalize_hostname(machine_name)
     with tempfile.NamedTemporaryFile() as tmp:
         try:
@@ -455,11 +449,7 @@ def create_if_vm(ctx, machine_name):
             lcnfg = {}
 
         distro = lcnfg.get('distro', os_type.lower())
-        try:
-            distroversion = ctx.config.get(
-                'os_version', default_os_version[distro])
-        except AttributeError:
-            distroversion = default_os_version[distro]
+        distroversion = lcnfg.get('distroversion', os_version)
 
         file_info = {}
         file_info['disk-size'] = lcnfg.get('disk-size', '30G')
index 9892fe3189530ee473b436c6758dbfcccda040a2..5fe5bfe733a152066085296ae43248ff2bbea9ac 100644 (file)
@@ -921,3 +921,28 @@ def get_distro(ctx):
         return os_type
     except AttributeError:
         return ctx.os_type
+
+def get_distro_version(ctx):
+    default_os_version = dict(
+        ubuntu="12.04",
+        fedora="18",
+        centos="6.4",
+        opensuse="12.2",
+        sles="11-sp2",
+        rhel="6.4",
+        debian='7.0'
+    )
+    distro = get_distro(ctx)
+    try:
+        os_version = ctx.config.get('os_version', ctx.os_version)
+    except AttributeError:
+        os_version = default_os_version[distro]
+    try:
+        return ctx.config['downburst'].get('distroversion', os_type)
+    except KeyError:
+        return os_version
+    except AttributeError:
+        if ctx.os_version is not None:
+            return ctx.os_version
+        return os_version
+
diff --git a/teuthology/test/test_get_distro_version.py b/teuthology/test/test_get_distro_version.py
new file mode 100644 (file)
index 0000000..17dc6cf
--- /dev/null
@@ -0,0 +1,46 @@
+from .. import misc as teuthology
+
+class Mock: pass
+
+class TestGetDistroVersion(object):
+
+    def setup(self):
+        self.fake_ctx = Mock()
+        self.fake_ctx.config = {}
+        self.fake_ctx.os_version = '13.04'
+        self.fake_ctx_noarg = Mock()
+        self.fake_ctx_noarg.config = {}
+
+    def test_default_distro_version(self):
+        distroversion = teuthology.get_distro_version(self.fake_ctx)
+        assert distroversion == '13.04'
+
+    def test_argument_version(self):
+        self.fake_ctx.os_version = '13.04'
+        distroversion = teuthology.get_distro_version(self.fake_ctx)
+        assert distroversion == '13.04'
+
+    def test_teuth_config_version(self):
+        self.fake_ctx.config = {'os_version': '13.04'}
+        distroversion = teuthology.get_distro_version(self.fake_ctx)
+        assert distroversion == '13.04'
+
+    def test_teuth_config_downburst_version(self):
+        self.fake_ctx.config = {'downburst' : {'distroversion': '13.04'}}
+        distroversion = teuthology.get_distro_version(self.fake_ctx)
+        assert distroversion == '13.04'
+
+    def test_default_distro_noarg_version(self):
+        distroversion = teuthology.get_distro_version(self.fake_ctx_noarg)
+        #Default distro is ubuntu, default version of ubuntu is 012.04
+        assert distroversion == '12.04'
+
+    def test_teuth_config_noarg_version(self):
+        self.fake_ctx_noarg.config = {'os_version': '13.04'}
+        distroversion = teuthology.get_distro_version(self.fake_ctx_noarg)
+        assert distroversion == '13.04'
+
+    def test_teuth_config_downburst_noarg_version(self):
+        self.fake_ctx_noarg.config = {'downburst' : {'distroversion': '13.04'}}
+        distroversion = teuthology.get_distro_version(self.fake_ctx_noarg)
+        assert distroversion == '13.04'