From: Steven Dake Date: Thu, 13 Sep 2012 05:43:30 +0000 (-0700) Subject: creating instances failed as a result of regression in last commit X-Git-Tag: 2014.1~1429 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=da37711c68d885bf883b49aec3ce05917e9c5bbd;p=openstack-build%2Fheat-build.git creating instances failed as a result of regression in last commit 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 --- diff --git a/heat/engine/instance.py b/heat/engine/instance.py index 9b456e6c..9c00c506 100644 --- a/heat/engine/instance.py +++ b/heat/engine/instance.py @@ -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'] diff --git a/heat/engine/resources.py b/heat/engine/resources.py index 0caa20ab..98c8e5d2 100644 --- a/heat/engine/resources.py +++ b/heat/engine/resources.py @@ -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))