Commit b7d5041e authored by Romain Courteaud's avatar Romain Courteaud

slapos_*: use the successor category instead of predecessor

parent 3eb3f76c
......@@ -79,7 +79,7 @@
<key> <string>text</string> </key>
<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>
</item>
......
......@@ -79,7 +79,7 @@
<key> <string>text</string> </key>
<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>
</item>
......
<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 table_1>.title <> <dtml-var query_table>.title
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>
</item>
<item>
<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>
<key> <string>max_cache_</string> </key>
......@@ -61,7 +61,7 @@ query_table="catalog"</string> </value>
</item>
<item>
<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>
</dictionary>
</pickle>
......
......@@ -2,5 +2,5 @@
<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_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>
\ No newline at end of file
......@@ -8,7 +8,7 @@
<dictionary>
<item>
<key> <string>active_sense_method_id</string> </key>
<value> <string>Alarm_assertHostingSubscriptionHasPredecessor</string> </value>
<value> <string>Alarm_assertHostingSubscriptionHasSuccessor</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -22,7 +22,7 @@
</item>
<item>
<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>
<key> <string>periodicity_hour</string> </key>
......@@ -83,7 +83,7 @@
</item>
<item>
<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>
</dictionary>
</pickle>
......
......@@ -28,17 +28,17 @@
<key> <string>expression</string> </key>
<value> <string encoding="cdata"><![CDATA[
python: len(context.getPredecessorRelatedList()) <= 1
python: len(context.getSuccessorRelatedList()) <= 1
]]></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>predecessor_related_constraint</string> </value>
<value> <string>successor_related_constraint</string> </value>
</item>
<item>
<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>
<key> <string>portal_type</string> </key>
......
......@@ -8,7 +8,7 @@
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>predecessor_category</string> </value>
<value> <string>successor_category</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
......
......@@ -28,17 +28,17 @@
<key> <string>expression</string> </key>
<value> <string encoding="cdata"><![CDATA[
python: len(context.getPredecessorRelatedList()) <= 1
python: len(context.getSuccessorRelatedList()) <= 1
]]></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>predecessor_related_constraint</string> </value>
<value> <string>successor_related_constraint</string> </value>
</item>
<item>
<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>
<key> <string>portal_type</string> </key>
......
......@@ -4,9 +4,9 @@ from Products.ZSQLCatalog.SQLCatalog import SimpleQuery, NegatedQuery
portal.portal_catalog.searchAndActivate(
portal_type='Hosting Subscription',
validation_state='validated',
related_predecessor_but_with_different_title_than_catalog_title="%",
predecessor_title=NegatedQuery(SimpleQuery(predecessor_title=None, comparison_operator='is')),
method_id='HostingSubscription_assertPredecessor',
related_successor_but_with_different_title_than_catalog_title="%",
successor_title=NegatedQuery(SimpleQuery(successor_title=None, comparison_operator='is')),
method_id='HostingSubscription_assertSuccessor',
activate_kw={'tag': tag})
context.activate(after_tag=tag).getId()
......@@ -54,7 +54,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Alarm_assertHostingSubscriptionHasPredecessor</string> </value>
<value> <string>Alarm_assertHostingSubscriptionHasSuccessor</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -5,7 +5,7 @@ portal.portal_catalog.searchAndActivate(
portal_type=["Software Instance", "Slave Instance"],
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',
activate_kw={'tag': tag}
)
......
if context.getPortalType() != 'Hosting Subscription' \
or context.getValidationState() != 'validated' \
or context.getSlapState() not in ['start_requested', 'stop_requested'] \
or context.getTitle() in context.getPredecessorTitleList():
or context.getTitle() in context.getSuccessorTitleList():
# nothing to do
return
......
......@@ -54,7 +54,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>HostingSubscription_assertPredecessor</string> </value>
<value> <string>HostingSubscription_assertSuccessor</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -116,7 +116,7 @@
<key> <string>right</string> </key>
<value>
<list>
<string>my_predecessor_title_list</string>
<string>my_successor_title_list</string>
<string>my_destination_section_title</string>
<string>my_translated_slap_state_title</string>
<string>my_translated_validation_state_title</string>
......
......@@ -18,7 +18,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_predecessor_title_list</string> </value>
<value> <string>my_successor_title_list</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......@@ -106,7 +106,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Predecessors</string> </value>
<value> <string>Successors</string> </value>
</item>
</dictionary>
</value>
......
......@@ -112,7 +112,7 @@
<string>my_specialise_title</string>
<string>my_aggregate_parent_reference</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_validation_state_title</string>
</list>
......
......@@ -19,7 +19,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_predecessor_title_list</string> </value>
<value> <string>my_successor_title_list</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......@@ -76,7 +76,7 @@
<dictionary>
<item>
<key> <string>base_category</string> </key>
<value> <string>predecessor</string> </value>
<value> <string>successor</string> </value>
</item>
<item>
<key> <string>catalog_index</string> </key>
......@@ -107,7 +107,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Predecessors</string> </value>
<value> <string>Successors</string> </value>
</item>
</dictionary>
</value>
......
......@@ -4,7 +4,7 @@ if (instance.getSlapState() != "destroy_requested"):
hosting_subscription = instance.getSpecialiseValue(portal_type="Hosting Subscription")
if (hosting_subscription.getValidationState() == "archived"):
# Buildout didn't propagate the destruction request
requester = instance.getPredecessorRelatedValue()
requester = instance.getSuccessorRelatedValue()
if instance.getPortalType() == 'Software Instance':
is_slave = False
......@@ -15,7 +15,7 @@ if (instance.getSlapState() != "destroy_requested"):
(instance.getPortalType(), instance.getRelativeUrl())
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 = {
'instance_xml': instance.getTextContent(),
'software_type': instance.getSourceReference(),
......@@ -25,8 +25,8 @@ if (instance.getSlapState() != "destroy_requested"):
}
instance.requestDestroy(**promise_kw)
# Unlink all children of this instance
instance.edit(predecessor="", comment="Destroyed garbage collector!")
elif (instance.getRelativeUrl() in requester.getPredecessorList()) and \
instance.edit(successor="", comment="Destroyed garbage collector!")
elif (instance.getRelativeUrl() in requester.getSuccessorList()) and \
(requester.getSlapState() == "destroy_requested"):
# For security, only destroyed if parent is also destroyed
......
......@@ -22,9 +22,9 @@ if (int(DateTime()) - int(latest_edit_time)) < 259200:
# Only destroy if the instance is the only one in the tree
hosting_subscription = instance.getSpecialiseValue("Hosting Subscription")
if (hosting_subscription.getPredecessor() != instance.getRelativeUrl()):
if (hosting_subscription.getSuccessor() != instance.getRelativeUrl()):
return
if (len(hosting_subscription.getPredecessorList()) != 1):
if (len(hosting_subscription.getSuccessorList()) != 1):
return
instance_list = portal.portal_catalog(
portal_type=["Software Instance", "Slave Instance"],
......
......@@ -8,7 +8,7 @@ instance = context
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 = []
if instance_list == []:
......@@ -16,7 +16,7 @@ def checkInstanceTree(instance_list):
for item in instance_list:
if item.getUid() == instance.getUid():
return item
sub_instance_list.extend(item.getPredecessorValueList())
sub_instance_list.extend(item.getSuccessorValueList())
return checkInstanceTree(sub_instance_list)
......@@ -28,7 +28,7 @@ if hosting_subscription is None or \
hosting_subscription.getSlapState() == "destroy_requested":
return
root_instance = hosting_subscription.getPredecessorValue()
root_instance = hosting_subscription.getSuccessorValue()
if root_instance is None:
# Refuse to destroy root instance
raise ValueError("Hosting Subscription %s has no root instance, this should "\
......@@ -53,6 +53,6 @@ if checkInstanceTree([root_instance]) is None:
}
instance.requestDestroy(**promise_kw)
# Unlink all children of this instance
instance.edit(predecessor="", comment="Destroyed garbage collector!")
instance.edit(successor="", comment="Destroyed garbage collector!")
return instance.getRelativeUrl()
......@@ -8,8 +8,8 @@ if (instance.getSlapState() == "start_requested"):
hosting_subscription = instance.getSpecialiseValue(portal_type="Hosting Subscription")
if (hosting_subscription.getSlapState() == "stop_requested"):
# Buildout may not propagate the stop request
requester = instance.getPredecessorRelatedValue()
if (instance.getRelativeUrl() in requester.getPredecessorList()) and \
requester = instance.getSuccessorRelatedValue()
if (instance.getRelativeUrl() in requester.getSuccessorList()) and \
(requester.getSlapState() == "stop_requested"):
# For security, only stop if parent is also stopped
......
......@@ -116,7 +116,7 @@
<string>my_specialise_title</string>
<string>my_aggregate_parent_reference</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_validation_state_title</string>
</list>
......
......@@ -19,7 +19,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_predecessor_title_list</string> </value>
<value> <string>my_successor_title_list</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......@@ -76,7 +76,7 @@
<dictionary>
<item>
<key> <string>base_category</string> </key>
<value> <string>predecessor</string> </value>
<value> <string>successor</string> </value>
</item>
<item>
<key> <string>catalog_index</string> </key>
......@@ -111,7 +111,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Predecessors</string> </value>
<value> <string>Successors</string> </value>
</item>
</dictionary>
</value>
......
......@@ -356,7 +356,7 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
self.assertEqual(1, len(hosting_subscription_list))
hosting_subscription = hosting_subscription_list[0]
software_instance = hosting_subscription.getPredecessorValue()
software_instance = hosting_subscription.getSuccessorValue()
self.assertEqual(software_instance.getTitle(),
hosting_subscription.getTitle())
connection_dict = software_instance.getConnectionXmlAsDict()
......@@ -523,7 +523,7 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
self.assertEqual(1, len(hosting_subscription_list))
hosting_subscription = hosting_subscription_list[0]
software_instance = hosting_subscription.getPredecessorValue()
software_instance = hosting_subscription.getSuccessorValue()
self.assertEqual(software_instance.getTitle(),
hosting_subscription.getTitle())
connection_dict = software_instance.getConnectionXmlAsDict()
......
......@@ -215,7 +215,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
text_content=self.request_kw['instance_xml'],
sla_xml=self.request_kw['sla_xml'],
root_slave=self.request_kw['shared'],
predecessor=self.software_instance.getRelativeUrl(),
successor=self.software_instance.getRelativeUrl(),
destination_section=self.person_user.getRelativeUrl()
)
self.hosting_subscription.validate()
......@@ -231,7 +231,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
text_content=self.request_kw['instance_xml'],
sla_xml=self.request_kw['sla_xml'],
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.software_instance.validate()
......@@ -368,7 +368,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
hosting_subscription.requestStart(**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())
if with_slave:
......@@ -392,7 +392,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
hosting_subscription.requestStart(**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())
hosting_subscription = self.portal.hosting_subscription_module\
......@@ -416,7 +416,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
hosting_subscription.requestStop(**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(
aggregate=self.computer.partition2.getRelativeUrl()
)
......@@ -444,7 +444,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
kw['state'] = 'destroyed'
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.edit(
aggregate=self.computer.partition3.getRelativeUrl()
......@@ -473,7 +473,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
kw['state'] = 'destroyed'
hosting_subscription.requestDestroy(**kw)
self.destroyed_software_instance = hosting_subscription.getPredecessorValue()
self.destroyed_software_instance = hosting_subscription.getSuccessorValue()
self.destroyed_software_instance.edit(
aggregate=self.computer.partition4.getRelativeUrl()
)
......
......@@ -9,26 +9,26 @@ from DateTime import DateTime
from erp5.component.module.DateUtils import addToDate
from App.Common import rfc1123_date
class TestSlapOSCoreSlapOSAssertHostingSubscriptionPredecessorAlarm(
class TestSlapOSCoreSlapOSAssertHostingSubscriptionSuccessorAlarm(
SlapOSTestCaseMixin):
def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
self._makeTree()
def test_HostingSubscription_assertPredecessor(self):
def test_HostingSubscription_assertSuccessor(self):
self.software_instance.rename(new_name=self.generateNewSoftwareTitle())
self.tic()
# check that no interaction has recreated the instance
self.assertFalse(self.hosting_subscription.getTitle() in
self.hosting_subscription.getPredecessorTitleList())
self.hosting_subscription.getSuccessorTitleList())
self.hosting_subscription.HostingSubscription_assertPredecessor()
self.hosting_subscription.HostingSubscription_assertSuccessor()
self.assertTrue(self.hosting_subscription.getTitle() in
self.hosting_subscription.getPredecessorTitleList())
self.hosting_subscription.getSuccessorTitleList())
def test_HostingSubscription_assertPredecessor_stop_requested(self):
def test_HostingSubscription_assertSuccessor_stop_requested(self):
self.software_instance.rename(new_name=self.generateNewSoftwareTitle())
self.portal.portal_workflow._jumpToStateFor(self.hosting_subscription,
'stop_requested')
......@@ -36,13 +36,13 @@ class TestSlapOSCoreSlapOSAssertHostingSubscriptionPredecessorAlarm(
# check that no interaction has recreated the instance
self.assertFalse(self.hosting_subscription.getTitle() in
self.hosting_subscription.getPredecessorTitleList())
self.hosting_subscription.getSuccessorTitleList())
self.hosting_subscription.HostingSubscription_assertPredecessor()
self.hosting_subscription.HostingSubscription_assertSuccessor()
self.assertTrue(self.hosting_subscription.getTitle() in
self.hosting_subscription.getPredecessorTitleList())
self.hosting_subscription.getSuccessorTitleList())
def test_HostingSubscription_assertPredecessor_destroy_requested(self):
def test_HostingSubscription_assertSuccessor_destroy_requested(self):
self.software_instance.rename(new_name=self.generateNewSoftwareTitle())
self.portal.portal_workflow._jumpToStateFor(self.hosting_subscription,
'destroy_requested')
......@@ -50,27 +50,27 @@ class TestSlapOSCoreSlapOSAssertHostingSubscriptionPredecessorAlarm(
# check that no interaction has recreated the instance
self.assertFalse(self.hosting_subscription.getTitle() in
self.hosting_subscription.getPredecessorTitleList())
self.hosting_subscription.getSuccessorTitleList())
self.hosting_subscription.HostingSubscription_assertPredecessor()
self.hosting_subscription.HostingSubscription_assertSuccessor()
self.assertFalse(self.hosting_subscription.getTitle() in
self.hosting_subscription.getPredecessorTitleList())
self.hosting_subscription.getSuccessorTitleList())
def test_HostingSubscription_assertPredecessor_archived(self):
def test_HostingSubscription_assertSuccessor_archived(self):
self.software_instance.rename(new_name=self.generateNewSoftwareTitle())
self.hosting_subscription.archive()
self.tic()
# check that no interaction has recreated the instance
self.assertFalse(self.hosting_subscription.getTitle() in
self.hosting_subscription.getPredecessorTitleList())
self.hosting_subscription.getSuccessorTitleList())
self.hosting_subscription.HostingSubscription_assertPredecessor()
self.hosting_subscription.HostingSubscription_assertSuccessor()
self.assertFalse(self.hosting_subscription.getTitle() in
self.hosting_subscription.getPredecessorTitleList())
self.hosting_subscription.getSuccessorTitleList())
def _simulateHostingSubscription_assertPredecessor(self):
script_name = 'HostingSubscription_assertPredecessor'
def _simulateHostingSubscription_assertSuccessor(self):
script_name = 'HostingSubscription_assertSuccessor'
if script_name in self.portal.portal_skins.custom.objectIds():
raise ValueError('Precondition failed: %s exists in custom' % script_name)
createZODBPythonScript(self.portal.portal_skins.custom,
......@@ -78,11 +78,11 @@ class TestSlapOSCoreSlapOSAssertHostingSubscriptionPredecessorAlarm(
'*args, **kwargs',
'# Script body\n'
"""portal_workflow = context.portal_workflow
portal_workflow.doActionFor(context, action='edit_action', comment='Visited by HostingSubscription_assertPredecessor') """ )
portal_workflow.doActionFor(context, action='edit_action', comment='Visited by HostingSubscription_assertSuccessor') """ )
transaction.commit()
def _dropHostingSubscription_assertPredecessor(self):
script_name = 'HostingSubscription_assertPredecessor'
def _dropHostingSubscription_assertSuccessor(self):
script_name = 'HostingSubscription_assertSuccessor'
if script_name in self.portal.portal_skins.custom.objectIds():
self.portal.portal_skins.custom.manage_delObjects(script_name)
transaction.commit()
......@@ -90,25 +90,25 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by H
def test_alarm_renamed(self):
self.software_instance.edit(title=self.generateNewSoftwareTitle())
self.tic()
self._simulateHostingSubscription_assertPredecessor()
self._simulateHostingSubscription_assertSuccessor()
try:
self.portal.portal_alarms.slapos_assert_hosting_subscription_predecessor.activeSense()
self.portal.portal_alarms.slapos_assert_hosting_subscription_successor.activeSense()
self.tic()
finally:
self._dropHostingSubscription_assertPredecessor()
self._dropHostingSubscription_assertSuccessor()
self.assertEqual(
'Visited by HostingSubscription_assertPredecessor',
'Visited by HostingSubscription_assertSuccessor',
self.hosting_subscription.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_not_renamed(self):
self._simulateHostingSubscription_assertPredecessor()
self._simulateHostingSubscription_assertSuccessor()
try:
self.portal.portal_alarms.slapos_assert_hosting_subscription_predecessor.activeSense()
self.portal.portal_alarms.slapos_assert_hosting_subscription_successor.activeSense()
self.tic()
finally:
self._dropHostingSubscription_assertPredecessor()
self._dropHostingSubscription_assertSuccessor()
self.assertNotEqual(
'Visited by HostingSubscription_assertPredecessor',
'Visited by HostingSubscription_assertSuccessor',
self.hosting_subscription.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSFreeComputerPartitionAlarm(SlapOSTestCaseMixin):
......@@ -318,8 +318,8 @@ class TestSlapOSGarbageCollectDestroyedRootTreeAlarm(SlapOSTestCaseMixin):
self.assertEqual('validated',
self.requested_software_instance.getValidationState())
def test_SoftwareInstance_tryToGarbageCollect_unlinked_predecessor(self):
self.requested_software_instance.edit(predecessor_list=[])
def test_SoftwareInstance_tryToGarbageCollect_unlinked_successor(self):
self.requested_software_instance.edit(successor_list=[])
self.hosting_subscription.archive()
self.portal.portal_workflow._jumpToStateFor(self.hosting_subscription,
'destroy_requested')
......@@ -345,10 +345,10 @@ class TestSlapOSGarbageCollectDestroyedRootTreeAlarm(SlapOSTestCaseMixin):
state='started'
)
self.requested_software_instance.requestInstance(**instance_kw)
sub_instance = self.requested_software_instance.getPredecessorValue()
sub_instance = self.requested_software_instance.getSuccessorValue()
self.assertNotEqual(sub_instance, None)
self.requested_software_instance.edit(predecessor_list=[])
self.requested_software_instance.edit(successor_list=[])
self.hosting_subscription.archive()
self.portal.portal_workflow._jumpToStateFor(self.hosting_subscription,
'destroy_requested')
......@@ -364,7 +364,7 @@ class TestSlapOSGarbageCollectDestroyedRootTreeAlarm(SlapOSTestCaseMixin):
self.assertEqual('validated',
self.requested_software_instance.getValidationState())
self.assertEqual(self.requested_software_instance.getPredecessorValue(),
self.assertEqual(self.requested_software_instance.getSuccessorValue(),
None)
self.assertEqual(sub_instance.getSlapState(), 'start_requested')
......@@ -655,7 +655,7 @@ class TestSlapOSGarbageCollectStoppedRootTreeAlarm(SlapOSTestCaseMixin):
hosting_subscription.requestStart(**request_kw)
hosting_subscription.requestInstance(**request_kw)
instance = hosting_subscription.getPredecessorValue()
instance = hosting_subscription.getSuccessorValue()
self.tic()
return instance
......@@ -747,7 +747,7 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin):
hosting_subscription.requestStart(**request_kw)
hosting_subscription.requestInstance(**request_kw)
instance = hosting_subscription.getPredecessorValue()
instance = hosting_subscription.getSuccessorValue()
return instance
def createComputerPartition(self):
......@@ -856,7 +856,7 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin):
state='started'
)
instance.requestInstance(**request_kw)
sub_instance = instance.getPredecessorValue()
sub_instance = instance.getSuccessorValue()
self.tic()
sub_instance.workflow_history['edit_workflow'].append({
'comment':'Allocation failed: no free Computer Partition',
......@@ -884,7 +884,7 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin):
state='started'
)
instance.requestInstance(**request_kw)
sub_instance = instance.getPredecessorValue()
sub_instance = instance.getSuccessorValue()
self.tic()
sub_instance.workflow_history['edit_workflow'].append({
'comment':'Allocation failed: Allocation disallowed',
......@@ -999,7 +999,7 @@ class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin):
hosting_subscription.requestInstance(**request_kw)
self.hosting_subscription = hosting_subscription
instance = hosting_subscription.getPredecessorValue()
instance = hosting_subscription.getSuccessorValue()
return instance
def createComputerPartition(self):
......@@ -1024,7 +1024,7 @@ class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin):
)
instance.requestInstance(**instance_kw)
self.tic()
sub_instance = instance.getPredecessorValue()
sub_instance = instance.getSuccessorValue()
partition = self.createComputerPartition()
sub_instance.edit(aggregate_value=partition)
self.tic()
......@@ -1056,12 +1056,12 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
instance.edit(aggregate_value=partition)
self.tic()
instance0 = self.doRequestInstance(instance, 'instance0')
self.assertEqual(instance0.getPredecessorRelatedTitle(), instance.getTitle())
self.assertEqual(instance0.getSuccessorRelatedTitle(), instance.getTitle())
# Remove predecessor link
instance.edit(predecessor_list=[])
# Remove successor link
instance.edit(successor_list=[])
self.tic()
self.assertEqual(instance0.getPredecessorRelatedTitle(), None)
self.assertEqual(instance0.getSuccessorRelatedTitle(), None)
instance0.SoftwareInstance_tryToGarbageUnlinkedInstance(delay_time=-1)
self.tic()
self.assertEqual(instance0.getSlapState(), 'destroy_requested')
......@@ -1072,7 +1072,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
instance.edit(aggregate_value=partition)
self.tic()
instance0 = self.doRequestInstance(instance, 'instance0')
instance.edit(predecessor_list=[])
instance.edit(successor_list=[])
self.tic()
self.hosting_subscription.archive()
......@@ -1093,18 +1093,18 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
self.tic()
instance0 = self.doRequestInstance(instance, 'instance0')
instance_instance0 = self.doRequestInstance(instance0, 'Subinstance0')
self.assertEqual(instance_instance0.getPredecessorRelatedTitle(),
self.assertEqual(instance_instance0.getSuccessorRelatedTitle(),
'instance0')
instance.edit(predecessor_list=[])
instance.edit(successor_list=[])
self.tic()
self.assertEqual(instance0.getPredecessorRelatedTitle(), None)
self.assertEqual(instance0.getSuccessorRelatedTitle(), None)
instance0.SoftwareInstance_tryToGarbageUnlinkedInstance(delay_time=-1)
self.tic()
self.assertEqual(instance0.getSlapState(), 'destroy_requested')
self.assertEqual(instance_instance0.getSlapState(), 'start_requested')
# Link of child removed
self.assertEqual(instance_instance0.getPredecessorRelatedTitle(), None)
self.assertEqual(instance_instance0.getSuccessorRelatedTitle(), None)
def test_SoftwareInstance_tryToGarbageUnlinkedInstance_will_delay(self):
instance = self.createInstance()
......@@ -1113,11 +1113,11 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
self.tic()
instance0 = self.doRequestInstance(instance, 'instance0')
instance_instance0 = self.doRequestInstance(instance0, 'Subinstance0')
self.assertEqual(instance_instance0.getPredecessorRelatedTitle(),
self.assertEqual(instance_instance0.getSuccessorRelatedTitle(),
'instance0')
instance.edit(predecessor_list=[])
instance.edit(successor_list=[])
self.tic()
self.assertEqual(instance0.getPredecessorRelatedTitle(), None)
self.assertEqual(instance0.getSuccessorRelatedTitle(), None)
instance0.SoftwareInstance_tryToGarbageUnlinkedInstance()
self.tic()
......@@ -1133,7 +1133,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
self.assertEqual(instance0.getSlapState(), 'destroy_requested')
self.assertEqual(instance_instance0.getSlapState(), 'start_requested')
# Link of child removed
self.assertEqual(instance_instance0.getPredecessorRelatedTitle(), None)
self.assertEqual(instance_instance0.getSuccessorRelatedTitle(), None)
def test_SoftwareInstance_tryToGarbageUnlinkedInstance_unlinked_root(self):
instance = self.createInstance()
......@@ -1143,10 +1143,10 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
self.assertEqual(self.hosting_subscription.getTitle(), instance.getTitle())
# Remove predecessor link
self.hosting_subscription.edit(predecessor_list=[])
# Remove successor link
self.hosting_subscription.edit(successor_list=[])
self.tic()
self.assertEqual(instance.getPredecessorRelatedTitle(), None)
self.assertEqual(instance.getSuccessorRelatedTitle(), None)
# will not destroy
self.assertRaises(
ValueError,
......@@ -1162,11 +1162,11 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
self.tic()
instance0 = self.doRequestInstance(instance, 'instance0')
instance_instance0 = self.doRequestInstance(instance0, 'Subinstance0')
self.assertEqual(instance_instance0.getPredecessorRelatedTitle(),
self.assertEqual(instance_instance0.getSuccessorRelatedTitle(),
'instance0')
self.assertEqual(instance_instance0.getSlapState(), 'start_requested')
# Try to remove without delete predecessor link
# Try to remove without delete successor link
instance_instance0.SoftwareInstance_tryToGarbageUnlinkedInstance(delay_time=-1)
self.tic()
self.assertEqual(instance_instance0.getSlapState(), 'start_requested')
......@@ -1177,7 +1177,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
instance.edit(aggregate_value=partition)
self.tic()
instance0 = self.doRequestInstance(instance, 'instance0')
self.assertEqual(instance.getPredecessorReference(),
self.assertEqual(instance.getSuccessorReference(),
instance0.getReference())
self._simulateSoftwareInstance_tryToGarbageUnlinkedInstance()
try:
......@@ -1189,8 +1189,8 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
'Visited by SoftwareInstance_tryToGarbageUnlinkedInstance',
instance0.workflow_history['edit_workflow'][-1]['comment'])
# Remove predecessor link
instance.edit(predecessor_list=[])
# Remove successor link
instance.edit(successor_list=[])
self._simulateSoftwareInstance_tryToGarbageUnlinkedInstance()
self.tic()
try:
......@@ -1208,9 +1208,9 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
instance.edit(aggregate_value=partition)
self.tic()
slave_instance0 = self.doRequestInstance(instance, 'slaveInstance0', True)
self.assertEqual(instance.getPredecessorTitle(), 'slaveInstance0')
self.assertEqual(instance.getSuccessorTitle(), 'slaveInstance0')
self._simulateSoftwareInstance_tryToGarbageUnlinkedInstance()
instance.edit(predecessor_list=[])
instance.edit(successor_list=[])
self.tic()
try:
self.portal.portal_alarms.slapos_garbage_collect_destroy_unlinked_instance.activeSense()
......
......@@ -235,7 +235,7 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin):
self.software_instance.edit(**{property_id:''})
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(
portal_type='Software Instance')
software_instance3 = self.portal.software_instance_module.newContent(
......@@ -244,25 +244,25 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin):
# fetch basic list of consistency messages
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
self.assertFalse(consistency_message in current_message_list)
# if too many, it shall cry
software_instance2.edit(predecessor=self.software_instance.getRelativeUrl())
software_instance3.edit(predecessor=self.software_instance.getRelativeUrl())
software_instance2.edit(successor=self.software_instance.getRelativeUrl())
software_instance3.edit(successor=self.software_instance.getRelativeUrl())
self.tic()
self.assertTrue(consistency_message in self.getMessageList(self.software_instance))
# one is good
software_instance2.edit(predecessor=None)
software_instance2.edit(successor=None)
self.tic()
self.assertFalse(consistency_message in self.getMessageList(self.software_instance))
self.assertSameSet(current_message_list, self.getMessageList(self.software_instance))
# none is good
software_instance3.edit(predecessor=None)
software_instance3.edit(successor=None)
self.tic()
self.assertFalse(consistency_message in self.getMessageList(self.software_instance))
self.assertSameSet(current_message_list, self.getMessageList(self.software_instance))
......@@ -374,7 +374,7 @@ class TestSlapOSSlaveInstanceConstraint(TestSlapOSConstraintMixin):
'Property existence error for property reference, this document'
' 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(
portal_type='Slave Instance')
software_instance3 = self.portal.software_instance_module.newContent(
......@@ -383,25 +383,25 @@ class TestSlapOSSlaveInstanceConstraint(TestSlapOSConstraintMixin):
# fetch basic list of consistency messages
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
self.assertFalse(consistency_message in current_message_list)
# if too many, it shall cry
software_instance2.edit(predecessor=self.software_instance.getRelativeUrl())
software_instance3.edit(predecessor=self.software_instance.getRelativeUrl())
software_instance2.edit(successor=self.software_instance.getRelativeUrl())
software_instance3.edit(successor=self.software_instance.getRelativeUrl())
self.tic()
self.assertTrue(consistency_message in self.getMessageList(self.software_instance))
# one is good
software_instance2.edit(predecessor=None)
software_instance2.edit(successor=None)
self.tic()
self.assertFalse(consistency_message in self.getMessageList(self.software_instance))
self.assertSameSet(current_message_list, self.getMessageList(self.software_instance))
# none is good
software_instance3.edit(predecessor=None)
software_instance3.edit(successor=None)
self.tic()
self.assertFalse(consistency_message in self.getMessageList(self.software_instance))
self.assertSameSet(current_message_list, self.getMessageList(self.software_instance))
......
......@@ -699,7 +699,7 @@ class TestSlapOSCoreInstanceSlapInterfaceWorkflow(SlapOSTestCaseMixin):
hosting_subscription.requestStart(**self.request_kw)
hosting_subscription.requestInstance(**self.request_kw)
self.instance = hosting_subscription.getPredecessorValue()
self.instance = hosting_subscription.getSuccessorValue()
self.tic()
def _countInstanceBang(self, instance, comment):
......@@ -1102,7 +1102,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin):
text_content=self.request_kw['instance_xml'],
sla_xml=self.request_kw['sla_xml'],
root_slave=self.request_kw['shared'],
predecessor=self.software_instance.getRelativeUrl()
successor=self.software_instance.getRelativeUrl()
)
hosting_subscription.validate()
self.portal.portal_workflow._jumpToStateFor(hosting_subscription, 'start_requested')
......@@ -1357,7 +1357,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin):
self.software_instance.getSpecialiseValue(
portal_type='Hosting Subscription').edit(
predecessor_list=[
successor_list=[
duplicate.getRelativeUrl(),
duplicate2.getRelativeUrl(),
self.software_instance.getRelativeUrl()
......@@ -1405,7 +1405,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin):
requested_instance2.getRelativeUrl())
self.assertSameSet(
self.software_instance.getPredecessorList(),
self.software_instance.getSuccessorList(),
[requested_instance.getRelativeUrl(),
requested_instance2.getRelativeUrl()])
......@@ -1440,7 +1440,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin):
C_instance = self.software_instance.REQUEST.get('request_instance')
self.assertSameSet(
self.software_instance.getPredecessorList(),
self.software_instance.getSuccessorList(),
[B_instance.getRelativeUrl(), C_instance.getRelativeUrl()])
self.tic() # in order to recalculate tree
......@@ -1450,9 +1450,9 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin):
self.assertEqual(C_instance.getRelativeUrl(), C1_instance.getRelativeUrl())
self.assertSameSet(self.software_instance.getPredecessorList(),
self.assertSameSet(self.software_instance.getSuccessorList(),
[B_instance.getRelativeUrl()])
self.assertSameSet(B_instance.getPredecessorList(),
self.assertSameSet(B_instance.getSuccessorList(),
[C_instance.getRelativeUrl()])
def test_request_tree_change_not_indexed(self):
......@@ -1479,7 +1479,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin):
C_instance = self.software_instance.REQUEST.get('request_instance')
self.assertSameSet(
self.software_instance.getPredecessorList(),
self.software_instance.getSuccessorList(),
[B_instance.getRelativeUrl(), C_instance.getRelativeUrl()])
transaction.commit()
......@@ -1512,7 +1512,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin):
C_instance = self.software_instance.REQUEST.get('request_instance')
self.assertSameSet(
self.software_instance.getPredecessorList(),
self.software_instance.getSuccessorList(),
[B_instance.getRelativeUrl(), C_instance.getRelativeUrl()])
self.assertRaises(NotImplementedError, B_instance.requestInstance,
......@@ -1582,7 +1582,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin):
# in case of destruction instance is not returned, so fetch it
# directly form document
requested_instance3 = self.software_instance.getPredecessorValue(
requested_instance3 = self.software_instance.getSuccessorValue(
portal_type='Software Instance')
self.assertEqual(request_kw['software_title'],
requested_instance3.getTitle())
......@@ -1665,7 +1665,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin):
request_kw['state'] = 'destroyed'
self.software_instance.requestInstance(**request_kw)
transaction.commit()
requested_instance2 = self.software_instance.getPredecessorValue(
requested_instance2 = self.software_instance.getSuccessorValue(
portal_type='Software Instance')
self.assertEqual(requested_instance.getRelativeUrl(),
......@@ -1704,7 +1704,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin):
C_instance = self.software_instance.REQUEST.get('request_instance')
self.assertSameSet(
self.software_instance.getPredecessorList(),
self.software_instance.getSuccessorList(),
[B_instance.getRelativeUrl(), C_instance.getRelativeUrl()])
self.tic() # in order to recalculate tree
......@@ -1714,9 +1714,9 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin):
self.assertEqual(C_instance.getRelativeUrl(), C1_instance.getRelativeUrl())
self.assertSameSet(self.software_instance.getPredecessorList(),
self.assertSameSet(self.software_instance.getSuccessorList(),
[B_instance.getRelativeUrl()])
self.assertSameSet(B_instance.getPredecessorList(),
self.assertSameSet(B_instance.getSuccessorList(),
[C_instance.getRelativeUrl()])
def test_request_tree_change_not_indexed_shared(self):
......@@ -1744,7 +1744,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin):
C_instance = self.software_instance.REQUEST.get('request_instance')
self.assertSameSet(
self.software_instance.getPredecessorList(),
self.software_instance.getSuccessorList(),
[B_instance.getRelativeUrl(), C_instance.getRelativeUrl()])
transaction.commit()
......@@ -1778,7 +1778,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin):
C_instance = self.software_instance.REQUEST.get('request_instance')
self.assertSameSet(
self.software_instance.getPredecessorList(),
self.software_instance.getSuccessorList(),
[B_instance.getRelativeUrl(), C_instance.getRelativeUrl()])
self.assertRaises(NotImplementedError, B_instance.requestInstance,
......@@ -1799,7 +1799,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin):
request_kw['software_release'] = self.generateNewSoftwareReleaseUrl()
self.software_instance.requestInstance(**request_kw)
requested_instance2 = self.software_instance.getPredecessorValue(
requested_instance2 = self.software_instance.getSuccessorValue(
portal_type='Software Instance')
transaction.commit()
......@@ -1825,7 +1825,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin):
request_kw['software_type'] = self.generateNewSoftwareReleaseUrl()
self.software_instance.requestInstance(**request_kw)
requested_instance2 = self.software_instance.getPredecessorValue(
requested_instance2 = self.software_instance.getSuccessorValue(
portal_type='Software Instance')
transaction.commit()
......@@ -1851,7 +1851,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin):
request_kw['instance_xml'] = self.generateSafeXml()
self.software_instance.requestInstance(**request_kw)
requested_instance2 = self.software_instance.getPredecessorValue(
requested_instance2 = self.software_instance.getSuccessorValue(
portal_type='Software Instance')
transaction.commit()
......@@ -1877,7 +1877,7 @@ class TestSlapOSCoreSoftwareInstanceRequest(SlapOSTestCaseMixin):
request_kw['sla_xml'] = self.generateSafeXml()
self.software_instance.requestInstance(**request_kw)
requested_instance2 = self.software_instance.getPredecessorValue(
requested_instance2 = self.software_instance.getSuccessorValue(
portal_type='Software Instance')
transaction.commit()
......@@ -2914,7 +2914,7 @@ class TestSlapOSCoreSlapOSCloudInteractionWorkflow(SlapOSTestCaseMixin):
return self.check_change_instance_parameter("Slave Instance",
'sla_xml')
def test_SoftwareInstance_setPredecessorList(self):
def test_SoftwareInstance_setSuccessorList(self):
portal_type = "Software Instance"
self.person_user = self.makePerson()
......@@ -2938,7 +2938,7 @@ class TestSlapOSCoreSlapOSCloudInteractionWorkflow(SlapOSTestCaseMixin):
destination_reference="TESTINST-%s" % new_id,
ssl_certificate="foo",
ssl_key="bar",
predecessor_value=instance3,
successor_value=instance3,
)
new_id = self.generateNewId()
......@@ -2949,7 +2949,7 @@ class TestSlapOSCoreSlapOSCloudInteractionWorkflow(SlapOSTestCaseMixin):
destination_reference="TESTINST-%s" % new_id,
ssl_certificate="foo",
ssl_key="bar",
predecessor_value=instance2,
successor_value=instance2,
)
self.tic()
......@@ -2967,7 +2967,7 @@ class TestSlapOSCoreSlapOSCloudInteractionWorkflow(SlapOSTestCaseMixin):
Base.reindexObject_call = Base._reindexObject
Base._reindexObject = verify_reindexObject_call
try:
instance1.edit(predecessor_value=instance3)
instance1.edit(successor_value=instance3)
self.tic()
finally:
Base._reindexObject = Base.reindexObject_call
......
......@@ -3,7 +3,7 @@ portal = instance.getPortalObject()
for requester_instance in portal.portal_catalog(
portal_type="Software Instance",
default_predecessor_uid=instance.getUid()):
default_successor_uid=instance.getUid()):
requester_instance.getObject().bang(
bang_tree=False,
comment="%s parameters changed" % instance.getRelativeUrl())
......@@ -36,17 +36,17 @@ if (portal.portal_activities.countMessageWithTag(tag) > 0):
# graph allows to "simulate" tree change after requested operation
graph = {}
predecessor_list = hosting_subscription.getPredecessorValueList()
graph[hosting_subscription.getUid()] = [predecessor.getUid() for predecessor in predecessor_list]
successor_list = hosting_subscription.getSuccessorValueList()
graph[hosting_subscription.getUid()] = [successor.getUid() for successor in successor_list]
while True:
try:
current_software_instance = predecessor_list.pop(0)
current_software_instance = successor_list.pop(0)
except IndexError:
break
current_software_instance_predecessor_list = current_software_instance.getPredecessorValueList() or []
graph[current_software_instance.getUid()] = [predecessor.getUid()
for predecessor in current_software_instance_predecessor_list]
predecessor_list.extend(current_software_instance_predecessor_list)
current_software_instance_successor_list = current_software_instance.getSuccessorValueList() or []
graph[current_software_instance.getUid()] = [successor.getUid()
for successor in current_software_instance_successor_list]
successor_list.extend(current_software_instance_successor_list)
# Check if it already exists
request_software_instance_list = portal.portal_catalog(
......@@ -110,24 +110,24 @@ if (request_software_instance is None):
else:
instance_found = True
# Update the predecessor category of the previous requester
predecessor = request_software_instance.getPredecessorRelatedValue(portal_type="Software Instance")
if (predecessor is None):
# Update the successor category of the previous requester
successor = request_software_instance.getSuccessorRelatedValue(portal_type="Software Instance")
if (successor is None):
# 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):
raise ValueError('It is disallowed to request root software instance %s' % request_software_instance.getRelativeUrl())
else:
predecessor = requester_instance
successor = requester_instance
# It was a loose node, so check if it ok:
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()
if request_software_instance.getUid() in predecessor_uid_list:
predecessor_uid_list.remove(request_software_instance.getUid())
predecessor.edit(predecessor_uid_list=predecessor_uid_list)
graph[predecessor.getUid()] = predecessor_uid_list
successor_uid_list = successor.getSuccessorUidList()
if request_software_instance.getUid() in successor_uid_list:
successor_uid_list.remove(request_software_instance.getUid())
successor.edit(successor_uid_list=successor_uid_list)
graph[successor.getUid()] = successor_uid_list
if instance_found:
......@@ -151,21 +151,21 @@ if instance_found:
else:
raise ValueError, "state should be started, stopped or destroyed"
predecessor_list = requester_instance.getPredecessorList() + [request_software_instance_url]
uniq_predecessor_list = list(set(predecessor_list))
predecessor_list.sort()
uniq_predecessor_list.sort()
successor_list = requester_instance.getSuccessorList() + [request_software_instance_url]
uniq_successor_list = list(set(successor_list))
successor_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
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
request_software_instance.checkConnected(graph, hosting_subscription.getUid())
request_software_instance.checkNotCyclic(graph)
requester_instance.edit(predecessor_list=predecessor_list)
requester_instance.edit(successor_list=successor_list)
else:
context.REQUEST.set('request_instance', None)
......@@ -28,7 +28,7 @@
<key> <string>after_script_name</string> </key>
<value>
<list>
<string>SoftwareInstance_reindexRecursivelyPredecessorSoftwareInstanceList</string>
<string>SoftwareInstance_reindexRecursivelySuccessorSoftwareInstanceList</string>
</list>
</value>
</item>
......@@ -52,13 +52,13 @@ It will create duplicate activities, but only one for each will be fired.</strin
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SoftwareInstance_setPredecessorList</string> </value>
<value> <string>SoftwareInstance_setSuccessorList</string> </value>
</item>
<item>
<key> <string>method_id</string> </key>
<value>
<list>
<string>_setPredecessor.*</string>
<string>_setSuccessor.*</string>
</list>
</value>
</item>
......@@ -78,7 +78,7 @@ It will create duplicate activities, but only one for each will be fired.</strin
<key> <string>script_name</string> </key>
<value>
<list>
<string>SoftwareInstance_reindexRecursivelyPredecessorSoftwareInstanceList</string>
<string>SoftwareInstance_reindexRecursivelySuccessorSoftwareInstanceList</string>
</list>
</value>
</item>
......
def reindexRecursively(document, after_tag=None):
tag = document.getPath() + '_reindex'
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':
reindexRecursively(subdocument, tag)
......
......@@ -54,7 +54,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SoftwareInstance_reindexRecursivelyPredecessorSoftwareInstanceList</string> </value>
<value> <string>SoftwareInstance_reindexRecursivelySuccessorSoftwareInstanceList</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -19,4 +19,4 @@ erp5_mysql_innodb/z_create_software_instance_tree
erp5_mysql_innodb/z_create_versioning
erp5_mysql_innodb/z_related_causality_subscription_request
erp5_mysql_innodb/z_related_default_or_child_aggregate
erp5_mysql_innodb/z_related_predecessor_but_with_different_title_than_catalog_title
\ No newline at end of file
erp5_mysql_innodb/z_related_successor_but_with_different_title_than_catalog_title
\ No newline at end of file
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_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
person_module/template_member
person_module/template_member/**
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_free_computer_partition
portal_alarms/slapos_garbage_collect_destroy_unlinked_instance
......
......@@ -22,7 +22,7 @@ for hosting_subscription in hosting_subscription_list:
if hosting_subscription.getSlapState() == 'destroy_requested':
continue
instance = hosting_subscription.getPredecessorValue()
instance = hosting_subscription.getSuccessorValue()
if instance is None or instance.getSlapState() in ('destroy_requested', 'stop_requested'):
continue
......
......@@ -5,7 +5,7 @@ if hosting_subscription is None:
return
instance = None
for possible_instance in hosting_subscription.getPredecessorValueList():
for possible_instance in hosting_subscription.getSuccessorValueList():
if possible_instance.getSlapState() != 'destroy_requested':
instance = possible_instance
break
......
......@@ -116,12 +116,12 @@ class TestSlapOSSupportRequestModule_getMonitoringUrlList(TestCRMSkinsMixin):
self.assertEqual(module.SupportRequestModule_getMonitoringUrlList(), [])
support_request.setAggregateValue(hosting_subscription)
support_request.validate()
self.assertNotEqual(hosting_subscription.getPredecessorList(), [])
self.assertNotEqual(hosting_subscription.getSuccessorList(), [])
self.tic()
self.assertEqual(module.SupportRequestModule_getMonitoringUrlList(), [])
instance = hosting_subscription.getPredecessorValue()
instance = hosting_subscription.getSuccessorValue()
instance.setConnectionXml("""<?xml version='1.0' encoding='utf-8'?>
<instance>
<parameter id="aa">xx</parameter>
......@@ -153,7 +153,7 @@ class TestSlapOSSupportRequestModule_getMonitoringUrlList(TestCRMSkinsMixin):
"http://monitor.url/#/ABC")
support_request.invalidate()
self.tic()
self.assertNotEqual(hosting_subscription.getPredecessorList(), [])
self.assertNotEqual(hosting_subscription.getSuccessorList(), [])
class TestSlapOSFolder_getOpenTicketList(TestCRMSkinsMixin):
......@@ -1025,7 +1025,7 @@ class TestSlapOSGenerateSupportRequestForSlapOS(TestCRMSkinsMixin):
self._makeSoftwareInstance(hosting_subscription,
self.generateNewSoftwareReleaseUrl())
instance = hosting_subscription.getPredecessorValue()
instance = hosting_subscription.getSuccessorValue()
title = "Test Support Request %s" % instance.getReference()
support_request = instance.Base_generateSupportRequestForSlapOS(
title, title, instance.getRelativeUrl()
......@@ -1517,7 +1517,7 @@ class TestSlapOSHasError(SlapOSTestCaseMixin):
hosting_subscription = self._makeHostingSubscription()
self._makeSoftwareInstance(hosting_subscription,
self.generateNewSoftwareReleaseUrl())
instance = hosting_subscription.getPredecessorValue()
instance = hosting_subscription.getSuccessorValue()
self._makeComputer()
self._makeComputerPartitionList()
......@@ -1590,7 +1590,7 @@ class TestSlapOSHasError(SlapOSTestCaseMixin):
self._makeSoftwareInstance(hosting_subscription,
self.generateNewSoftwareReleaseUrl())
instance = hosting_subscription.getPredecessorValue()
instance = hosting_subscription.getSuccessorValue()
self.assertEqual(instance.getCreationDate(), date - 2)
......@@ -1649,7 +1649,7 @@ class TestSlapOSHasError(SlapOSTestCaseMixin):
self._makeSoftwareInstance(hosting_subscription,
self.generateNewSoftwareReleaseUrl())
instance = hosting_subscription.getPredecessorValue()
instance = hosting_subscription.getSuccessorValue()
self.assertEqual(instance.getCreationDate(), date - 2)
......@@ -1698,7 +1698,7 @@ class TestSlapOSHasError(SlapOSTestCaseMixin):
self._makeSoftwareInstance(hosting_subscription,
self.generateNewSoftwareReleaseUrl())
instance = hosting_subscription.getPredecessorValue()
instance = hosting_subscription.getSuccessorValue()
self.assertEqual(instance.getCreationDate(), date - 2)
......@@ -1728,7 +1728,7 @@ class TestSlapOSHasError(SlapOSTestCaseMixin):
self.assertEqual(
'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"),
hosting_subscription.HostingSubscription_checkSoftwareInstanceState())
......@@ -1752,7 +1752,7 @@ class TestSlapOSHasError(SlapOSTestCaseMixin):
self._makeSoftwareInstance(hosting_subscription,
self.generateNewSoftwareReleaseUrl())
instance = hosting_subscription.getPredecessorValue()
instance = hosting_subscription.getSuccessorValue()
self._makeComputer()
......
......@@ -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/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_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_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
......
......@@ -3740,7 +3740,7 @@ slapos_base;Login_unrestrictedSearchAuthenticationEvent;External Method;d41d8cd9
slapos_base;Login_unrestrictedSearchPasswordEvent;External Method;d41d8cd98f00b204e9800998ecf8427e
slapos_base;Person_generatePassword;Script (Python);c7ef6238cae53aa95b033073585f0901
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_garbageCollectDestroyedRootTree;Script (Python);c7693ceb6f665d589769e75f76bba13a
slapos_cloud;Alarm_garbageCollectNonAllocatedRootTree;Script (Python);f4cac8eb737a55987061cbcc5d4bed5a
......@@ -3794,7 +3794,7 @@ slapos_cloud;Computer_viewCurrentUsage;ERP5 Form;567bc1d268f135496de3d5b946b691f
slapos_cloud;Computer_viewModel;ERP5 Form;567bc1d268f135496de3d5b946b691f3
slapos_cloud;ERP5Type_asSecurityGroupId;Script (Python);6abe5e755c936d813d93ca1fcd441580
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_requestDestroy;Script (Python);8e98fdfd518b1de8dcbb3a5d0ba37e5a
slapos_cloud;HostingSubscription_requestPerson;Script (Python);0f307b89333e4376e21ba85e600372d0
......@@ -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;SoftwareInstallation_reindexComputer;Script (Python);85f2179687f313a0ca70f2be62064bbc
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_setupSlapOSMasterStandardBT5;Script (Python);be0a52a246011ea6a23811640b864cbe
slapos_configurator;TemplateTool_getSlapOSMasterBusinessTemplateList;Script (Python);620fc8300f61b25e30507b4f2eb18f39
......
......@@ -16771,12 +16771,12 @@ SlaveInstanceConstraint
reference: non_draft_property_existence
SlaveInstanceConstraint
expression: python: len(context.getPredecessorRelatedList()) <= 1
id: predecessor_related_constraint
expression: python: len(context.getSuccessorRelatedList()) <= 1
id: successor_related_constraint
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
reference: predecessor_related
reference: successor_related
SlaveInstanceConstraint
constraint_property_list: ['reference']
......@@ -16817,9 +16817,9 @@ SoftwareInstance
write_permission: Modify portal content
SoftwareInstance
id: predecessor_category
id: successor_category
portal_type: Category Property
reference: predecessor
reference: successor
SoftwareInstance
elementary_type: text
......@@ -16889,12 +16889,12 @@ SoftwareInstanceConstraint
reference: not_draft_propert_existence
SoftwareInstanceConstraint
expression: python: len(context.getPredecessorRelatedList()) <= 1
id: predecessor_related_constraint
expression: python: len(context.getSuccessorRelatedList()) <= 1
id: successor_related_constraint
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
reference: predecessor_related
reference: successor_related
SoftwareInstanceConstraint
constraint_property_list: ['destination_reference', 'reference']
......
......@@ -13741,7 +13741,7 @@ Slave Instance
Slave Instance
Reference: jump_to_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
Permission: View
Action Type: object_jump
......@@ -13841,7 +13841,7 @@ Software Instance
Software Instance
Reference: jump_to_software_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
Permission: View
Action Type: object_jump
......
title = context.getTitle()
result = []
found = False
for instance in context.getPredecessorValueList():
for instance in context.getSuccessorValueList():
if (instance.getTitle() == title) and (instance.getSlapState() != 'destroy_requested'):
found = True
break
......
......@@ -21,7 +21,7 @@ hosting_subscription = context
if hosting_subscription.getSlapState() == 'destroy_requested':
return json.dumps({})
instance = hosting_subscription.getPredecessorValue()
instance = hosting_subscription.getSuccessorValue()
if instance is None or instance.getSlapState() == 'destroy_requested':
return json.dumps({})
......
......@@ -16,7 +16,7 @@ elif context.getPortalType() != "Hosting Subscription":
response.setStatus(403)
return ""
instance_list = context.getPredecessorValueList()
instance_list = context.getSuccessorValueList()
for instance in instance_list:
if instance.getTitle() == context.getTitle():
root_instance = instance
......
......@@ -462,7 +462,7 @@ class TestSlapOSHostingSubscription_getHateoasRootSoftwareInstance(TestSlapOSHyp
subscription = self._makeHostingSubscription()
instance = self._makeInstance()
instance.edit(specialise_value=subscription, title=subscription.getTitle())
subscription.edit(predecessor_value=instance)
subscription.edit(successor_value=instance)
self.tic()
fake_request = do_fake_request("GET")
......
......@@ -7,7 +7,7 @@ if upgrade_scope in ["never", "disabled"]:
return
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 len(root_instance_list) == 0:
return
......
hosting_subscription = context
software_instance = hosting_subscription.getPredecessorValue()
software_instance = hosting_subscription.getSuccessorValue()
if not software_instance:
return None
software_release_list = context.SoftwareProduct_getSortedSoftwareReleaseList(
......
......@@ -11,7 +11,7 @@ slap_state = ['start_requested', 'stop_requested']
if not hosting_subscription.getSlapState() in slap_state:
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:
return None
source_instance = source_instance_list[0]
......
portal = context.getPortalObject()
# 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"])
if root_instance is not None and root_instance.getPortalType() == 'Slave Instance':
return True
......
......@@ -80,7 +80,7 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
hosting_subscription.requestStart(**request_kw)
hosting_subscription.requestInstance(**request_kw)
instance = hosting_subscription.getPredecessorValue()
instance = hosting_subscription.getSuccessorValue()
self.tic()
return hosting_subscription, instance
......@@ -185,7 +185,7 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
self._makeFullSoftwareInstance(hosting_subscription, url_string)
self._markComputerPartitionBusy(computer,
hosting_subscription.getPredecessorValue())
hosting_subscription.getSuccessorValue())
self._requestSoftwareRelease(software_product.getRelativeUrl())
self.tic()
......@@ -209,7 +209,7 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
url_string, person)
self._makeFullSoftwareInstance(hosting_subscription, url_string)
self._markComputerPartitionBusy(computer,
hosting_subscription.getPredecessorValue())
hosting_subscription.getSuccessorValue())
# Install the Newest software release
software_release2 = self._requestSoftwareRelease(
......@@ -237,7 +237,7 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
url_string, person)
self._makeFullSoftwareInstance(hosting_subscription, url_string)
self._markComputerPartitionBusy(computer,
hosting_subscription.getPredecessorValue())
hosting_subscription.getSuccessorValue())
# Install the Newest software release
software_release2 = self._requestSoftwareRelease(
......@@ -271,7 +271,7 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
url_string, person)
self._makeFullSoftwareInstance(hosting_subscription, url_string)
self._markComputerPartitionBusy(computer,
hosting_subscription.getPredecessorValue())
hosting_subscription.getSuccessorValue())
# Install the Newest software release
software_release2 = self._requestSoftwareRelease(
......@@ -311,7 +311,7 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
url_string, person)
self._makeFullSoftwareInstance(hosting_subscription, url_string)
self._markComputerPartitionBusy(computer,
hosting_subscription.getPredecessorValue())
hosting_subscription.getSuccessorValue())
# Install the Newest software release
software_release2 = self._requestSoftwareRelease(
......@@ -351,7 +351,7 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
url_string, person)
self._makeFullSoftwareInstance(hosting_subscription, url_string)
self._markComputerPartitionBusy(computer,
hosting_subscription.getPredecessorValue())
hosting_subscription.getSuccessorValue())
# Install the Newest software release
software_release2 = self._requestSoftwareRelease(
......@@ -390,7 +390,7 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
url_string, person)
self._makeFullSoftwareInstance(hosting_subscription, url_string)
self._markComputerPartitionBusy(computer,
hosting_subscription.getPredecessorValue())
hosting_subscription.getSuccessorValue())
# Install the Newest software release
software_release2 = self._requestSoftwareRelease(
......
......@@ -45,7 +45,7 @@ class TestSlapOSDestroySoftwareInstallationWithArchivedSoftwareReleaseAlarm(Slap
hosting_subscription.requestStart(**request_kw)
hosting_subscription.requestInstance(**request_kw)
instance = hosting_subscription.getPredecessorValue()
instance = hosting_subscription.getSuccessorValue()
self.tic()
return instance
......
......@@ -156,7 +156,7 @@ class TestSlapOSPDMMixinSkins(SlapOSTestCaseMixin):
specialise=hosting_subscription.getRelativeUrl()
)
hosting_subscription.edit(
predecessor=software_instance.getRelativeUrl()
successor=software_instance.getRelativeUrl()
)
self.portal.portal_workflow._jumpToStateFor(software_instance, 'start_requested')
software_instance.validate()
......@@ -291,7 +291,7 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins):
None)
self._makeFullSoftwareInstance(hs, oldest_software_url)
self._markComputerPartitionBusy(computer, hs.getPredecessorValue())
self._markComputerPartitionBusy(computer, hs.getSuccessorValue())
self._makeCustomSoftwareRelease(software_product.getRelativeUrl(),
newest_software_url)
self.tic()
......@@ -313,7 +313,7 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins):
oldest_software_url, person)
self._makeFullSoftwareInstance(hs, oldest_software_url)
self._markComputerPartitionBusy(computer, hs.getPredecessorValue())
self._markComputerPartitionBusy(computer, hs.getSuccessorValue())
self._makeCustomSoftwareRelease(software_product.getRelativeUrl(),
newest_software_url)
self._makeSoftwareInstallation(computer,
......
......@@ -2064,7 +2064,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
if os.path.exists(self.instance_request_simulator):
os.unlink(self.instance_request_simulator)
def test_updateInstancePredecessorList(self):
def test_updateInstanceSuccessorList(self):
self._makeComplexComputer()
partition_id = self.start_requested_software_instance.getAggregateValue(
......@@ -2086,9 +2086,9 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
self.start_requested_software_instance.requestInstance(**instance_kw)
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.start_requested_software_instance.getPredecessorTitleList())
self.start_requested_software_instance.getSuccessorTitleList())
# Update with no changes
instance_list_xml = """
......@@ -2101,7 +2101,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
instance_reference_xml=instance_list_xml)
self.tic()
self.assertSameSet(['Instance0', 'Instance1'],
self.start_requested_software_instance.getPredecessorTitleList())
self.start_requested_software_instance.getSuccessorTitleList())
# Update Instance0 was not requested
instance_list_xml = """
......@@ -2114,9 +2114,9 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
instance_reference_xml=instance_list_xml)
self.tic()
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()
partition_id = self.start_requested_software_instance.getAggregateValue(
......@@ -2136,9 +2136,9 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
self.start_requested_software_instance.requestInstance(**instance_kw)
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.start_requested_software_instance.getPredecessorTitleList())
self.start_requested_software_instance.getSuccessorTitleList())
instance_list_xml = '<marshal><list id="i2" /></marshal>'
self.portal_slap.updateComputerPartitionRelatedInstanceList(
......@@ -2147,9 +2147,9 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
instance_reference_xml=instance_list_xml)
self.tic()
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()
partition_id = self.start_requested_software_instance.getAggregateValue(
......@@ -2157,7 +2157,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
self.login(self.start_requested_software_instance.getUserId())
self.assertEqual([],
self.start_requested_software_instance.getPredecessorTitleList())
self.start_requested_software_instance.getSuccessorTitleList())
instance_list_xml = '<marshal><list id="i2" /></marshal>'
self.portal_slap.updateComputerPartitionRelatedInstanceList(
......@@ -2166,7 +2166,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
instance_reference_xml=instance_list_xml)
self.tic()
self.assertEqual([],
self.start_requested_software_instance.getPredecessorTitleList())
self.start_requested_software_instance.getSuccessorTitleList())
# Try with something that doesn't exist
instance_list_xml = """
......@@ -2179,7 +2179,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
instance_reference_xml=instance_list_xml)
self.tic()
self.assertEqual([],
self.start_requested_software_instance.getPredecessorTitleList())
self.start_requested_software_instance.getSuccessorTitleList())
def test_stoppedComputerPartition(self):
self._makeComplexComputer()
......
......@@ -599,7 +599,7 @@ class SlapTool(BaseTool):
computer_partition_id,
instance_reference_xml):
"""
Update Software Instance predecessor list
Update Software Instance successor list
"""
return self._updateComputerPartitionRelatedInstanceList(computer_id,
computer_partition_id,
......@@ -1430,9 +1430,9 @@ class SlapTool(BaseTool):
def _updateComputerPartitionRelatedInstanceList(self, computer_id,
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
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!
instance_reference_xml contain list of title of sub-instances requested by
......@@ -1446,21 +1446,21 @@ class SlapTool(BaseTool):
if self._getLastData(cache_reference) != 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'])
current_predecessor_title_list = [i.getTitle() for i in
current_predecessor_list]
current_successor_title_list = [i.getTitle() for i in
current_successor_list]
# If there are items to remove
if list(set(current_predecessor_title_list).difference(instance_reference_list)) != []:
predecessor_list = [instance.getRelativeUrl() for instance in
current_predecessor_list if instance.getTitle()
if list(set(current_successor_title_list).difference(instance_reference_list)) != []:
successor_list = [instance.getRelativeUrl() for instance in
current_successor_list if instance.getTitle()
in instance_reference_list]
LOG('SlapTool', INFO, '%s, %s: Updating predecessor list to %s' % (
computer_id, computer_partition_id, predecessor_list), error=False)
software_instance_document.edit(predecessor_list=predecessor_list,
comment='predecessor_list edited to unlink non commited instances')
LOG('SlapTool', INFO, '%s, %s: Updating successor list to %s' % (
computer_id, computer_partition_id, successor_list), error=False)
software_instance_document.edit(successor_list=successor_list,
comment='successor_list edited to unlink non commited instances')
self._storeLastData(cache_reference, instance_reference_xml)
####################################################
......
......@@ -15,7 +15,7 @@ if hosting_subscription is not None:
# Call it as soon as possible
hosting_subscription.HostingSubscription_requestUpdateOpenSaleOrder()
instance = hosting_subscription.getPredecessorValue()
instance = hosting_subscription.getSuccessorValue()
# This ensure that the user has a valid cloud contract.
# At this stage he already have a paied invoice for the reservation,
......
......@@ -41,7 +41,7 @@ person.requestSoftwareInstance(**request_kw)
assert hosting_subscription.getSlapState() == "destroy_requested",\
"Hosting Subscription not destroyed!!"
connection_dict = hosting_subscription.getPredecessorValue().getConnectionXmlAsDict()
connection_dict = hosting_subscription.getSuccessorValue().getConnectionXmlAsDict()
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])
......
......@@ -1083,12 +1083,12 @@ class TestSubscriptionRequest_processOrdered(TestSubscriptionSkinsMixin):
hosting_subscription = subscription_request.getAggregateValue(portal_type="Hosting Subscription")
self.assertNotEqual(hosting_subscription, None)
instance = hosting_subscription.getPredecessorValue()
instance = hosting_subscription.getSuccessorValue()
self.assertNotEqual(instance, None)
self.assertEqual('diverged', hosting_subscription.getCausalityState())
instance = hosting_subscription.getPredecessorValue()
instance = hosting_subscription.getSuccessorValue()
self.assertNotEqual(instance, None)
......@@ -1166,7 +1166,7 @@ class TestSubscriptionRequest_processOrdered(TestSubscriptionSkinsMixin):
self.assertEqual('diverged', hosting_subscription.getCausalityState())
self.assertEqual('start_requested', hosting_subscription.getSlapState())
instance = hosting_subscription.getPredecessorValue()
instance = hosting_subscription.getSuccessorValue()
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