diff --git a/heat/engine/resources/quantum/router.py b/heat/engine/resources/quantum/router.py index bb5324f2ad..46c0075054 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 25613c602c..ee5a6a3c2d 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()