]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Implement SecurityGroupIds property for instances
authorJeff Peeler <jpeeler@redhat.com>
Fri, 24 May 2013 17:41:45 +0000 (13:41 -0400)
committerJeff Peeler <jpeeler@redhat.com>
Fri, 24 May 2013 21:30:07 +0000 (17:30 -0400)
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 <stackname>.<security group name> since
there's no way to determine the ID beforehand.

Fixes bug #1163991

Change-Id: I26bb43ee89806cefc92ba2d0319340c4cd56ed06

heat/engine/resources/instance.py

index 94bf7fa52b8dee3c4c4b1a200a2d4b09a431dae8..153189f23d3e4f81a5844a90ce6ad977068442f5 100644 (file)
@@ -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']