From 3a502dec21f7f440a6b3494fd34ff4d6aa02d5eb Mon Sep 17 00:00:00 2001 From: Andrew Schoen Date: Wed, 17 Dec 2014 09:20:19 -0600 Subject: [PATCH] Use teuthology.misc.get_distro and teuthology.misc.get_distro_ version in the internal.lock_machines task. When the internal task wasn't using get_distro to retrieve os_type it could set os_type to None, causing the lock to fail. This happened when there was not an os_type defined in the config or a --os-type flag given. Now, os_type will be properly defaulted to ubuntu when trying to lock bare metal machines. Signed-off-by: Andrew Schoen --- teuthology/misc.py | 4 +++- teuthology/provision.py | 5 ++--- teuthology/task/internal.py | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/teuthology/misc.py b/teuthology/misc.py index 440888424..d4fa4fb2b 100644 --- a/teuthology/misc.py +++ b/teuthology/misc.py @@ -1154,7 +1154,9 @@ def get_distro(ctx): Get the name of the distro that we are using (usually the os_type). """ os_type = None - # first, try to get the os_type from the config of --os-type + # first, try to get the os_type from the config or --os-type + # note that if --os-type is passed it's assigned to config["os_type"] + # in teuthology.run.py try: os_type = ctx.config.get('os_type', ctx.os_type) except AttributeError: diff --git a/teuthology/provision.py b/teuthology/provision.py index 8bc1ca7e2..07ac8bb40 100644 --- a/teuthology/provision.py +++ b/teuthology/provision.py @@ -5,10 +5,9 @@ import tempfile import yaml from .config import config -from .misc import decanonicalize_hostname +from .misc import decanonicalize_hostname, get_distro, get_distro_version from .lockstatus import get_status -from .misc import get_distro -from .misc import get_distro_version + log = logging.getLogger(__name__) diff --git a/teuthology/task/internal.py b/teuthology/task/internal.py index b77c24fbb..430b5fed1 100644 --- a/teuthology/task/internal.py +++ b/teuthology/task/internal.py @@ -65,8 +65,8 @@ def lock_machines(ctx, config): new machines. This is not called if the one has teuthology-locked machines and placed those keys in the Targets section of a yaml file. """ - os_type = ctx.config.get('os_type') - os_version = ctx.config.get('os_version') + os_type = misc.get_distro(ctx) + os_version = misc.get_distro_version(ctx) arch = ctx.config.get('arch') log.info('Locking machines...') assert isinstance(config[0], int), 'config[0] must be an integer' -- 2.47.3