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 <sdake@redhat.com>
This commit is contained in:
Steven Dake 2012-09-12 22:43:30 -07:00
parent 04701a275f
commit da37711c68
2 changed files with 12 additions and 1 deletions

View 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']

View 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))