From: Andrew Schoen Date: Wed, 28 Jan 2015 20:40:38 +0000 (-0600) Subject: Remove support for a custom downburst config in teuthology.provision X-Git-Tag: 1.1.0~1023^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F420%2Fhead;p=teuthology.git Remove support for a custom downburst config in teuthology.provision Will log a warning message if a custom downburst config is found in ctx.config. Removes unused --downburst-conf option from teuthology-lock. Signed-off-by: Andrew Schoen --- diff --git a/scripts/lock.py b/scripts/lock.py index 2511ddf39..d47a26ab1 100644 --- a/scripts/lock.py +++ b/scripts/lock.py @@ -158,10 +158,5 @@ def parse_args(): default=None, help='OS (distro) version such as "12.10"', ) - parser.add_argument( - '--downburst-conf', - default=None, - help='Downburst meta-data yaml file to be used for vps machines', - ) return parser.parse_args() diff --git a/teuthology/misc.py b/teuthology/misc.py index 109b1bea3..b818093df 100644 --- a/teuthology/misc.py +++ b/teuthology/misc.py @@ -1154,17 +1154,17 @@ def get_distro(ctx): """ Get the name of the distro that we are using (usually the os_type). """ - # ubuntu is our default distro choice - os_type = "ubuntu" + os_type = None if ctx.os_type: return ctx.os_type try: - os_type = ctx.config.get('os_type', os_type) + os_type = ctx.config.get('os_type', None) except AttributeError: pass - return os_type + # if os_type is None, return the default of ubuntu + return os_type or "ubuntu" def get_distro_version(ctx): diff --git a/teuthology/provision.py b/teuthology/provision.py index e8d23a859..e9803f516 100644 --- a/teuthology/provision.py +++ b/teuthology/provision.py @@ -49,32 +49,29 @@ def create_if_vm(ctx, machine_name): createMe = decanonicalize_hostname(machine_name) with tempfile.NamedTemporaryFile() as tmp: - if hasattr(ctx, 'config') and ctx.config is not None: - lcnfg = ctx.config.get('downburst', dict()) - else: - lcnfg = {} - distro = lcnfg.get('distro', os_type.lower()) - distroversion = lcnfg.get('distroversion', os_version) + has_config = hasattr(ctx, 'config') and ctx.config is not None + if has_config and 'downburst' in ctx.config: + log.warning( + 'Usage of a custom downburst config has been deprecated.' + ) log.info("Provisioning a {distro} {distroversion} vps".format( - distro=distro, - distroversion=distroversion + distro=os_type, + distroversion=os_version )) - file_info = {} - file_info['disk-size'] = lcnfg.get('disk-size', '100G') - file_info['ram'] = lcnfg.get('ram', '1.9G') - file_info['cpus'] = lcnfg.get('cpus', 1) - file_info['networks'] = lcnfg.get( - 'networks', - [{'source': 'front', 'mac': status_info['mac_address']}]) - file_info['distro'] = distro - file_info['distroversion'] = distroversion - file_info['additional-disks'] = lcnfg.get( - 'additional-disks', 3) - file_info['additional-disks-size'] = lcnfg.get( - 'additional-disks-size', '200G') - file_info['arch'] = lcnfg.get('arch', 'x86_64') + file_info = { + 'disk-size': '100G', + 'ram': '1.9G', + 'cpus': 1, + 'networks': [ + {'source': 'front', 'mac': status_info['mac_address']}], + 'distro': os_type.lower(), + 'distroversion': os_version, + 'additional-disks': 3, + 'additional-disks-size': '200G', + 'arch': 'x86_64', + } fqdn = machine_name.split('@')[1] file_out = {'downburst': file_info, 'local-hostname': fqdn} yaml.safe_dump(file_out, tmp) @@ -89,13 +86,13 @@ def create_if_vm(ctx, machine_name): owt, err = p.communicate() if err: log.info("Downburst completed on %s: %s" % - (machine_name, err)) + (machine_name, err)) else: log.info("%s created: %s" % (machine_name, owt)) # If the guest already exists first destroy then re-create: if 'exists' in err: log.info("Guest files exist. Re-creating guest: %s" % - (machine_name)) + (machine_name)) destroy_if_vm(ctx, machine_name) create_if_vm(ctx, machine_name) return True diff --git a/teuthology/test/test_get_distro.py b/teuthology/test/test_get_distro.py index 9c9990306..f3c96586e 100644 --- a/teuthology/test/test_get_distro.py +++ b/teuthology/test/test_get_distro.py @@ -40,3 +40,8 @@ class TestGetDistro(object): self.fake_ctx.os_type = None distro = get_distro(self.fake_ctx) assert distro == 'ubuntu' + + def test_config_os_type_is_none(self): + self.fake_ctx.config["os_type"] = None + distro = get_distro(self.fake_ctx) + assert distro == 'ubuntu'