]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Fix TemplateResource list property conversion
authorAngus Salkeld <asalkeld@redhat.com>
Thu, 5 Sep 2013 04:19:23 +0000 (14:19 +1000)
committerAngus Salkeld <asalkeld@redhat.com>
Thu, 5 Sep 2013 10:09:47 +0000 (20:09 +1000)
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
heat/tests/test_provider_template.py

index dfb462ddcf443256c24aa1afa6d017587346ae06..219fca05721f2a535905cfe5a8f49251c0b8e606 100644 (file)
@@ -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()):
index fe8431cc55fe56fc375509ef2f51fe64a25369cb..828f2f0804959266f7e9bd9ceeace5d4d47c9ce7 100644 (file)
@@ -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
             }