From c357666d74528a19e767b4f3cc6e48e6328c5c2c Mon Sep 17 00:00:00 2001 From: Steven Hardy Date: Fri, 4 Jan 2013 17:21:53 +0000 Subject: [PATCH] heat engine : map DBInstance DBSecurityGroups parameter correctly 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 --- heat/engine/resources/dbinstance.py | 11 +++++++++-- heat/tests/test_dbinstance.py | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/heat/engine/resources/dbinstance.py b/heat/engine/resources/dbinstance.py index ea6a8633..568b223a 100644 --- a/heat/engine/resources/dbinstance.py +++ b/heat/engine/resources/dbinstance.py @@ -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 diff --git a/heat/tests/test_dbinstance.py b/heat/tests/test_dbinstance.py index 1cd0cd1d..498e7df4 100644 --- a/heat/tests/test_dbinstance.py +++ b/heat/tests/test_dbinstance.py @@ -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', -- 2.45.2