Commit 74bc8891 authored by Romain Courteaud's avatar Romain Courteaud

slapos_upgrader: some sla xml seems broken

parent eb5d1265
...@@ -10,6 +10,14 @@ instance_tree = context.getObject() ...@@ -10,6 +10,14 @@ instance_tree = context.getObject()
instance_tree_relative_url = instance_tree.getRelativeUrl() instance_tree_relative_url = instance_tree.getRelativeUrl()
software_instance = ([x for x in instance_tree.getSuccessorValueList() if x.getTitle()==instance_tree.getTitle()] + [None])[0] software_instance = ([x for x in instance_tree.getSuccessorValueList() if x.getTitle()==instance_tree.getTitle()] + [None])[0]
sla_xml_dict = {}
if software_instance is None:
try:
sla_xml_dict = software_instance.getSlaXmlAsDict()
except:
# XMLSyntaxError
pass
last_affectation_list = instance_tree.Item_getAffectationList() last_affectation_list = instance_tree.Item_getAffectationList()
project_relative_url = None project_relative_url = None
if last_affectation_list and last_affectation_list[0].project_uid: if last_affectation_list and last_affectation_list[0].project_uid:
...@@ -34,16 +42,16 @@ if not_migrated_instance_tree_dict[instance_tree_relative_url]['project_relative ...@@ -34,16 +42,16 @@ if not_migrated_instance_tree_dict[instance_tree_relative_url]['project_relative
not_migrated_instance_tree_dict.pop(instance_tree_relative_url) not_migrated_instance_tree_dict.pop(instance_tree_relative_url)
# Node requested to be allocated on a specific project # Node requested to be allocated on a specific project
elif (software_instance is not None) and (software_instance.getSlaXmlAsDict().get('project_guid', None) is not None): elif (software_instance is not None) and (sla_xml_dict.get('project_guid', None) is not None):
project_reference = software_instance.getSlaXmlAsDict().get('project_guid', None) project_reference = sla_xml_dict.get('project_guid', None)
project = portal.portal_catalog.getResultValue(portal_type='Project', reference=project_reference) project = portal.portal_catalog.getResultValue(portal_type='Project', reference=project_reference)
if project is not None: if project is not None:
instance_tree.activate().Base_activateObjectMigrationToVirtualMaster(project.getRelativeUrl()) instance_tree.activate().Base_activateObjectMigrationToVirtualMaster(project.getRelativeUrl())
not_migrated_instance_tree_dict.pop(instance_tree_relative_url) not_migrated_instance_tree_dict.pop(instance_tree_relative_url)
# Node requested to be allocated on a specific node # Node requested to be allocated on a specific node
elif (software_instance is not None) and (software_instance.getSlaXmlAsDict().get('computer_guid', None) is not None): elif (software_instance is not None) and (sla_xml_dict.get('computer_guid', None) is not None):
project_instance_reference = software_instance.getSlaXmlAsDict().get('computer_guid', None) project_instance_reference = sla_xml_dict.get('computer_guid', None)
project_instance = portal.portal_catalog.getResultValue(portal_type='Compute Node', reference=project_instance_reference) project_instance = portal.portal_catalog.getResultValue(portal_type='Compute Node', reference=project_instance_reference)
if project_instance is not None: if project_instance is not None:
...@@ -53,8 +61,8 @@ elif (software_instance is not None) and (software_instance.getSlaXmlAsDict().ge ...@@ -53,8 +61,8 @@ elif (software_instance is not None) and (software_instance.getSlaXmlAsDict().ge
not_migrated_instance_tree_dict.pop(instance_tree_relative_url) not_migrated_instance_tree_dict.pop(instance_tree_relative_url)
# Slave Node requested to be allocated on a specific project instance # Slave Node requested to be allocated on a specific project instance
elif (software_instance is not None) and (software_instance.getSlaXmlAsDict().get('instance_guid', None) is not None): elif (software_instance is not None) and (sla_xml_dict.get('instance_guid', None) is not None):
project_instance_reference = software_instance.getSlaXmlAsDict().get('instance_guid', None) project_instance_reference = sla_xml_dict.get('instance_guid', None)
project_instance = portal.portal_catalog.getResultValue(portal_type='Software Instance', reference=project_instance_reference) project_instance = portal.portal_catalog.getResultValue(portal_type='Software Instance', reference=project_instance_reference)
if project_instance is not None: if project_instance is not None:
......
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