From: Ilya Dryomov Date: Thu, 7 May 2015 10:30:09 +0000 (+0300) Subject: kernel: separate version keys into a list, use constants X-Git-Tag: 1.1.0~859^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0597ce084ea4e5a48d22ec359fa06810667fbebe;p=teuthology.git kernel: separate version keys into a list, use constants Use constants for config snippet and timeout defaults. Signed-off-by: Ilya Dryomov --- diff --git a/teuthology/task/kernel.py b/teuthology/task/kernel.py index bd4ba431f..ea0c8b08a 100644 --- a/teuthology/task/kernel.py +++ b/teuthology/task/kernel.py @@ -27,6 +27,10 @@ from ..packaging import ( log = logging.getLogger(__name__) +CONFIG_DEFAULT = {'branch': 'master'} +TIMEOUT_DEFAULT = 300 + +VERSION_KEYS = ['branch', 'tag', 'sha1', 'deb', 'rpm', 'koji', 'koji_task'] def normalize_config(ctx, config): """ @@ -68,13 +72,11 @@ def normalize_config(ctx, config): :param config: Configuration """ if config is None or \ - len(filter(lambda x: x in ['tag', 'branch', 'sha1', 'kdb', - 'deb', 'rpm', 'koji', 'koji_task', - 'flavor'], + len(filter(lambda x: x in VERSION_KEYS + ['kdb', 'flavor'], config.keys())) == len(config.keys()): new_config = {} if config is None: - config = {'branch': 'master'} + config = CONFIG_DEFAULT for _, roles_for_host in ctx.cluster.remotes.iteritems(): new_config[roles_for_host[0]] = config return new_config @@ -82,7 +84,7 @@ def normalize_config(ctx, config): new_config = {} for role, role_config in config.iteritems(): if role_config is None: - role_config = {'branch': 'master'} + role_config = CONFIG_DEFAULT if '.' in role: new_config[role] = role_config else: @@ -1102,7 +1104,7 @@ def task(ctx, config): assert config is None or isinstance(config, dict), \ "task kernel only supports a dictionary for configuration" - timeout = 300 + timeout = TIMEOUT_DEFAULT if config is not None and 'timeout' in config: timeout = config.pop('timeout')