Merge "Add dependency between FloatingIP and RouterGateway"
This commit is contained in:
commit
665d202306
|
@ -31,6 +31,16 @@ class FloatingIP(quantum.QuantumResource):
|
||||||
'port_id': {'Type': 'String'},
|
'port_id': {'Type': 'String'},
|
||||||
'fixed_ip_address': {'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):
|
def handle_create(self):
|
||||||
props = self.prepare_properties(
|
props = self.prepare_properties(
|
||||||
self.properties,
|
self.properties,
|
||||||
|
@ -74,6 +84,8 @@ class FloatingIPAssociation(quantum.QuantumResource):
|
||||||
self.resource_id_set('%s:%s' % (floatingip_id, props['port_id']))
|
self.resource_id_set('%s:%s' % (floatingip_id, props['port_id']))
|
||||||
|
|
||||||
def handle_delete(self):
|
def handle_delete(self):
|
||||||
|
if not self.resource_id:
|
||||||
|
return
|
||||||
client = self.quantum()
|
client = self.quantum()
|
||||||
(floatingip_id, port_id) = self.resource_id.split(':')
|
(floatingip_id, port_id) = self.resource_id.split(':')
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -126,6 +126,16 @@ quantum_floating_template = '''
|
||||||
"floatingip_id": { "Ref" : "floating_ip" },
|
"floatingip_id": { "Ref" : "floating_ip" },
|
||||||
"port_id": { "Ref" : "port_floating" }
|
"port_id": { "Ref" : "port_floating" }
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"router": {
|
||||||
|
"Type": "OS::Quantum::Router"
|
||||||
|
},
|
||||||
|
"gateway": {
|
||||||
|
"Type": "OS::Quantum::RouterGateway",
|
||||||
|
"Properties": {
|
||||||
|
"router_id": { "Ref" : "router" },
|
||||||
|
"network_id": "abcd1234"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -621,6 +631,11 @@ class QuantumFloatingIPTest(HeatTestCase):
|
||||||
t = template_format.parse(quantum_floating_template)
|
t = template_format.parse(quantum_floating_template)
|
||||||
stack = parse_stack(t)
|
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']
|
fip = stack['floating_ip']
|
||||||
scheduler.TaskRunner(fip.create)()
|
scheduler.TaskRunner(fip.create)()
|
||||||
self.assertEqual((fip.CREATE, fip.COMPLETE), fip.state)
|
self.assertEqual((fip.CREATE, fip.COMPLETE), fip.state)
|
||||||
|
|
Loading…
Reference in New Issue