]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Create implicit depends from gateway to public subnet.
authorSteve Baker <sbaker@redhat.com>
Fri, 12 Jul 2013 03:02:17 +0000 (15:02 +1200)
committerSteve Baker <sbaker@redhat.com>
Fri, 12 Jul 2013 03:22:16 +0000 (15:22 +1200)
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
heat/tests/test_quantum.py

index bb5324f2ad59bf412bf3fbb9524c0be727e92957..46c007505461e3864de10c4ff0632274f6f1ed14 100644 (file)
@@ -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')
index 25613c602c15bf24b10d54f51a9678774d390386..ee5a6a3c2d15b1588dbc0887d23fdb381f8b3b52 100644 (file)
@@ -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()