From 7056f6216075726083a97ea6658b14e8c228aac7 Mon Sep 17 00:00:00 2001 From: Steve Baker Date: Fri, 12 Jul 2013 15:02:17 +1200 Subject: [PATCH] Create implicit depends from gateway to public subnet. Depend on any subnet in this template with the same network_id as this network_id, as the gateway implicitly creates a port on that subnet. Fixes bug: #1195599 Change-Id: Ie850a82dce551d46341b1eef7f0208074b72453f --- heat/engine/resources/quantum/router.py | 11 +++++++++-- heat/tests/test_quantum.py | 4 ++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/heat/engine/resources/quantum/router.py b/heat/engine/resources/quantum/router.py index bb5324f2..46c00750 100644 --- a/heat/engine/resources/quantum/router.py +++ b/heat/engine/resources/quantum/router.py @@ -100,13 +100,20 @@ class RouterGateway(quantum.QuantumResource): def add_dependencies(self, deps): super(RouterGateway, self).add_dependencies(deps) - # depend on any RouterInterface in this template with the same - # router_id as this router_id for resource in self.stack.resources.itervalues(): + # depend on any RouterInterface in this template with the same + # router_id as this router_id if (resource.type() == 'OS::Quantum::RouterInterface' and resource.properties.get('router_id') == self.properties.get('router_id')): deps += (self, resource) + # depend on any subnet in this template with the same network_id + # as this network_id, as the gateway implicitly creates a port + # on that subnet + elif (resource.type() == 'OS::Quantum::Subnet' and + resource.properties.get('network_id') == + self.properties.get('network_id')): + deps += (self, resource) def handle_create(self): router_id = self.properties.get('router_id') diff --git a/heat/tests/test_quantum.py b/heat/tests/test_quantum.py index 25613c60..ee5a6a3c 100644 --- a/heat/tests/test_quantum.py +++ b/heat/tests/test_quantum.py @@ -305,6 +305,10 @@ class QuantumNetTest(HeatTestCase): deps = stack.dependencies[stack['router_interface']] self.assertIn(stack['gateway'], deps) + # assert the implicit dependency between the gateway and the subnet + deps = stack.dependencies[stack['subnet']] + self.assertIn(stack['gateway'], deps) + rsrc.validate() ref_id = rsrc.FnGetRefId() -- 2.45.2