Commit 6fab175c authored by Romain Courteaud's avatar Romain Courteaud

slapos_upgrader: do not create not needed activities

parent 64586594
......@@ -17,29 +17,25 @@ wait_activate_kw = {
'after_tag': tag
}
# Delay the script to prevent conflict with serialize
# in the caller script
if is_first_call:
return person.activate(**wait_activate_kw).Person_checkSiteMigrationCreatePersonalVirtualMaster(relative_url_to_migrate_list, tag=tag, *args, **kw)
# Prevent concurrent activities
person.serialize()
if 0 < portal.portal_activities.countMessageWithTag(tag):
return person.activate(**wait_activate_kw).Person_checkSiteMigrationCreatePersonalVirtualMaster(relative_url_to_migrate_list, tag=tag, *args, **kw)
# No concurrent activity.
# Search the existing virtual master
virtual_master_title = 'Migrated personal for %s' % person.getTitle()
project = portal.portal_catalog.getResultValue(
portal_type='Project',
destination__uid=person.getUid(),
title={'query': virtual_master_title, 'key': 'ExactMatch'}
)
# Or create it
if project is None:
context.log('%s 1 %s' % (script.id, person.getRelativeUrl()))
# Delay the script to prevent conflict with serialize
# in the caller script
# Prevent concurrent activities
if is_first_call or (0 < portal.portal_activities.countMessageWithTag(tag)):
return person.activate(**wait_activate_kw).Person_checkSiteMigrationCreatePersonalVirtualMaster(relative_url_to_migrate_list, tag=tag, *args, **kw)
person.serialize()
# No concurrent activity.
# Create it
project = person.Person_addVirtualMaster(
title=virtual_master_title,
is_compute_node_payable=False,
......@@ -49,9 +45,8 @@ if project is None:
batch=1,
activate_kw=activate_kw
)
context.log('%s 2 %s' % (script.id, project))
# XXX Then, migrate other documents linked to the virtual master
for relative_url_to_migrate in relative_url_to_migrate_list:
object_to_migrate = portal.restrictedTraverse(relative_url_to_migrate)
object_to_migrate.activate(serialization_tag='Person_checkSiteMigrationCreatePersonalVirtualMaster_%s' % relative_url_to_migrate).Base_activateObjectMigrationToVirtualMaster(project.getRelativeUrl())
object_to_migrate.activate().Base_activateObjectMigrationToVirtualMaster(project.getRelativeUrl())
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