From fb246087fd660241f5d5095b4a456f7a1b76a9ba Mon Sep 17 00:00:00 2001 From: Steve Baker Date: Mon, 10 Jun 2013 11:44:45 +1200 Subject: [PATCH] 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 --- heat/engine/template.py | 2 ++ heat/tests/test_parser.py | 4 ++++ 2 files changed, 6 insertions(+) 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, -- 2.45.2