From 3eafb93e6846805b541e9fd5b30bb03d024b0d89 Mon Sep 17 00:00:00 2001 From: Jeff Peeler Date: Fri, 24 May 2013 13:41:45 -0400 Subject: [PATCH] Implement SecurityGroupIds property for instances Currently handling SecurityGroups and SecurityGroupIds the same exact way, that is both are passed directly to nova. If one wishes to pass a security group by parameter of a group to be created in the template, it must be in the format of . since there's no way to determine the ID beforehand. Fixes bug #1163991 Change-Id: I26bb43ee89806cefc92ba2d0319340c4cd56ed06 --- heat/engine/resources/instance.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/heat/engine/resources/instance.py b/heat/engine/resources/instance.py index 94bf7fa5..153189f2 100644 --- a/heat/engine/resources/instance.py +++ b/heat/engine/resources/instance.py @@ -89,8 +89,7 @@ class Instance(resource.Resource): 'RamDiskId': {'Type': 'String', 'Implemented': False}, 'SecurityGroups': {'Type': 'List'}, - 'SecurityGroupIds': {'Type': 'List', - 'Implemented': False}, + 'SecurityGroupIds': {'Type': 'List'}, 'NetworkInterfaces': {'Type': 'List'}, 'SourceDestCheck': {'Type': 'Boolean', 'Implemented': False}, @@ -272,7 +271,14 @@ class Instance(resource.Resource): return nics def handle_create(self): - security_groups = self.properties.get('SecurityGroups') + security_groups = [] + for property in ('SecurityGroups', 'SecurityGroupIds'): + if self.properties.get(property) is not None: + for sg in self.properties.get(property): + security_groups.append(sg) + if not security_groups: + security_groups = None + userdata = self.properties['UserData'] or '' flavor = self.properties['InstanceType'] key_name = self.properties['KeyName'] -- 2.45.2