Commit bbca224a authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_crm: Ensure message is always present

parent 1916c113
...@@ -14,16 +14,18 @@ error_dict = { ...@@ -14,16 +14,18 @@ error_dict = {
'compute_node_title': compute_node_title, 'compute_node_title': compute_node_title,
'compute_node_id': reference, 'compute_node_id': reference,
'last_contact': None, 'last_contact': None,
'issue_document_reference': None 'issue_document_reference': None,
'message': None
} }
if compute_node.getMonitorScope() == "disabled": if compute_node.getMonitorScope() == "disabled":
for i in ['ticket_title', 'ticket_description', 'last_contact']: for i in ['ticket_title', 'ticket_description', 'last_contact', 'message']:
error_dict[i] = "Monitor is disabled on this Compute Node." error_dict[i] = "Monitor is disabled on this Compute Node."
return error_dict return error_dict
if d.get("no_data") == 1: if d.get("no_data") == 1:
error_dict['last_contact'] = "No Contact Information" error_dict['last_contact'] = "No Contact Information"
error_dict['message'] = error_dict['last_contact']
error_dict['ticket_title'] = "Lost contact with compute_node %s" % reference error_dict['ticket_title'] = "Lost contact with compute_node %s" % reference
error_dict['ticket_description'] = \ error_dict['ticket_description'] = \
"The Compute Node %s (%s) has not contacted the server (No Contact Information)" % ( "The Compute Node %s (%s) has not contacted the server (No Contact Information)" % (
...@@ -38,6 +40,7 @@ if (now - last_contact) > 0.01: ...@@ -38,6 +40,7 @@ if (now - last_contact) > 0.01:
error_dict['should_notify'] = True error_dict['should_notify'] = True
error_dict['ticket_title'] = "Lost contact with compute_node %s" % reference error_dict['ticket_title'] = "Lost contact with compute_node %s" % reference
error_dict['last_contact'] = last_contact error_dict['last_contact'] = last_contact
error_dict['message'] = "Lost contact with %s since %s" % (reference, last_contact)
error_dict['notification_message_reference'] = 'slapos-crm-compute_node_check_state.notification' error_dict['notification_message_reference'] = 'slapos-crm-compute_node_check_state.notification'
error_dict['ticket_description'] = "The Compute Node %s (%s) has not contacted the server for more than 30 minutes" \ error_dict['ticket_description'] = "The Compute Node %s (%s) has not contacted the server for more than 30 minutes" \
"(last contact date: %s)" % (compute_node_title, reference, last_contact) "(last contact date: %s)" % (compute_node_title, reference, last_contact)
...@@ -50,6 +53,7 @@ if data_array: ...@@ -50,6 +53,7 @@ if data_array:
error_dict['notification_message_reference'] = "slapos-crm-compute_node_check_modified_file.notification" error_dict['notification_message_reference'] = "slapos-crm-compute_node_check_modified_file.notification"
error_dict['ticket_title'] = "Compute Node %s has modified file" % reference error_dict['ticket_title'] = "Compute Node %s has modified file" % reference
error_dict['issue_document_reference'] = data_array.getReference() error_dict['issue_document_reference'] = data_array.getReference()
error_dict['message'] = "%s has modified file" % reference
error_dict['ticket_description'] = "The Compute Node %s (%s) has modified file: %s" % ( error_dict['ticket_description'] = "The Compute Node %s (%s) has modified file: %s" % (
compute_node_title, reference, error_dict['issue_document_reference']) compute_node_title, reference, error_dict['issue_document_reference'])
return error_dict return error_dict
...@@ -91,6 +95,7 @@ if compute_partition_uid_list: ...@@ -91,6 +95,7 @@ if compute_partition_uid_list:
error_dict['ticket_title'] = "Compute Node %s has a stalled instance process" % reference error_dict['ticket_title'] = "Compute Node %s has a stalled instance process" % reference
error_dict['ticket_description'] = "The Compute Node %s (%s) didnt process its instances for more than 24 hours, last contact from the node: %s" % ( error_dict['ticket_description'] = "The Compute Node %s (%s) didnt process its instances for more than 24 hours, last contact from the node: %s" % (
compute_node_title, reference, last_contact) compute_node_title, reference, last_contact)
error_dict['message'] = "%s has a stalled instance process" % reference
return error_dict return error_dict
for software_installation in portal.portal_catalog( for software_installation in portal.portal_catalog(
......
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