Commit 5f948c1b authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

Release resources of Network only on deletion

Assert that this is an 'real' deletion of a Network before releasing
it's resources. Without this patch, a resource used by an other Network
could be released, if someone called the Network.update_state function
parent 88237753
......@@ -504,6 +504,9 @@ class Network(models.Model):
the BackendNetworks operstate.
old_state = self.state
backend_states = [s.operstate for s in self.backend_networks.all()]
if not backend_states:
self.state = 'PENDING'
......@@ -513,7 +516,8 @@ class Network(models.Model):
all_equal = len(set(backend_states)) <= 1
self.state = all_equal and backend_states[0] or 'PENDING'
if self.state == 'DELETED':
# Release the resources on the deletion of the Network
if old_state != 'DELETED' and self.state == 'DELETED':
self.deleted = True
if self.mac_prefix:
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