Commit 01550c05 authored by Romain Courteaud's avatar Romain Courteaud

slapos_upgrader: if all instances are linked to the same project, move the computer to that project

parent 0a539290
...@@ -29,6 +29,7 @@ not_migrated_compute_node_dict[compute_node_relative_url] = not_migrated_compute ...@@ -29,6 +29,7 @@ not_migrated_compute_node_dict[compute_node_relative_url] = not_migrated_compute
partition_list = compute_node.contentValues(portal_type='Compute Partition') partition_list = compute_node.contentValues(portal_type='Compute Partition')
instance_tree_list = [] instance_tree_list = []
for partition in partition_list: for partition in partition_list:
instance_list = portal.portal_catalog( instance_list = portal.portal_catalog(
portal_type=['Slave Instance', 'Software Instance'], portal_type=['Slave Instance', 'Software Instance'],
...@@ -59,7 +60,9 @@ elif not_migrated_compute_node['project_relative_url'] is not None: ...@@ -59,7 +60,9 @@ elif not_migrated_compute_node['project_relative_url'] is not None:
else: else:
# If the related instance are all grouped on this machine, and from the same user # If the related instance are all grouped on this machine, and from the same user
from_same_user_only = True from_same_user_only = True
instance_project_list = []
for instance_tree in instance_tree_list: for instance_tree in instance_tree_list:
instance_project_list.append(instance_tree.getFollowUp(None))
if instance_tree.getDestinationSection() != not_migrated_compute_node['source_administration']: if instance_tree.getDestinationSection() != not_migrated_compute_node['source_administration']:
from_same_user_only = False from_same_user_only = False
else: else:
...@@ -67,11 +70,16 @@ else: ...@@ -67,11 +70,16 @@ else:
partition = software_instance.getAggregate(None) partition = software_instance.getAggregate(None)
if (partition is not None) and (partition.startswith(compute_node_relative_url)): if (partition is not None) and (partition.startswith(compute_node_relative_url)):
from_same_user_only = False from_same_user_only = False
instance_project_list = list(set(instance_project_list))
if from_same_user_only: if from_same_user_only:
not_migrated_compute_node_dict.pop(compute_node_relative_url) not_migrated_compute_node_dict.pop(compute_node_relative_url)
source_administration_value.Person_checkSiteMigrationCreatePersonalVirtualMaster([compute_node_relative_url] + [x.getRelativeUrl() for x in instance_tree_list]) source_administration_value.Person_checkSiteMigrationCreatePersonalVirtualMaster([compute_node_relative_url] + [x.getRelativeUrl() for x in instance_tree_list])
elif (len(instance_project_list) == 1) and (instance_project_list[0] is not None):
# Else, check if all related instances tree are on the same virtual master
not_migrated_compute_node_dict.pop(compute_node_relative_url)
compute_node.activate().Base_activateObjectMigrationToVirtualMaster(instance_project_list[0])
# Log # Log
if not_migrated_compute_node_dict: if not_migrated_compute_node_dict:
......
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