From 46dcceb8986b7e93a4a4bd4370b317d522c7d516 Mon Sep 17 00:00:00 2001 From: Angus Salkeld Date: Thu, 5 Sep 2013 14:19:23 +1000 Subject: [PATCH] Fix TemplateResource list property conversion In the convertion from "a,b,c" to ['a', 'b', 'c'] we are not checking for the case of an empty list. Change-Id: I834c4755abf33793a9484138f9dac97d7d8194da Closes-bug: #1221009 --- heat/engine/resources/template_resource.py | 4 +++- heat/tests/test_provider_template.py | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/heat/engine/resources/template_resource.py b/heat/engine/resources/template_resource.py index dfb462dd..219fca05 100644 --- a/heat/engine/resources/template_resource.py +++ b/heat/engine/resources/template_resource.py @@ -72,7 +72,9 @@ class TemplateResource(stack_resource.StackResource): if val is not None: # take a list and create a CommaDelimitedList if v.type() == properties.LIST: - if isinstance(val[0], dict): + if len(val) == 0: + val = '' + elif isinstance(val[0], dict): flattened = [] for (i, item) in enumerate(val): for (k, v) in iter(item.items()): diff --git a/heat/tests/test_provider_template.py b/heat/tests/test_provider_template.py index fe8431cc..828f2f08 100644 --- a/heat/tests/test_provider_template.py +++ b/heat/tests/test_provider_template.py @@ -91,6 +91,7 @@ class ProviderTemplateTest(HeatTestCase): 'Parameters': { 'Foo': {'Type': 'String'}, 'AList': {'Type': 'CommaDelimitedList'}, + 'ListEmpty': {'Type': 'CommaDelimitedList'}, 'ANum': {'Type': 'Number'}, 'AMap': {'Type': 'Json'}, }, @@ -106,6 +107,7 @@ class ProviderTemplateTest(HeatTestCase): properties_schema = { "Foo": {"Type": "String"}, "AList": {"Type": "List"}, + "ListEmpty": {"Type": "List"}, "ANum": {"Type": "Number"}, "AMap": {"Type": "Map"} } @@ -131,6 +133,7 @@ class ProviderTemplateTest(HeatTestCase): "Properties": { "Foo": "Bar", "AList": ["one", "two", "three"], + "ListEmpty": [], "ANum": 5, "AMap": map_prop_val } -- 2.45.2