Commit ac424d91 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_crm: fixes and tests for SLA related tickets.

parent 035e7b8b
Pipeline #38410 failed with stage
in 0 seconds
......@@ -50,8 +50,15 @@ if context.getPortalType() == 'Slave Instance' and compute_node.getPortalType()
sla_dict = context.getSlaXmlAsDict()
instance_sla_error_list = []
instance_project_reference = context.getFollowUpReference()
project_reference = compute_node.getFollowUpReference()
if project_reference != instance_project_reference:
instance_sla_error_list.append("Instance and Compute node project do not match on: %s (%s != %s)" % (
context.getTitle(), project_reference, instance_project_reference))
if sla_dict:
instance_sla_error_list = []
instance_title = context.getTitle()
# Simple check of instance SLAs
if "computer_guid" in sla_dict:
......@@ -60,21 +67,18 @@ if sla_dict:
instance_sla_error_list.append('computer_guid do not match on: %s (%s != %s)' % (
instance_title, computer_guid, compute_node.getReference()))
if "instance_guid" in sla_dict:
instance_guid = sla_dict.pop("instance_guid")
if context.getPortalType() != 'Slave Instance':
instance_sla_error_list.append('instance_guid is provided to a Software Instance: %s' % instance_title)
if "instance_guid" in sla_dict:
instance_guid = sla_dict.pop("instance_guid")
if context.getPortalType() != 'Slave Instance':
instance_sla_error_list.append('instance_guid is provided to a Software Instance: %s' % instance_title)
else:
if compute_node.getPortalType() == "Remote Node":
instance_sla_error_list.append('instance_guid provided on %s and it is allocated on a REMOTE NODE' % instance_title)
else:
if compute_node.getPortalType() == "Remote Node":
instance_sla_error_list.append('instance_guid provided on %s and it is allocated on a REMOTE NODE' % instance_title)
else:
software_instance = compute_partition.getAggregateRelatedValue(portal_type='Software Instance')
if software_instance is None:
instance_sla_error_list.append('instance_guid provided on %s but no Software Instance was found' % instance_title)
else:
if software_instance.getReference() != instance_guid:
instance_sla_error_list.append('instance_guid do not match on: %s (%s != %s)' % (
instance_title, instance_guid, software_instance.getReference()))
software_instance = compute_partition.getAggregateRelatedValue(portal_type='Software Instance')
if software_instance is not None and software_instance.getReference() != instance_guid:
instance_sla_error_list.append('instance_guid do not match on: %s (%s != %s)' % (
instance_title, instance_guid, software_instance.getReference()))
if 'network_guid' in sla_dict:
network_guid = sla_dict.pop('network_guid')
......@@ -83,31 +87,28 @@ if sla_dict:
instance_sla_error_list.append('network_guid do not match on: %s (%s != %s)' % (
instance_title, network_guid, network_reference))
project_reference = compute_node.getFollowUpReference()
if 'project_guid' in sla_dict:
project_guid = sla_dict.pop("project_guid")
if project_reference != project_guid:
instance_sla_error_list.append('project_guid do not match on: %s (%s != %s)' % (
instance_title, project_guid, project_reference))
instance_project_reference = context.getFollowUpReference()
if project_reference != instance_project_reference:
instance_sla_error_list.append("Instance and Compute node project don't match on: %s (%s != %s)" % (
instance_title, project_reference, instance_project_reference))
if instance_sla_error_list:
# Slave instance is allocated but the software instance was already destroyed
error_dict['notification_message_reference'] = 'slapos-crm-instance-tree-has-invalid-sla.notification'
error_dict = updateErrorDictWithError(error_dict)
error_text = ""
for _e in instance_sla_error_list:
error_text += " * %s\n" % _e
if instance_sla_error_list:
# Slave instance is allocated but the software instance was already destroyed
error_dict['notification_message_reference'] = 'slapos-crm-instance-tree-has-invalid-sla.notification'
error_dict = updateErrorDictWithError(error_dict)
error_text = ""
for _e in instance_sla_error_list:
error_text += " * %s\n" % _e
error_dict['error_text'] = error_text
error_dict['ticket_description'] = "%s has invalid Service Level Aggrement." % instance_title
error_dict['message'] = "%s Detected inconsistencies:\n%s" % (
error_text, error_dict['ticket_description'])
return error_dict
error_dict['error_text'] = error_text
error_dict['ticket_description'] = """%s has invalid Service Level Aggrement.
Detected inconsistencies:
%s""" % (instance_title, error_text)
error_dict['message'] = error_dict['ticket_description']
return error_dict
# Skip to check if monitor disabled on the compute node.
# Remote node has no state.
......
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