Commit 0a0d2470 authored by Gabriel Monnerat's avatar Gabriel Monnerat

Simplify erp5_upgrader to be possible upgrade any project just enabling the...

Simplify erp5_upgrader to be possible upgrade any project just enabling the alarms that all Constraints will be called and fixed.

The alarms were renamed to cover each step of upgrader and give the possibility to call each step manually one-by-one. Also, all Scripts that the logic can be done by installing Business Template was removed.

Also added:
 - Constraints that can be used in the upgrader
 - Unit test to check different scenarios
 - Extend external method to be possible dump workflow chains to be compared with all configuration defined on Business Templates
parent 97a6db68
...@@ -32,9 +32,8 @@ ...@@ -32,9 +32,8 @@
from App.config import getConfiguration from App.config import getConfiguration
from Products.ERP5Type.Log import log from Products.ERP5Type.Log import log
from Products.CMFActivity.ActiveResult import ActiveResult from Products.CMFActivity.ActiveResult import ActiveResult
from time import sleep
import os import os
from Acquisition import aq_base
def ERP5Site_editERP5SiteProperty(self, prop, value): def ERP5Site_editERP5SiteProperty(self, prop, value):
""" """
...@@ -47,28 +46,6 @@ def ERP5Site_editERP5SiteProperty(self, prop, value): ...@@ -47,28 +46,6 @@ def ERP5Site_editERP5SiteProperty(self, prop, value):
method(prop, value) method(prop, value)
return True return True
def ERP5Site_restartZopeInstance(self):
"""
Zope must be restart after update the Products or Software
But the restart into one activity, will make the activity always
fail and with the server will be restart many times.
This method use a flag to define if the server was already restarted.
If yes, the flag is removed and the restart will be ignored.
This method should be run into a single activity to prevent rollback
other parts.
"""
import Lifetime
Lifetime.shutdown(1,fast=1)
log("Zope Restart was launched.")
active_result = ActiveResult()
active_result.edit(summary="Zope Restart",
severity=0,
detail="Zope was restart Sucessfully.")
return active_result
def ERP5Site_clearActivities(self): def ERP5Site_clearActivities(self):
""" """
This method is used to recreated the activities keeping the This method is used to recreated the activities keeping the
...@@ -119,42 +96,26 @@ def ERP5Site_runVerificationScript(self, method_id): ...@@ -119,42 +96,26 @@ def ERP5Site_runVerificationScript(self, method_id):
if len(integrity_result) > 0: if len(integrity_result) > 0:
return '%s : \n - %s ' % (method_id, '\n - '.join(integrity_result)) return '%s : \n - %s ' % (method_id, '\n - '.join(integrity_result))
def ERP5Site_changeAuthoredDocumentListOwnership(self, old_owner, new_owner): def ERP5Site_dumpWorkflowChainByPortalType(self, REQUEST=None):
""" # This method outputs the workflow chain by portal type
Change owneship for all documents in the system belonging to # ---
an user (i.e. represented by user_name/reference). # {"Account": ['account_workflow', "edit_workflow"]}
""" # ---
# Move import to here prevents the raise error when this External #
# Be imported during the upgrade. if REQUEST:
from Products.ERP5Type.Utils import _setSuperSecurityManager raise RuntimeError("You can not call this script from the url")
from AccessControl.SecurityManagement import setSecurityManager workflow_tool = self.getPortalObject().portal_workflow
from Products.ERP5Security.ERP5UserManager import SUPER_USER cbt = workflow_tool._chains_by_type
ti = workflow_tool._listTypeInfo()
result = [] chain_by_type_dict = {}
orginal_security_manager = _setSuperSecurityManager(self, SUPER_USER) for t in ti:
portal = self.getPortalObject() id = t.getId()
user_folder = portal.acl_users title = t.Title()
if title == id:
new_owner_as_user = user_folder.getUserById(new_owner).__of__(user_folder) title = None
document_list = portal.portal_catalog.unrestrictedSearchResults(owner = old_owner) if cbt is not None and cbt.has_key(id):
for document in document_list: chain = sorted(cbt[id])
document = document.getObject() else:
# change document ownership chain = ['(Default)']
document.changeOwnership(new_owner_as_user) chain_by_type_dict.setdefault(id, []).extend(chain)
# fix local roles return chain_by_type_dict
for item in document.get_local_roles(): \ No newline at end of file
user = item[0]
role_list = item[1]
if user == old_owner:
# replace old Owner with new One
document.manage_delLocalRoles((old_owner,))
document.manage_setLocalRoles(new_owner, role_list)
result.append(document.getRelativeUrl())
# finally reindex document
document.reindexObject()
# restore security
setSecurityManager(orginal_security_manager)
return dict(old_owner = old_owner, \
new_owner = new_owner, \
changed_document_list = result)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Alarm" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>active_sense_method_id</string> </key>
<value> <string>Alarm_senseFullUpgradeNeed</string> </value>
</item>
<item>
<key> <string>alarm_notification_mode</string> </key>
<value>
<tuple>
<string>always</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>This alarm checks that the upgrader is required. If yes, the upgrader have three steps:\n
\n
1. Pre-upgrade\n
This step will run all constraints that have contraint_type equal pre_upgrade.\n
\n
2. Upgrader\n
This step will run all constraints that have contraint_type equal upgrade. In this step is supposed to install/upgrade all Business Template required.\n
\n
3. Post-Upgrade\n
This step will run all constraints that have contraint_type equal post_upgrade.</string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>promise_check_upgrade</string> </value>
</item>
<item>
<key> <string>periodicity_hour</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_minute</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_minute_frequency</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>periodicity_month</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_month_day</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_start_date</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1384423200.0</float>
<string>GMT</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>periodicity_week</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Alarm</string> </value>
</item>
<item>
<key> <string>sense_method_id</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>solve_method_id</string> </key>
<value> <string>Alarm_runFullUpgrader</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Run Full Upgrade</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -14,17 +14,13 @@ ...@@ -14,17 +14,13 @@
<key> <string>alarm_notification_mode</string> </key> <key> <string>alarm_notification_mode</string> </key>
<value> <value>
<tuple> <tuple>
<string>never</string> <string>always</string>
</tuple> </tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
<value> <string>This alarms acts as a cron job. It will start an instance upgrade if any of the following this alarms sequence:\n <value> <string>This step will run all constraints that have contraint_type equal post_upgrade.</string> </value>
1) bt5_upgrader (supported)\n
2) finalize_upgrader (supported)\n
\n
"sense" a need of an upgrade. This alarm is likely to disappear soon as it\'s needed due to lack of functionality (which is that alarms can not automatically "solve" themselves).</string> </value>
</item> </item>
<item> <item>
<key> <string>enabled</string> </key> <key> <string>enabled</string> </key>
...@@ -32,7 +28,7 @@ ...@@ -32,7 +28,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>upgrader_controller</string> </value> <value> <string>upgrader_check_post_upgrade</string> </value>
</item> </item>
<item> <item>
<key> <string>periodicity_hour</string> </key> <key> <string>periodicity_hour</string> </key>
...@@ -48,7 +44,9 @@ ...@@ -48,7 +44,9 @@
</item> </item>
<item> <item>
<key> <string>periodicity_minute_frequency</string> </key> <key> <string>periodicity_minute_frequency</string> </key>
<value> <int>30</int> </value> <value>
<none/>
</value>
</item> </item>
<item> <item>
<key> <string>periodicity_month</string> </key> <key> <string>periodicity_month</string> </key>
...@@ -74,7 +72,7 @@ ...@@ -74,7 +72,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1136073600.0</float> <float>1384423200.0</float>
<string>GMT</string> <string>GMT</string>
</tuple> </tuple>
</state> </state>
...@@ -97,9 +95,13 @@ ...@@ -97,9 +95,13 @@
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>solve_method_id</string> </key>
<value> <string>Alarm_runPostUpgrade</string> </value>
</item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string>Upgrader Controller</string> </value> <value> <string>Run Post Upgrade</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -6,6 +6,10 @@ ...@@ -6,6 +6,10 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>active_sense_method_id</string> </key>
<value> <string>Alarm_senseUpgradeNeed</string> </value>
</item>
<item> <item>
<key> <string>alarm_notification_mode</string> </key> <key> <string>alarm_notification_mode</string> </key>
<value> <value>
...@@ -16,7 +20,7 @@ ...@@ -16,7 +20,7 @@
</item> </item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
<value> <string>This business template finalize the upgrade, this should contains the last steps of upgrade system (ie.: Clear Cache).</string> </value> <value> <string>This step will run all constraints that have contraint_type equal pre_upgrade.</string> </value>
</item> </item>
<item> <item>
<key> <string>enabled</string> </key> <key> <string>enabled</string> </key>
...@@ -24,7 +28,7 @@ ...@@ -24,7 +28,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>finalize_upgrader</string> </value> <value> <string>upgrader_check_pre_upgrade</string> </value>
</item> </item>
<item> <item>
<key> <string>periodicity_hour</string> </key> <key> <string>periodicity_hour</string> </key>
...@@ -68,7 +72,7 @@ ...@@ -68,7 +72,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1136073600.0</float> <float>1384423200.0</float>
<string>GMT</string> <string>GMT</string>
</tuple> </tuple>
</state> </state>
...@@ -87,15 +91,17 @@ ...@@ -87,15 +91,17 @@
</item> </item>
<item> <item>
<key> <string>sense_method_id</string> </key> <key> <string>sense_method_id</string> </key>
<value> <string>Alarm_senseFinalizeUpgrade</string> </value> <value>
<none/>
</value>
</item> </item>
<item> <item>
<key> <string>solve_method_id</string> </key> <key> <string>solve_method_id</string> </key>
<value> <string>Alarm_upgradeFinalize</string> </value> <value> <string>Alarm_runPreUpgrade</string> </value>
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string>Finalize Upgrader</string> </value> <value> <string>Run Pre Upgrade</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -6,6 +6,10 @@ ...@@ -6,6 +6,10 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>active_sense_method_id</string> </key>
<value> <string>Alarm_senseUpgradeNeed</string> </value>
</item>
<item> <item>
<key> <string>alarm_notification_mode</string> </key> <key> <string>alarm_notification_mode</string> </key>
<value> <value>
...@@ -16,7 +20,7 @@ ...@@ -16,7 +20,7 @@
</item> </item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
<value> <string>This Alarm check that bt5 are the right ones. If not, it upgrades the bt5 using SVN (for dedicate instances) or using shared repository for Free / Express instances.</string> </value> <value> <string>This step will run all constraints that have contraint_type equal upgrader.</string> </value>
</item> </item>
<item> <item>
<key> <string>enabled</string> </key> <key> <string>enabled</string> </key>
...@@ -24,7 +28,7 @@ ...@@ -24,7 +28,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>bt5_upgrader</string> </value> <value> <string>upgrader_check_upgrader</string> </value>
</item> </item>
<item> <item>
<key> <string>periodicity_hour</string> </key> <key> <string>periodicity_hour</string> </key>
...@@ -68,7 +72,7 @@ ...@@ -68,7 +72,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1136073600.0</float> <float>1384423200.0</float>
<string>GMT</string> <string>GMT</string>
</tuple> </tuple>
</state> </state>
...@@ -87,15 +91,17 @@ ...@@ -87,15 +91,17 @@
</item> </item>
<item> <item>
<key> <string>sense_method_id</string> </key> <key> <string>sense_method_id</string> </key>
<value> <string>Alarm_senseBT5Version</string> </value> <value>
<none/>
</value>
</item> </item>
<item> <item>
<key> <string>solve_method_id</string> </key> <key> <string>solve_method_id</string> </key>
<value> <string>Alarm_upgradeBT5Version</string> </value> <value> <string>Alarm_runUpgrader</string> </value>
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string>BT5 Upgrader</string> </value> <value> <string>Run Upgrader</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
<property_sheet_list>
<portal_type id="Template Tool">
<item>TemplateToolUpgraderConstraint</item>
</portal_type>
</property_sheet_list>
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Property Sheet" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>TemplateToolPostUpgradeConstraint</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Property Sheet</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Length" module="BTrees.Length"/>
</pickle>
<pickle> <int>0</int> </pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Script Constraint" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>constraint_type/post_upgrade</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>workflow_chain_constraint</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Script Constraint</string> </value>
</item>
<item>
<key> <string>script_id</string> </key>
<value> <string>TemplateTool_checkPostUpgradeWorkflowChainConsistency</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Property Sheet" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>TemplateToolUpgraderConstraint</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Property Sheet</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Length" module="BTrees.Length"/>
</pickle>
<pickle> <int>0</int> </pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Script Constraint" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>constraint_type/upgrader</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>business_template_installed_constraint</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Script Constraint</string> </value>
</item>
<item>
<key> <string>script_id</string> </key>
<value> <string>TemplateTool_checkUpgradeConsistency</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="SQL" module="Products.ZSQLMethods.SQL"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_col</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>name</string> </key>
<value> <string>Field</string> </value>
</item>
<item>
<key> <string>null</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>t</string> </value>
</item>
<item>
<key> <string>width</string> </key>
<value> <int>18</int> </value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>name</string> </key>
<value> <string>Type</string> </value>
</item>
<item>
<key> <string>null</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>t</string> </value>
</item>
<item>
<key> <string>width</string> </key>
<value> <int>19</int> </value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>name</string> </key>
<value> <string>Null</string> </value>
</item>
<item>
<key> <string>null</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>t</string> </value>
</item>
<item>
<key> <string>width</string> </key>
<value> <int>3</int> </value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>name</string> </key>
<value> <string>Key</string> </value>
</item>
<item>
<key> <string>null</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>t</string> </value>
</item>
<item>
<key> <string>width</string> </key>
<value> <int>3</int> </value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>name</string> </key>
<value> <string>Default</string> </value>
</item>
<item>
<key> <string>null</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>t</string> </value>
</item>
<item>
<key> <string>width</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>name</string> </key>
<value> <string>Extra</string> </value>
</item>
<item>
<key> <string>null</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>t</string> </value>
</item>
<item>
<key> <string>width</string> </key>
<value> <int>0</int> </value>
</item>
</dictionary>
</list>
</value>
</item>
<item>
<key> <string>arguments_src</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>connection_id</string> </key>
<value> <string>cmf_activity_sql_connection</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ActivityTool_showMessageQueueTableColumns</string> </value>
</item>
<item>
<key> <string>src</string> </key>
<value> <string>show columns from message_queue</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="SQL" module="Products.ZSQLMethods.SQL"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>arguments_src</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>connection_id</string> </key>
<value> <string>cmf_activity_sql_connection</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ActivityTool_upgradeMessageQueueTable</string> </value>
</item>
<item>
<key> <string>src</string> </key>
<value> <string>alter table message_queue add column `group_method_id` VARCHAR(255) NOT NULL DEFAULT \'\' AFTER `priority`</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -51,32 +51,27 @@ ...@@ -51,32 +51,27 @@
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n <value> <string>portal = context.getPortalObject()\n
message_list = []\n constraint_type_per_type, _ = context.Base_getConstraintTypeListPerPortalType()\n
is_upgrade_required = 0\n constraint_type = filter_dict.get("constraint_type")\n
site_property_dict = portal.ERP5Site_getUpgraderSignature().get(\'erp5_site_property_dict\', {})\n
\n \n
for prop in site_property_dict:\n for portal_type, constraint_type_list in constraint_type_per_type.iteritems():\n
if site_property_dict[prop] != getattr(portal,prop , None):\n if not constraint_type and constraint_type not in constraint_type_list:\n
if not upgrade:\n continue\n
return ["Upgrade Required for Global Properties."]\n method_kw = {\'fixit\': fixit,\n
is_upgrade_required = 1\n \'filter\': filter_dict,\n
break\n \'active_process\': active_process.getRelativeUrl()}\n
\n portal.portal_catalog.searchAndActivate(\'Base_postCheckConsistencyResult\',\n
if is_upgrade_required:\n portal_type=portal_type,\n
for prop in site_property_dict:\n method_kw=method_kw)\n
portal.ERP5Site_editERP5SiteProperty(prop, site_property_dict[prop])\n
message_list.append("Upgrade Executed for Global Properties (%s)." % prop)\n
\n
return message_list\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>upgrade=0</string> </value> <value> <string>active_process, fixit=False, filter_dict={}</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>ERP5Site_upgradeGlobalPropertyList</string> </value> <value> <string>Alarm_checkUpgraderConsistency</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -50,38 +50,43 @@ ...@@ -50,38 +50,43 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>"""\n <value> <string>if REQUEST is not None:\n
Migrate Object Classes based on upgrade signature\n from zExceptions import Unauthorized\n
"""\n raise Unauthorized("You can not call this script from the url")\n
class_signature_list = context.ERP5Site_getUpgraderSignature().get(\'upgrade_object_class_list\', [])\n \n
alarm_id_list = ("upgrader_check_pre_upgrade",\n
"upgrader_check_upgrader",\n
"upgrader_check_post_upgrade")\n
\n \n
portal = context.getPortalObject()\n portal = context.getPortalObject()\n
portal_alarms = portal.portal_alarms\n
message_list = []\n message_list = []\n
\n \n
test_only = not upgrade\n for alarm_id in alarm_id_list:\n
\n alarm = getattr(portal_alarms, alarm_id, None)\n
for object_class in class_signature_list:\n if alarm is not None and alarm.sense():\n
folder, test_before , from_class, to_class , test_after = object_class\n last_active_process = alarm.getLastActiveProcess()\n
folder_object = portal.restrictedTraverse(folder)\n result_list = last_active_process.getResultList()\n
test_before_method = getattr(context, test_before )\n if result_list:\n
test_after_method = getattr(context, test_after )\n detail = result_list[0].detail\n
result = folder_object.upgradeObjectClass(test_before_method, \n else:\n
from_class, \n detail = ["Require solve %s" % alarm_id,]\n
to_class, \n message_list.extend(detail)\n
test_after_method, \n
test_only)\n
message_list.extend(result)\n
\n \n
return message_list\n active_process = portal.restrictedTraverse(active_process)\n
if message_list:\n
active_process.postActiveResult(\n
summary=context.getTitle(),\n
severity=1, detail=message_list)\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>upgrade=0</string> </value> <value> <string>active_process, REQUEST=None</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>ERP5Site_upgradeObjectClass</string> </value> <value> <string>Alarm_postFullUpgradeNeed</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -53,35 +53,42 @@ ...@@ -53,35 +53,42 @@
<value> <string encoding="cdata"><![CDATA[ <value> <string encoding="cdata"><![CDATA[
"""\n """\n
Here we make sure the installed bt5 are the right ones.\n Run upgrader\n
If the installed bt5 are too old, then they must be upgraded\n """\n
portal = context.getPortalObject()\n
portal_alarms = portal.portal_alarms\n
\n \n
NOTE: some day, we will mix multiple bt5 sources. The code\n def launchUpgraderAlarm(alarm_id, after_method_id=[]):\n
will be a bit longer. It could be a good idea to create\n """ Get the alarm and use sense and solve """\n
a kind of dict or a central data structure somewhere (like\n upgrader_alarm = getattr(portal_alarms, alarm_id, None)\n
the system signature in portal_introspections) instead of\n if upgrader_alarm is not None and upgrader_alarm.sense():\n
having to repeat everywhere 5.4.3 or other release numbers.\n # call solve method\n
kw = dict(tag=alarm_id)\n
if len(after_method_id) > 0:\n
kw["after_method_id"] = after_method_id\n
method_id = upgrader_alarm.getSolveMethodId()\n
if method_id not in (None, \'\'):\n
method = getattr(upgrader_alarm.activate(**kw), method_id)\n
method()\n
return [method_id] + after_method_id\n
return after_method_id\n
\n \n
NOTE: the idea is to call a long list of "check list" scripts,\n previous_method_id = launchUpgraderAlarm(\'upgrader_check_pre_upgrade\')\n
each of which has a "check" part and a "fix" (ie. upgrade) part, just like\n
constraints in ERP5. However, the order is very important\n
for upgrade, unlike constraints. And we need to be able\n
to override upgrade scripts for certain source releases.\n
\n \n
NOTE2: you can split if needed the upgrade process into more\n previous_method_id.extend([\'recursiveImmediateReindexObject\',\n
alarms (this can be useful if restart is needed for example\n \'immediateReindexObject\',\n
between stages of upgrade)\n \'callMethodOnObjectList\'])\n
"""\n
# Setup skins\n
context.ERP5Site_setupUpgraderSkinSelection()\n
\n \n
# Right way is like this\n previous_method_id = launchUpgraderAlarm(\'upgrader_check_upgrader\',\n
# Now start the update\n after_method_id=previous_method_id)\n
\n \n
if len(context.ERP5Site_upgradeBusinessTemplateList()) > 0: \n previous_method_id.append(\'updateBusinessTemplateFromUrl\')\n
return True\n previous_method_id = launchUpgraderAlarm(\'upgrader_check_post_upgrade\',\n
after_method_id=previous_method_id)\n
\n \n
return False\n # Nothing else to do, so we can disable.\n
context.setEnabled(False)\n
return\n
]]></string> </value> ]]></string> </value>
...@@ -92,7 +99,7 @@ return False\n ...@@ -92,7 +99,7 @@ return False\n
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>Alarm_senseBT5Version</string> </value> <value> <string>Alarm_runFullUpgrader</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -51,32 +51,35 @@ ...@@ -51,32 +51,35 @@
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>"""\n <value> <string>"""\n
verify if the workflow was updated, if is not updated update it.\n Run Post upgrade\n
"""\n """\n
workflow_chain_dict = context.ERP5Site_getUpgraderSignature().get(\'workflow_chain_dict\', {})\n portal_alarms = context.getPortalObject().portal_alarms\n
if workflow_chain_dict is None:\n active_process = context.newActiveProcess()\n
# If no signature, ignore.\n
return []\n
\n \n
chain = context.portal_workflow.getWorkflowChainDict()\n # We should not run post upgrade if upgrader was not solved or never executed\n
if chain == workflow_chain_dict:\n alarm = getattr(portal_alarms, \'upgrader_check_upgrader\')\n
return []\n if alarm.sense() in (None, True):\n
active_process.postActiveResult(summary=context.getTitle(),\n
severity=1,\n
detail="Is required run upgrade before solve it. " +\\\n
"You need run active sense once at least on this alarm")\n
return\n
\n \n
if int(upgrade) == 1:\n context.Alarm_checkUpgraderConsistency(fixit=True,\n
context.portal_workflow.manage_changeWorkflows(default_chain = \'\',\n active_process=active_process,\n
props = workflow_chain_dict)\n filter_dict={"constraint_type": ["post_upgrade",]})\n
return ["Upgrade Executed for Workflow Chain."]\n
\n \n
return ["Upgrade Required for Workflow Chain."]\n context.setEnabled(False)\n
return\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>upgrade=0</string> </value> <value> <string>**kw</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>ERP5Site_upgradeWorkflowChain</string> </value> <value> <string>Alarm_runPostUpgrade</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -51,22 +51,23 @@ ...@@ -51,22 +51,23 @@
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>"""\n <value> <string>"""\n
First, change skin order based on introspection \n Run Pre upgrade\n
of the current version which is installed\n
\n
XXX This configuration could be moved to upgrader signature\n
"""\n """\n
context.Alarm_checkUpgraderConsistency(fixit=True,\n
active_process=context.newActiveProcess(),\n
filter_dict={"constraint_type": ["pre_upgrade"]})\n
\n \n
return True\n context.setEnabled(False)\n
return\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string></string> </value> <value> <string>**kw</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>ERP5Site_setupUpgraderSkinSelection</string> </value> <value> <string>Alarm_runPreUpgrade</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -53,21 +53,51 @@ ...@@ -53,21 +53,51 @@
<value> <string encoding="cdata"><![CDATA[ <value> <string encoding="cdata"><![CDATA[
"""\n """\n
Finalize Upgrade is the final step of upgrader. Here should contains\n Run Upgrader\n
the scripts that should be executed after the business template installation.\n \n
IMPORTANT: Don\'t use the constraint_type upgrader to data migration or big amount of objects,\n
because this step is suppose to run all constraints in the same transaction. \n
To not kill the instance, searchAndActivate will be used if countResults() > REINDEX_SPLIT_COUNT\n
"""\n """\n
# Setup skins\n
context.ERP5Site_setupUpgraderSkinSelection()\n
\n \n
alarm_dict = context.ERP5Site_getUpgraderSignature().get(\'alarm_dict\', {})\n REINDEX_SPLIT_COUNT = 100\n
if not alarm_dict.get(context.getId(), True):\n portal = context.getPortalObject()\n
return False\n portal_alarms = portal.portal_alarms\n
active_process = context.newActiveProcess()\n
\n
# We should not run upgrader if pre upgrade was not solved or never executed \n
alarm = getattr(portal_alarms, \'upgrader_check_pre_upgrade\')\n
if alarm.sense() in (None, True):\n
active_process.postActiveResult(summary=context.getTitle(),\n
severity=1,\n
detail="Is required solve Pre Upgrade first. " +\\\n
"You need run active sense once at least on this alarm")\n
return\n
\n
_, type_per_constraint_type = context.Base_getConstraintTypeListPerPortalType()\n
portal_type_list = type_per_constraint_type.get(\'upgrader\', [])\n
\n
tool_portal_type = \'Template Tool\' \n
if tool_portal_type in portal_type_list:\n
portal_type_list.remove(tool_portal_type)\n
\n
method_kw = {\'fixit\': True,\n
\'filter\': {"constraint_type": \'upgrader\'},\n
\'active_process\': active_process.getRelativeUrl()}\n
\n \n
for script_id in context.ERP5Site_getUpgraderSignature().get(\'finalize_upgrade_script_list\', []):\n portal.portal_templates.Base_postCheckConsistencyResult(**method_kw)\n
if len(getattr(context, script_id)()) > 0:\n for portal_type in portal_type_list:\n
return True\n if portal.portal_catalog.countResults(\n
portal_type=portal_type_list)[0][0] > REINDEX_SPLIT_COUNT:\n
portal.portal_catalog.searchAndActivate(\'Base_postCheckConsistencyResult\',\n
portal_type=portal_type,\n
method_kw=method_kw)\n
else:\n
for result in portal.portal_catalog(portal_type=portal_type):\n
result.Base_postCheckConsistencyResult(**method_kw)\n
\n \n
return False\n context.setEnabled(False)\n
return\n
]]></string> </value> ]]></string> </value>
...@@ -78,7 +108,7 @@ return False\n ...@@ -78,7 +108,7 @@ return False\n
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>Alarm_senseFinalizeUpgrade</string> </value> <value> <string>Alarm_runUpgrader</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<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>_body</string> </key>
<value> <string>from Products.ERP5Type.Log import log\n
from Products.CMFActivity.ActiveResult import ActiveResult\n
\n
# Log Result to make debug easy in case of failure.\n
log("Summary: %s , Details: %s " % (summary, detail))\n
\n
active_result = ActiveResult()\n
active_result.edit(summary=summary, severity=severity, detail=detail)\n
return active_result\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>summary, severity=0, detail=\'\'</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Alarm_saveActiveResult</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -53,37 +53,51 @@ ...@@ -53,37 +53,51 @@
<value> <string encoding="cdata"><![CDATA[ <value> <string encoding="cdata"><![CDATA[
"""\n """\n
Verify if this instance is a properly configured one.\n Run upgrader\n
This script could be used in functional tests\n
"""\n """\n
portal = context.getPortalObject()\n portal = context.getPortalObject()\n
portal_alarms = portal.portal_alarms\n
\n \n
message_list = []\n after_method_id = \'callMethodOnObjectList\'\n
def launchSenseAlarm(alarm_id, after_tag=[]):\n
""" Get the alarm and use sense"""\n
upgrader_alarm = getattr(portal_alarms, alarm_id, None)\n
if upgrader_alarm is not None:\n
# call solve method\n
kw = {"tag": alarm_id,\n
"after_method_id": after_method_id}\n
if len(after_tag) > 0:\n
kw["after_tag"] = after_tag\n
method_id = upgrader_alarm.getActiveSenseMethodId()\n
if method_id not in (None, \'\'):\n
method = getattr(upgrader_alarm.activate(**kw), method_id)\n
method()\n
return [alarm_id,]\n
return after_tag\n
\n \n
activity_failure_list = context.portal_activities.getMessageList(processing_node=-2)\n previous_tag = launchSenseAlarm(\'upgrader_check_pre_upgrade\')\n
\n \n
if len(activity_failure_list) > 0:\n previous_tag = launchSenseAlarm(\'upgrader_check_upgrader\',\n
message_list.append("Activity Failures was found (%s)." % (len(activity_failure_list),))\n after_tag=previous_tag)\n
return message_list\n \n
previous_tag = launchSenseAlarm(\'upgrader_check_post_upgrade\',\n
after_tag=previous_tag)\n
\n
active_process = context.newActiveProcess()\n
context.activate(after_tag=previous_tag,\n
after_method_id=after_method_id).Alarm_postFullUpgradeNeed(\n
active_process=active_process.getRelativeUrl())\n
]]></string> </value> ]]></string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string></string> </value> <value> <string>REQUEST=None, **kw</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>ERP5Site_verifyActivityIntegrity</string> </value> <value> <string>Alarm_senseFullUpgradeNeed</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -50,92 +50,18 @@ ...@@ -50,92 +50,18 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[ <value> <string>"""\n
Check if upgrader is required\n
"""\n """\n
This script is used in an alarm that acts as a cron job.\n constraint_type = context.getId().replace("upgrader_check_", "")\n
It will start an instance upgrade if any of the following alarms:\n context.Alarm_checkUpgraderConsistency(\n
- bt5_upgrader (supported)\n active_process=context.newActiveProcess(),\n
\n filter_dict={"constraint_type": constraint_type})\n
"sense" a need of an upgrade. This alarm is likely to disappear soon as it\'s needed \n </string> </value>
due to lack of functionality (which is that alarms can not automatically "solve" themselves).\n
"""\n
# If before script is present call it.\n
before_script = getattr(context, \'ERP5Site_beforeSenseUpgrade\', None)\n
if before_script is not None:\n
before_script()\n
\n
context.ERP5Site_setupUpgraderSkinSelection()\n
\n
portal_alarms = context.getPortalObject().portal_alarms\n
activate = context.portal_activities.activate\n
previous_tag = None\n
\n
# XXX get the last activate process if exists\n
active_process = context.getLastActiveProcess()\n
if active_process is None or ((DateTime() - active_process.getStartDate()) > 1):\n
active_process = context.newActiveProcess()\n
\n
active_process = active_process.getPath()\n
\n
def launchUpgraderAlarm(alarm_id, after_method_id=[]):\n
"""\n
Get the alarm and use sense and solve\n
"""\n
upgrader_alarm = getattr(portal_alarms, alarm_id, None)\n
if upgrader_alarm is not None and upgrader_alarm.sense():\n
# call solve method\n
activate(active_process=active_process,\n
activity=\'SQLQueue\', \n
priority=2).Alarm_saveActiveResult(\n
summary=upgrader_alarm.getTitle(), \n
severity=0, \n
detail="Upgrade Required for %s" % \\\n
(upgrader_alarm.getTitle()))\n
\n
kw = dict(tag=alarm_id)\n
if len(after_method_id) > 0:\n
kw["after_method_id"] = after_method_id\n
# alarm.solve() dos not support activate parameters\n
# so it is not possible to use it directly.\n
method_id = upgrader_alarm.getSolveMethodId()\n
if method_id not in (None, \'\'):\n
method = getattr(upgrader_alarm.activate(**kw), method_id)\n
method()\n
return [ method_id ]\n
return after_method_id\n
\n
# There is one strict order to run the alarms\n
# This is required because the one alarms depends the previous one be\n
# Fully done.\n
previous_method_id = launchUpgraderAlarm(\'bt5_upgrader\')\n
\n
previous_method_id.extend([\'updateBusinessTemplateFromUrl\',\n
\'immediateReindexObject\'])\n
\n
previous_method_id = launchUpgraderAlarm(\'finalize_upgrader\',\n
after_method_id = previous_method_id)\n
\n
for alarm_id in [\'bt5_upgrader\' , \'finalize_upgrader\']:\n
\n
upgrader_alarm = getattr(portal_alarms, alarm_id, None)\n
if upgrader_alarm is not None and upgrader_alarm.sense():\n
# Upgrade still needed for part.\n
#return\n
# XXX Do not retry run upgrader again, this is cause too much\n
# noise during this stage of development.\n
pass\n
\n
# Nothing else to do, so we can disable.\n
context.setEnabled(False)\n
return\n
]]></string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string></string> </value> <value> <string>REQUEST=None, **kw</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<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>_body</string> </key>
<value> <string>"""\n
This script explains how to upgrade bt5. This script only update\n
the business templates, nothing else. Any other post script should\n
be handle by finalize upgrader.\n
"""\n
# Setup skins\n
context.ERP5Site_setupUpgraderSkinSelection()\n
\n
alarm_dict = context.ERP5Site_getUpgraderSignature().get(\'alarm_dict\', {})\n
if not alarm_dict.get(context.getId(), True):\n
return False\n
\n
portal_alarms = context.getPortalObject().portal_alarms\n
activate = context.portal_activities.activate\n
# Group Messages into the same active process.\n
active_process = portal_alarms.upgrader_controller.getLastActiveProcess()\n
if active_process is None:\n
active_process = context.newActiveProcess()\n
\n
active_process = active_process.getPath()\n
\n
message_list = []\n
\n
# update existing bt5\n
message_list.extend(context.ERP5Site_upgradeBusinessTemplateList(upgrade=1))\n
\n
activate(active_process=active_process,\n
activity=\'SQLQueue\',\n
priority=2).Alarm_saveActiveResult(summary="Upgrade BT5 Version",\n
severity=0,\n
detail=\'\\n\'.join(message_list))\n
\n
return message_list\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>**kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Alarm_upgradeBT5Version</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<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>_body</string> </key>
<value> <string>"""\n
Finalize Upgrade is the final step of upgrader. Here should contains\n
the scripts that should be executed after the business template installation.\n
"""\n
# Setup skins\n
context.ERP5Site_setupUpgraderSkinSelection()\n
\n
clear_cache_kw = dict(activity=\'SQLQueue\', \n
priority=3, \n
tag="tag_upgrader_clear_cache")\n
\n
portal_alarms = context.getPortalObject().portal_alarms\n
activate = context.portal_activities.activate\n
# Group Messages into the same active process.\n
active_process = portal_alarms.upgrader_controller.getLastActiveProcess()\n
if active_process is None:\n
active_process = context.newActiveProcess()\n
\n
active_process = active_process.getPath()\n
\n
message_list = []\n
bt5_upgrader_sense = portal_alarms.bt5_upgrader.sense()\n
if bt5_upgrader_sense:\n
activate(active_process=active_process,\n
activity=\'SQLQueue\',\n
priority=2).Alarm_saveActiveResult(\n
summary="ERROR: Finalize Upgrader not started",\n
severity=0,\n
detail=\'BT5 Upgrader Sense: %s\' % (bt5_upgrader_sense))\n
\n
for script_id in context.ERP5Site_getUpgraderSignature().get(\'finalize_upgrade_script_list\', []):\n
message_list.extend(getattr(context, script_id)(upgrade=1))\n
\n
activate(active_process=active_process,\n
activity=\'SQLQueue\',\n
priority=2).Alarm_saveActiveResult(summary="Finalize Upgrade",\n
severity=0,\n
detail=\'\\n\'.join(message_list))\n
\n
clear_cache_kw[\'after_method_id\'] = [\'Alarm_saveActiveResult\',\'immediateReindexObject\']\n
context.portal_caches.activate(**clear_cache_kw).clearAllCache()\n
\n
activate(active_process=active_process,\n
activity=\'SQLQueue\',\n
priority=4,\n
after_tag=clear_cache_kw[\'tag\']).ERP5Site_notifyUpgradeIntegrity(active_process=active_process)\n
\n
return message_list\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>**kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Alarm_upgradeFinalize</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -50,50 +50,69 @@ ...@@ -50,50 +50,69 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>"""\n <value> <string>portal = context.getPortalObject()\n
Verify if this instance is a properly configured one.\n constraint_type_list = portal.getPortalConstraintTypeList()\n
This script could be used in functional tests\n
"""\n
\n \n
portal = context.getPortalObject()\n property_sheet_by_type_dict = {}\n
for portal_type in portal.portal_types.objectValues():\n
property_sheet_list = portal_type.getTypePropertySheetList()\n
if not property_sheet_list:\n
continue\n
for property_sheet in property_sheet_list:\n
property_sheet_by_type_dict.setdefault(\n
property_sheet, []).append(portal_type.getId())\n
\n \n
message_list = []\n type_per_constraint_type = {}\n
constraint_type_per_id = {}\n
for property_sheet in portal.portal_property_sheets.objectValues():\n
constraint_list = property_sheet.objectValues(\n
portal_type=constraint_type_list)\n
if not constraint_list:\n
continue\n
type_list = []\n
type_list_append = type_list.append\n
property_sheet_id = property_sheet.getId()\n
for constraint in constraint_list:\n
method = getattr(constraint, \'getConstraintType\', None)\n
if not method:\n
continue\n
constraint_type = method()\n
if constraint_type:\n
if property_sheet_id in property_sheet_by_type_dict:\n
type_per_constraint_type.setdefault(\n
constraint_type, []).extend(\n
property_sheet_by_type_dict[property_sheet_id])\n
type_list_append(constraint_type)\n
if type_list:\n
constraint_type_per_id.setdefault(property_sheet_id, []).extend(type_list)\n
\n \n
message_list.extend(context.ERP5Site_upgradeBusinessTemplateList())\n constraint_type_per_type = {}\n
for property_sheet_id, category_list in constraint_type_per_id.iteritems():\n
for portal_type in property_sheet_by_type_dict.get(property_sheet_id, []):\n
constraint_type_per_type.setdefault(portal_type, []).extend(category_list)\n
\n \n
message_list.extend(context.ERP5Site_upgradeGlobalPropertyList())\n portal_type_tool = portal.portal_types\n
portal_type_list = constraint_type_per_type.keys()\n
\n \n
message_list.extend(context.ERP5Site_upgradeValidationStateList())\n for portal_type in portal_type_list:\n
allowed_content_type_list = \\\n
portal_type_tool[portal_type].getTypeAllowedContentTypeList()\n
for allowed_content_type in allowed_content_type_list:\n
if allowed_content_type in portal_type_list:\n
type_list = constraint_type_per_type.pop(allowed_content_type)\n
for constraint_type in type_list:\n
type_per_constraint_type[constraint_type].remove(allowed_content_type)\n
\n \n
message_list.extend(context.ERP5Site_upgradeWorkflowChain())\n return constraint_type_per_type, type_per_constraint_type\n
\n
message_list.extend(context.ERP5Site_upgradeSQLCatalog())\n
\n
if getattr(context, \'WizardTool_isPersonReferenceGloballyUnique\', None) is not None:\n
if len(context.PersonModule_getUserAccountList(\'occupied\')) == 0 and \\\n
getattr(portal.acl_users, \'nexedi_authentication\', None) is not None:\n
# If there is collision this verification should not be launch be\n
# because it should fail anyway.\n
message_list.extend(context.ERP5Site_upgradeData())\n
\n
return message_list\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>ERP5Site_verifyUpgradeIntegrity</string> </value> <value> <string>Base_getConstraintTypeListPerPortalType</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -50,17 +50,23 @@ ...@@ -50,17 +50,23 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n <value> <string>"""\n
portal.manage_addProperty(\'custom_property_without_meaning\', \'I was there\', \'string\')\n This script should returns always two list of Business Template.\n
- The first list is to resolve dependencies and upgrade.\n
- The second list is what you want to keep. This is useful if we want to keep \n
a old business template without updating it and without removing it\n
"""\n
\n
return (\'erp5_base\',), []\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string></string> </value> <value> <string>fixit=False</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>ERP5Site_updateSitePropertyForTestOnly</string> </value> <value> <string>Base_getUpgradeBusinessTemplateList</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -50,36 +50,32 @@ ...@@ -50,36 +50,32 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>"""\n <value> <string>traverse = context.getPortalObject().restrictedTraverse\n
Verify instance integrity launch all Integrity Verification scripts. \n active_process = traverse(active_process)\n
\n \n
Run all verification scripts defined at Signature.\n # We don\'t need check more if something is already inconsistent\n
"""\n if (active_process.ActiveProcess_sense() and not fixit):\n
message_list = []\n return\n
\n \n
for script_id in context.ERP5Site_getUpgraderSignature().get(\'integrity_verification_script_id_list\', []):\n constraint_message_list = context.checkConsistency(fixit=fixit,\n
result = context.ERP5Site_runVerificationScript(script_id)\n filter=filter)\n
if result is not None:\n
message_list.append(result)\n
\n \n
return message_list\n if constraint_message_list and not active_process.getResultList():\n
summary = "%s Consistency - At least one inconsistent object found" % \\\n
(fixit and \'Fix\' or \'Check\')\n
active_process.postActiveResult(\n
severity=(not fixit and 1) or 0,\n
summary=summary,\n
detail=[m.message for m in constraint_message_list])\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string></string> </value> <value> <string>fixit, filter, active_process</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>ERP5Site_verifyInstanceIntegrity</string> </value> <value> <string>Base_postCheckConsistencyResult</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ExternalMethod" module="Products.ExternalMethod.ExternalMethod"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_function</string> </key>
<value> <string>ERP5Site_clearActivities</string> </value>
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>ERP5UpgraderUtils</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_clearActivities</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_function</string> </key> <key> <string>_function</string> </key>
<value> <string>ERP5Site_runVerificationScript</string> </value> <value> <string>ERP5Site_dumpWorkflowChainByPortalType</string> </value>
</item> </item>
<item> <item>
<key> <string>_module</string> </key> <key> <string>_module</string> </key>
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>ERP5Site_runVerificationScript</string> </value> <value> <string>ERP5Site_dumpWorkflowChainByPortalType</string> </value>
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ExternalMethod" module="Products.ExternalMethod.ExternalMethod"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_function</string> </key>
<value> <string>ERP5Site_editERP5SiteProperty</string> </value>
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>ERP5UpgraderUtils</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_editERP5SiteProperty</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<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>_body</string> </key>
<value> <string>"""\n
Site\'s version is the version of the erp5_core business template\n
This script could be moved to should use System Signature or \n
simple replaced by:\n
portal_instropections.getSystemSignature()["business_templates"]\n
"""\n
bt5 = context.getPortalObject().portal_templates.getInstalledBusinessTemplate("erp5_core")\n
return str(bt5.getVersion())\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_getBusinessTemplateVersion</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ExternalMethod" module="Products.ExternalMethod.ExternalMethod"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_function</string> </key>
<value> <string>ERP5Site_restartZopeInstance</string> </value>
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>ERP5UpgraderUtils</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_restartZopeInstance</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<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>_body</string> </key>
<value> <string>"""\n
"""\n
message_list = []\n
portal_alarms = context.portal_alarms\n
alarm_tool_configuration_list = context.ERP5Site_getUpgraderSignature().get(\'alarm_tool_configuration_list\', [])\n
if alarm_tool_configuration_list is None:\n
return message_list\n
\n
for alarm_id, is_enabled in alarm_tool_configuration_list: \n
obj = getattr(portal_alarms, alarm_id, None)\n
if obj is not None and int(obj.getEnabled()) != int(is_enabled):\n
message = "Upgrade is required for Alarm %s, enabled = %s (expected %s)" % \\\n
(alarm_id, obj.getEnabled(),is_enabled )\n
if int(upgrade) == 1:\n
obj.setEnabled(int(is_enabled))\n
message = "[ UPDATED ] " + message\n
message_list.append(message)\n
\n
return message_list\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>upgrade=0</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_upgradeAlarmToolConfiguration</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<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>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
"""\n
Check installed business templates one \n
by one. If one of the business templates does not \n
use the latest revision, then we need to install.\n
"""\n
# Initialize variables\n
portal = context.getPortalObject()\n
portal_templates = portal.portal_templates\n
signature = portal.ERP5Site_getUpgraderSignature()\n
message_list = []\n
\n
previous_bt5_id = None\n
bt5_counter = 0\n
available_bt5_list = portal_templates.getRepositoryBusinessTemplateList(newest_only=True)\n
available_bt5_id_list = [x.title for x in available_bt5_list]\n
required_bt5_id_list = signature.get(\'required_bt5_id_list\', [])\n
upgradable_bt5_id_list = signature.get(\'upgradable_bt5_id_list\', [])\n
if len(upgradable_bt5_id_list) == 0:\n
# by default, we try to upgrade all installed business templates.\n
upgradable_bt5_id_list = portal_templates.getInstalledBusinessTemplateTitleList()\n
reinstallable_bt5_id_list = signature.get(\'reinstallable_bt5_id_list\', signature.get(\'reinstalable_bt5_id_list\', []))\n
before_triggered_bt5_id_dict = signature.get(\'before_triggered_bt5_id_dict\', {})\n
after_triggered_bt5_id_dict = signature.get(\'after_triggered_bt5_id_dict\', {})\n
update_catalog_bt5_id_list = signature.get(\'update_catalog_bt5_id_list\', [])\n
not_upgradable_id_list = signature.get(\'not_upgradable_id_list\', [])\n
\n
bt5_id_list = dict([(x, True) for x in list(required_bt5_id_list) + \\\n
list(upgradable_bt5_id_list) + \\\n
list(reinstallable_bt5_id_list) \\\n
if x in available_bt5_id_list and x not in not_upgradable_id_list]).keys()\n
\n
# sort by dependencies\n
bt5_list = [portal_templates.decodeRepositoryBusinessTemplateUid(x.uid) for x in \\\n
available_bt5_list if x.title in bt5_id_list]\n
bt5_list = portal_templates.sortBusinessTemplateList(bt5_list)\n
\n
installed_bt5_title_list = [o.getTitle() for o in portal_templates.getInstalledBusinessTemplateList()]\n
\n
bt5_counter = portal_templates.countFolder()[0][0]\n
\n
def installBT5(bt5_url, bt5_title, previous_bt5, bt5_counter, force=False):\n
bt5_id = "%s_%s" % (bt5_counter, bt5_title)\n
kw = dict(activity="SQLQueue", tag=bt5_id)\n
if previous_bt5 is not None:\n
kw[\'after_tag\'] = previous_bt5\n
# We must make sure all documents from previous installations \n
# are already indexed (specially categories).\n
kw[\'after_method_id\'] = "immediateReindexObject"\n
update_catalog = bt5_title in update_catalog_bt5_id_list\n
before_triggered_bt5_id_list = before_triggered_bt5_id_dict.get(bt5_title, ())\n
after_triggered_bt5_id_list = after_triggered_bt5_id_dict.get(bt5_title, ())\n
keep_original_list = signature.get(\'keep_original_dict\', {}).get(bt5_title, ())\n
if upgrade:\n
portal_templates.activate(**kw).updateBusinessTemplateFromUrl(\n
bt5_url, # id=bt5_id, \n
keep_original_list=keep_original_list,\n
before_triggered_bt5_id_list=before_triggered_bt5_id_list,\n
after_triggered_bt5_id_list=after_triggered_bt5_id_list,\n
update_catalog=update_catalog,\n
reinstall=force)\n
previous_bt5_id = bt5_id\n
bt5_counter += 1\n
message_list.append("%s will be installed" % bt5_url)\n
return bt5_id\n
\n
previous_bt5 = None\n
for repository, bt5_id in bt5_list:\n
new_bt = [x for x in available_bt5_list \\\n
if portal_templates.decodeRepositoryBusinessTemplateUid(x.uid) == (repository, bt5_id)][0]\n
bt5_url = \'/\'.join((repository, bt5_id))\n
bt5_title = new_bt.title\n
if bt5_title in reinstallable_bt5_id_list:\n
bt5_id = installBT5(bt5_url, bt5_title, previous_bt5, bt5_counter, force=True)\n
previous_bt5 = bt5_id\n
else:\n
installed_bt = portal_templates.getInstalledBusinessTemplate(bt5_title, strict=True)\n
if installed_bt is not None:\n
if int(installed_bt.getRevision() or 0) >= int(new_bt.revision or 0):\n
continue\n
if bt5_title in required_bt5_id_list:\n
bt5_counter += 1\n
bt5_id = installBT5(bt5_url, bt5_title, previous_bt5, bt5_counter)\n
previous_bt5 = bt5_id\n
elif bt5_title in installed_bt5_title_list: # update_bt5_id_list\n
bt5_counter += 1\n
bt5_id = installBT5(bt5_url, bt5_title, previous_bt5, bt5_counter)\n
previous_bt5 = bt5_id\n
\n
return message_list\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>upgrade=0</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_upgradeBusinessTemplateList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<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>_body</string> </key>
<value> <string>"""\n
It is expected that some objects has some state in the after upgrade finish.\n
This alarm verify and upgrade the objects that were defined in signature.\n
"""\n
from Products.ERP5Type.Log import log\n
portal_templates = context.portal_templates\n
validation_dict = context.ERP5Site_getUpgraderSignature().get(\'object_action_dict\', {})\n
param_not_provided = "PARAM_NOT_PROVIDED"\n
\n
# get list of title of bt5 that are installed.\n
installed_bt5_title_list = [t.getTitle() for t in portal_templates.getInstalledBusinessTemplateList()]\n
\n
# get the list of keys that correspond to a valid business template.\n
upgradable_list = []\n
for k in validation_dict.keys():\n
if k in installed_bt5_title_list:\n
upgradable_list.extend(validation_dict[k])\n
\n
message_list = []\n
for definition in upgradable_list:\n
if len(definition) == 5:\n
path, method_id, expected_state, action, param_list = definition\n
else:\n
path, method_id, expected_state, action = definition\n
param_list = param_not_provided\n
sub_message_list = []\n
try:\n
obj = context.restrictedTraverse(path)\n
except KeyError:\n
obj = None\n
log("Unable to find %s" % path)\n
if obj is not None:\n
method = getattr(obj, method_id, None)\n
if method is not None and method() == expected_state:\n
sub_message_list.append("Upgrade is required for Object List (%s object is in %s state, action %s.)" %\n
(path, expected_state, action))\n
if int(upgrade) == 1:\n
action_method = getattr(obj, action , None)\n
if action_method is not None:\n
if param_list == param_not_provided:\n
action_method()\n
else:\n
action_method(*param_list)\n
sub_message_list.append("[UPDATED]")\n
message_list.append(\' \'.join(sub_message_list))\n
\n
return message_list\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>upgrade=0</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_upgradeObjectList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<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>_body</string> </key>
<value> <string>"""\n
Verify if a Property Sheet is associated with the Portal Type.\n
"""\n
\n
message_list = []\n
\n
portal_type_property_sheet_list = context.ERP5Site_getUpgraderSignature().get(\'portal_type_property_sheet_list\', [])\n
\n
for expected_property_sheet, portal_type_id_list in portal_type_property_sheet_list:\n
\n
portal_type_list = context.portal_types.searchFolder(id=portal_type_id_list)\n
portal_type_to_fix = []\n
\n
for pt in portal_type_list:\n
property_sheet_list = pt.getTypePropertySheetList()\n
if expected_property_sheet not in pt.getTypePropertySheetList():\n
if upgrade:\n
property_sheet_list.append(expected_property_sheet)\n
pt.setTypePropertySheet(property_sheet_list)\n
message_list.append("Associate PropertySheet %s into Portal Type %s." % (expected_property_sheet,pt.getId()))\n
else:\n
message_list.append("%s doesn\'t has %s associated." % (pt.getId(), expected_property_sheet))\n
\n
return message_list\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>upgrade=0</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_upgradePortalTypePropertySheet</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<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>_body</string> </key>
<value> <string>"""\n
Update SQLCatalog, this script update the catalog when it is needed.\n
Finalize Upgrade never make sense become True, because there is no\n
standard way to detect if the SQLUpgrade is needed. Reindexation should \n
be only a consequence of other script only.\n
"""\n
signature = context.ERP5Site_getUpgraderSignature()\n
if not signature.get("recatalog", True):\n
return []\n
\n
if not upgrade:\n
# Never consider outdated.\n
return []\n
\n
# Could we consider always update this after some business templates\n
# was updated?\n
message_list = []\n
\n
if not upgrade:\n
# Upgrade Required\n
return [\'Upgrade required for SQLCatalog\']\n
\n
catalog = context.portal_catalog.getSQLCatalog()\n
\n
# clear the catalog\n
catalog.manage_catalogClear()\n
message_list.append("Catalog %s was Clear." % (catalog.getId()))\n
\n
tag = "tag_migration_finish"\n
# reindex the while site\n
context.getPortalObject().ERP5Site_reindexAll(final_activity_tag=tag)\n
message_list.append("Launched Reindex of ERP5.")\n
# update translation\n
context.getPortalObject().ERP5Site_updateTranslationTable()\n
message_list.append("Update Translation Table.")\n
return message_list\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>upgrade=0</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_upgradeSQLCatalog</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<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>_body</string> </key>
<value> <string>message_list = []\n
expect_expression_dict = context.ERP5Site_getUpgraderSignature().get(\'catalog_filter_dict\', None)\n
if expect_expression_dict is None:\n
# If key is not provided, ignore.\n
return []\n
\n
catalog = context.portal_catalog.erp5_mysql_innodb\n
\n
filter_dict = catalog.getFilterDict()\n
catalog_filter_dict = {}\n
for key in filter_dict:\n
catalog_filter_dict[key] = filter_dict[key][\'expression\']\n
\n
# test if keys are the same\n
for key in expect_expression_dict:\n
if expect_expression_dict[key] != catalog_filter_dict[key]:\n
message_list.append("Wrong expression definition found at %s: %s (Expected) != %s (Found)" % (key, expect_expression_dict[key], catalog_filter_dict[key]))\n
\n
if not upgrade:\n
return message_list\n
\n
message_list = []\n
# test if keys are the same\n
for key in expect_expression_dict:\n
if expect_expression_dict[key] != catalog_filter_dict[key]:\n
message_list.append("Upgraded Catalog Filter Expression definition found at %s ." % (key))\n
catalog.setFilterExpression(key, expect_expression_dict[key])\n
return message_list\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>upgrade=0</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_upgradeSQLCatalogFilter</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<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>_body</string> </key>
<value> <string>"""\n
Place for add Security or Roles upgrade.\n
\n
There is tools and new modules added by upgrader\n
and those the roles should be updated. \n
\n
ie.: Make Web site available for old instances or\n
update local roles.\n
\n
"""\n
message_list = []\n
\n
# Currently is never needed to update security, it is always forced.\n
if not upgrade:\n
return message_list\n
\n
portal = context.getPortalObject()\n
portal_workflow = portal.portal_workflow\n
workflow_id_list = portal.ERP5Site_getUpgraderSignature().get(\'update_security_workflow_id_list\', [])\n
for workflow_id in workflow_id_list:\n
workflow = getattr(portal_workflow, workflow_id, None)\n
if workflow is not None:\n
workflow.updateRoleMappings()\n
\n
message_list.append(\n
"Update workflow security for: \\n\\t%s" % \\\n
(\'\\n\\t\'.join(workflow_id_list)))\n
\n
types_tool = portal.portal_types\n
portal_type_list = portal.ERP5Site_getUpgraderSignature().get(\'update_role_portal_type_list\', [])\n
\n
for pt in portal_type_list:\n
# Note: Raises on purpose\n
types_tool[pt].updateRoleMapping()\n
\n
message_list.append(\n
"Update Local Roles for security groups for: \\n\\t%s" % \\\n
(\'\\n\\t\'.join(portal_type_list)))\n
\n
return message_list\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>upgrade=0</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_upgradeSecurity</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<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>_body</string> </key>
<value> <string>"""\n
Verify if this instance is a properly configured one.\n
This script could be used in functional tests\n
"""\n
plugin_id_list = [\'default_memcached_plugin\',\'persistent_memcached_plugin\']\n
portal = context.getPortalObject()\n
key_prefix = \'upgrade_verification\'\n
if getattr(portal, "erp5_site_global_id", None) == "test_client_chroot":\n
# This is a test environment so all instance will have the same prefix.\n
# change key_prefix to prevent useless failure.\n
key_prefix = \'upgrade_verification%s\' % str(float(DateTime()))\n
\n
message_list = []\n
\n
def assertEquals(value1, value2, label=""):\n
if not (value1 == value2):\n
message_list.append("Memcached: %s Fail (%s != %s)" % (label, value1, value2))\n
\n
def assertNotEquals(value1, value2, label=""):\n
if not (value1 != value2):\n
message_list.append("Memcached: %s Fail (%s == %s)" % (label, value1, value2))\n
\n
# Verify if memcached and plugins are present into the instance\n
portal_memcached = getattr(portal, "portal_memcached", None)\n
if portal_memcached is not None:\n
plugin_object_id_list = portal_memcached.objectIds()\n
for plugin_id in plugin_id_list:\n
if plugin_id not in plugin_object_id_list:\n
message_list.append("Memcached plugin %s is not present." % plugin_id)\n
else: \n
message_list.append("Portal Memcached is not present.")\n
\n
# Test Plugins\n
def getMemcachedDict(plugin_path):\n
return portal_memcached.getMemcachedDict(key_prefix=key_prefix, \n
plugin_path=plugin_path)\n
\n
# If this is not None the value was get from another instance\n
site_id = getattr(portal, "erp5_site_global_id", None)\n
for plugin_id in plugin_id_list:\n
plugin_object = getMemcachedDict(\'portal_memcached/%s\' % plugin_id)\n
if plugin_object.get("upgrade_verification_key") in ("Foo Bar", None):\n
# Solve some possible legacy.\n
plugin_object["upgrade_verification_key"] = site_id\n
assertEquals(plugin_object.get("upgrade_verification_key", site_id),\n
site_id, "upgrade_verification_key")\n
plugin_object.set("upgrade_verification_key", site_id)\n
assertEquals(plugin_object.get("upgrade_verification_key", None),\n
site_id, "upgrade_verification_key")\n
\n
return message_list\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_verifyMemcachedIntegrity</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<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>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
message_list = []\n
\n
catalog = context.portal_catalog.erp5_mysql_innodb\n
filter_dict = catalog.getFilterDict()\n
catalog_filter_dict = {}\n
for key in filter_dict:\n
catalog_filter_dict[key] = filter_dict[key][\'expression\']\n
\n
expect_expression_dict = context.ERP5Site_getUpgraderSignature().get(\'catalog_filter_dict\', {})\n
\n
if len(catalog_filter_dict.keys()) != len(expect_expression_dict.keys()):\n
message_list.append("Catalog filter have diferent key lenght (%s != %s): %s != %s" % \\\n
(len(catalog_filter_dict.keys()), len(expect_expression_dict.keys()),\n
catalog_filter_dict.keys(), expect_expression_dict.keys()))\n
\n
missing_key_list = [ key for key in expect_expression_dict if key not in catalog_filter_dict ]\n
\n
if len(missing_key_list) > 0:\n
message_list.append("Missing keys at Catalog filter: %s" % missing_key_list)\n
\n
for key in expect_expression_dict:\n
if expect_expression_dict[key] != catalog_filter_dict[key]:\n
message_list.append("Wrong expression definition found at %s: %s (Expected) != %s (Found)" % (key, expect_expression_dict[key], catalog_filter_dict[key]))\n
\n
real_data_verified = 0\n
for person in context.getPortalObject().person_module.contentValues():\n
organisation = person.getSubordinationValue()\n
if organisation is not None:\n
real_data_verified = 1\n
if person not in organisation.getSubordinationRelatedValueList(portal_type=\'Person\'):\n
message_list.append("Catalog is broken. Acquired categories are not in category table.")\n
# it is enough to check one object - there is full reindex done\n
break\n
\n
if not real_data_verified:\n
message_list.append("It was not possible to verify catalog integrity using real data.")\n
return message_list\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_verifySQLCatalogFilterIntegrity</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -52,80 +52,74 @@ ...@@ -52,80 +52,74 @@
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[ <value> <string encoding="cdata"><![CDATA[
# This script is called at the end of reindex and Run \n import re\n
# the verification scripts for this migration \n template_tool = context\n
# \n
# In addition to verification script, this send the log of\n
# migration for each instance. So we can analize the result \n
# later. One event could be created into nexedi erp5 for \n
# each instance updated.\n
# \n
try:\n
result = context.ERP5Site_verifyInstanceIntegrity()\n
except:\n
# Make Sure that the email will be send and indicates which \n
# Instance fails to verify.\n
result = ["Verification Failed."]\n
if erp5_uid is None:\n
erp5_uid = getattr(context.getPortalObject(), "erp5_site_global_id", \'%s (%s)\' % (context.getPortalObject().getTitle(), context.getPortalObject().absolute_url()))\n
\n \n
body="""\n bt5_per_title_dict = {}\n
Result for Upgrader Verification Script for %s Instance: \n bt5_list = [i.getTitle() for i in \\\n
context.portal_templates.getRepositoryBusinessTemplateList()]\n
\n \n
installed_bt5_list = template_tool.getInstalledBusinessTemplateList()\n
for bt5 in installed_bt5_list:\n
bt5_title = bt5.title\n
if bt5_title not in bt5_list:\n
continue\n
bt5_per_title_dict[bt5_title] = bt5\n
\n \n
""" % (erp5_uid)\n resolved_list = template_tool.resolveBusinessTemplateListDependency(bt5_per_title_dict.iterkeys())\n
\n \n
status = "OK"\n pattern = re.compile(r"(?P<portal_type>.*)[| ]\\|[| ](?P<workflow_id>.*)")\n
if len(result) > 0:\n portal_type_dict = {}\n
status = "Failed"\n for _, bt5_id in resolved_list:\n
body += \' \\n\'.join(result)\n if bt5_id not in bt5_per_title_dict:\n
else:\n continue\n
body += \'NO MESSAGE\'\n workflow_chain_list = bt5_per_title_dict[bt5_id].getTemplatePortalTypeWorkflowChainList()\n
if not workflow_chain_list:\n
continue\n
for workflow_chain in workflow_chain_list:\n
group_dict = pattern.match(workflow_chain).groupdict()\n
portal_type = group_dict[\'portal_type\']\n
workflow_id = group_dict[\'workflow_id\']\n
workflow_id_list = portal_type_dict.setdefault("%s" % portal_type, [])\n
if workflow_id.startswith(\'-\'):\n
workflow_id_list.remove(workflow_id.replace(\'-\', \'\'))\n
continue\n
elif workflow_id in workflow_id_list:\n
continue\n
workflow_id_list.append(workflow_id)\n
\n \n
body += """\n error_list = []\n
========= Upgrader Log ============\n workflow_chain_by_portal_type_dict = context.ERP5Site_dumpWorkflowChainByPortalType()\n
"""\n new_workflow_chain_dict = {\'chain_%s\' % portal_type : \',\'.join(chain) \\\n
for portal_type, chain in workflow_chain_by_portal_type_dict.iteritems()}\n
\n \n
if active_process is not None:\n for portal_type, workflow_chain in portal_type_dict.iteritems():\n
process = context.restrictedTraverse(active_process)\n try:\n
if process is not None:\n workflow_chain_list = list(workflow_chain_by_portal_type_dict[portal_type])\n
for active_result in process.getResultList():\n except:\n
body += """\n return workflow_chain_by_portal_type_dict[portal_type]\n
%s\n expected_workflow_chain = sorted(workflow_chain)\n
""" % (active_result.detail)\n if sorted(workflow_chain_list) != expected_workflow_chain:\n
else:\n error_list.append("%s - Expected: %s <> Found: %s" % (portal_type, \', \'.join(workflow_chain), \', \'.join(workflow_chain_list)))\n
body += "Fail to get log from activity result!"\n if fixit:\n
new_workflow_chain_dict["chain_%s" % portal_type] = \',\'.join(expected_workflow_chain)\n
\n \n
subject = "%s: Upgrade Result for %s" % (status, erp5_uid)\n if fixit and new_workflow_chain_dict:\n
portal_workflow = context.getPortalObject().portal_workflow\n
portal_workflow.manage_changeWorkflows(default_chain="", props=new_workflow_chain_dict)\n
\n \n
kw = {\'body\': body,\n return error_list\n
\'erp5_uid\': erp5_uid,\n
\'subject\' : subject}\n
\n
# If the instance is well configured this will send a message\n
# to email_to_address or email_from_address. \n
context.portal_notifications.sendMessage(\n
sender=None,\n
recipient=[],\n
subject=subject,\n
message=body,\n
message_text_format=\'text/plain\',\n
notifier_list=(\'Mail Message\',),\n
store_as_event=False,\n
)\n
\n
return ["Notification is sent!"]\n
]]></string> </value> ]]></string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>erp5_uid=None, active_process=None</string> </value> <value> <string>fixit=False, **kw</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>ERP5Site_notifyUpgradeIntegrity</string> </value> <value> <string>TemplateTool_checkPostUpgradeWorkflowChainConsistency</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -50,19 +50,21 @@ ...@@ -50,19 +50,21 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>"""\n <value> <string>bt5_list, keep_bt5_id_set = context.Base_getUpgradeBusinessTemplateList()\n
Dummy script used by Upgrader Script\n \n
"""\n template_tool = context.getPortalObject().portal_templates\n
return [ (upgrade_object.getRelativeUrl(), upgrade_object.getMetaType()) ]\n return template_tool.upgradeSite(bt5_list,\n
keep_bt5_id_set=keep_bt5_id_set,\n
dry_run=(not fixit))\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>upgrade_object</string> </value> <value> <string>fixit=False, **kw</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>ERP5Site_testUpgradeObjectClass</string> </value> <value> <string>TemplateTool_checkUpgradeConsistency</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -6,13 +6,25 @@ ...@@ -6,13 +6,25 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>testLiveUpgrader</string> </value> <value> <string>testUpgrader</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>test.erp5.testLiveUpgrader</string> </value> <value> <string>test.erp5.testUpgrader</string> </value>
</item> </item>
<item> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
...@@ -24,6 +36,31 @@ ...@@ -24,6 +36,31 @@
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple>
<string>R: 33, 0: Too many ancestors (9/7) (too-many-ancestors)</string>
<string>W: 59,64: Unused argument \'sequence\' (unused-argument)</string>
<string>W: 76,42: Unused argument \'sequence\' (unused-argument)</string>
<string>W: 89,48: Unused argument \'sequence\' (unused-argument)</string>
<string>W:104,53: Unused argument \'sequence\' (unused-argument)</string>
<string>W:109,51: Unused argument \'sequence\' (unused-argument)</string>
<string>W:112,52: Unused argument \'sequence\' (unused-argument)</string>
<string>W:115,56: Unused argument \'sequence\' (unused-argument)</string>
<string>W:122,54: Unused argument \'sequence\' (unused-argument)</string>
<string>W:140,54: Unused argument \'sequence\' (unused-argument)</string>
<string>W:147,54: Unused argument \'sequence\' (unused-argument)</string>
<string>R: 33, 0: Too many public methods (136/20) (too-many-public-methods)</string>
</tuple>
</value>
</item>
<item> <item>
<key> <string>version</string> </key> <key> <string>version</string> </key>
<value> <string>erp5</string> </value> <value> <string>erp5</string> </value>
...@@ -31,13 +68,28 @@ ...@@ -31,13 +68,28 @@
<item> <item>
<key> <string>workflow_history</string> </key> <key> <string>workflow_history</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="PersistentMapping" module="Persistence.mapping"/> <global name="PersistentMapping" module="Persistence.mapping"/>
</pickle> </pickle>
...@@ -50,7 +102,7 @@ ...@@ -50,7 +102,7 @@
<item> <item>
<key> <string>component_validation_workflow</string> </key> <key> <string>component_validation_workflow</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -59,7 +111,7 @@ ...@@ -59,7 +111,7 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="3" aka="AAAAAAAAAAM="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle> </pickle>
...@@ -74,7 +126,7 @@ ...@@ -74,7 +126,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>ERP5TypeTestCase</string> </value> <value> <string>zope</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -92,8 +144,8 @@ ...@@ -92,8 +144,8 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1377844666.57</float> <float>1384357832.27</float>
<string>GMT+9</string> <string>GMT+1</string>
</tuple> </tuple>
</state> </state>
</object> </object>
......
2013-11-18 Gabriel Monnerat
* The alarms were renamed to cover each step of upgrader and give the possibility to call each step manually one-by-one.
* Also, all Scripts that the logic can be done by installing Business Template was removed.
2013-09-03 arnaud.fontaine 2013-09-03 arnaud.fontaine
* ZODB Components: Workflow History must always be kept, so avoid an extra step for developers. * ZODB Components: Workflow History must always be kept, so avoid an extra step for developers.
...@@ -5,7 +9,7 @@ ...@@ -5,7 +9,7 @@
* ZODB Components: Migrate Documents, Extensions and Tests. * ZODB Components: Migrate Documents, Extensions and Tests.
2012-10-05 arnaud.fontaine 2012-10-05 arnaud.fontaine
* Allow to specify bt5 which are not going to be upgraded (meaningful for master data for example). * Allow to specify bt5 which are not going to be upgraded (meaningful for master data for example).
2011-03-10 Kazuhiko 2011-03-10 Kazuhiko
* by default, all installed business templates will be upgraded, not all existing business templates in the repository. * by default, all installed business templates will be upgraded, not all existing business templates in the repository.
......
erp5_upgrader can be used to upgrade any site: erp5_upgrader can be used to upgrade any site:
* create Business Template which overrides upgrader scripts in its own skin (XXX_erp5_upgrader) * Create Business Template and override TemplateTool_checkUpgradeConsistency script to set the Business Template list related to your project
* set extremely high business_template_skin_layer_priority (like 10000.0) * Set extremely high business_template_skin_layer_priority (like 10000.0)
* develop this Business Template * Develop constraints and set Constraint Type following upgrader steps
* to upgrade site install first XXX_erp5_upgrader, then erp5_upgrader * To upgrade site install first XXX_erp5_upgrader, then erp5_upgrader
* voilà - site upgraded * Solve the alarm portal_alarms/upgrader_launch_full_upgrade
\ No newline at end of file \ No newline at end of file
601 612
\ No newline at end of file \ No newline at end of file
portal_alarms/bt5_upgrader portal_alarms/promise_check_upgrade
portal_alarms/finalize_upgrader portal_alarms/upgrader_check_post_upgrade
portal_alarms/upgrader_controller portal_alarms/upgrader_check_pre_upgrade
\ No newline at end of file portal_alarms/upgrader_check_upgrader
\ No newline at end of file
Template Tool | TemplateToolPostUpgradeConstraint
Template Tool | TemplateToolUpgraderConstraint
\ No newline at end of file
TemplateToolUpgraderConstraint
TemplateToolPostUpgradeConstraint
\ No newline at end of file
test.erp5.testLiveUpgrader test.erp5.testUpgrader
\ No newline at end of file \ No newline at end of file
erp5_full_text_myisam_catalog
erp5_base
erp5_upgrader_test
\ No newline at end of file
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