From 710114b0ee82cd0f4b7ad9847011a2e5daaf69f5 Mon Sep 17 00:00:00 2001 From: Steve Baker Date: Tue, 12 Feb 2013 13:15:47 +1300 Subject: [PATCH] Use physical_resource_name for quantum/vpc resources. This give a bit more namespace seperation for quantum resource names. Change-Id: I72736b4409937eb8511ef94dc58407aed20a0f67 --- heat/engine/resources/quantum/floatingip.py | 4 +++- heat/engine/resources/quantum/net.py | 4 +++- heat/engine/resources/quantum/port.py | 10 ++++++---- heat/engine/resources/quantum/router.py | 4 +++- heat/engine/resources/quantum/subnet.py | 4 +++- heat/engine/resources/subnet.py | 2 +- heat/engine/resources/vpc.py | 2 +- heat/tests/test_vpc.py | 16 +++++++++------- 8 files changed, 29 insertions(+), 17 deletions(-) diff --git a/heat/engine/resources/quantum/floatingip.py b/heat/engine/resources/quantum/floatingip.py index d9edff16..9f044212 100644 --- a/heat/engine/resources/quantum/floatingip.py +++ b/heat/engine/resources/quantum/floatingip.py @@ -31,7 +31,9 @@ class FloatingIP(quantum.QuantumResource): 'fixed_ip_address': {'Type': 'String'}} def handle_create(self): - props = self.prepare_properties(self.properties, self.name) + props = self.prepare_properties( + self.properties, + self.physical_resource_name()) fip = self.quantum().create_floatingip({ 'floatingip': props})['floatingip'] self.resource_id_set(fip['id']) diff --git a/heat/engine/resources/quantum/net.py b/heat/engine/resources/quantum/net.py index 007aff2a..fe8c226e 100644 --- a/heat/engine/resources/quantum/net.py +++ b/heat/engine/resources/quantum/net.py @@ -33,7 +33,9 @@ class Net(quantum.QuantumResource): super(Net, self).__init__(name, json_snippet, stack) def handle_create(self): - props = self.prepare_properties(self.properties, self.name) + props = self.prepare_properties( + self.properties, + self.physical_resource_name()) net = self.quantum().create_network({'network': props})['network'] self.resource_id_set(net['id']) diff --git a/heat/engine/resources/quantum/port.py b/heat/engine/resources/quantum/port.py index 222d379c..a8890304 100644 --- a/heat/engine/resources/quantum/port.py +++ b/heat/engine/resources/quantum/port.py @@ -26,8 +26,7 @@ class Port(quantum.QuantumResource): fixed_ip_schema = {'subnet_id': {'Type': 'String', 'Required': True}, - 'ip_address': {'Type': 'String', - 'Required': True}} + 'ip_address': {'Type': 'String'}} properties_schema = {'network_id': {'Type': 'String', 'Required': True}, @@ -40,13 +39,16 @@ class Port(quantum.QuantumResource): 'Schema': {'Type': 'Map', 'Schema': fixed_ip_schema}}, 'mac_address': {'Type': 'String'}, - 'device_id': {'Type': 'String'}} + 'device_id': {'Type': 'String'}, + 'security_groups': {'Type': 'List'}} def __init__(self, name, json_snippet, stack): super(Port, self).__init__(name, json_snippet, stack) def handle_create(self): - props = self.prepare_properties(self.properties, self.name) + props = self.prepare_properties( + self.properties, + self.physical_resource_name()) port = self.quantum().create_port({'port': props})['port'] self.resource_id_set(port['id']) diff --git a/heat/engine/resources/quantum/router.py b/heat/engine/resources/quantum/router.py index 291def42..a3984396 100644 --- a/heat/engine/resources/quantum/router.py +++ b/heat/engine/resources/quantum/router.py @@ -34,7 +34,9 @@ class Router(quantum.QuantumResource): super(Router, self).__init__(name, json_snippet, stack) def handle_create(self): - props = self.prepare_properties(self.properties, self.name) + props = self.prepare_properties( + self.properties, + self.physical_resource_name()) router = self.quantum().create_router({'router': props})['router'] self.resource_id_set(router['id']) diff --git a/heat/engine/resources/quantum/subnet.py b/heat/engine/resources/quantum/subnet.py index 90251d7a..322667e2 100644 --- a/heat/engine/resources/quantum/subnet.py +++ b/heat/engine/resources/quantum/subnet.py @@ -52,7 +52,9 @@ class Subnet(quantum.QuantumResource): super(Subnet, self).__init__(name, json_snippet, stack) def handle_create(self): - props = self.prepare_properties(self.properties, self.name) + props = self.prepare_properties( + self.properties, + self.physical_resource_name()) subnet = self.quantum().create_subnet({'subnet': props})['subnet'] self.resource_id_set(subnet['id']) diff --git a/heat/engine/resources/subnet.py b/heat/engine/resources/subnet.py index 87294d9e..66fcab52 100644 --- a/heat/engine/resources/subnet.py +++ b/heat/engine/resources/subnet.py @@ -52,7 +52,7 @@ class Subnet(resource.Resource): props = { 'network_id': network_id, 'cidr': self.properties.get('CidrBlock'), - 'name': self.name, + 'name': self.physical_resource_name(), 'ip_version': 4 } subnet = client.create_subnet({'subnet': props})['subnet'] diff --git a/heat/engine/resources/vpc.py b/heat/engine/resources/vpc.py index fa73e61f..de5738cb 100644 --- a/heat/engine/resources/vpc.py +++ b/heat/engine/resources/vpc.py @@ -46,7 +46,7 @@ class VPC(resource.Resource): def handle_create(self): client = self.quantum() - props = {'name': self.name} + props = {'name': self.physical_resource_name()} # Creates a network with an implicit router net = client.create_network({'network': props})['network'] router = client.create_router({'router': props})['router'] diff --git a/heat/tests/test_vpc.py b/heat/tests/test_vpc.py index c4041004..1b6b103b 100644 --- a/heat/tests/test_vpc.py +++ b/heat/tests/test_vpc.py @@ -111,7 +111,9 @@ class VPCTestBase(unittest.TestCase): def mock_create_network(self): quantumclient.Client.create_network( - {'network': {'name': 'the_vpc'}}).AndReturn({'network': { + { + 'network': {'name': 'test_stack.the_vpc'} + }).AndReturn({'network': { 'status': 'ACTIVE', 'subnets': [], 'name': 'name', @@ -121,7 +123,7 @@ class VPCTestBase(unittest.TestCase): 'id': 'aaaa' }}) quantumclient.Client.create_router( - {'router': {'name': 'the_vpc'}}).AndReturn({'router': { + {'router': {'name': 'test_stack.the_vpc'}}).AndReturn({'router': { 'status': 'ACTIVE', 'name': 'name', 'admin_state_up': True, @@ -135,10 +137,10 @@ class VPCTestBase(unittest.TestCase): 'network_id': u'aaaa', 'cidr': u'10.0.0.0/24', 'ip_version': 4, - 'name': u'the_subnet'}}).AndReturn({ + 'name': u'test_stack.the_subnet'}}).AndReturn({ 'subnet': { 'status': 'ACTIVE', - 'name': 'the_subnet', + 'name': 'test_stack.the_subnet', 'admin_state_up': True, 'tenant_id': 'c1210485b2424d48804aad5d39c61b8f', 'id': 'cccc'}}) @@ -149,7 +151,7 @@ class VPCTestBase(unittest.TestCase): def mock_create_network_interface(self): quantumclient.Client.show_subnet('cccc').AndReturn({ 'subnet': { - 'name': 'the_subnet', + 'name': 'test_stack.the_subnet', 'network_id': 'aaaa', 'tenant_id': 'c1210485b2424d48804aad5d39c61b8f', 'allocation_pools': [{ @@ -164,7 +166,7 @@ class VPCTestBase(unittest.TestCase): 'port': { 'status': 'ACTIVE', 'device_owner': '', - 'name': '', + 'name': 'test_stack.the_nic', 'admin_state_up': True, 'network_id': 'aaaa', 'tenant_id': 'c1210485b2424d48804aad5d39c61b8f', @@ -187,7 +189,7 @@ class VPCTestBase(unittest.TestCase): ], 'id': 'dddd', 'mac_address': 'fa:16:3e:25:32:5d', - 'name': '', + 'name': 'test_stack.the_nic', 'network_id': 'aaaa', 'status': 'ACTIVE', 'tenant_id': 'c1210485b2424d48804aad5d39c61b8f' -- 2.45.2