Commit a274bef8 authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

cyclades: Allow floating IPs from drained networks

This commit makes possible to create a port to a drained network when
using a floating IP that has been already allocated. The 'drained' flag
should only affect the allocation of new IPs and not the use of existing
ones.
parent 8ce13d08
......@@ -456,9 +456,6 @@ def _create_port(userid, network, machine=None, use_ipaddress=None,
elif network.action == "DESTROY":
msg = "Cannot create port. Network %s is being deleted."
raise faults.Conflict(msg % network.id)
elif network.drained:
raise faults.Conflict("Cannot create port while network %s is in"
" 'SNF:DRAINED' status" % network.id)
utils.check_name_length(name, NetworkInterface.NETWORK_IFACE_NAME_LENGTH,
"Port name is too long")
......@@ -471,6 +468,10 @@ def _create_port(userid, network, machine=None, use_ipaddress=None,
msg = "IP Address %s does not belong to network %s"
raise faults.Conflict(msg % (ipaddress.address, network.id))
else:
# Do not allow allocation of new IPs if the network is drained
if network.drained:
raise faults.Conflict("Cannot create port while network %s is in"
" 'SNF:DRAINED' status" % network.id)
# If network has IPv4 subnets, try to allocate the address that the
# the user specified or a random one.
if network.subnets.filter(ipversion=4).exists():
......
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