]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
heat engine : map DBInstance DBSecurityGroups parameter correctly
authorSteven Hardy <shardy@redhat.com>
Fri, 4 Jan 2013 17:21:53 +0000 (17:21 +0000)
committerSteven Hardy <shardy@redhat.com>
Fri, 4 Jan 2013 17:53:01 +0000 (17:53 +0000)
The DBInstance nested stack template defines a DBSecurityGroups list parameter,
which should be "CommaDelimitedList" type, curently it's a "List" type which
breaks when the template is parsed.  To make this work we also have to mangle
the property (passed in the top level template) format to match the parameter
format, because in AWS Lists are not represented in the same way for Properties and
Parameters (sigh..)

fixes bug 1096099

Change-Id: Ie078d61847d89ea9dcd55f798b808e595c2d2e12
Signed-off-by: Steven Hardy <shardy@redhat.com>
heat/engine/resources/dbinstance.py
heat/tests/test_dbinstance.py

index ea6a8633b6175202ef145db16ce284ca549487c3..568b223ae91bc29d369ebace29a293a76d6db68f 100644 (file)
@@ -46,7 +46,8 @@ mysql_template = r'''
     },
 
     "DBSecurityGroups" : {
-      "Type": "List"
+      "Type": "CommaDelimitedList",
+      "Default": ""
     },
 
     "Port" : {
@@ -214,7 +215,13 @@ class DBInstance(stack.Stack):
         # Ignore the not implemented ones
         for key, value in self.properties_schema.items():
             if value.get('Implemented', True) and key != 'Engine':
-                params[key] = self.properties[key]
+                # There is a mismatch between the properties "List" format
+                # and the parameters "CommaDelimitedList" format, so we need
+                # to translate lists into the expected comma-delimited form
+                if isinstance(self.properties[key], list):
+                    params[key] = ','.join(self.properties[key])
+                else:
+                    params[key] = self.properties[key]
         p = self.stack.resolve_static_data(params)
         return p
 
index 1cd0cd1d37c6201692765a5eb0c0ee0b58184000..498e7df45fa346dc0ef53358b9f838acfdf05063 100644 (file)
@@ -83,7 +83,7 @@ class DBInstanceTest(unittest.TestCase):
             'AllocatedStorage': u'5',
             'DBInstanceClass': u'db.m1.small',
             'DBName': u'wordpress',
-            'DBSecurityGroups': [],
+            'DBSecurityGroups': '',
             'KeyName': 'test',
             'MasterUserPassword': u'admin',
             'MasterUsername': u'admin',