diff options
author | Tomas Sedovic <tsedovic@redhat.com> | 2014-08-19 18:35:06 +0200 |
---|---|---|
committer | Zane Bitter <zbitter@redhat.com> | 2015-03-04 13:07:57 -0500 |
commit | 678ea1315e4b2a0f47134679418be7d9f77a32b5 (patch) | |
tree | 73b5e19902d72b95117805e048d0f4b1c3d3d924 | |
parent | 02d86fdea4a8bbb3c314ee8e43fd56761f974627 (diff) | |
download | heat-678ea1315e4b2a0f47134679418be7d9f77a32b5.tar.gz |
Use empty list in list_join for validation
Calling list_join on the list of ResourceGroup's attributes in a
SoftwareConfig fails during template validation with:
ERROR: Property error : my_config: config "list_join" must operate on a
list
Closes-Bug: 1358831
Change-Id: I39d2da7a28ba53fbe3a95bff0198fa5c2f87aa3b
(cherry picked from commit 61a9d167c0f36a2846e39fd33a77ce2755801fe6)
-rw-r--r-- | heat/engine/cfn/functions.py | 2 | ||||
-rw-r--r-- | heat/tests/test_hot.py | 21 |
2 files changed, 23 insertions, 0 deletions
diff --git a/heat/engine/cfn/functions.py b/heat/engine/cfn/functions.py index d7f4f042d..6d5fc789d 100644 --- a/heat/engine/cfn/functions.py +++ b/heat/engine/cfn/functions.py @@ -278,6 +278,8 @@ class Join(function.Function): def result(self): strings = function.resolve(self._strings) + if strings is None: + strings = [] if (isinstance(strings, basestring) or not isinstance(strings, collections.Sequence)): raise TypeError(_('"%s" must operate on a list') % self.fn_name) diff --git a/heat/tests/test_hot.py b/heat/tests/test_hot.py index 452c14dae..019af719e 100644 --- a/heat/tests/test_hot.py +++ b/heat/tests/test_hot.py @@ -301,6 +301,27 @@ class HOTemplateTest(HeatTestCase): err = self.assertRaises(KeyError, tmpl.__getitem__, tmpl.OUTPUTS) self.assertIn('Value', str(err)) + def test_resource_group_list_join(self): + """Test list_join on a ResourceGroup's inner attributes + + This should not fail during validation (i.e. before the ResourceGroup + can return the list of the runtime values. + """ + hot_tpl = template_format.parse(''' + heat_template_version: 2013-05-23 + resources: + rg: + type: OS::Heat::ResourceGroup + properties: + count: 3 + resource_def: + type: OS::Nova::Server + ''') + tmpl = parser.Template(hot_tpl) + stack = parser.Stack(utils.dummy_context(), 'test_stack', tmpl) + snippet = {'Fn::Join': ["\n", {'get_attr': ['rg', 'name']}]} + self.assertEqual(self.resolve(snippet, tmpl, stack), '') + def test_str_replace(self): """Test str_replace function.""" |