From 797af4b3ad6220732df84561b0cea1e42c7f1012 Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Fri, 14 Nov 2014 13:31:17 -0700 Subject: [PATCH 1/2] Drop ubuntu as default distro for scheduled runs Signed-off-by: Zack Cerza --- scripts/suite.py | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/suite.py b/scripts/suite.py index 8554845dc82..48cc5e59804 100644 --- a/scripts/suite.py +++ b/scripts/suite.py @@ -41,7 +41,6 @@ Standard arguments: Machine type [default: {default_machine_type}] -d , --distro Distribution to run against - [default: ubuntu] --suite-branch Use this suite branch instead of the ceph branch --suite-dir Use this alternative directory as-is when From b62da9ee213d85a2d579a68cdcef99c4729ccec3 Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Tue, 18 Nov 2014 16:19:11 -0700 Subject: [PATCH 2/2] Drop null values in placeholders Signed-off-by: Zack Cerza --- teuthology/suite.py | 9 +++++++-- teuthology/test/test_suite.py | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/teuthology/suite.py b/teuthology/suite.py index 49f350c9146..d4f0e9b2b26 100644 --- a/teuthology/suite.py +++ b/teuthology/suite.py @@ -626,7 +626,9 @@ class Placeholder(object): def substitute_placeholders(input_dict, values_dict): """ - Replace any Placeholder instances with values named in values_dict. + Replace any Placeholder instances with values named in values_dict. In the + case of None values, the key is omitted from the result. + Searches through nested dicts. :param input_dict: A dict which may contain one or more Placeholder @@ -639,10 +641,13 @@ def substitute_placeholders(input_dict, values_dict): input_dict = copy.deepcopy(input_dict) def _substitute(input_dict, values_dict): - for (key, value) in input_dict.iteritems(): + for key, value in input_dict.items(): if isinstance(value, dict): _substitute(value, values_dict) elif isinstance(value, Placeholder): + if values_dict[value.name] is None: + del input_dict[key] + continue # If there is a Placeholder without a corresponding entry in # values_dict, we will hit a KeyError - we want this. input_dict[key] = values_dict[value.name] diff --git a/teuthology/test/test_suite.py b/teuthology/test/test_suite.py index f7306d058e0..b267628ec2d 100644 --- a/teuthology/test/test_suite.py +++ b/teuthology/test/test_suite.py @@ -52,3 +52,17 @@ class TestSuiteOffline(object): assert isinstance( suite.dict_templ['overrides']['admin_socket']['branch'], suite.Placeholder) + + def test_null_placeholders_dropped(self): + input_dict = dict( + suite='suite', + suite_branch='suite_branch', + ceph_branch='ceph_branch', + ceph_hash='ceph_hash', + teuthology_branch='teuthology_branch', + machine_type='machine_type', + distro=None, + ) + output_dict = suite.substitute_placeholders(suite.dict_templ, + input_dict) + assert 'os_type' not in output_dict