Commit 81b6993b authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

Do not automatically update network state

Each modification in a BackendNetwork object, triggers an update
to the corresponding Network object. Until now this was done by
the BackendNetwork save() method. Now it is explicitly done
from the backend pross_network_status.
parent 51c20a90
......@@ -32,7 +32,6 @@ import datetime
from django.conf import settings
from django.db import models
from django.db import IntegrityError
from django.db import transaction
import utils
from contextlib import contextmanager
......@@ -492,45 +491,6 @@ class Network(models.Model):
return getattr(snf_settings, self.type + '_TAGS')
def update_state(self):
"""Update state of the Network.
Update the state of the Network depending on the related
backend_networks. When backend networks do not have the same operstate,
the Network's state is PENDING. Otherwise it is the same with
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'
all_equal = len(set(backend_states)) <= 1
self.state = all_equal and backend_states[0] or 'PENDING'
# Release the resources on the deletion of the Network
if old_state != 'DELETED' and self.state == 'DELETED':"Network %r deleted. Releasing link %r mac_prefix %r",, self.mac_prefix,
self.deleted = True
if self.mac_prefix and self.type == 'PRIVATE_MAC_FILTERED':
mac_pool = MacPrefixPoolTable.get_pool()
if and self.type == 'PRIVATE_PHYSICAL_VLAN':
bridge_pool = BridgePoolTable.get_pool()
def create_backend_network(self, backend=None):
"""Create corresponding BackendNetwork entries."""
......@@ -627,14 +587,6 @@ class BackendNetwork(models.Model):
self.mac_prefix = mac_prefix
def save(self, *args, **kwargs):
super(BackendNetwork, self).save(*args, **kwargs)
def delete(self, *args, **kwargs):
super(BackendNetwork, self).delete(*args, **kwargs)
class NetworkInterface(models.Model):
......@@ -39,7 +39,8 @@ from datetime import datetime
from synnefo.db.models import (Backend, VirtualMachine, Network,
pooled_rapi_client, VirtualMachineDiagnostic)
pooled_rapi_client, BridgePoolTable,
MacPrefixPoolTable, VirtualMachineDiagnostic)
from synnefo.logic import utils
from logging import getLogger
......@@ -225,6 +226,8 @@ def process_network_status(back_network, etime, jobid, opcode, status, logmsg):
if status == 'success':
back_network.backendtime = etime
# Also you must update the state of the Network!!
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