Commit 9cb7298a authored by Romain Courteaud's avatar Romain Courteaud

slapos_upgrader: migrate compute node

parent 1bc9e78a
from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
return context.getTypeBasedMethod('triggerObjectMigrationToVirtualMaster')(project_relative_url)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>project_relative_url, REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_activateObjectMigrationToVirtualMaster</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -57,7 +57,7 @@ if (len(not_migrated_compute_node['instance_list']) == 0) and \
personal_virtual_master_dict[not_migrated_compute_node['source_administration']]['compute_node_list'].append(compute_node_relative_url)
not_migrated_compute_node_dict.pop(compute_node_relative_url)
source_administration_value.Person_checkSiteMigrationCreatePersonalVirtualMaster()
source_administration_value.Person_checkSiteMigrationCreatePersonalVirtualMaster([compute_node_relative_url])
# Node linked to a project
elif not_migrated_compute_node['project_relative_url'] is not None:
......@@ -84,7 +84,7 @@ else:
if from_same_user_only:
not_migrated_compute_node_dict.pop(compute_node_relative_url)
source_administration_value.Person_checkSiteMigrationCreatePersonalVirtualMaster()
source_administration_value.Person_checkSiteMigrationCreatePersonalVirtualMaster([compute_node_relative_url])
# Log
......
from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
portal = context.getPortalObject()
compute_node = context
project = portal.restrictedTraverse(project_relative_url)
# Check if it has been migrated first
if compute_node.getFollowUpValue() is not None:
return
# Migrate
# Compute Node only need a link on itself.
compute_node.edit(follow_up_value=project)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>project_relative_url, REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ComputeNode_triggerObjectMigrationToVirtualMaster</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -19,12 +19,12 @@ wait_activate_kw = {
# Delay the script to prevent conflict with serialize
# in the caller script
if is_first_call:
return person.activate(**wait_activate_kw).Person_checkSiteMigrationCreatePersonalVirtualMaster(tag=tag, *args, **kw)
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(tag=tag, *args, **kw)
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
......@@ -43,6 +43,7 @@ if project is None:
title=virtual_master_title,
is_compute_node_payable=False,
is_instance_tree_payable=False,
# Hardcoded
price_currency='currency_module/EUR',
batch=1,
activate_kw=activate_kw
......@@ -50,3 +51,6 @@ if project is None:
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())
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None, tag=None, *args, **kw</string> </value>
<value> <string>relative_url_to_migrate_list, REQUEST=None, tag=None, *args, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
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