From 3ea48c23c0251c5bb7f021e219021ea3e31d2339 Mon Sep 17 00:00:00 2001 From: Jeff Peeler Date: Tue, 21 May 2013 15:52:41 -0400 Subject: [PATCH] Change SecurityGroups to be passed directly to nova This changes SecurityGroups to return the complete name of a resource (stack.name). Change-Id: I945f1213b3ddcb5550e7b4ed3d982d4ee7c4e912 --- heat/engine/resource.py | 6 ------ heat/engine/resources/instance.py | 7 +------ heat/engine/resources/security_group.py | 2 +- heat/tests/test_security_group.py | 8 ++++---- 4 files changed, 6 insertions(+), 17 deletions(-) diff --git a/heat/engine/resource.py b/heat/engine/resource.py index 706e1087..c48076b9 100644 --- a/heat/engine/resource.py +++ b/heat/engine/resource.py @@ -405,12 +405,6 @@ 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 resource_name in self.stack: - return '%s.%s' % (self.stack.name, resource_name) - else: - raise IndexError('no such resource') - def validate(self): logger.info('Validating %s' % str(self)) diff --git a/heat/engine/resources/instance.py b/heat/engine/resources/instance.py index 65847ca0..94bf7fa5 100644 --- a/heat/engine/resources/instance.py +++ b/heat/engine/resources/instance.py @@ -272,12 +272,7 @@ class Instance(resource.Resource): return nics def handle_create(self): - if self.properties.get('SecurityGroups') is None: - security_groups = None - else: - security_groups = [self.physical_resource_name_find(sg) - for sg in self.properties.get('SecurityGroups')] - + security_groups = self.properties.get('SecurityGroups') userdata = self.properties['UserData'] or '' flavor = self.properties['InstanceType'] key_name = self.properties['KeyName'] diff --git a/heat/engine/resources/security_group.py b/heat/engine/resources/security_group.py index 94f8f1d9..24089784 100644 --- a/heat/engine/resources/security_group.py +++ b/heat/engine/resources/security_group.py @@ -179,7 +179,7 @@ class SecurityGroup(resource.Resource): self.resource_id = None def FnGetRefId(self): - return unicode(self.name) + return self.physical_resource_name() def resource_mapping(): diff --git a/heat/tests/test_security_group.py b/heat/tests/test_security_group.py index cfb496f5..5be744df 100644 --- a/heat/tests/test_security_group.py +++ b/heat/tests/test_security_group.py @@ -195,7 +195,7 @@ Resources: sg = stack['the_sg'] self.assertRaises(resource.UpdateReplace, sg.handle_update, {}, {}, {}) - self.assertResourceState(sg, 'the_sg') + self.assertResourceState(sg, 'test_stack.the_sg') stack.delete() self.m.VerifyAll() @@ -268,7 +268,7 @@ Resources: sg = stack['the_sg'] self.assertRaises(resource.UpdateReplace, sg.handle_update, {}, {}, {}) - self.assertResourceState(sg, 'the_sg') + self.assertResourceState(sg, 'test_stack.the_sg') self.assertEqual(None, sg.delete()) @@ -412,7 +412,7 @@ Resources: sg = stack['the_sg'] self.assertRaises(resource.UpdateReplace, sg.handle_update, {}, {}, {}) - self.assertResourceState(sg, 'the_sg') + self.assertResourceState(sg, 'test_stack.the_sg') stack.delete() self.m.VerifyAll() @@ -528,7 +528,7 @@ Resources: sg = stack['the_sg'] self.assertRaises(resource.UpdateReplace, sg.handle_update, {}, {}, {}) - self.assertResourceState(sg, 'the_sg') + self.assertResourceState(sg, 'test_stack.the_sg') self.assertEqual(None, sg.delete()) -- 2.45.2