From: Steve Baker Date: Sun, 9 Jun 2013 23:44:45 +0000 (+1200) Subject: Return empty string when Fn::Select target is None. X-Git-Tag: 2014.1~504^2 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=fb246087fd660241f5d5095b4a456f7a1b76a9ba;p=openstack-build%2Fheat-build.git Return empty string when Fn::Select target is None. This can happen when a resource is not in the required state to resolve its FnGetAtt. Change-Id: I4d104b3577fbd94b920ff172c00d60914d7acd45 --- diff --git a/heat/engine/template.py b/heat/engine/template.py index 15c6ab78..77ca03f2 100644 --- a/heat/engine/template.py +++ b/heat/engine/template.py @@ -244,6 +244,8 @@ class Template(collections.Mapping): return strings[index] if isinstance(strings, dict) and isinstance(index, basestring): return strings[index] + if strings is None: + return '' raise TypeError('Arguments to "Fn::Select" not fully resolved') diff --git a/heat/tests/test_parser.py b/heat/tests/test_parser.py index 66e9605c..d628d576 100644 --- a/heat/tests/test_parser.py +++ b/heat/tests/test_parser.py @@ -226,6 +226,10 @@ class TemplateTest(HeatTestCase): data = {"Fn::Select": ["red", {"red": "robin", "re": "foo"}]} self.assertEqual(parser.Template.resolve_select(data), "robin") + def test_select_from_none(self): + data = {"Fn::Select": ["red", None]} + self.assertEqual(parser.Template.resolve_select(data), "") + def test_select_from_dict_not_str(self): data = {"Fn::Select": ["1", {"red": "robin", "re": "foo"}]} self.assertRaises(TypeError, parser.Template.resolve_select,