Commit 5b6f9cc1 by Chif Gergő

Modify wrong nodes message function, logging infos of monitor info

Using join method on the nodes list instead of string concatenation. Logging if monitor info unreachable or None in get_monitor_info method.
parent 0a580d1d
Pipeline #664 failed with stage
in 0 seconds
...@@ -215,15 +215,14 @@ class NodeList(LoginRequiredMixin, GraphMixin, SingleTableView): ...@@ -215,15 +215,14 @@ class NodeList(LoginRequiredMixin, GraphMixin, SingleTableView):
number_of_VMs=Count('instance_set')).select_related('host') number_of_VMs=Count('instance_set')).select_related('host')
def wrong_nodes_message(self): def wrong_nodes_message(self):
wrong_nodes = '' wrong_nodes = []
for node in Node.objects.all(): for node in Node.objects.all():
if node.monitor_info is None: if node.monitor_info is None:
if wrong_nodes != '': wrong_nodes.append(node.name)
wrong_nodes += ',' message = ', '.join(wrong_nodes)
wrong_nodes += ' ' + node.name if wrong_nodes :
if wrong_nodes != '':
messages.error(self.request, messages.error(self.request,
"Can't reach" + wrong_nodes + " monitor info") "Can't reach " + message + " monitor info")
class NodeCreate(LoginRequiredMixin, SuperuserRequiredMixin, TemplateView): class NodeCreate(LoginRequiredMixin, SuperuserRequiredMixin, TemplateView):
......
...@@ -367,8 +367,10 @@ class Node(OperatedMixin, TimeStampedModel): ...@@ -367,8 +367,10 @@ class Node(OperatedMixin, TimeStampedModel):
# return with the metric value if the monitor info not none # return with the metric value if the monitor info not none
# or return 0 if its None or the metric unreachable # or return 0 if its None or the metric unreachable
if self.monitor_info is None: if self.monitor_info is None:
logger.warning('Monitor info is None')
return 0 return 0
elif self.monitor_info.get(metric) is None: elif self.monitor_info.get(metric) is None:
logger.warning('Unreachable monitor info of: ' + metric )
return 0 return 0
else: else:
return self.monitor_info.get(metric) return self.monitor_info.get(metric)
......
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