Commit 6849b899 authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

cyclades: Fix wrong state of deleted networks

Before deleting a network, the network is marked as drained to be
excluded from automatic IP allocation. The state of the network that is
exposed in the API is always 'SNF:DRAINED' if the drained flag is set.
This resulted in deleted networks to appear as 'SNF:DRAINED'. This
commit fixes this issue by clearing the 'drained' flag when deleting the
network.

Also, this commit sets the 'drained' flag only when deleting public
networks that can take part in automatic IP allocation. For private
networs setting this flag is not needed.
parent b7543281
......@@ -503,6 +503,9 @@ def update_network_state(network):
network.id, network.mac_prefix, network.link)
network.deleted = True
network.state = "DELETED"
# Undrain the network, otherwise the network state will remain
# as 'SNF:DRAINED'
network.drained = False
if network.mac_prefix:
if network.FLAVORS[network.flavor]["mac_prefix"] == "pool":
release_resource(res_type="mac_prefix",
......
......@@ -147,6 +147,7 @@ def delete(network):
network.action = "DESTROY"
# Mark network as drained to prevent automatic allocation of
# public/floating IPs while the network is being deleted
if network.public:
network.drained = True
network.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