Add dependency between FloatingIP and RouterGateway
When a template has a FloatingIP and a RouterGateway on the same external network, there is an implicit dependency on create where the gateway must be created before the floating ip. This is implemented by overiding add_dependencies in FloatingIP and looking in the stack for RouterGateway resource to depend on. Fixed bug: #1182266 Change-Id: I40f281e5bf2a27280d328fe11d32e6404f412a79
This commit is contained in:
parent
d25c1e94ed
commit
ccba71e38a
|
@ -31,6 +31,16 @@ class FloatingIP(quantum.QuantumResource):
|
|||
'port_id': {'Type': 'String'},
|
||||
'fixed_ip_address': {'Type': 'String'}}
|
||||
|
||||
def add_dependencies(self, deps):
|
||||
super(FloatingIP, self).add_dependencies(deps)
|
||||
# depend on any RouterGateway in this template with the same
|
||||
# network_id as this floating_network_id
|
||||
for resource in self.stack.resources.itervalues():
|
||||
if (resource.type() == 'OS::Quantum::RouterGateway' and
|
||||
resource.properties.get('network_id') ==
|
||||
self.properties.get('floating_network_id')):
|
||||
deps += (self, resource)
|
||||
|
||||
def handle_create(self):
|
||||
props = self.prepare_properties(
|
||||
self.properties,
|
||||
|
@ -74,6 +84,8 @@ class FloatingIPAssociation(quantum.QuantumResource):
|
|||
self.resource_id_set('%s:%s' % (floatingip_id, props['port_id']))
|
||||
|
||||
def handle_delete(self):
|
||||
if not self.resource_id:
|
||||
return
|
||||
client = self.quantum()
|
||||
(floatingip_id, port_id) = self.resource_id.split(':')
|
||||
try:
|
||||
|
|
|
@ -128,6 +128,16 @@ quantum_floating_template = '''
|
|||
"floatingip_id": { "Ref" : "floating_ip" },
|
||||
"port_id": { "Ref" : "port_floating" }
|
||||
}
|
||||
},
|
||||
"router": {
|
||||
"Type": "OS::Quantum::Router"
|
||||
},
|
||||
"gateway": {
|
||||
"Type": "OS::Quantum::RouterGateway",
|
||||
"Properties": {
|
||||
"router_id": { "Ref" : "router" },
|
||||
"network_id": "abcd1234"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -624,6 +634,11 @@ class QuantumFloatingIPTest(HeatTestCase):
|
|||
t = template_format.parse(quantum_floating_template)
|
||||
stack = parse_stack(t)
|
||||
|
||||
# assert the implicit dependency between the floating_ip
|
||||
# and the gateway
|
||||
deps = stack.dependencies[stack['gateway']]
|
||||
self.assertIn(stack['floating_ip'], deps)
|
||||
|
||||
fip = stack['floating_ip']
|
||||
scheduler.TaskRunner(fip.create)()
|
||||
self.assertEqual(floatingip.FloatingIP.CREATE_COMPLETE, fip.state)
|
||||
|
|
Loading…
Reference in New Issue