Commit 6179081a authored by Rafael Monnerat's avatar Rafael Monnerat

Migrate predecessor category to successor

See merge request nexedi/slapos.core!307
parents 7a12d3f6 d28d3575
...@@ -79,7 +79,7 @@ ...@@ -79,7 +79,7 @@
<key> <string>text</string> </key> <key> <string>text</string> </key>
<value> <string encoding="cdata"><![CDATA[ <value> <string encoding="cdata"><![CDATA[
string:${object_url}/Base_jumpToRelatedObject?base_category=predecessor&portal_type=Software+Instance string:${object_url}/Base_jumpToRelatedObject?base_category=successor&portal_type=Software+Instance
]]></string> </value> ]]></string> </value>
</item> </item>
......
...@@ -79,7 +79,7 @@ ...@@ -79,7 +79,7 @@
<key> <string>text</string> </key> <key> <string>text</string> </key>
<value> <string encoding="cdata"><![CDATA[ <value> <string encoding="cdata"><![CDATA[
string:${object_url}/Base_jumpToRelatedObject?base_category=predecessor&portal_type:list=Software+Instance&portal_type:list=Hosting+Subscription string:${object_url}/Base_jumpToRelatedObject?base_category=successor&portal_type:list=Software+Instance&portal_type:list=Hosting+Subscription
]]></string> </value> ]]></string> </value>
</item> </item>
......
<dtml-var table_1>.uid = <dtml-var table_0>.category_uid <dtml-var table_1>.uid = <dtml-var table_0>.category_uid
AND <dtml-var table_0>.base_category_uid = <dtml-var "portal_categories.predecessor.getUid()"> AND <dtml-var table_0>.base_category_uid = <dtml-var "portal_categories.successor.getUid()">
<dtml-var RELATED_QUERY_SEPARATOR> <dtml-var RELATED_QUERY_SEPARATOR>
<dtml-var table_1>.title <> <dtml-var query_table>.title <dtml-var table_1>.title <> <dtml-var query_table>.title
AND <dtml-var table_0>.uid = <dtml-var query_table>.uid AND <dtml-var table_0>.uid = <dtml-var query_table>.uid
\ No newline at end of file
...@@ -45,7 +45,7 @@ query_table="catalog"</string> </value> ...@@ -45,7 +45,7 @@ query_table="catalog"</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>z_related_predecessor_but_with_different_title_than_catalog_title</string> </value> <value> <string>z_related_successor_but_with_different_title_than_catalog_title</string> </value>
</item> </item>
<item> <item>
<key> <string>max_cache_</string> </key> <key> <string>max_cache_</string> </key>
...@@ -61,7 +61,7 @@ query_table="catalog"</string> </value> ...@@ -61,7 +61,7 @@ query_table="catalog"</string> </value>
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string>z_related_predecessor_but_with_different_title_than_catalog_title</string> </value> <value> <string>z_related_successor_but_with_different_title_than_catalog_title</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -2,5 +2,5 @@ ...@@ -2,5 +2,5 @@
<key>causality_subscription_request_related_uid | category,catalog/uid/z_related_causality_subscription_request</key> <key>causality_subscription_request_related_uid | category,catalog/uid/z_related_causality_subscription_request</key>
<key>default_or_child_aggregate_reference | catalog,category,catalog/reference/z_related_default_or_child_aggregate</key> <key>default_or_child_aggregate_reference | catalog,category,catalog/reference/z_related_default_or_child_aggregate</key>
<key>default_or_child_aggregate_uid | catalog,category,catalog/uid/z_related_default_or_child_aggregate</key> <key>default_or_child_aggregate_uid | catalog,category,catalog/uid/z_related_default_or_child_aggregate</key>
<key>related_predecessor_but_with_different_title_than_catalog_title | category,catalog/uid/z_related_predecessor_but_with_different_title_than_catalog_title</key> <key>related_successor_but_with_different_title_than_catalog_title | category,catalog/uid/z_related_successor_but_with_different_title_than_catalog_title</key>
</key_list> </key_list>
\ No newline at end of file
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>active_sense_method_id</string> </key> <key> <string>active_sense_method_id</string> </key>
<value> <string>Alarm_assertHostingSubscriptionHasPredecessor</string> </value> <value> <string>Alarm_assertHostingSubscriptionHasSuccessor</string> </value>
</item> </item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>slapos_assert_hosting_subscription_predecessor</string> </value> <value> <string>slapos_assert_hosting_subscription_successor</string> </value>
</item> </item>
<item> <item>
<key> <string>periodicity_hour</string> </key> <key> <string>periodicity_hour</string> </key>
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string>Asserts that Hosting Subscription has predecessor with same title</string> </value> <value> <string>Asserts that Hosting Subscription has successor with same title</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
<property_sheet_list> <property_sheet_list>
<portal_type id="Alarm Tool">
<item>SlapOSMasterUpgradeConstraint</item>
</portal_type>
<portal_type id="Assignment"> <portal_type id="Assignment">
<item>SlaposAssignmentConstraint</item> <item>SlaposAssignmentConstraint</item>
</portal_type> </portal_type>
...@@ -23,6 +26,7 @@ ...@@ -23,6 +26,7 @@
<item>HostingSubscription</item> <item>HostingSubscription</item>
<item>SlaposHostingSubscriptionConstraint</item> <item>SlaposHostingSubscriptionConstraint</item>
<item>SoftwareInstance</item> <item>SoftwareInstance</item>
<item>SoftwareInstanceUpgradeConstraint</item>
<item>TextDocument</item> <item>TextDocument</item>
<item>Url</item> <item>Url</item>
<item>VariationRange</item> <item>VariationRange</item>
...@@ -49,6 +53,7 @@ ...@@ -49,6 +53,7 @@
<item>Reference</item> <item>Reference</item>
<item>SoftwareInstance</item> <item>SoftwareInstance</item>
<item>SoftwareInstanceConstraint</item> <item>SoftwareInstanceConstraint</item>
<item>SoftwareInstanceUpgradeConstraint</item>
<item>TextDocument</item> <item>TextDocument</item>
<item>Url</item> <item>Url</item>
<item>VariationRange</item> <item>VariationRange</item>
......
<?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>SlapOSMasterUpgradeConstraint</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>predecessor_to_successor_migration_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>AlarmTool_checkPredecessorToSuccessorMigrationConsistency</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>
...@@ -28,17 +28,17 @@ ...@@ -28,17 +28,17 @@
<key> <string>expression</string> </key> <key> <string>expression</string> </key>
<value> <string encoding="cdata"><![CDATA[ <value> <string encoding="cdata"><![CDATA[
python: len(context.getPredecessorRelatedList()) <= 1 python: len(context.getSuccessorRelatedList()) <= 1
]]></string> </value> ]]></string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>predecessor_related_constraint</string> </value> <value> <string>successor_related_constraint</string> </value>
</item> </item>
<item> <item>
<key> <string>message_expression_false</string> </key> <key> <string>message_expression_false</string> </key>
<value> <string>There is more then one related predecessor</string> </value> <value> <string>There is more then one related successor</string> </value>
</item> </item>
<item> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Category Property" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>successor_category</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Category Property</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -28,17 +28,17 @@ ...@@ -28,17 +28,17 @@
<key> <string>expression</string> </key> <key> <string>expression</string> </key>
<value> <string encoding="cdata"><![CDATA[ <value> <string encoding="cdata"><![CDATA[
python: len(context.getPredecessorRelatedList()) <= 1 python: len(context.getSuccessorRelatedList()) <= 1
]]></string> </value> ]]></string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>predecessor_related_constraint</string> </value> <value> <string>successor_related_constraint</string> </value>
</item> </item>
<item> <item>
<key> <string>message_expression_false</string> </key> <key> <string>message_expression_false</string> </key>
<value> <string>There is more then one related predecessor</string> </value> <value> <string>There is more then one related successor</string> </value>
</item> </item>
<item> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
......
<?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>SoftwareInstanceUpgradeConstraint</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/default</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>predecessor_to_successor_migration_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>SoftwareInstance_checkPredecessorToSuccessorMigrationConsistency</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>
portal = context.getPortalObject()
result_list = []
migration_kw = {
'portal_type': ['Software Instance', 'Hosting Subscription'],
'predecessor__uid': '%'
}
non_migrated_instance = portal.portal_catalog(limit=1, **migration_kw)
if len(non_migrated_instance) == 1:
result_list.append("all X needs updates %s" % non_migrated_instance[0].getRelativeUrl())
if fixit:
portal.portal_catalog.searchAndActivate(
activate_kw=dict(priority=5,
tag=script.getId(),
after_method_id=('immediateReindexObject',
'recursiveImmediateReindexObject')),
method_id='fixConsistency',
**migration_kw)
return result_list
<?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>_params</string> </key>
<value> <string>fixit=False</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>AlarmTool_checkPredecessorToSuccessorMigrationConsistency</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -4,9 +4,9 @@ from Products.ZSQLCatalog.SQLCatalog import SimpleQuery, NegatedQuery ...@@ -4,9 +4,9 @@ from Products.ZSQLCatalog.SQLCatalog import SimpleQuery, NegatedQuery
portal.portal_catalog.searchAndActivate( portal.portal_catalog.searchAndActivate(
portal_type='Hosting Subscription', portal_type='Hosting Subscription',
validation_state='validated', validation_state='validated',
related_predecessor_but_with_different_title_than_catalog_title="%", related_successor_but_with_different_title_than_catalog_title="%",
predecessor_title=NegatedQuery(SimpleQuery(predecessor_title=None, comparison_operator='is')), successor_title=NegatedQuery(SimpleQuery(successor_title=None, comparison_operator='is')),
method_id='HostingSubscription_assertPredecessor', method_id='HostingSubscription_assertSuccessor',
activate_kw={'tag': tag}) activate_kw={'tag': tag})
context.activate(after_tag=tag).getId() context.activate(after_tag=tag).getId()
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>Alarm_assertHostingSubscriptionHasPredecessor</string> </value> <value> <string>Alarm_assertHostingSubscriptionHasSuccessor</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -5,7 +5,7 @@ portal.portal_catalog.searchAndActivate( ...@@ -5,7 +5,7 @@ portal.portal_catalog.searchAndActivate(
portal_type=["Software Instance", "Slave Instance"], portal_type=["Software Instance", "Slave Instance"],
validation_state="validated", validation_state="validated",
specialise_validation_state="validated", specialise_validation_state="validated",
predecessor_related_uid=SimpleQuery(predecessor_related_uid=None, comparison_operator='is'), successor_related_uid=SimpleQuery(successor_related_uid=None, comparison_operator='is'),
method_id='SoftwareInstance_tryToGarbageUnlinkedInstance', method_id='SoftwareInstance_tryToGarbageUnlinkedInstance',
activate_kw={'tag': tag} activate_kw={'tag': tag}
) )
......
if context.getPortalType() != 'Hosting Subscription' \ if context.getPortalType() != 'Hosting Subscription' \
or context.getValidationState() != 'validated' \ or context.getValidationState() != 'validated' \
or context.getSlapState() not in ['start_requested', 'stop_requested'] \ or context.getSlapState() not in ['start_requested', 'stop_requested'] \
or context.getTitle() in context.getPredecessorTitleList(): or context.getTitle() in context.getSuccessorTitleList():
# nothing to do # nothing to do
return return
......
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>HostingSubscription_assertPredecessor</string> </value> <value> <string>HostingSubscription_assertSuccessor</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -116,7 +116,7 @@ ...@@ -116,7 +116,7 @@
<key> <string>right</string> </key> <key> <string>right</string> </key>
<value> <value>
<list> <list>
<string>my_predecessor_title_list</string> <string>my_successor_title_list</string>
<string>my_destination_section_title</string> <string>my_destination_section_title</string>
<string>my_translated_slap_state_title</string> <string>my_translated_slap_state_title</string>
<string>my_translated_validation_state_title</string> <string>my_translated_validation_state_title</string>
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>my_predecessor_title_list</string> </value> <value> <string>my_successor_title_list</string> </value>
</item> </item>
<item> <item>
<key> <string>message_values</string> </key> <key> <string>message_values</string> </key>
...@@ -106,7 +106,7 @@ ...@@ -106,7 +106,7 @@
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string>Predecessors</string> </value> <value> <string>Successors</string> </value>
</item> </item>
</dictionary> </dictionary>
</value> </value>
......
...@@ -112,7 +112,7 @@ ...@@ -112,7 +112,7 @@
<string>my_specialise_title</string> <string>my_specialise_title</string>
<string>my_aggregate_parent_reference</string> <string>my_aggregate_parent_reference</string>
<string>my_aggregate_title</string> <string>my_aggregate_title</string>
<string>my_predecessor_title_list</string> <string>my_successor_title_list</string>
<string>my_translated_slap_state_title</string> <string>my_translated_slap_state_title</string>
<string>my_translated_validation_state_title</string> <string>my_translated_validation_state_title</string>
</list> </list>
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>my_predecessor_title_list</string> </value> <value> <string>my_successor_title_list</string> </value>
</item> </item>
<item> <item>
<key> <string>message_values</string> </key> <key> <string>message_values</string> </key>
...@@ -76,7 +76,7 @@ ...@@ -76,7 +76,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>base_category</string> </key> <key> <string>base_category</string> </key>
<value> <string>predecessor</string> </value> <value> <string>successor</string> </value>
</item> </item>
<item> <item>
<key> <string>catalog_index</string> </key> <key> <string>catalog_index</string> </key>
...@@ -107,7 +107,7 @@ ...@@ -107,7 +107,7 @@
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string>Predecessors</string> </value> <value> <string>Successors</string> </value>
</item> </item>
</dictionary> </dictionary>
</value> </value>
......
predecessor_list = context.getPredecessorList()
successor_list = context.getSuccessorList()
error_list = []
if predecessor_list:
if successor_list:
return ['Error: Instance has both predecessor and successor categories']
error_list.append('Instance has predecessor categories not yet migrated to successor categories')
if fixit:
context.edit(successor_list=predecessor_list, predecessor_list=[])
assert not context.getPredecessorList()
assert len(context.getSuccessorList()) == len(predecessor_list)
return error_list
<?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>_params</string> </key>
<value> <string>fixit=False</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SoftwareInstance_checkPredecessorToSuccessorMigrationConsistency</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -4,7 +4,7 @@ if (instance.getSlapState() != "destroy_requested"): ...@@ -4,7 +4,7 @@ if (instance.getSlapState() != "destroy_requested"):
hosting_subscription = instance.getSpecialiseValue(portal_type="Hosting Subscription") hosting_subscription = instance.getSpecialiseValue(portal_type="Hosting Subscription")
if (hosting_subscription.getValidationState() == "archived"): if (hosting_subscription.getValidationState() == "archived"):
# Buildout didn't propagate the destruction request # Buildout didn't propagate the destruction request
requester = instance.getPredecessorRelatedValue() requester = instance.getSuccessorRelatedValue()
if instance.getPortalType() == 'Software Instance': if instance.getPortalType() == 'Software Instance':
is_slave = False is_slave = False
...@@ -15,7 +15,7 @@ if (instance.getSlapState() != "destroy_requested"): ...@@ -15,7 +15,7 @@ if (instance.getSlapState() != "destroy_requested"):
(instance.getPortalType(), instance.getRelativeUrl()) (instance.getPortalType(), instance.getRelativeUrl())
if requester is None: if requester is None:
# This instance has no predecessor (link removed) and should be trashed # This instance has no successor (link removed) and should be trashed
promise_kw = { promise_kw = {
'instance_xml': instance.getTextContent(), 'instance_xml': instance.getTextContent(),
'software_type': instance.getSourceReference(), 'software_type': instance.getSourceReference(),
...@@ -25,8 +25,8 @@ if (instance.getSlapState() != "destroy_requested"): ...@@ -25,8 +25,8 @@ if (instance.getSlapState() != "destroy_requested"):
} }
instance.requestDestroy(**promise_kw) instance.requestDestroy(**promise_kw)
# Unlink all children of this instance # Unlink all children of this instance
instance.edit(predecessor="", comment="Destroyed garbage collector!") instance.edit(successor="", comment="Destroyed garbage collector!")
elif (instance.getRelativeUrl() in requester.getPredecessorList()) and \ elif (instance.getRelativeUrl() in requester.getSuccessorList()) and \
(requester.getSlapState() == "destroy_requested"): (requester.getSlapState() == "destroy_requested"):
# For security, only destroyed if parent is also destroyed # For security, only destroyed if parent is also destroyed
......
...@@ -22,9 +22,9 @@ if (int(DateTime()) - int(latest_edit_time)) < 259200: ...@@ -22,9 +22,9 @@ if (int(DateTime()) - int(latest_edit_time)) < 259200:
# Only destroy if the instance is the only one in the tree # Only destroy if the instance is the only one in the tree
hosting_subscription = instance.getSpecialiseValue("Hosting Subscription") hosting_subscription = instance.getSpecialiseValue("Hosting Subscription")
if (hosting_subscription.getPredecessor() != instance.getRelativeUrl()): if (hosting_subscription.getSuccessor() != instance.getRelativeUrl()):
return return
if (len(hosting_subscription.getPredecessorList()) != 1): if (len(hosting_subscription.getSuccessorList()) != 1):
return return
instance_list = portal.portal_catalog( instance_list = portal.portal_catalog(
portal_type=["Software Instance", "Slave Instance"], portal_type=["Software Instance", "Slave Instance"],
......
...@@ -8,7 +8,7 @@ instance = context ...@@ -8,7 +8,7 @@ instance = context
def checkInstanceTree(instance_list): def checkInstanceTree(instance_list):
""" """
Check if predecessor link is really removed to this instance Check if successor link is really removed to this instance
""" """
sub_instance_list = [] sub_instance_list = []
if instance_list == []: if instance_list == []:
...@@ -16,7 +16,7 @@ def checkInstanceTree(instance_list): ...@@ -16,7 +16,7 @@ def checkInstanceTree(instance_list):
for item in instance_list: for item in instance_list:
if item.getUid() == instance.getUid(): if item.getUid() == instance.getUid():
return item return item
sub_instance_list.extend(item.getPredecessorValueList()) sub_instance_list.extend(item.getSuccessorValueList())
return checkInstanceTree(sub_instance_list) return checkInstanceTree(sub_instance_list)
...@@ -28,7 +28,7 @@ if hosting_subscription is None or \ ...@@ -28,7 +28,7 @@ if hosting_subscription is None or \
hosting_subscription.getSlapState() == "destroy_requested": hosting_subscription.getSlapState() == "destroy_requested":
return return
root_instance = hosting_subscription.getPredecessorValue() root_instance = hosting_subscription.getSuccessorValue()
if root_instance is None: if root_instance is None:
# Refuse to destroy root instance # Refuse to destroy root instance
raise ValueError("Hosting Subscription %s has no root instance, this should "\ raise ValueError("Hosting Subscription %s has no root instance, this should "\
...@@ -53,6 +53,6 @@ if checkInstanceTree([root_instance]) is None: ...@@ -53,6 +53,6 @@ if checkInstanceTree([root_instance]) is None:
} }
instance.requestDestroy(**promise_kw) instance.requestDestroy(**promise_kw)
# Unlink all children of this instance # Unlink all children of this instance
instance.edit(predecessor="", comment="Destroyed garbage collector!") instance.edit(successor="", comment="Destroyed garbage collector!")
return instance.getRelativeUrl() return instance.getRelativeUrl()
...@@ -8,8 +8,8 @@ if (instance.getSlapState() == "start_requested"): ...@@ -8,8 +8,8 @@ if (instance.getSlapState() == "start_requested"):
hosting_subscription = instance.getSpecialiseValue(portal_type="Hosting Subscription") hosting_subscription = instance.getSpecialiseValue(portal_type="Hosting Subscription")
if (hosting_subscription.getSlapState() == "stop_requested"): if (hosting_subscription.getSlapState() == "stop_requested"):
# Buildout may not propagate the stop request # Buildout may not propagate the stop request
requester = instance.getPredecessorRelatedValue() requester = instance.getSuccessorRelatedValue()
if (instance.getRelativeUrl() in requester.getPredecessorList()) and \ if (instance.getRelativeUrl() in requester.getSuccessorList()) and \
(requester.getSlapState() == "stop_requested"): (requester.getSlapState() == "stop_requested"):
# For security, only stop if parent is also stopped # For security, only stop if parent is also stopped
......
...@@ -116,7 +116,7 @@ ...@@ -116,7 +116,7 @@
<string>my_specialise_title</string> <string>my_specialise_title</string>
<string>my_aggregate_parent_reference</string> <string>my_aggregate_parent_reference</string>
<string>my_aggregate_title</string> <string>my_aggregate_title</string>
<string>my_predecessor_title_list</string> <string>my_successor_title_list</string>
<string>my_translated_slap_state_title</string> <string>my_translated_slap_state_title</string>
<string>my_translated_validation_state_title</string> <string>my_translated_validation_state_title</string>
</list> </list>
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>my_predecessor_title_list</string> </value> <value> <string>my_successor_title_list</string> </value>
</item> </item>
<item> <item>
<key> <string>message_values</string> </key> <key> <string>message_values</string> </key>
...@@ -76,7 +76,7 @@ ...@@ -76,7 +76,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>base_category</string> </key> <key> <string>base_category</string> </key>
<value> <string>predecessor</string> </value> <value> <string>successor</string> </value>
</item> </item>
<item> <item>
<key> <string>catalog_index</string> </key> <key> <string>catalog_index</string> </key>
...@@ -111,7 +111,7 @@ ...@@ -111,7 +111,7 @@
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string>Predecessors</string> </value> <value> <string>Successors</string> </value>
</item> </item>
</dictionary> </dictionary>
</value> </value>
......
...@@ -356,7 +356,7 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin): ...@@ -356,7 +356,7 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
self.assertEqual(1, len(hosting_subscription_list)) self.assertEqual(1, len(hosting_subscription_list))
hosting_subscription = hosting_subscription_list[0] hosting_subscription = hosting_subscription_list[0]
software_instance = hosting_subscription.getPredecessorValue() software_instance = hosting_subscription.getSuccessorValue()
self.assertEqual(software_instance.getTitle(), self.assertEqual(software_instance.getTitle(),
hosting_subscription.getTitle()) hosting_subscription.getTitle())
connection_dict = software_instance.getConnectionXmlAsDict() connection_dict = software_instance.getConnectionXmlAsDict()
...@@ -523,7 +523,7 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin): ...@@ -523,7 +523,7 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
self.assertEqual(1, len(hosting_subscription_list)) self.assertEqual(1, len(hosting_subscription_list))
hosting_subscription = hosting_subscription_list[0] hosting_subscription = hosting_subscription_list[0]
software_instance = hosting_subscription.getPredecessorValue() software_instance = hosting_subscription.getSuccessorValue()
self.assertEqual(software_instance.getTitle(), self.assertEqual(software_instance.getTitle(),
hosting_subscription.getTitle()) hosting_subscription.getTitle())
connection_dict = software_instance.getConnectionXmlAsDict() connection_dict = software_instance.getConnectionXmlAsDict()
......
...@@ -215,7 +215,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin): ...@@ -215,7 +215,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
text_content=self.request_kw['instance_xml'], text_content=self.request_kw['instance_xml'],
sla_xml=self.request_kw['sla_xml'], sla_xml=self.request_kw['sla_xml'],
root_slave=self.request_kw['shared'], root_slave=self.request_kw['shared'],
predecessor=self.software_instance.getRelativeUrl(), successor=self.software_instance.getRelativeUrl(),
destination_section=self.person_user.getRelativeUrl() destination_section=self.person_user.getRelativeUrl()
) )
self.hosting_subscription.validate() self.hosting_subscription.validate()
...@@ -231,7 +231,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin): ...@@ -231,7 +231,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
text_content=self.request_kw['instance_xml'], text_content=self.request_kw['instance_xml'],
sla_xml=self.request_kw['sla_xml'], sla_xml=self.request_kw['sla_xml'],
specialise=self.hosting_subscription.getRelativeUrl(), specialise=self.hosting_subscription.getRelativeUrl(),
predecessor=self.requested_software_instance.getRelativeUrl() successor=self.requested_software_instance.getRelativeUrl()
) )
self.portal.portal_workflow._jumpToStateFor(self.software_instance, 'start_requested') self.portal.portal_workflow._jumpToStateFor(self.software_instance, 'start_requested')
self.software_instance.validate() self.software_instance.validate()
...@@ -368,7 +368,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin): ...@@ -368,7 +368,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
hosting_subscription.requestStart(**kw) hosting_subscription.requestStart(**kw)
hosting_subscription.requestInstance(**kw) hosting_subscription.requestInstance(**kw)
self.start_requested_software_instance = hosting_subscription.getPredecessorValue() self.start_requested_software_instance = hosting_subscription.getSuccessorValue()
self.start_requested_software_instance.edit(aggregate=self.computer.partition1.getRelativeUrl()) self.start_requested_software_instance.edit(aggregate=self.computer.partition1.getRelativeUrl())
if with_slave: if with_slave:
...@@ -392,7 +392,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin): ...@@ -392,7 +392,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
hosting_subscription.requestStart(**slave_kw) hosting_subscription.requestStart(**slave_kw)
hosting_subscription.requestInstance(**slave_kw) hosting_subscription.requestInstance(**slave_kw)
self.start_requested_slave_instance = hosting_subscription.getPredecessorValue() self.start_requested_slave_instance = hosting_subscription.getSuccessorValue()
self.start_requested_slave_instance.edit(aggregate=self.computer.partition1.getRelativeUrl()) self.start_requested_slave_instance.edit(aggregate=self.computer.partition1.getRelativeUrl())
hosting_subscription = self.portal.hosting_subscription_module\ hosting_subscription = self.portal.hosting_subscription_module\
...@@ -416,7 +416,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin): ...@@ -416,7 +416,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
hosting_subscription.requestStop(**kw) hosting_subscription.requestStop(**kw)
hosting_subscription.requestInstance(**kw) hosting_subscription.requestInstance(**kw)
self.stop_requested_software_instance = hosting_subscription.getPredecessorValue() self.stop_requested_software_instance = hosting_subscription.getSuccessorValue()
self.stop_requested_software_instance.edit( self.stop_requested_software_instance.edit(
aggregate=self.computer.partition2.getRelativeUrl() aggregate=self.computer.partition2.getRelativeUrl()
) )
...@@ -444,7 +444,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin): ...@@ -444,7 +444,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
kw['state'] = 'destroyed' kw['state'] = 'destroyed'
hosting_subscription.requestDestroy(**kw) hosting_subscription.requestDestroy(**kw)
self.destroy_requested_software_instance = hosting_subscription.getPredecessorValue() self.destroy_requested_software_instance = hosting_subscription.getSuccessorValue()
self.destroy_requested_software_instance.requestDestroy(**kw) self.destroy_requested_software_instance.requestDestroy(**kw)
self.destroy_requested_software_instance.edit( self.destroy_requested_software_instance.edit(
aggregate=self.computer.partition3.getRelativeUrl() aggregate=self.computer.partition3.getRelativeUrl()
...@@ -473,7 +473,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin): ...@@ -473,7 +473,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
kw['state'] = 'destroyed' kw['state'] = 'destroyed'
hosting_subscription.requestDestroy(**kw) hosting_subscription.requestDestroy(**kw)
self.destroyed_software_instance = hosting_subscription.getPredecessorValue() self.destroyed_software_instance = hosting_subscription.getSuccessorValue()
self.destroyed_software_instance.edit( self.destroyed_software_instance.edit(
aggregate=self.computer.partition4.getRelativeUrl() aggregate=self.computer.partition4.getRelativeUrl()
) )
......
...@@ -235,7 +235,7 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin): ...@@ -235,7 +235,7 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin):
self.software_instance.edit(**{property_id:''}) self.software_instance.edit(**{property_id:''})
self.assertFalse(consistency_message in self.getMessageList(self.software_instance)) self.assertFalse(consistency_message in self.getMessageList(self.software_instance))
def test_predecessor_related(self): def test_successor_related(self):
software_instance2 = self.portal.software_instance_module.newContent( software_instance2 = self.portal.software_instance_module.newContent(
portal_type='Software Instance') portal_type='Software Instance')
software_instance3 = self.portal.software_instance_module.newContent( software_instance3 = self.portal.software_instance_module.newContent(
...@@ -244,25 +244,25 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin): ...@@ -244,25 +244,25 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin):
# fetch basic list of consistency messages # fetch basic list of consistency messages
current_message_list = self.getMessageList(self.software_instance) current_message_list = self.getMessageList(self.software_instance)
consistency_message = "There is more then one related predecessor" consistency_message = "There is more then one related successor"
# test the test: no expected message found # test the test: no expected message found
self.assertFalse(consistency_message in current_message_list) self.assertFalse(consistency_message in current_message_list)
# if too many, it shall cry # if too many, it shall cry
software_instance2.edit(predecessor=self.software_instance.getRelativeUrl()) software_instance2.edit(successor=self.software_instance.getRelativeUrl())
software_instance3.edit(predecessor=self.software_instance.getRelativeUrl()) software_instance3.edit(successor=self.software_instance.getRelativeUrl())
self.tic() self.tic()
self.assertTrue(consistency_message in self.getMessageList(self.software_instance)) self.assertTrue(consistency_message in self.getMessageList(self.software_instance))
# one is good # one is good
software_instance2.edit(predecessor=None) software_instance2.edit(successor=None)
self.tic() self.tic()
self.assertFalse(consistency_message in self.getMessageList(self.software_instance)) self.assertFalse(consistency_message in self.getMessageList(self.software_instance))
self.assertSameSet(current_message_list, self.getMessageList(self.software_instance)) self.assertSameSet(current_message_list, self.getMessageList(self.software_instance))
# none is good # none is good
software_instance3.edit(predecessor=None) software_instance3.edit(successor=None)
self.tic() self.tic()
self.assertFalse(consistency_message in self.getMessageList(self.software_instance)) self.assertFalse(consistency_message in self.getMessageList(self.software_instance))
self.assertSameSet(current_message_list, self.getMessageList(self.software_instance)) self.assertSameSet(current_message_list, self.getMessageList(self.software_instance))
...@@ -374,7 +374,7 @@ class TestSlapOSSlaveInstanceConstraint(TestSlapOSConstraintMixin): ...@@ -374,7 +374,7 @@ class TestSlapOSSlaveInstanceConstraint(TestSlapOSConstraintMixin):
'Property existence error for property reference, this document' 'Property existence error for property reference, this document'
' has no such property or the property has never been set') ' has no such property or the property has never been set')
def test_predecessor_related(self): def test_successor_related(self):
software_instance2 = self.portal.software_instance_module.newContent( software_instance2 = self.portal.software_instance_module.newContent(
portal_type='Slave Instance') portal_type='Slave Instance')
software_instance3 = self.portal.software_instance_module.newContent( software_instance3 = self.portal.software_instance_module.newContent(
...@@ -383,25 +383,25 @@ class TestSlapOSSlaveInstanceConstraint(TestSlapOSConstraintMixin): ...@@ -383,25 +383,25 @@ class TestSlapOSSlaveInstanceConstraint(TestSlapOSConstraintMixin):
# fetch basic list of consistency messages # fetch basic list of consistency messages
current_message_list = self.getMessageList(self.software_instance) current_message_list = self.getMessageList(self.software_instance)
consistency_message = "There is more then one related predecessor" consistency_message = "There is more then one related successor"
# test the test: no expected message found # test the test: no expected message found
self.assertFalse(consistency_message in current_message_list) self.assertFalse(consistency_message in current_message_list)
# if too many, it shall cry # if too many, it shall cry
software_instance2.edit(predecessor=self.software_instance.getRelativeUrl()) software_instance2.edit(successor=self.software_instance.getRelativeUrl())
software_instance3.edit(predecessor=self.software_instance.getRelativeUrl()) software_instance3.edit(successor=self.software_instance.getRelativeUrl())
self.tic() self.tic()
self.assertTrue(consistency_message in self.getMessageList(self.software_instance)) self.assertTrue(consistency_message in self.getMessageList(self.software_instance))
# one is good # one is good
software_instance2.edit(predecessor=None) software_instance2.edit(successor=None)
self.tic() self.tic()
self.assertFalse(consistency_message in self.getMessageList(self.software_instance)) self.assertFalse(consistency_message in self.getMessageList(self.software_instance))
self.assertSameSet(current_message_list, self.getMessageList(self.software_instance)) self.assertSameSet(current_message_list, self.getMessageList(self.software_instance))
# none is good # none is good
software_instance3.edit(predecessor=None) software_instance3.edit(successor=None)
self.tic() self.tic()
self.assertFalse(consistency_message in self.getMessageList(self.software_instance)) self.assertFalse(consistency_message in self.getMessageList(self.software_instance))
self.assertSameSet(current_message_list, self.getMessageList(self.software_instance)) self.assertSameSet(current_message_list, self.getMessageList(self.software_instance))
......
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2021 Nexedi SA and Contributors. All Rights Reserved.
#
##############################################################################
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
def getMessageList(instance):
return [str(m.getMessage()) for m in instance.checkConsistency()]
class TestSlapOSCloudUpgrader(SlapOSTestCaseMixin):
def check_upgrade_instance_predecessor(self, portal_type):
error_message = 'Error: Instance has both predecessor and successor categories'
migration_message = 'Instance has predecessor categories not yet migrated to successor categories'
module = self.portal.getDefaultModule(portal_type)
instance_nothing_to_migrate = module.newContent(
portal_type=portal_type
)
instance_to_migrate = module.newContent(
portal_type=portal_type,
predecessor_value=instance_nothing_to_migrate
)
instance_badly_migrated = module.newContent(
portal_type=portal_type,
predecessor_value=instance_nothing_to_migrate,
successor_value=instance_nothing_to_migrate
)
# Nothing to migrate
self.assertFalse(migration_message in getMessageList(instance_nothing_to_migrate))
self.assertFalse(error_message in getMessageList(instance_nothing_to_migrate))
# Migrate
self.assertTrue(migration_message in getMessageList(instance_to_migrate))
self.assertFalse(error_message in getMessageList(instance_to_migrate))
instance_to_migrate.fixConsistency()
self.assertEqual(None, instance_to_migrate.getPredecessor())
self.assertEqual(instance_nothing_to_migrate.getRelativeUrl(),
instance_to_migrate.getSuccessor())
self.assertFalse(migration_message in getMessageList(instance_to_migrate))
self.assertFalse(error_message in getMessageList(instance_to_migrate))
# Error
self.assertFalse(migration_message in getMessageList(instance_badly_migrated))
self.assertTrue(error_message in getMessageList(instance_badly_migrated))
instance_badly_migrated.fixConsistency()
self.assertEqual(instance_nothing_to_migrate.getRelativeUrl(),
instance_badly_migrated.getPredecessor())
self.assertEqual(instance_nothing_to_migrate.getRelativeUrl(),
instance_badly_migrated.getSuccessor())
self.assertFalse(migration_message in getMessageList(instance_badly_migrated))
self.assertTrue(error_message in getMessageList(instance_badly_migrated))
def test_upgrade_software_instance_predecessor(self):
return self.check_upgrade_instance_predecessor('Software Instance')
def test_upgrade_hosting_subscription_predecessor(self):
return self.check_upgrade_instance_predecessor('Hosting Subscription')
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testSlapOSCloudUpgrader</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testSlapOSCloudUpgrader</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</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/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</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>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -699,7 +699,7 @@ class TestSlapOSCoreInstanceSlapInterfaceWorkflow(SlapOSTestCaseMixin): ...@@ -699,7 +699,7 @@ class TestSlapOSCoreInstanceSlapInterfaceWorkflow(SlapOSTestCaseMixin):
hosting_subscription.requestStart(**self.request_kw) hosting_subscription.requestStart(**self.request_kw)
hosting_subscription.requestInstance(**self.request_kw) hosting_subscription.requestInstance(**self.request_kw)
self.instance = hosting_subscription.getPredecessorValue() self.instance = hosting_subscription.getSuccessorValue()
self.tic() self.tic()
def _countInstanceBang(self, instance, comment): def _countInstanceBang(self, instance, comment):
...@@ -1102,7 +1102,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin): ...@@ -1102,7 +1102,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin):
text_content=self.request_kw['instance_xml'], text_content=self.request_kw['instance_xml'],
sla_xml=self.request_kw['sla_xml'], sla_xml=self.request_kw['sla_xml'],
root_slave=self.request_kw['shared'], root_slave=self.request_kw['shared'],
predecessor=self.software_instance.getRelativeUrl() successor=self.software_instance.getRelativeUrl()
) )
hosting_subscription.validate() hosting_subscription.validate()
self.portal.portal_workflow._jumpToStateFor(hosting_subscription, 'start_requested') self.portal.portal_workflow._jumpToStateFor(hosting_subscription, 'start_requested')
...@@ -1357,7 +1357,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin): ...@@ -1357,7 +1357,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin):
self.software_instance.getSpecialiseValue( self.software_instance.getSpecialiseValue(
portal_type='Hosting Subscription').edit( portal_type='Hosting Subscription').edit(
predecessor_list=[ successor_list=[
duplicate.getRelativeUrl(), duplicate.getRelativeUrl(),
duplicate2.getRelativeUrl(), duplicate2.getRelativeUrl(),
self.software_instance.getRelativeUrl() self.software_instance.getRelativeUrl()
...@@ -1405,7 +1405,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin): ...@@ -1405,7 +1405,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin):
requested_instance2.getRelativeUrl()) requested_instance2.getRelativeUrl())
self.assertSameSet( self.assertSameSet(
self.software_instance.getPredecessorList(), self.software_instance.getSuccessorList(),
[requested_instance.getRelativeUrl(), [requested_instance.getRelativeUrl(),
requested_instance2.getRelativeUrl()]) requested_instance2.getRelativeUrl()])
...@@ -1440,7 +1440,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin): ...@@ -1440,7 +1440,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin):
C_instance = self.software_instance.REQUEST.get('request_instance') C_instance = self.software_instance.REQUEST.get('request_instance')
self.assertSameSet( self.assertSameSet(
self.software_instance.getPredecessorList(), self.software_instance.getSuccessorList(),
[B_instance.getRelativeUrl(), C_instance.getRelativeUrl()]) [B_instance.getRelativeUrl(), C_instance.getRelativeUrl()])
self.tic() # in order to recalculate tree self.tic() # in order to recalculate tree
...@@ -1450,9 +1450,9 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin): ...@@ -1450,9 +1450,9 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin):
self.assertEqual(C_instance.getRelativeUrl(), C1_instance.getRelativeUrl()) self.assertEqual(C_instance.getRelativeUrl(), C1_instance.getRelativeUrl())
self.assertSameSet(self.software_instance.getPredecessorList(), self.assertSameSet(self.software_instance.getSuccessorList(),
[B_instance.getRelativeUrl()]) [B_instance.getRelativeUrl()])
self.assertSameSet(B_instance.getPredecessorList(), self.assertSameSet(B_instance.getSuccessorList(),
[C_instance.getRelativeUrl()]) [C_instance.getRelativeUrl()])
def test_request_tree_change_not_indexed(self): def test_request_tree_change_not_indexed(self):
...@@ -1479,7 +1479,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin): ...@@ -1479,7 +1479,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin):
C_instance = self.software_instance.REQUEST.get('request_instance') C_instance = self.software_instance.REQUEST.get('request_instance')
self.assertSameSet( self.assertSameSet(
self.software_instance.getPredecessorList(), self.software_instance.getSuccessorList(),
[B_instance.getRelativeUrl(), C_instance.getRelativeUrl()]) [B_instance.getRelativeUrl(), C_instance.getRelativeUrl()])
transaction.commit() transaction.commit()
...@@ -1512,7 +1512,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin): ...@@ -1512,7 +1512,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin):
C_instance = self.software_instance.REQUEST.get('request_instance') C_instance = self.software_instance.REQUEST.get('request_instance')
self.assertSameSet( self.assertSameSet(
self.software_instance.getPredecessorList(), self.software_instance.getSuccessorList(),
[B_instance.getRelativeUrl(), C_instance.getRelativeUrl()]) [B_instance.getRelativeUrl(), C_instance.getRelativeUrl()])
self.assertRaises(NotImplementedError, B_instance.requestInstance, self.assertRaises(NotImplementedError, B_instance.requestInstance,
...@@ -1582,7 +1582,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin): ...@@ -1582,7 +1582,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin):
# in case of destruction instance is not returned, so fetch it # in case of destruction instance is not returned, so fetch it
# directly form document # directly form document
requested_instance3 = self.software_instance.getPredecessorValue( requested_instance3 = self.software_instance.getSuccessorValue(
portal_type='Software Instance') portal_type='Software Instance')
self.assertEqual(request_kw['software_title'], self.assertEqual(request_kw['software_title'],
requested_instance3.getTitle()) requested_instance3.getTitle())
...@@ -1665,7 +1665,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin): ...@@ -1665,7 +1665,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin):
request_kw['state'] = 'destroyed' request_kw['state'] = 'destroyed'
self.software_instance.requestInstance(**request_kw) self.software_instance.requestInstance(**request_kw)
transaction.commit() transaction.commit()
requested_instance2 = self.software_instance.getPredecessorValue( requested_instance2 = self.software_instance.getSuccessorValue(
portal_type='Software Instance') portal_type='Software Instance')
self.assertEqual(requested_instance.getRelativeUrl(), self.assertEqual(requested_instance.getRelativeUrl(),
...@@ -1704,7 +1704,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin): ...@@ -1704,7 +1704,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin):
C_instance = self.software_instance.REQUEST.get('request_instance') C_instance = self.software_instance.REQUEST.get('request_instance')
self.assertSameSet( self.assertSameSet(
self.software_instance.getPredecessorList(), self.software_instance.getSuccessorList(),
[B_instance.getRelativeUrl(), C_instance.getRelativeUrl()]) [B_instance.getRelativeUrl(), C_instance.getRelativeUrl()])
self.tic() # in order to recalculate tree self.tic() # in order to recalculate tree
...@@ -1714,9 +1714,9 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin): ...@@ -1714,9 +1714,9 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin):
self.assertEqual(C_instance.getRelativeUrl(), C1_instance.getRelativeUrl()) self.assertEqual(C_instance.getRelativeUrl(), C1_instance.getRelativeUrl())
self.assertSameSet(self.software_instance.getPredecessorList(), self.assertSameSet(self.software_instance.getSuccessorList(),
[B_instance.getRelativeUrl()]) [B_instance.getRelativeUrl()])
self.assertSameSet(B_instance.getPredecessorList(), self.assertSameSet(B_instance.getSuccessorList(),
[C_instance.getRelativeUrl()]) [C_instance.getRelativeUrl()])
def test_request_tree_change_not_indexed_shared(self): def test_request_tree_change_not_indexed_shared(self):
...@@ -1744,7 +1744,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin): ...@@ -1744,7 +1744,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin):
C_instance = self.software_instance.REQUEST.get('request_instance') C_instance = self.software_instance.REQUEST.get('request_instance')
self.assertSameSet( self.assertSameSet(
self.software_instance.getPredecessorList(), self.software_instance.getSuccessorList(),
[B_instance.getRelativeUrl(), C_instance.getRelativeUrl()]) [B_instance.getRelativeUrl(), C_instance.getRelativeUrl()])
transaction.commit() transaction.commit()
...@@ -1778,7 +1778,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin): ...@@ -1778,7 +1778,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin):
C_instance = self.software_instance.REQUEST.get('request_instance') C_instance = self.software_instance.REQUEST.get('request_instance')
self.assertSameSet( self.assertSameSet(
self.software_instance.getPredecessorList(), self.software_instance.getSuccessorList(),
[B_instance.getRelativeUrl(), C_instance.getRelativeUrl()]) [B_instance.getRelativeUrl(), C_instance.getRelativeUrl()])
self.assertRaises(NotImplementedError, B_instance.requestInstance, self.assertRaises(NotImplementedError, B_instance.requestInstance,
...@@ -1799,7 +1799,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin): ...@@ -1799,7 +1799,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin):
request_kw['software_release'] = self.generateNewSoftwareReleaseUrl() request_kw['software_release'] = self.generateNewSoftwareReleaseUrl()
self.software_instance.requestInstance(**request_kw) self.software_instance.requestInstance(**request_kw)
requested_instance2 = self.software_instance.getPredecessorValue( requested_instance2 = self.software_instance.getSuccessorValue(
portal_type='Software Instance') portal_type='Software Instance')
transaction.commit() transaction.commit()
...@@ -1825,7 +1825,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin): ...@@ -1825,7 +1825,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin):
request_kw['software_type'] = self.generateNewSoftwareReleaseUrl() request_kw['software_type'] = self.generateNewSoftwareReleaseUrl()
self.software_instance.requestInstance(**request_kw) self.software_instance.requestInstance(**request_kw)
requested_instance2 = self.software_instance.getPredecessorValue( requested_instance2 = self.software_instance.getSuccessorValue(
portal_type='Software Instance') portal_type='Software Instance')
transaction.commit() transaction.commit()
...@@ -1851,7 +1851,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin): ...@@ -1851,7 +1851,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin):
request_kw['instance_xml'] = self.generateSafeXml() request_kw['instance_xml'] = self.generateSafeXml()
self.software_instance.requestInstance(**request_kw) self.software_instance.requestInstance(**request_kw)
requested_instance2 = self.software_instance.getPredecessorValue( requested_instance2 = self.software_instance.getSuccessorValue(
portal_type='Software Instance') portal_type='Software Instance')
transaction.commit() transaction.commit()
...@@ -1877,7 +1877,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin): ...@@ -1877,7 +1877,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin):
request_kw['sla_xml'] = self.generateSafeXml() request_kw['sla_xml'] = self.generateSafeXml()
self.software_instance.requestInstance(**request_kw) self.software_instance.requestInstance(**request_kw)
requested_instance2 = self.software_instance.getPredecessorValue( requested_instance2 = self.software_instance.getSuccessorValue(
portal_type='Software Instance') portal_type='Software Instance')
transaction.commit() transaction.commit()
...@@ -2914,7 +2914,7 @@ class TestSlapOSCoreSlapOSCloudInteractionWorkflow(SlapOSTestCaseMixin): ...@@ -2914,7 +2914,7 @@ class TestSlapOSCoreSlapOSCloudInteractionWorkflow(SlapOSTestCaseMixin):
return self.check_change_instance_parameter("Slave Instance", return self.check_change_instance_parameter("Slave Instance",
'sla_xml') 'sla_xml')
def test_SoftwareInstance_setPredecessorList(self): def test_SoftwareInstance_setSuccessorList(self):
portal_type = "Software Instance" portal_type = "Software Instance"
self.person_user = self.makePerson() self.person_user = self.makePerson()
...@@ -2938,7 +2938,7 @@ class TestSlapOSCoreSlapOSCloudInteractionWorkflow(SlapOSTestCaseMixin): ...@@ -2938,7 +2938,7 @@ class TestSlapOSCoreSlapOSCloudInteractionWorkflow(SlapOSTestCaseMixin):
destination_reference="TESTINST-%s" % new_id, destination_reference="TESTINST-%s" % new_id,
ssl_certificate="foo", ssl_certificate="foo",
ssl_key="bar", ssl_key="bar",
predecessor_value=instance3, successor_value=instance3,
) )
new_id = self.generateNewId() new_id = self.generateNewId()
...@@ -2949,7 +2949,7 @@ class TestSlapOSCoreSlapOSCloudInteractionWorkflow(SlapOSTestCaseMixin): ...@@ -2949,7 +2949,7 @@ class TestSlapOSCoreSlapOSCloudInteractionWorkflow(SlapOSTestCaseMixin):
destination_reference="TESTINST-%s" % new_id, destination_reference="TESTINST-%s" % new_id,
ssl_certificate="foo", ssl_certificate="foo",
ssl_key="bar", ssl_key="bar",
predecessor_value=instance2, successor_value=instance2,
) )
self.tic() self.tic()
...@@ -2967,7 +2967,7 @@ class TestSlapOSCoreSlapOSCloudInteractionWorkflow(SlapOSTestCaseMixin): ...@@ -2967,7 +2967,7 @@ class TestSlapOSCoreSlapOSCloudInteractionWorkflow(SlapOSTestCaseMixin):
Base.reindexObject_call = Base._reindexObject Base.reindexObject_call = Base._reindexObject
Base._reindexObject = verify_reindexObject_call Base._reindexObject = verify_reindexObject_call
try: try:
instance1.edit(predecessor_value=instance3) instance1.edit(successor_value=instance3)
self.tic() self.tic()
finally: finally:
Base._reindexObject = Base.reindexObject_call Base._reindexObject = Base.reindexObject_call
......
...@@ -3,7 +3,7 @@ portal = instance.getPortalObject() ...@@ -3,7 +3,7 @@ portal = instance.getPortalObject()
for requester_instance in portal.portal_catalog( for requester_instance in portal.portal_catalog(
portal_type="Software Instance", portal_type="Software Instance",
default_predecessor_uid=instance.getUid()): default_successor_uid=instance.getUid()):
requester_instance.getObject().bang( requester_instance.getObject().bang(
bang_tree=False, bang_tree=False,
comment="%s parameters changed" % instance.getRelativeUrl()) comment="%s parameters changed" % instance.getRelativeUrl())
...@@ -36,17 +36,17 @@ if (portal.portal_activities.countMessageWithTag(tag) > 0): ...@@ -36,17 +36,17 @@ if (portal.portal_activities.countMessageWithTag(tag) > 0):
# graph allows to "simulate" tree change after requested operation # graph allows to "simulate" tree change after requested operation
graph = {} graph = {}
predecessor_list = hosting_subscription.getPredecessorValueList() successor_list = hosting_subscription.getSuccessorValueList()
graph[hosting_subscription.getUid()] = [predecessor.getUid() for predecessor in predecessor_list] graph[hosting_subscription.getUid()] = [successor.getUid() for successor in successor_list]
while True: while True:
try: try:
current_software_instance = predecessor_list.pop(0) current_software_instance = successor_list.pop(0)
except IndexError: except IndexError:
break break
current_software_instance_predecessor_list = current_software_instance.getPredecessorValueList() or [] current_software_instance_successor_list = current_software_instance.getSuccessorValueList() or []
graph[current_software_instance.getUid()] = [predecessor.getUid() graph[current_software_instance.getUid()] = [successor.getUid()
for predecessor in current_software_instance_predecessor_list] for successor in current_software_instance_successor_list]
predecessor_list.extend(current_software_instance_predecessor_list) successor_list.extend(current_software_instance_successor_list)
# Check if it already exists # Check if it already exists
request_software_instance_list = portal.portal_catalog( request_software_instance_list = portal.portal_catalog(
...@@ -110,24 +110,24 @@ if (request_software_instance is None): ...@@ -110,24 +110,24 @@ if (request_software_instance is None):
else: else:
instance_found = True instance_found = True
# Update the predecessor category of the previous requester # Update the successor category of the previous requester
predecessor = request_software_instance.getPredecessorRelatedValue(portal_type="Software Instance") successor = request_software_instance.getSuccessorRelatedValue(portal_type="Software Instance")
if (predecessor is None): if (successor is None):
# Check if the precessor is a Hosting Subscription # Check if the precessor is a Hosting Subscription
hosting_subscription_precessesor = request_software_instance.getPredecessorRelatedValue(portal_type="Hosting Subscription") hosting_subscription_precessesor = request_software_instance.getSuccessorRelatedValue(portal_type="Hosting Subscription")
if (requester_instance.getPortalType() != "Hosting Subscription" and hosting_subscription_precessesor is not None): if (requester_instance.getPortalType() != "Hosting Subscription" and hosting_subscription_precessesor is not None):
raise ValueError('It is disallowed to request root software instance %s' % request_software_instance.getRelativeUrl()) raise ValueError('It is disallowed to request root software instance %s' % request_software_instance.getRelativeUrl())
else: else:
predecessor = requester_instance successor = requester_instance
# It was a loose node, so check if it ok: # It was a loose node, so check if it ok:
if request_software_instance.getUid() not in graph: if request_software_instance.getUid() not in graph:
graph[request_software_instance.getUid()] = request_software_instance.getPredecessorUidList() graph[request_software_instance.getUid()] = request_software_instance.getSuccessorUidList()
predecessor_uid_list = predecessor.getPredecessorUidList() successor_uid_list = successor.getSuccessorUidList()
if request_software_instance.getUid() in predecessor_uid_list: if request_software_instance.getUid() in successor_uid_list:
predecessor_uid_list.remove(request_software_instance.getUid()) successor_uid_list.remove(request_software_instance.getUid())
predecessor.edit(predecessor_uid_list=predecessor_uid_list) successor.edit(successor_uid_list=successor_uid_list)
graph[predecessor.getUid()] = predecessor_uid_list graph[successor.getUid()] = successor_uid_list
if instance_found: if instance_found:
...@@ -151,21 +151,21 @@ if instance_found: ...@@ -151,21 +151,21 @@ if instance_found:
else: else:
raise ValueError, "state should be started, stopped or destroyed" raise ValueError, "state should be started, stopped or destroyed"
predecessor_list = requester_instance.getPredecessorList() + [request_software_instance_url] successor_list = requester_instance.getSuccessorList() + [request_software_instance_url]
uniq_predecessor_list = list(set(predecessor_list)) uniq_successor_list = list(set(successor_list))
predecessor_list.sort() successor_list.sort()
uniq_predecessor_list.sort() uniq_successor_list.sort()
assert predecessor_list == uniq_predecessor_list, "%s != %s" % (predecessor_list, uniq_predecessor_list) assert successor_list == uniq_successor_list, "%s != %s" % (successor_list, uniq_successor_list)
# update graph to reflect requested operation # update graph to reflect requested operation
graph[requester_instance.getUid()] = requester_instance.getPredecessorUidList() + [request_software_instance.getUid()] graph[requester_instance.getUid()] = requester_instance.getSuccessorUidList() + [request_software_instance.getUid()]
# check if all elements are still connected and if there is no cycle # check if all elements are still connected and if there is no cycle
request_software_instance.checkConnected(graph, hosting_subscription.getUid()) request_software_instance.checkConnected(graph, hosting_subscription.getUid())
request_software_instance.checkNotCyclic(graph) request_software_instance.checkNotCyclic(graph)
requester_instance.edit(predecessor_list=predecessor_list) requester_instance.edit(successor_list=successor_list)
else: else:
context.REQUEST.set('request_instance', None) context.REQUEST.set('request_instance', None)
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
<key> <string>after_script_name</string> </key> <key> <string>after_script_name</string> </key>
<value> <value>
<list> <list>
<string>SoftwareInstance_reindexRecursivelyPredecessorSoftwareInstanceList</string> <string>SoftwareInstance_reindexRecursivelySuccessorSoftwareInstanceList</string>
</list> </list>
</value> </value>
</item> </item>
...@@ -52,13 +52,13 @@ It will create duplicate activities, but only one for each will be fired.</strin ...@@ -52,13 +52,13 @@ It will create duplicate activities, but only one for each will be fired.</strin
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>SoftwareInstance_setPredecessorList</string> </value> <value> <string>SoftwareInstance_setSuccessorList</string> </value>
</item> </item>
<item> <item>
<key> <string>method_id</string> </key> <key> <string>method_id</string> </key>
<value> <value>
<list> <list>
<string>_setPredecessor.*</string> <string>_setSuccessor.*</string>
</list> </list>
</value> </value>
</item> </item>
...@@ -78,7 +78,7 @@ It will create duplicate activities, but only one for each will be fired.</strin ...@@ -78,7 +78,7 @@ It will create duplicate activities, but only one for each will be fired.</strin
<key> <string>script_name</string> </key> <key> <string>script_name</string> </key>
<value> <value>
<list> <list>
<string>SoftwareInstance_reindexRecursivelyPredecessorSoftwareInstanceList</string> <string>SoftwareInstance_reindexRecursivelySuccessorSoftwareInstanceList</string>
</list> </list>
</value> </value>
</item> </item>
......
def reindexRecursively(document, after_tag=None): def reindexRecursively(document, after_tag=None):
tag = document.getPath() + '_reindex' tag = document.getPath() + '_reindex'
document.activate(after_tag=after_tag).reindexObject(activate_kw=dict(tag=tag)) document.activate(after_tag=after_tag).reindexObject(activate_kw=dict(tag=tag))
for subdocument in document.getPredecessorValueList(portal_type='Software Instance'): for subdocument in document.getSuccessorValueList(portal_type='Software Instance'):
if subdocument.getValidationState() != 'invalidated': if subdocument.getValidationState() != 'invalidated':
reindexRecursively(subdocument, tag) reindexRecursively(subdocument, tag)
......
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>SoftwareInstance_reindexRecursivelyPredecessorSoftwareInstanceList</string> </value> <value> <string>SoftwareInstance_reindexRecursivelySuccessorSoftwareInstanceList</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -19,4 +19,4 @@ erp5_mysql_innodb/z_create_software_instance_tree ...@@ -19,4 +19,4 @@ erp5_mysql_innodb/z_create_software_instance_tree
erp5_mysql_innodb/z_create_versioning erp5_mysql_innodb/z_create_versioning
erp5_mysql_innodb/z_related_causality_subscription_request erp5_mysql_innodb/z_related_causality_subscription_request
erp5_mysql_innodb/z_related_default_or_child_aggregate erp5_mysql_innodb/z_related_default_or_child_aggregate
erp5_mysql_innodb/z_related_predecessor_but_with_different_title_than_catalog_title erp5_mysql_innodb/z_related_successor_but_with_different_title_than_catalog_title
\ No newline at end of file \ No newline at end of file
causality_subscription_request_related_uid | category,catalog/uid/z_related_causality_subscription_request causality_subscription_request_related_uid | category,catalog/uid/z_related_causality_subscription_request
related_predecessor_but_with_different_title_than_catalog_title | category,catalog/uid/z_related_predecessor_but_with_different_title_than_catalog_title related_successor_but_with_different_title_than_catalog_title | category,catalog/uid/z_related_successor_but_with_different_title_than_catalog_title
default_or_child_aggregate_reference | catalog,category,catalog/reference/z_related_default_or_child_aggregate default_or_child_aggregate_reference | catalog,category,catalog/reference/z_related_default_or_child_aggregate
default_or_child_aggregate_uid | catalog,category,catalog/uid/z_related_default_or_child_aggregate default_or_child_aggregate_uid | catalog,category,catalog/uid/z_related_default_or_child_aggregate
\ No newline at end of file
...@@ -9,7 +9,7 @@ hosting_subscription_module/template_hosting_subscription ...@@ -9,7 +9,7 @@ hosting_subscription_module/template_hosting_subscription
person_module/template_member person_module/template_member
person_module/template_member/** person_module/template_member/**
portal_alarms/slapos_allocate_instance portal_alarms/slapos_allocate_instance
portal_alarms/slapos_assert_hosting_subscription_predecessor portal_alarms/slapos_assert_hosting_subscription_successor
portal_alarms/slapos_cloud_invalidate_destroyed_instance portal_alarms/slapos_cloud_invalidate_destroyed_instance
portal_alarms/slapos_free_computer_partition portal_alarms/slapos_free_computer_partition
portal_alarms/slapos_garbage_collect_destroy_unlinked_instance portal_alarms/slapos_garbage_collect_destroy_unlinked_instance
......
Alarm Tool | SlapOSMasterUpgradeConstraint
Assignment | SlaposAssignmentConstraint Assignment | SlaposAssignmentConstraint
Computer Model | SlaposCapacity Computer Model | SlaposCapacity
Computer Partition | ComputerPartition Computer Partition | ComputerPartition
...@@ -11,6 +12,7 @@ Email | SlaposEmailConstraint ...@@ -11,6 +12,7 @@ Email | SlaposEmailConstraint
Hosting Subscription | HostingSubscription Hosting Subscription | HostingSubscription
Hosting Subscription | SlaposHostingSubscriptionConstraint Hosting Subscription | SlaposHostingSubscriptionConstraint
Hosting Subscription | SoftwareInstance Hosting Subscription | SoftwareInstance
Hosting Subscription | SoftwareInstanceUpgradeConstraint
Hosting Subscription | TextDocument Hosting Subscription | TextDocument
Hosting Subscription | Url Hosting Subscription | Url
Hosting Subscription | VariationRange Hosting Subscription | VariationRange
...@@ -29,6 +31,7 @@ Software Instance | HostingSubscription ...@@ -29,6 +31,7 @@ Software Instance | HostingSubscription
Software Instance | Reference Software Instance | Reference
Software Instance | SoftwareInstance Software Instance | SoftwareInstance
Software Instance | SoftwareInstanceConstraint Software Instance | SoftwareInstanceConstraint
Software Instance | SoftwareInstanceUpgradeConstraint
Software Instance | TextDocument Software Instance | TextDocument
Software Instance | Url Software Instance | Url
Software Instance | VariationRange Software Instance | VariationRange
......
SoftwareInstanceConstraint SoftwareInstanceConstraint
SlapOSMasterUpgradeConstraint
SlaposComputerPartitionConstraint SlaposComputerPartitionConstraint
SlaposHostingSubscriptionConstraint SlaposHostingSubscriptionConstraint
SlaveInstanceConstraint SlaveInstanceConstraint
InternetProtocolAddress InternetProtocolAddress
ComputerPartition ComputerPartition
SoftwareInstance SoftwareInstance
SoftwareInstanceUpgradeConstraint
HostingSubscription HostingSubscription
SlaposCapacity SlaposCapacity
SlaposPersonConstraint SlaposPersonConstraint
......
...@@ -3,6 +3,7 @@ test.erp5.testSlapOSCloudAllocationAlarm ...@@ -3,6 +3,7 @@ test.erp5.testSlapOSCloudAllocationAlarm
test.erp5.testSlapOSCloudWorkflow test.erp5.testSlapOSCloudWorkflow
test.erp5.testSlapOSCloudSecurityGroup test.erp5.testSlapOSCloudSecurityGroup
test.erp5.testSlapOSCloudConstraint test.erp5.testSlapOSCloudConstraint
test.erp5.testSlapOSCloudUpgrader
test.erp5.testSlapOSCloudShadow test.erp5.testSlapOSCloudShadow
test.erp5.SlapOSTestCaseMixin test.erp5.SlapOSTestCaseMixin
test.erp5.SlapOSTestCaseDefaultScenarioMixin test.erp5.SlapOSTestCaseDefaultScenarioMixin
......
...@@ -22,7 +22,7 @@ for hosting_subscription in hosting_subscription_list: ...@@ -22,7 +22,7 @@ for hosting_subscription in hosting_subscription_list:
if hosting_subscription.getSlapState() == 'destroy_requested': if hosting_subscription.getSlapState() == 'destroy_requested':
continue continue
instance = hosting_subscription.getPredecessorValue() instance = hosting_subscription.getSuccessorValue()
if instance is None or instance.getSlapState() in ('destroy_requested', 'stop_requested'): if instance is None or instance.getSlapState() in ('destroy_requested', 'stop_requested'):
continue continue
......
...@@ -5,7 +5,7 @@ if hosting_subscription is None: ...@@ -5,7 +5,7 @@ if hosting_subscription is None:
return return
instance = None instance = None
for possible_instance in hosting_subscription.getPredecessorValueList(): for possible_instance in hosting_subscription.getSuccessorValueList():
if possible_instance.getSlapState() != 'destroy_requested': if possible_instance.getSlapState() != 'destroy_requested':
instance = possible_instance instance = possible_instance
break break
......
...@@ -116,12 +116,12 @@ class TestSlapOSSupportRequestModule_getMonitoringUrlList(TestCRMSkinsMixin): ...@@ -116,12 +116,12 @@ class TestSlapOSSupportRequestModule_getMonitoringUrlList(TestCRMSkinsMixin):
self.assertEqual(module.SupportRequestModule_getMonitoringUrlList(), []) self.assertEqual(module.SupportRequestModule_getMonitoringUrlList(), [])
support_request.setAggregateValue(hosting_subscription) support_request.setAggregateValue(hosting_subscription)
support_request.validate() support_request.validate()
self.assertNotEqual(hosting_subscription.getPredecessorList(), []) self.assertNotEqual(hosting_subscription.getSuccessorList(), [])
self.tic() self.tic()
self.assertEqual(module.SupportRequestModule_getMonitoringUrlList(), []) self.assertEqual(module.SupportRequestModule_getMonitoringUrlList(), [])
instance = hosting_subscription.getPredecessorValue() instance = hosting_subscription.getSuccessorValue()
instance.setConnectionXml("""<?xml version='1.0' encoding='utf-8'?> instance.setConnectionXml("""<?xml version='1.0' encoding='utf-8'?>
<instance> <instance>
<parameter id="aa">xx</parameter> <parameter id="aa">xx</parameter>
...@@ -153,7 +153,7 @@ class TestSlapOSSupportRequestModule_getMonitoringUrlList(TestCRMSkinsMixin): ...@@ -153,7 +153,7 @@ class TestSlapOSSupportRequestModule_getMonitoringUrlList(TestCRMSkinsMixin):
"http://monitor.url/#/ABC") "http://monitor.url/#/ABC")
support_request.invalidate() support_request.invalidate()
self.tic() self.tic()
self.assertNotEqual(hosting_subscription.getPredecessorList(), []) self.assertNotEqual(hosting_subscription.getSuccessorList(), [])
class TestSlapOSFolder_getOpenTicketList(TestCRMSkinsMixin): class TestSlapOSFolder_getOpenTicketList(TestCRMSkinsMixin):
...@@ -1025,7 +1025,7 @@ class TestSlapOSGenerateSupportRequestForSlapOS(TestCRMSkinsMixin): ...@@ -1025,7 +1025,7 @@ class TestSlapOSGenerateSupportRequestForSlapOS(TestCRMSkinsMixin):
self._makeSoftwareInstance(hosting_subscription, self._makeSoftwareInstance(hosting_subscription,
self.generateNewSoftwareReleaseUrl()) self.generateNewSoftwareReleaseUrl())
instance = hosting_subscription.getPredecessorValue() instance = hosting_subscription.getSuccessorValue()
title = "Test Support Request %s" % instance.getReference() title = "Test Support Request %s" % instance.getReference()
support_request = instance.Base_generateSupportRequestForSlapOS( support_request = instance.Base_generateSupportRequestForSlapOS(
title, title, instance.getRelativeUrl() title, title, instance.getRelativeUrl()
...@@ -1517,7 +1517,7 @@ class TestSlapOSHasError(SlapOSTestCaseMixin): ...@@ -1517,7 +1517,7 @@ class TestSlapOSHasError(SlapOSTestCaseMixin):
hosting_subscription = self._makeHostingSubscription() hosting_subscription = self._makeHostingSubscription()
self._makeSoftwareInstance(hosting_subscription, self._makeSoftwareInstance(hosting_subscription,
self.generateNewSoftwareReleaseUrl()) self.generateNewSoftwareReleaseUrl())
instance = hosting_subscription.getPredecessorValue() instance = hosting_subscription.getSuccessorValue()
self._makeComputer() self._makeComputer()
self._makeComputerPartitionList() self._makeComputerPartitionList()
...@@ -1590,7 +1590,7 @@ class TestSlapOSHasError(SlapOSTestCaseMixin): ...@@ -1590,7 +1590,7 @@ class TestSlapOSHasError(SlapOSTestCaseMixin):
self._makeSoftwareInstance(hosting_subscription, self._makeSoftwareInstance(hosting_subscription,
self.generateNewSoftwareReleaseUrl()) self.generateNewSoftwareReleaseUrl())
instance = hosting_subscription.getPredecessorValue() instance = hosting_subscription.getSuccessorValue()
self.assertEqual(instance.getCreationDate(), date - 2) self.assertEqual(instance.getCreationDate(), date - 2)
...@@ -1649,7 +1649,7 @@ class TestSlapOSHasError(SlapOSTestCaseMixin): ...@@ -1649,7 +1649,7 @@ class TestSlapOSHasError(SlapOSTestCaseMixin):
self._makeSoftwareInstance(hosting_subscription, self._makeSoftwareInstance(hosting_subscription,
self.generateNewSoftwareReleaseUrl()) self.generateNewSoftwareReleaseUrl())
instance = hosting_subscription.getPredecessorValue() instance = hosting_subscription.getSuccessorValue()
self.assertEqual(instance.getCreationDate(), date - 2) self.assertEqual(instance.getCreationDate(), date - 2)
...@@ -1698,7 +1698,7 @@ class TestSlapOSHasError(SlapOSTestCaseMixin): ...@@ -1698,7 +1698,7 @@ class TestSlapOSHasError(SlapOSTestCaseMixin):
self._makeSoftwareInstance(hosting_subscription, self._makeSoftwareInstance(hosting_subscription,
self.generateNewSoftwareReleaseUrl()) self.generateNewSoftwareReleaseUrl())
instance = hosting_subscription.getPredecessorValue() instance = hosting_subscription.getSuccessorValue()
self.assertEqual(instance.getCreationDate(), date - 2) self.assertEqual(instance.getCreationDate(), date - 2)
...@@ -1728,7 +1728,7 @@ class TestSlapOSHasError(SlapOSTestCaseMixin): ...@@ -1728,7 +1728,7 @@ class TestSlapOSHasError(SlapOSTestCaseMixin):
self.assertEqual( self.assertEqual(
'Visited by HostingSubscription_createSupportRequestEvent %s %s' % \ 'Visited by HostingSubscription_createSupportRequestEvent %s %s' % \
(instance.getPredecessor(portal_type="Software Instance"), (instance.getSuccessor(portal_type="Software Instance"),
"slapos-crm-hosting-subscription-instance-allocation.notification"), "slapos-crm-hosting-subscription-instance-allocation.notification"),
hosting_subscription.HostingSubscription_checkSoftwareInstanceState()) hosting_subscription.HostingSubscription_checkSoftwareInstanceState())
...@@ -1752,7 +1752,7 @@ class TestSlapOSHasError(SlapOSTestCaseMixin): ...@@ -1752,7 +1752,7 @@ class TestSlapOSHasError(SlapOSTestCaseMixin):
self._makeSoftwareInstance(hosting_subscription, self._makeSoftwareInstance(hosting_subscription,
self.generateNewSoftwareReleaseUrl()) self.generateNewSoftwareReleaseUrl())
instance = hosting_subscription.getPredecessorValue() instance = hosting_subscription.getSuccessorValue()
self._makeComputer() self._makeComputer()
......
...@@ -20,7 +20,7 @@ portal_alarms/open_bugs_alarm;0;None;BugModule_sendOpenBugListReminder;None;None ...@@ -20,7 +20,7 @@ portal_alarms/open_bugs_alarm;0;None;BugModule_sendOpenBugListReminder;None;None
portal_alarms/promise_check_upgrade;0;None;Alarm_runFullUpgrader;None;None;None;();None;();None;();();None;2013/11/14 10:00:00 GMT;None;();None;None portal_alarms/promise_check_upgrade;0;None;Alarm_runFullUpgrader;None;None;None;();None;();None;();();None;2013/11/14 10:00:00 GMT;None;();None;None
portal_alarms/slapos_accounting_generate_packing_list_from_tioxml;1;None;Alarm_searchSubmittedConsumptionTioXMLFileList;None;None;1;(4,);None;(0,);None;();();None;1970/01/01 00:00:00 GMT;None;();None;None portal_alarms/slapos_accounting_generate_packing_list_from_tioxml;1;None;Alarm_searchSubmittedConsumptionTioXMLFileList;None;None;1;(4,);None;(0,);None;();();None;1970/01/01 00:00:00 GMT;None;();None;None
portal_alarms/slapos_allocate_instance;1;None;Alarm_allocateInstance;None;None;None;();None;();1;();();None;2010/10/26 00:00:00 GMT;None;();None;None portal_alarms/slapos_allocate_instance;1;None;Alarm_allocateInstance;None;None;None;();None;();1;();();None;2010/10/26 00:00:00 GMT;None;();None;None
portal_alarms/slapos_assert_hosting_subscription_predecessor;1;None;Alarm_assertHostingSubscriptionHasPredecessor;None;None;None;();None;();1;();();None;1980/01/01 00:00:00 GMT;None;();None;None portal_alarms/slapos_assert_hosting_subscription_successor;1;None;Alarm_assertHostingSubscriptionHasSuccessor;None;None;None;();None;();1;();();None;1980/01/01 00:00:00 GMT;None;();None;None
portal_alarms/slapos_check_duplicated_software_instance;0;None;Alarm_searchDuplicatedSoftwareInstance;None;None;None;None;None;None;None;None;None;None;1983/10/01 00:00:00 GMT;None;None;None;None portal_alarms/slapos_check_duplicated_software_instance;0;None;Alarm_searchDuplicatedSoftwareInstance;None;None;None;None;None;None;None;None;None;None;1983/10/01 00:00:00 GMT;None;None;None;None
portal_alarms/slapos_check_security_uid;0;None;Alarm_checkUnindexedSecurityUid;None;None;None;None;None;None;None;None;None;None;1983/10/01 00:00:00 GMT;None;None;None;None portal_alarms/slapos_check_security_uid;0;None;Alarm_checkUnindexedSecurityUid;None;None;None;None;None;None;None;None;None;None;1983/10/01 00:00:00 GMT;None;None;None;None
portal_alarms/slapos_cloud_invalidate_destroyed_instance;1;None;Alarm_invalidateDestroyedInstance;None;None;None;();1;();None;();();None;2010/10/26 00:00:00 GMT;None;();None;None portal_alarms/slapos_cloud_invalidate_destroyed_instance;1;None;Alarm_invalidateDestroyedInstance;None;None;None;();1;();None;();();None;2010/10/26 00:00:00 GMT;None;();None;None
......
...@@ -3740,7 +3740,7 @@ slapos_base;Login_unrestrictedSearchAuthenticationEvent;External Method;d41d8cd9 ...@@ -3740,7 +3740,7 @@ slapos_base;Login_unrestrictedSearchAuthenticationEvent;External Method;d41d8cd9
slapos_base;Login_unrestrictedSearchPasswordEvent;External Method;d41d8cd98f00b204e9800998ecf8427e slapos_base;Login_unrestrictedSearchPasswordEvent;External Method;d41d8cd98f00b204e9800998ecf8427e
slapos_base;Person_generatePassword;Script (Python);c7ef6238cae53aa95b033073585f0901 slapos_base;Person_generatePassword;Script (Python);c7ef6238cae53aa95b033073585f0901
slapos_cloud;Alarm_allocateInstance;Script (Python);acc96d48f45c96906bc0d8534ed3dea6 slapos_cloud;Alarm_allocateInstance;Script (Python);acc96d48f45c96906bc0d8534ed3dea6
slapos_cloud;Alarm_assertHostingSubscriptionHasPredecessor;Script (Python);7c0335b05dbeaae5da24936c7822cd08 slapos_cloud;Alarm_assertHostingSubscriptionHasSuccessor;Script (Python);7c0335b05dbeaae5da24936c7822cd08
slapos_cloud;Alarm_garbageCollectDestroyUnlinkedInstance;Script (Python);a9fa5bcdfbbc9d2e97a53c31082b8d54 slapos_cloud;Alarm_garbageCollectDestroyUnlinkedInstance;Script (Python);a9fa5bcdfbbc9d2e97a53c31082b8d54
slapos_cloud;Alarm_garbageCollectDestroyedRootTree;Script (Python);c7693ceb6f665d589769e75f76bba13a slapos_cloud;Alarm_garbageCollectDestroyedRootTree;Script (Python);c7693ceb6f665d589769e75f76bba13a
slapos_cloud;Alarm_garbageCollectNonAllocatedRootTree;Script (Python);f4cac8eb737a55987061cbcc5d4bed5a slapos_cloud;Alarm_garbageCollectNonAllocatedRootTree;Script (Python);f4cac8eb737a55987061cbcc5d4bed5a
...@@ -3794,7 +3794,7 @@ slapos_cloud;Computer_viewCurrentUsage;ERP5 Form;567bc1d268f135496de3d5b946b691f ...@@ -3794,7 +3794,7 @@ slapos_cloud;Computer_viewCurrentUsage;ERP5 Form;567bc1d268f135496de3d5b946b691f
slapos_cloud;Computer_viewModel;ERP5 Form;567bc1d268f135496de3d5b946b691f3 slapos_cloud;Computer_viewModel;ERP5 Form;567bc1d268f135496de3d5b946b691f3
slapos_cloud;ERP5Type_asSecurityGroupId;Script (Python);6abe5e755c936d813d93ca1fcd441580 slapos_cloud;ERP5Type_asSecurityGroupId;Script (Python);6abe5e755c936d813d93ca1fcd441580
slapos_cloud;HostingSubscriptionModule_viewHostingSubscriptionList;ERP5 Form;567bc1d268f135496de3d5b946b691f3 slapos_cloud;HostingSubscriptionModule_viewHostingSubscriptionList;ERP5 Form;567bc1d268f135496de3d5b946b691f3
slapos_cloud;HostingSubscription_assertPredecessor;Script (Python);b5ff47cbf59b6b48746890b0753e7606 slapos_cloud;HostingSubscription_assertSuccessor;Script (Python);b5ff47cbf59b6b48746890b0753e7606
slapos_cloud;HostingSubscription_createMovement;Script (Python);c2f26b34c511ea84c1bb6cb6cbf4f06d slapos_cloud;HostingSubscription_createMovement;Script (Python);c2f26b34c511ea84c1bb6cb6cbf4f06d
slapos_cloud;HostingSubscription_requestDestroy;Script (Python);8e98fdfd518b1de8dcbb3a5d0ba37e5a slapos_cloud;HostingSubscription_requestDestroy;Script (Python);8e98fdfd518b1de8dcbb3a5d0ba37e5a
slapos_cloud;HostingSubscription_requestPerson;Script (Python);0f307b89333e4376e21ba85e600372d0 slapos_cloud;HostingSubscription_requestPerson;Script (Python);0f307b89333e4376e21ba85e600372d0
...@@ -3854,7 +3854,7 @@ slapos_cloud_interaction_workflow;Instance_invalidate;Script (Python);fcaf874d03 ...@@ -3854,7 +3854,7 @@ slapos_cloud_interaction_workflow;Instance_invalidate;Script (Python);fcaf874d03
slapos_cloud_interaction_workflow;Instance_triggerAllocationAlarm;Script (Python);613d655f8c33a46c141848330a6fa24c slapos_cloud_interaction_workflow;Instance_triggerAllocationAlarm;Script (Python);613d655f8c33a46c141848330a6fa24c
slapos_cloud_interaction_workflow;SoftwareInstallation_reindexComputer;Script (Python);85f2179687f313a0ca70f2be62064bbc slapos_cloud_interaction_workflow;SoftwareInstallation_reindexComputer;Script (Python);85f2179687f313a0ca70f2be62064bbc
slapos_cloud_interaction_workflow;SoftwareInstance_reindexComputerPartition;Script (Python);5189f54f1d3e70956ef2d573c13b8a3f slapos_cloud_interaction_workflow;SoftwareInstance_reindexComputerPartition;Script (Python);5189f54f1d3e70956ef2d573c13b8a3f
slapos_cloud_interaction_workflow;SoftwareInstance_reindexRecursivelyPredecessorSoftwareInstanceList;Script (Python);cb79894e2b06592e4f15092182f63830 slapos_cloud_interaction_workflow;SoftwareInstance_reindexRecursivelySuccessorSoftwareInstanceList;Script (Python);cb79894e2b06592e4f15092182f63830
slapos_configurator;BusinessConfiguration_invokeSlapOSMasterPromiseAlarmList;Script (Python);26e275695886835b1c8957aa23da5b7c slapos_configurator;BusinessConfiguration_invokeSlapOSMasterPromiseAlarmList;Script (Python);26e275695886835b1c8957aa23da5b7c
slapos_configurator;BusinessConfiguration_setupSlapOSMasterStandardBT5;Script (Python);be0a52a246011ea6a23811640b864cbe slapos_configurator;BusinessConfiguration_setupSlapOSMasterStandardBT5;Script (Python);be0a52a246011ea6a23811640b864cbe
slapos_configurator;TemplateTool_getSlapOSMasterBusinessTemplateList;Script (Python);620fc8300f61b25e30507b4f2eb18f39 slapos_configurator;TemplateTool_getSlapOSMasterBusinessTemplateList;Script (Python);620fc8300f61b25e30507b4f2eb18f39
......
...@@ -16771,12 +16771,12 @@ SlaveInstanceConstraint ...@@ -16771,12 +16771,12 @@ SlaveInstanceConstraint
reference: non_draft_property_existence reference: non_draft_property_existence
SlaveInstanceConstraint SlaveInstanceConstraint
expression: python: len(context.getPredecessorRelatedList()) <= 1 expression: python: len(context.getSuccessorRelatedList()) <= 1
id: predecessor_related_constraint id: successor_related_constraint
message_expression_error: Error while evaluating expression: ${error} message_expression_error: Error while evaluating expression: ${error}
message_expression_false: There is more then one related predecessor message_expression_false: There is more then one related successor
portal_type: TALES Constraint portal_type: TALES Constraint
reference: predecessor_related reference: successor_related
SlaveInstanceConstraint SlaveInstanceConstraint
constraint_property_list: ['reference'] constraint_property_list: ['reference']
...@@ -16817,9 +16817,9 @@ SoftwareInstance ...@@ -16817,9 +16817,9 @@ SoftwareInstance
write_permission: Modify portal content write_permission: Modify portal content
SoftwareInstance SoftwareInstance
id: predecessor_category id: successor_category
portal_type: Category Property portal_type: Category Property
reference: predecessor reference: successor
SoftwareInstance SoftwareInstance
elementary_type: text elementary_type: text
...@@ -16889,12 +16889,12 @@ SoftwareInstanceConstraint ...@@ -16889,12 +16889,12 @@ SoftwareInstanceConstraint
reference: not_draft_propert_existence reference: not_draft_propert_existence
SoftwareInstanceConstraint SoftwareInstanceConstraint
expression: python: len(context.getPredecessorRelatedList()) <= 1 expression: python: len(context.getSuccessorRelatedList()) <= 1
id: predecessor_related_constraint id: successor_related_constraint
message_expression_error: Error while evaluating expression: ${error} message_expression_error: Error while evaluating expression: ${error}
message_expression_false: There is more then one related predecessor message_expression_false: There is more then one related successor
portal_type: TALES Constraint portal_type: TALES Constraint
reference: predecessor_related reference: successor_related
SoftwareInstanceConstraint SoftwareInstanceConstraint
constraint_property_list: ['destination_reference', 'reference'] constraint_property_list: ['destination_reference', 'reference']
......
...@@ -13741,7 +13741,7 @@ Slave Instance ...@@ -13741,7 +13741,7 @@ Slave Instance
Slave Instance Slave Instance
Reference: jump_to_software_instance Reference: jump_to_software_instance
Title: Software Instance Title: Software Instance
Action: string:${object_url}/Base_jumpToRelatedObject?base_category=predecessor&portal_type=Software+Instance Action: string:${object_url}/Base_jumpToRelatedObject?base_category=successor&portal_type=Software+Instance
Icon: None Icon: None
Permission: View Permission: View
Action Type: object_jump Action Type: object_jump
...@@ -13841,7 +13841,7 @@ Software Instance ...@@ -13841,7 +13841,7 @@ Software Instance
Software Instance Software Instance
Reference: jump_to_software_instance Reference: jump_to_software_instance
Title: Requester Instance Title: Requester Instance
Action: string:${object_url}/Base_jumpToRelatedObject?base_category=predecessor&portal_type:list=Software+Instance&portal_type:list=Hosting+Subscription Action: string:${object_url}/Base_jumpToRelatedObject?base_category=successor&portal_type:list=Software+Instance&portal_type:list=Hosting+Subscription
Icon: None Icon: None
Permission: View Permission: View
Action Type: object_jump Action Type: object_jump
......
title = context.getTitle() title = context.getTitle()
result = [] result = []
found = False found = False
for instance in context.getPredecessorValueList(): for instance in context.getSuccessorValueList():
if (instance.getTitle() == title) and (instance.getSlapState() != 'destroy_requested'): if (instance.getTitle() == title) and (instance.getSlapState() != 'destroy_requested'):
found = True found = True
break break
......
...@@ -21,7 +21,7 @@ hosting_subscription = context ...@@ -21,7 +21,7 @@ hosting_subscription = context
if hosting_subscription.getSlapState() == 'destroy_requested': if hosting_subscription.getSlapState() == 'destroy_requested':
return json.dumps({}) return json.dumps({})
instance = hosting_subscription.getPredecessorValue() instance = hosting_subscription.getSuccessorValue()
if instance is None or instance.getSlapState() == 'destroy_requested': if instance is None or instance.getSlapState() == 'destroy_requested':
return json.dumps({}) return json.dumps({})
......
...@@ -16,7 +16,7 @@ elif context.getPortalType() != "Hosting Subscription": ...@@ -16,7 +16,7 @@ elif context.getPortalType() != "Hosting Subscription":
response.setStatus(403) response.setStatus(403)
return "" return ""
instance_list = context.getPredecessorValueList() instance_list = context.getSuccessorValueList()
for instance in instance_list: for instance in instance_list:
if instance.getTitle() == context.getTitle(): if instance.getTitle() == context.getTitle():
root_instance = instance root_instance = instance
......
...@@ -462,7 +462,7 @@ class TestSlapOSHostingSubscription_getHateoasRootSoftwareInstance(TestSlapOSHyp ...@@ -462,7 +462,7 @@ class TestSlapOSHostingSubscription_getHateoasRootSoftwareInstance(TestSlapOSHyp
subscription = self._makeHostingSubscription() subscription = self._makeHostingSubscription()
instance = self._makeInstance() instance = self._makeInstance()
instance.edit(specialise_value=subscription, title=subscription.getTitle()) instance.edit(specialise_value=subscription, title=subscription.getTitle())
subscription.edit(predecessor_value=instance) subscription.edit(successor_value=instance)
self.tic() self.tic()
fake_request = do_fake_request("GET") fake_request = do_fake_request("GET")
......
...@@ -7,7 +7,7 @@ if upgrade_scope in ["never", "disabled"]: ...@@ -7,7 +7,7 @@ if upgrade_scope in ["never", "disabled"]:
return return
root_instance_list = [ root_instance_list = [
q for q in hosting_subscription.getPredecessorValueList(portal_type=["Software Instance", "Slave Instance"]) q for q in hosting_subscription.getSuccessorValueList(portal_type=["Software Instance", "Slave Instance"])
if q.getSlapState() != 'destroy_requested'] if q.getSlapState() != 'destroy_requested']
if len(root_instance_list) == 0: if len(root_instance_list) == 0:
return return
......
hosting_subscription = context hosting_subscription = context
software_instance = hosting_subscription.getPredecessorValue() software_instance = hosting_subscription.getSuccessorValue()
if not software_instance: if not software_instance:
return None return None
software_release_list = context.SoftwareProduct_getSortedSoftwareReleaseList( software_release_list = context.SoftwareProduct_getSortedSoftwareReleaseList(
......
...@@ -11,7 +11,7 @@ slap_state = ['start_requested', 'stop_requested'] ...@@ -11,7 +11,7 @@ slap_state = ['start_requested', 'stop_requested']
if not hosting_subscription.getSlapState() in slap_state: if not hosting_subscription.getSlapState() in slap_state:
return None return None
source_instance_list = [q for q in hosting_subscription.getPredecessorValueList() if q.getSlapState() in slap_state] source_instance_list = [q for q in hosting_subscription.getSuccessorValueList() if q.getSlapState() in slap_state]
if len(source_instance_list) == 0: if len(source_instance_list) == 0:
return None return None
source_instance = source_instance_list[0] source_instance = source_instance_list[0]
......
portal = context.getPortalObject() portal = context.getPortalObject()
# This won't work well on clusters deployed on multiple computers. # This won't work well on clusters deployed on multiple computers.
root_instance = context.getPredecessorValue( root_instance = context.getSuccessorValue(
portal_type=["Software Instance", "Slave Instance"]) portal_type=["Software Instance", "Slave Instance"])
if root_instance is not None and root_instance.getPortalType() == 'Slave Instance': if root_instance is not None and root_instance.getPortalType() == 'Slave Instance':
return True return True
......
...@@ -80,7 +80,7 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins): ...@@ -80,7 +80,7 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
hosting_subscription.requestStart(**request_kw) hosting_subscription.requestStart(**request_kw)
hosting_subscription.requestInstance(**request_kw) hosting_subscription.requestInstance(**request_kw)
instance = hosting_subscription.getPredecessorValue() instance = hosting_subscription.getSuccessorValue()
self.tic() self.tic()
return hosting_subscription, instance return hosting_subscription, instance
...@@ -185,7 +185,7 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins): ...@@ -185,7 +185,7 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
self._makeFullSoftwareInstance(hosting_subscription, url_string) self._makeFullSoftwareInstance(hosting_subscription, url_string)
self._markComputerPartitionBusy(computer, self._markComputerPartitionBusy(computer,
hosting_subscription.getPredecessorValue()) hosting_subscription.getSuccessorValue())
self._requestSoftwareRelease(software_product.getRelativeUrl()) self._requestSoftwareRelease(software_product.getRelativeUrl())
self.tic() self.tic()
...@@ -209,7 +209,7 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins): ...@@ -209,7 +209,7 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
url_string, person) url_string, person)
self._makeFullSoftwareInstance(hosting_subscription, url_string) self._makeFullSoftwareInstance(hosting_subscription, url_string)
self._markComputerPartitionBusy(computer, self._markComputerPartitionBusy(computer,
hosting_subscription.getPredecessorValue()) hosting_subscription.getSuccessorValue())
# Install the Newest software release # Install the Newest software release
software_release2 = self._requestSoftwareRelease( software_release2 = self._requestSoftwareRelease(
...@@ -237,7 +237,7 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins): ...@@ -237,7 +237,7 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
url_string, person) url_string, person)
self._makeFullSoftwareInstance(hosting_subscription, url_string) self._makeFullSoftwareInstance(hosting_subscription, url_string)
self._markComputerPartitionBusy(computer, self._markComputerPartitionBusy(computer,
hosting_subscription.getPredecessorValue()) hosting_subscription.getSuccessorValue())
# Install the Newest software release # Install the Newest software release
software_release2 = self._requestSoftwareRelease( software_release2 = self._requestSoftwareRelease(
...@@ -271,7 +271,7 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins): ...@@ -271,7 +271,7 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
url_string, person) url_string, person)
self._makeFullSoftwareInstance(hosting_subscription, url_string) self._makeFullSoftwareInstance(hosting_subscription, url_string)
self._markComputerPartitionBusy(computer, self._markComputerPartitionBusy(computer,
hosting_subscription.getPredecessorValue()) hosting_subscription.getSuccessorValue())
# Install the Newest software release # Install the Newest software release
software_release2 = self._requestSoftwareRelease( software_release2 = self._requestSoftwareRelease(
...@@ -311,7 +311,7 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins): ...@@ -311,7 +311,7 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
url_string, person) url_string, person)
self._makeFullSoftwareInstance(hosting_subscription, url_string) self._makeFullSoftwareInstance(hosting_subscription, url_string)
self._markComputerPartitionBusy(computer, self._markComputerPartitionBusy(computer,
hosting_subscription.getPredecessorValue()) hosting_subscription.getSuccessorValue())
# Install the Newest software release # Install the Newest software release
software_release2 = self._requestSoftwareRelease( software_release2 = self._requestSoftwareRelease(
...@@ -351,7 +351,7 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins): ...@@ -351,7 +351,7 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
url_string, person) url_string, person)
self._makeFullSoftwareInstance(hosting_subscription, url_string) self._makeFullSoftwareInstance(hosting_subscription, url_string)
self._markComputerPartitionBusy(computer, self._markComputerPartitionBusy(computer,
hosting_subscription.getPredecessorValue()) hosting_subscription.getSuccessorValue())
# Install the Newest software release # Install the Newest software release
software_release2 = self._requestSoftwareRelease( software_release2 = self._requestSoftwareRelease(
...@@ -390,7 +390,7 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins): ...@@ -390,7 +390,7 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
url_string, person) url_string, person)
self._makeFullSoftwareInstance(hosting_subscription, url_string) self._makeFullSoftwareInstance(hosting_subscription, url_string)
self._markComputerPartitionBusy(computer, self._markComputerPartitionBusy(computer,
hosting_subscription.getPredecessorValue()) hosting_subscription.getSuccessorValue())
# Install the Newest software release # Install the Newest software release
software_release2 = self._requestSoftwareRelease( software_release2 = self._requestSoftwareRelease(
......
...@@ -45,7 +45,7 @@ class TestSlapOSDestroySoftwareInstallationWithArchivedSoftwareReleaseAlarm(Slap ...@@ -45,7 +45,7 @@ class TestSlapOSDestroySoftwareInstallationWithArchivedSoftwareReleaseAlarm(Slap
hosting_subscription.requestStart(**request_kw) hosting_subscription.requestStart(**request_kw)
hosting_subscription.requestInstance(**request_kw) hosting_subscription.requestInstance(**request_kw)
instance = hosting_subscription.getPredecessorValue() instance = hosting_subscription.getSuccessorValue()
self.tic() self.tic()
return instance return instance
......
...@@ -156,7 +156,7 @@ class TestSlapOSPDMMixinSkins(SlapOSTestCaseMixin): ...@@ -156,7 +156,7 @@ class TestSlapOSPDMMixinSkins(SlapOSTestCaseMixin):
specialise=hosting_subscription.getRelativeUrl() specialise=hosting_subscription.getRelativeUrl()
) )
hosting_subscription.edit( hosting_subscription.edit(
predecessor=software_instance.getRelativeUrl() successor=software_instance.getRelativeUrl()
) )
self.portal.portal_workflow._jumpToStateFor(software_instance, 'start_requested') self.portal.portal_workflow._jumpToStateFor(software_instance, 'start_requested')
software_instance.validate() software_instance.validate()
...@@ -291,7 +291,7 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins): ...@@ -291,7 +291,7 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins):
None) None)
self._makeFullSoftwareInstance(hs, oldest_software_url) self._makeFullSoftwareInstance(hs, oldest_software_url)
self._markComputerPartitionBusy(computer, hs.getPredecessorValue()) self._markComputerPartitionBusy(computer, hs.getSuccessorValue())
self._makeCustomSoftwareRelease(software_product.getRelativeUrl(), self._makeCustomSoftwareRelease(software_product.getRelativeUrl(),
newest_software_url) newest_software_url)
self.tic() self.tic()
...@@ -313,7 +313,7 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins): ...@@ -313,7 +313,7 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins):
oldest_software_url, person) oldest_software_url, person)
self._makeFullSoftwareInstance(hs, oldest_software_url) self._makeFullSoftwareInstance(hs, oldest_software_url)
self._markComputerPartitionBusy(computer, hs.getPredecessorValue()) self._markComputerPartitionBusy(computer, hs.getSuccessorValue())
self._makeCustomSoftwareRelease(software_product.getRelativeUrl(), self._makeCustomSoftwareRelease(software_product.getRelativeUrl(),
newest_software_url) newest_software_url)
self._makeSoftwareInstallation(computer, self._makeSoftwareInstallation(computer,
......
...@@ -2064,7 +2064,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -2064,7 +2064,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
if os.path.exists(self.instance_request_simulator): if os.path.exists(self.instance_request_simulator):
os.unlink(self.instance_request_simulator) os.unlink(self.instance_request_simulator)
def test_updateInstancePredecessorList(self): def test_updateInstanceSuccessorList(self):
self._makeComplexComputer() self._makeComplexComputer()
partition_id = self.start_requested_software_instance.getAggregateValue( partition_id = self.start_requested_software_instance.getAggregateValue(
...@@ -2086,9 +2086,9 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -2086,9 +2086,9 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
self.start_requested_software_instance.requestInstance(**instance_kw) self.start_requested_software_instance.requestInstance(**instance_kw)
self.tic() self.tic()
self.assertEqual(len(self.start_requested_software_instance.getPredecessorList()), 2) self.assertEqual(len(self.start_requested_software_instance.getSuccessorList()), 2)
self.assertSameSet(['Instance0', 'Instance1'], self.assertSameSet(['Instance0', 'Instance1'],
self.start_requested_software_instance.getPredecessorTitleList()) self.start_requested_software_instance.getSuccessorTitleList())
# Update with no changes # Update with no changes
instance_list_xml = """ instance_list_xml = """
...@@ -2101,7 +2101,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -2101,7 +2101,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
instance_reference_xml=instance_list_xml) instance_reference_xml=instance_list_xml)
self.tic() self.tic()
self.assertSameSet(['Instance0', 'Instance1'], self.assertSameSet(['Instance0', 'Instance1'],
self.start_requested_software_instance.getPredecessorTitleList()) self.start_requested_software_instance.getSuccessorTitleList())
# Update Instance0 was not requested # Update Instance0 was not requested
instance_list_xml = """ instance_list_xml = """
...@@ -2114,9 +2114,9 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -2114,9 +2114,9 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
instance_reference_xml=instance_list_xml) instance_reference_xml=instance_list_xml)
self.tic() self.tic()
self.assertSameSet(['Instance1'], self.assertSameSet(['Instance1'],
self.start_requested_software_instance.getPredecessorTitleList()) self.start_requested_software_instance.getSuccessorTitleList())
def test_updateInstancePredecessorList_one_child(self): def test_updateInstanceSuccessorList_one_child(self):
self._makeComplexComputer() self._makeComplexComputer()
partition_id = self.start_requested_software_instance.getAggregateValue( partition_id = self.start_requested_software_instance.getAggregateValue(
...@@ -2136,9 +2136,9 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -2136,9 +2136,9 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
self.start_requested_software_instance.requestInstance(**instance_kw) self.start_requested_software_instance.requestInstance(**instance_kw)
self.tic() self.tic()
self.assertEqual(len(self.start_requested_software_instance.getPredecessorList()), 1) self.assertEqual(len(self.start_requested_software_instance.getSuccessorList()), 1)
self.assertSameSet(['Instance0'], self.assertSameSet(['Instance0'],
self.start_requested_software_instance.getPredecessorTitleList()) self.start_requested_software_instance.getSuccessorTitleList())
instance_list_xml = '<marshal><list id="i2" /></marshal>' instance_list_xml = '<marshal><list id="i2" /></marshal>'
self.portal_slap.updateComputerPartitionRelatedInstanceList( self.portal_slap.updateComputerPartitionRelatedInstanceList(
...@@ -2147,9 +2147,9 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -2147,9 +2147,9 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
instance_reference_xml=instance_list_xml) instance_reference_xml=instance_list_xml)
self.tic() self.tic()
self.assertEqual([], self.assertEqual([],
self.start_requested_software_instance.getPredecessorTitleList()) self.start_requested_software_instance.getSuccessorTitleList())
def test_updateInstancePredecessorList_no_child(self): def test_updateInstanceSuccessorList_no_child(self):
self._makeComplexComputer() self._makeComplexComputer()
partition_id = self.start_requested_software_instance.getAggregateValue( partition_id = self.start_requested_software_instance.getAggregateValue(
...@@ -2157,7 +2157,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -2157,7 +2157,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
self.login(self.start_requested_software_instance.getUserId()) self.login(self.start_requested_software_instance.getUserId())
self.assertEqual([], self.assertEqual([],
self.start_requested_software_instance.getPredecessorTitleList()) self.start_requested_software_instance.getSuccessorTitleList())
instance_list_xml = '<marshal><list id="i2" /></marshal>' instance_list_xml = '<marshal><list id="i2" /></marshal>'
self.portal_slap.updateComputerPartitionRelatedInstanceList( self.portal_slap.updateComputerPartitionRelatedInstanceList(
...@@ -2166,7 +2166,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -2166,7 +2166,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
instance_reference_xml=instance_list_xml) instance_reference_xml=instance_list_xml)
self.tic() self.tic()
self.assertEqual([], self.assertEqual([],
self.start_requested_software_instance.getPredecessorTitleList()) self.start_requested_software_instance.getSuccessorTitleList())
# Try with something that doesn't exist # Try with something that doesn't exist
instance_list_xml = """ instance_list_xml = """
...@@ -2179,7 +2179,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -2179,7 +2179,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
instance_reference_xml=instance_list_xml) instance_reference_xml=instance_list_xml)
self.tic() self.tic()
self.assertEqual([], self.assertEqual([],
self.start_requested_software_instance.getPredecessorTitleList()) self.start_requested_software_instance.getSuccessorTitleList())
def test_stoppedComputerPartition(self): def test_stoppedComputerPartition(self):
self._makeComplexComputer() self._makeComplexComputer()
......
...@@ -599,7 +599,7 @@ class SlapTool(BaseTool): ...@@ -599,7 +599,7 @@ class SlapTool(BaseTool):
computer_partition_id, computer_partition_id,
instance_reference_xml): instance_reference_xml):
""" """
Update Software Instance predecessor list Update Software Instance successor list
""" """
return self._updateComputerPartitionRelatedInstanceList(computer_id, return self._updateComputerPartitionRelatedInstanceList(computer_id,
computer_partition_id, computer_partition_id,
...@@ -1430,9 +1430,9 @@ class SlapTool(BaseTool): ...@@ -1430,9 +1430,9 @@ class SlapTool(BaseTool):
def _updateComputerPartitionRelatedInstanceList(self, computer_id, def _updateComputerPartitionRelatedInstanceList(self, computer_id,
computer_partition_id, instance_reference_xml): computer_partition_id, instance_reference_xml):
""" """
Update Software Instance predecessor list to match the given list. If one Update Software Instance successor list to match the given list. If one
instance was not requested by this computer partition, it should be removed instance was not requested by this computer partition, it should be removed
in the predecessor_list of this instance. in the successor_list of this instance.
Once the link is removed, this instance will be trashed by Garbage Collect! Once the link is removed, this instance will be trashed by Garbage Collect!
instance_reference_xml contain list of title of sub-instances requested by instance_reference_xml contain list of title of sub-instances requested by
...@@ -1446,21 +1446,21 @@ class SlapTool(BaseTool): ...@@ -1446,21 +1446,21 @@ class SlapTool(BaseTool):
if self._getLastData(cache_reference) != instance_reference_xml: if self._getLastData(cache_reference) != instance_reference_xml:
instance_reference_list = loads(instance_reference_xml) instance_reference_list = loads(instance_reference_xml)
current_predecessor_list = software_instance_document.getPredecessorValueList( current_successor_list = software_instance_document.getSuccessorValueList(
portal_type=['Software Instance', 'Slave Instance']) portal_type=['Software Instance', 'Slave Instance'])
current_predecessor_title_list = [i.getTitle() for i in current_successor_title_list = [i.getTitle() for i in
current_predecessor_list] current_successor_list]
# If there are items to remove # If there are items to remove
if list(set(current_predecessor_title_list).difference(instance_reference_list)) != []: if list(set(current_successor_title_list).difference(instance_reference_list)) != []:
predecessor_list = [instance.getRelativeUrl() for instance in successor_list = [instance.getRelativeUrl() for instance in
current_predecessor_list if instance.getTitle() current_successor_list if instance.getTitle()
in instance_reference_list] in instance_reference_list]
LOG('SlapTool', INFO, '%s, %s: Updating predecessor list to %s' % ( LOG('SlapTool', INFO, '%s, %s: Updating successor list to %s' % (
computer_id, computer_partition_id, predecessor_list), error=False) computer_id, computer_partition_id, successor_list), error=False)
software_instance_document.edit(predecessor_list=predecessor_list, software_instance_document.edit(successor_list=successor_list,
comment='predecessor_list edited to unlink non commited instances') comment='successor_list edited to unlink non commited instances')
self._storeLastData(cache_reference, instance_reference_xml) self._storeLastData(cache_reference, instance_reference_xml)
#################################################### ####################################################
......
...@@ -15,7 +15,7 @@ if hosting_subscription is not None: ...@@ -15,7 +15,7 @@ if hosting_subscription is not None:
# Call it as soon as possible # Call it as soon as possible
hosting_subscription.HostingSubscription_requestUpdateOpenSaleOrder() hosting_subscription.HostingSubscription_requestUpdateOpenSaleOrder()
instance = hosting_subscription.getPredecessorValue() instance = hosting_subscription.getSuccessorValue()
# This ensure that the user has a valid cloud contract. # This ensure that the user has a valid cloud contract.
# At this stage he already have a paied invoice for the reservation, # At this stage he already have a paied invoice for the reservation,
......
...@@ -41,7 +41,7 @@ person.requestSoftwareInstance(**request_kw) ...@@ -41,7 +41,7 @@ person.requestSoftwareInstance(**request_kw)
assert hosting_subscription.getSlapState() == "destroy_requested",\ assert hosting_subscription.getSlapState() == "destroy_requested",\
"Hosting Subscription not destroyed!!" "Hosting Subscription not destroyed!!"
connection_dict = hosting_subscription.getPredecessorValue().getConnectionXmlAsDict() connection_dict = hosting_subscription.getSuccessorValue().getConnectionXmlAsDict()
connection_key_list = context.getSubjectList() connection_key_list = context.getSubjectList()
connection_string = '\n'.join(['%s: %s' % (x,y) for x,y in connection_dict.items() if x in connection_key_list]) connection_string = '\n'.join(['%s: %s' % (x,y) for x,y in connection_dict.items() if x in connection_key_list])
......
...@@ -1083,12 +1083,12 @@ class TestSubscriptionRequest_processOrdered(TestSubscriptionSkinsMixin): ...@@ -1083,12 +1083,12 @@ class TestSubscriptionRequest_processOrdered(TestSubscriptionSkinsMixin):
hosting_subscription = subscription_request.getAggregateValue(portal_type="Hosting Subscription") hosting_subscription = subscription_request.getAggregateValue(portal_type="Hosting Subscription")
self.assertNotEqual(hosting_subscription, None) self.assertNotEqual(hosting_subscription, None)
instance = hosting_subscription.getPredecessorValue() instance = hosting_subscription.getSuccessorValue()
self.assertNotEqual(instance, None) self.assertNotEqual(instance, None)
self.assertEqual('diverged', hosting_subscription.getCausalityState()) self.assertEqual('diverged', hosting_subscription.getCausalityState())
instance = hosting_subscription.getPredecessorValue() instance = hosting_subscription.getSuccessorValue()
self.assertNotEqual(instance, None) self.assertNotEqual(instance, None)
...@@ -1166,7 +1166,7 @@ class TestSubscriptionRequest_processOrdered(TestSubscriptionSkinsMixin): ...@@ -1166,7 +1166,7 @@ class TestSubscriptionRequest_processOrdered(TestSubscriptionSkinsMixin):
self.assertEqual('diverged', hosting_subscription.getCausalityState()) self.assertEqual('diverged', hosting_subscription.getCausalityState())
self.assertEqual('start_requested', hosting_subscription.getSlapState()) self.assertEqual('start_requested', hosting_subscription.getSlapState())
instance = hosting_subscription.getPredecessorValue() instance = hosting_subscription.getSuccessorValue()
self.assertNotEqual(instance, None) self.assertNotEqual(instance, None)
......
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