Commit 690080dc authored by Romain Courteaud's avatar Romain Courteaud

slapos_cloud: migration: reindex after unindexing

parent cbd2ab8e
...@@ -148,7 +148,7 @@ def HostingSubscription_checkInstanceTreeMigrationConsistency(self, fixit=False) ...@@ -148,7 +148,7 @@ def HostingSubscription_checkInstanceTreeMigrationConsistency(self, fixit=False)
('hosting_subscription_workflow' in instance_tree.workflow_history): ('hosting_subscription_workflow' in instance_tree.workflow_history):
instance_tree.workflow_history['instance_tree_workflow'] = instance_tree.workflow_history.pop('hosting_subscription_workflow') instance_tree.workflow_history['instance_tree_workflow'] = instance_tree.workflow_history.pop('hosting_subscription_workflow')
instance_tree.reindexObject() instance_tree.activate(after_method_id="unindexObject").reindexObject()
# Migrate Predecessor/Successor if the instance wasn't migrated before. # Migrate Predecessor/Successor if the instance wasn't migrated before.
instance_tree.SoftwareInstance_checkPredecessorToSuccessorMigrationConsistency(fixit=True) instance_tree.SoftwareInstance_checkPredecessorToSuccessorMigrationConsistency(fixit=True)
UnrestrictedMethod(instance_tree.Base_updateRelatedContentWithoutReindextion)(hosting_subscription_relative_url, instance_tree.getRelativeUrl()) UnrestrictedMethod(instance_tree.Base_updateRelatedContentWithoutReindextion)(hosting_subscription_relative_url, instance_tree.getRelativeUrl())
...@@ -181,7 +181,7 @@ def ComputerPartition_checkComputePartitionMigrationConsistency(self, fixit=Fals ...@@ -181,7 +181,7 @@ def ComputerPartition_checkComputePartitionMigrationConsistency(self, fixit=Fals
('computer_partition_slap_interface_workflow' in compute_partition.workflow_history): ('computer_partition_slap_interface_workflow' in compute_partition.workflow_history):
compute_partition.workflow_history['compute_partition_slap_interface_workflow'] = compute_partition.workflow_history.pop('computer_partition_slap_interface_workflow') compute_partition.workflow_history['compute_partition_slap_interface_workflow'] = compute_partition.workflow_history.pop('computer_partition_slap_interface_workflow')
compute_partition.activate().reindexObject() compute_partition.activate(after_method_id="unindexObject").reindexObject()
else: else:
error_list.append('Computer Partition must be migrated to a Compute Partition') error_list.append('Computer Partition must be migrated to a Compute Partition')
...@@ -225,7 +225,7 @@ def Computer_checkComputeNodeMigrationConsistency(self, fixit=False): ...@@ -225,7 +225,7 @@ def Computer_checkComputeNodeMigrationConsistency(self, fixit=False):
for sub_obj in compute_node.contentValues(): for sub_obj in compute_node.contentValues():
sub_obj.activate().fixConsistency() sub_obj.activate().fixConsistency()
compute_node.activate().recursiveReindexObject() compute_node.activate(after_method_id="unindexObject").recursiveReindexObject()
UnrestrictedMethod(compute_node.Base_updateRelatedContentWithoutReindextion)(computer_relative_url, compute_node.getRelativeUrl()) UnrestrictedMethod(compute_node.Base_updateRelatedContentWithoutReindextion)(computer_relative_url, compute_node.getRelativeUrl())
else: else:
......
...@@ -149,6 +149,7 @@ class TestSlapOSCloudUpgrader(SlapOSTestCaseMixin): ...@@ -149,6 +149,7 @@ class TestSlapOSCloudUpgrader(SlapOSTestCaseMixin):
self.assertFalse(migration_message in getMessageList(migrated_instance_tree)) self.assertFalse(migration_message in getMessageList(migrated_instance_tree))
self.assertEqual(migrated_instance_tree.getRelativeUrl(), self.assertEqual(migrated_instance_tree.getRelativeUrl(),
software_instance.getAggregate()) software_instance.getAggregate())
self.assertEqual(1, len(self.portal.portal_catalog(uid=migrated_instance_tree.getUid())))
def test_upgrade_computer_to_compute_node(self): def test_upgrade_computer_to_compute_node(self):
migration_message = 'Computer must be migrated to a Compute Node' migration_message = 'Computer must be migrated to a Compute Node'
...@@ -266,6 +267,9 @@ class TestSlapOSCloudUpgrader(SlapOSTestCaseMixin): ...@@ -266,6 +267,9 @@ class TestSlapOSCloudUpgrader(SlapOSTestCaseMixin):
software_instance.getAggregate()) software_instance.getAggregate())
self.assertEqual('Compute Partition', self.assertEqual('Compute Partition',
migrated_computer_partition.getPortalType()) migrated_computer_partition.getPortalType())
self.assertEqual(1, len(self.portal.portal_catalog(uid=migrated_compute_node.getUid())))
self.assertEqual(1, len(self.portal.portal_catalog(uid=migrated_computer_partition.getUid())))
def test_upgrade_computer_partition_to_compute_partition(self): def test_upgrade_computer_partition_to_compute_partition(self):
migration_message = 'Computer Partition must be migrated to a Compute Partition' migration_message = 'Computer Partition must be migrated to a Compute Partition'
...@@ -343,3 +347,5 @@ class TestSlapOSCloudUpgrader(SlapOSTestCaseMixin): ...@@ -343,3 +347,5 @@ class TestSlapOSCloudUpgrader(SlapOSTestCaseMixin):
self.assertFalse('computer_partition_slap_interface_workflow' in migrated_computer_partition.workflow_history) self.assertFalse('computer_partition_slap_interface_workflow' in migrated_computer_partition.workflow_history)
self.assertFalse(migration_message in getMessageList(computer_partition_to_migrate)) self.assertFalse(migration_message in getMessageList(computer_partition_to_migrate))
self.assertEqual(1, len(self.portal.portal_catalog(uid=migrated_computer_partition.getUid())))
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