Commit 0a539290 authored by Romain Courteaud's avatar Romain Courteaud

slapos_upgrader: move an instance to the same virtual master than his main compute node

parent 10901d12
...@@ -8,6 +8,7 @@ not_migrated_instance_tree_dict = {} ...@@ -8,6 +8,7 @@ not_migrated_instance_tree_dict = {}
portal = context.getPortalObject() portal = context.getPortalObject()
instance_tree = context.getObject() 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]
last_affectation_list = instance_tree.Item_getAffectationList() last_affectation_list = instance_tree.Item_getAffectationList()
project_relative_url = None project_relative_url = None
...@@ -41,3 +42,41 @@ elif (not_migrated_instance_tree_dict[instance_tree_relative_url]['slap_state'] ...@@ -41,3 +42,41 @@ elif (not_migrated_instance_tree_dict[instance_tree_relative_url]['slap_state']
instance_tree.getDestinationSectionValue().Person_checkSiteMigrationCreatePersonalVirtualMaster([instance_tree_relative_url]) instance_tree.getDestinationSectionValue().Person_checkSiteMigrationCreatePersonalVirtualMaster([instance_tree_relative_url])
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
elif (software_instance is not None) and (software_instance.getSlaXmlAsDict().get('project_guid', None) is not None):
project_reference = software_instance.getSlaXmlAsDict().get('project_guid', None)
project = portal.portal_catalog.getResultValue(portal_type='Project', reference=project_reference)
if project is not None:
instance_tree.activate().Base_activateObjectMigrationToVirtualMaster(project.getRelativeUrl())
not_migrated_instance_tree_dict.pop(instance_tree_relative_url)
# 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):
project_instance_reference = software_instance.getSlaXmlAsDict().get('computer_guid', None)
project_instance = portal.portal_catalog.getResultValue(portal_type='Compute Node', reference=project_instance_reference)
if project_instance is not None:
project = project_instance.getFollowUpValue(None)
if project is not None:
instance_tree.activate().Base_activateObjectMigrationToVirtualMaster(project.getRelativeUrl())
not_migrated_instance_tree_dict.pop(instance_tree_relative_url)
# 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):
project_instance_reference = software_instance.getSlaXmlAsDict().get('instance_guid', None)
project_instance = portal.portal_catalog.getResultValue(portal_type='Software Instance', reference=project_instance_reference)
if project_instance is not None:
project = project_instance.getFollowUpValue(None)
if project is not None:
instance_tree.activate().Base_activateObjectMigrationToVirtualMaster(project.getRelativeUrl())
not_migrated_instance_tree_dict.pop(instance_tree_relative_url)
# Finally, use the same project than the allocation
elif (software_instance is not None) and (software_instance.getAggregateValue(None) is not None):
project = software_instance.getAggregateValue().getParentValue().getFollowUpValue(None)
if project is not None:
instance_tree.activate().Base_activateObjectMigrationToVirtualMaster(project.getRelativeUrl())
not_migrated_instance_tree_dict.pop(instance_tree_relative_url)
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