From b9c7445b1bc5a7f55e89521fefa03e6d71244df1 Mon Sep 17 00:00:00 2001 From: Sandon Van Ness Date: Mon, 29 Jul 2013 17:03:30 -0700 Subject: [PATCH] More changes for creating vms manually with lock (no config) Needed some more changes to allow for the case of creating vm's manually with teuthology-lock instead of letting teuthology handle it in internal.py with lock_machines(). Just some additional checks to go to defaults when ctx.config is non-existent (causes an attributeerror). Signed-off-by: Sandon Van Ness Reviewed-by: Warren Usui --- teuthology/lock.py | 9 +++++++-- teuthology/misc.py | 4 +++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/teuthology/lock.py b/teuthology/lock.py index 3873136d7c33a..b0e0f62c8cfab 100644 --- a/teuthology/lock.py +++ b/teuthology/lock.py @@ -558,10 +558,15 @@ def create_if_vm(ctx, machine_name): with tempfile.NamedTemporaryFile() as tmp: try: lcnfg = ctx.config['downburst'] - except KeyError: + except (KeyError, AttributeError): 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] + file_info = {} file_info['disk-size'] = lcnfg.get('disk-size', '30G') file_info['ram'] = lcnfg.get('ram', '1.9G') @@ -569,7 +574,7 @@ def create_if_vm(ctx, machine_name): file_info['networks'] = lcnfg.get('networks', [{'source' : 'front', 'mac' : status_info['mac']}]) file_info['distro'] = distro - file_info['distroversion'] = ctx.config.get('os_version', default_os_version[distro]) + file_info['distroversion'] = distroversion file_info['additional-disks'] = lcnfg.get( 'additional-disks', 3) file_info['additional-disks-size'] = lcnfg.get( diff --git a/teuthology/misc.py b/teuthology/misc.py index 13e274a9c75b6..86638e71d6df1 100644 --- a/teuthology/misc.py +++ b/teuthology/misc.py @@ -894,4 +894,6 @@ def get_distro(ctx): try: return ctx.config['downburst'].get('distro', os_type) except KeyError: - return os_type \ No newline at end of file + return os_type + except AttributeError: + return ctx.os_type -- 2.39.5