Commit 40175563 by Turcsik Máté

Merge branch 'node_list_error' into 'master'

Node list error

See merge request !399
parents a001ad0d 0646721b
Pipeline #688 passed with stage
in 0 seconds
......@@ -210,9 +210,20 @@ class NodeList(LoginRequiredMixin, GraphMixin, SingleTableView):
return super(NodeList, self).get(*args, **kwargs)
def get_queryset(self):
return Node.objects.annotate(
def wrong_nodes_message(self):
wrong_nodes = []
for node in Node.objects.all():
if node.monitor_info is None:
message = ', '.join(wrong_nodes)
if wrong_nodes:
"Can't reach " + message + " monitor info")
class NodeCreate(LoginRequiredMixin, SuperuserRequiredMixin, TemplateView):
......@@ -35,7 +35,7 @@ from django.db.models import (
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from celery.exceptions import TimeoutError
from celery.exceptions import TimeoutError, TaskRevokedError
from model_utils.models import TimeStampedModel
from taggit.managers import TaggableManager
......@@ -315,7 +315,7 @@ class Node(OperatedMixin, TimeStampedModel):
queue=self.get_remote_queue_name('vm', priority),
expires=timeout + 60)
return r.get(timeout=timeout)
except (TimeoutError, WorkerNotFound):
except (TimeoutError, WorkerNotFound, TaskRevokedError):
if raise_:
......@@ -363,15 +363,27 @@ class Node(OperatedMixin, TimeStampedModel):
def driver_version(self):
def get_monitor_info(self, metric):
# return with the metric value if the monitor info not none
# or return 0 if its None or the metric unreachable
if self.monitor_info is None:
logger.warning('Monitor info is None')
return 0
elif self.monitor_info.get(metric) is None:
logger.warning('Unreachable monitor info of: ' + metric)
return 0
return self.monitor_info.get(metric)
def cpu_usage(self):
return self.monitor_info.get('cpu.percent') / 100
return self.get_monitor_info('cpu.percent') / 100
def ram_usage(self):
return self.monitor_info.get('memory.usage') / 100
return self.get_monitor_info('memory.usage') / 100
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 sign in to comment