From: Steve Baker Date: Tue, 21 May 2013 01:21:11 +0000 (+1200) Subject: Add dependency between RouterGateway and RouterInterface X-Git-Tag: 2014.1~428^2 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=718c195a1be18470e9d5cb5a7a199f62548b937b;p=openstack-build%2Fheat-build.git Add dependency between RouterGateway and RouterInterface When a template has a RouterGateway and a RouterInterface with the same router_id, there is an implicit dependency on delete where the gateway must be deleted before the interface. This is implemented by overiding add_dependencies in RouterGateway and looking in the stack for RouterInterface resource to depend on. Fixed bug: #1182266 Change-Id: I90ebe987c1d6e81f8936ceb81b81376c7e0d497a --- diff --git a/heat/engine/resources/quantum/router.py b/heat/engine/resources/quantum/router.py index 898a7a84..7a628985 100644 --- a/heat/engine/resources/quantum/router.py +++ b/heat/engine/resources/quantum/router.py @@ -95,6 +95,16 @@ class RouterGateway(quantum.QuantumResource): 'network_id': {'Type': 'String', 'Required': True}} + 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(): + if (resource.type() == 'OS::Quantum::RouterInterface' and + resource.properties.get('router_id') == + self.properties.get('router_id')): + deps += (self, resource) + def handle_create(self): router_id = self.properties.get('router_id') network_id = self.properties.get('network_id') diff --git a/heat/tests/test_quantum.py b/heat/tests/test_quantum.py index 0c44c8b8..41e39c0e 100644 --- a/heat/tests/test_quantum.py +++ b/heat/tests/test_quantum.py @@ -281,6 +281,10 @@ class QuantumNetTest(HeatTestCase): stack = parse_stack(t) rsrc = self.create_net(t, stack, 'network') + # assert the implicit dependency between the gateway and the interface + deps = stack.dependencies[stack['router_interface']] + self.assertIn(stack['gateway'], deps) + rsrc.validate() ref_id = rsrc.FnGetRefId()