Commit 0b24cf2c authored by Christos Stavrakakis's avatar Christos Stavrakakis Committed by Dimitris Aragiorgis

Fix bug about networks and offline backends

Ignore offline backends when computing the state of the network, since
no notification will be received from them. Also, create no
BackendNetwork for an offline backend. This will be created by
reconcilliation, when the backend gets online again.
parent efe11b6c
......@@ -505,7 +505,8 @@ class Network(models.Model):
old_state = self.state
backend_states = [s.operstate for s in self.backend_networks.all()]
backend_states = [s.operstate for s in
self.backend_networks.filter(backend__offline=False)]
if not backend_states:
self.state = 'PENDING'
self.save()
......@@ -534,7 +535,8 @@ class Network(models.Model):
def create_backend_network(self, backend=None):
"""Create corresponding BackendNetwork entries."""
backends = [backend] if backend else Backend.objects.all()
backends = [backend] if backend\
else Backend.objects.filter(offline=False)
for backend in backends:
BackendNetwork.objects.create(backend=backend, network=self)
......
......@@ -57,7 +57,6 @@ class Command(BaseCommand):
make_option('--drained',
dest='drained',
action='store_true',
default=False,
help="Set the backend as drained to exclude from allocation "\
"operations"),
make_option('--no-drained',
......@@ -66,7 +65,6 @@ class Command(BaseCommand):
make_option('--offline',
dest='offline',
action='store_true',
default=False,
help="Set the backend as offline to not communicate in order "\
"to avoid delays"),
make_option('--no-offline',
......
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