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
......@@ -215,15 +215,14 @@ class NodeList(LoginRequiredMixin, GraphMixin, SingleTableView):
number_of_VMs=Count('instance_set')).select_related('host')
def wrong_nodes_message(self):
wrong_nodes = ''
wrong_nodes = []
for node in Node.objects.all():
if node.monitor_info is None:
if wrong_nodes != '':
wrong_nodes += ','
wrong_nodes += ' ' + node.name
if wrong_nodes != '':
wrong_nodes.append(node.name)
message = ', '.join(wrong_nodes)
if wrong_nodes :
messages.error(self.request,
"Can't reach" + wrong_nodes + " monitor info")
"Can't reach " + message + " monitor info")
class NodeCreate(LoginRequiredMixin, SuperuserRequiredMixin, TemplateView):
......
......@@ -367,8 +367,10 @@ class Node(OperatedMixin, TimeStampedModel):
# 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
else:
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