Commit 39283f1f authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

cyclades: Check if network exists in backend

Raise 503 if a user tries to add a floating IP to a VM that resides in a
Ganeti backend that the coressponding network does not exist.
parent 9912e839
......@@ -394,6 +394,12 @@ def add_floating_ip(vm, address):
raise faults.Conflict("Floating IP '%s' already in use" %
floating_ip.id)
bnet = floating_ip.network.backend_networks.filter(backend=vm.backend_id)
if not bnet.exists():
msg = "Network '%s' is a floating IP pool, but it not connected"\
" to backend '%s'" % (floating_ip.network, vm.backend)
raise faults.ServiceUnavailable(msg)
floating_ip.machine = vm
floating_ip.save()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment