]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
creating instances failed as a result of regression in last commit
authorSteven Dake <sdake@redhat.com>
Thu, 13 Sep 2012 05:43:30 +0000 (22:43 -0700)
committerSteven Dake <sdake@redhat.com>
Thu, 13 Sep 2012 05:46:08 +0000 (22:46 -0700)
The previous commit to the tree organizes resource names by
stack.resource.  Most of the openstack APIs take resource ids
but the instance create operation requires text identifiers.

Rewrite the text identifiers for the nova security groups before
starting an instance.

Change-Id: I8a842868781ecb353f66b5a4e3d022766a4c8a0e
Signed-off-by: Steven Dake <sdake@redhat.com>
heat/engine/instance.py
heat/engine/resources.py

index 9b456e6cb4fab9c2da707aca74345239e60476c4..9c00c506aff55a7a3e3a2f07bf24063ce8e88b80 100644 (file)
@@ -189,7 +189,12 @@ class Instance(resources.Resource):
         return self.mime_string
 
     def handle_create(self):
-        security_groups = self.properties.get('SecurityGroups')
+        if self.properties.get('SecurityGroups') == None:
+            security_groups = None
+        else:
+            security_groups = [self.physical_resource_name_find(sg) for sg in
+                    self.properties.get('SecurityGroups')]
+
         userdata = self.properties['UserData']
         userdata += '\ntouch /var/lib/cloud/instance/provision-finished\n'
         flavor = self.properties['InstanceType']
index 0caa20abcf37c7ab684f228767496f7a172c033c..98c8e5d2d3cb7b078289dbadbdadba98502b10c0 100644 (file)
@@ -313,6 +313,12 @@ class Resource(object):
     def physical_resource_name(self):
         return '%s.%s' % (self.stack.name, self.name)
 
+    def physical_resource_name_find(self, resource_name):
+        if name in self.stack:
+            return '%s.%s' % (self.stack.name, name)
+        else:
+            raise IndexError('no such resource')
+
     def validate(self):
         logger.info('Validating %s' % str(self))