Commit f7b3441b authored by Romain Courteaud's avatar Romain Courteaud

slapos_pdm: drop reviewRegistration

parent 913f0ef7
...@@ -14,16 +14,6 @@ if portal.portal_catalog.getResultValue( ...@@ -14,16 +14,6 @@ if portal.portal_catalog.getResultValue(
# There is already a upgrade decision, do nothing # There is already a upgrade decision, do nothing
return return
"""
if decision_in_progress is not None:
if 1:
raise NotImplementedError('reviewRegistration')
decision_in_progress.reviewRegistration(
software_release_url=newer_release.getUrlString())
if decision_in_progress.getSimulationState() != "cancelled":
return
"""
# Check if UpgradeDecision_approveRegistration is running # Check if UpgradeDecision_approveRegistration is running
# XXX we should instead look at the current upgrade decision state # XXX we should instead look at the current upgrade decision state
tag = "%s_requestUpgradeDecisionCreation_inProgress" % instance_tree.getUid() tag = "%s_requestUpgradeDecisionCreation_inProgress" % instance_tree.getUid()
......
...@@ -233,201 +233,6 @@ class TestSlapOSCoreProjectSlapInterfaceWorkflow(SlapOSTestCaseMixin): ...@@ -233,201 +233,6 @@ class TestSlapOSCoreProjectSlapInterfaceWorkflow(SlapOSTestCaseMixin):
self.assertEqual(2, self.assertEqual(2,
self.portal.portal_activities.countMessageWithTag(tag)) self.portal.portal_activities.countMessageWithTag(tag))
def test_upgrade_decision_reviewRegistration_no_software_release_url(self):
self.assertRaises(TypeError, self.upgrade_decision.reviewRegistration)
def test_upgrade_decision_reviewRegistration_draft(self):
# Do nothing as draft
software_release = self.generateNewSoftwareReleaseUrl()
self.upgrade_decision.reviewRegistration(software_release_url=software_release)
def test_upgrade_decision_reviewRegistration(self):
self._addUpgradeLine(self.compute_node)
software_release = self.generateNewSoftwareReleaseUrl()
self.upgrade_decision.reviewRegistration(
software_release_url=software_release)
self.assertEqual("draft",
self.upgrade_decision.getSimulationState())
self.upgrade_decision.plan()
self.tic()
self.upgrade_decision.reviewRegistration(
software_release_url=software_release)
self.assertEqual("cancelled",
self.upgrade_decision.getSimulationState())
def test_upgrade_decision_reviewRegistration_confirm(self):
self._addUpgradeLine(self.compute_node)
software_release = self.generateNewSoftwareReleaseUrl()
self.upgrade_decision.reviewRegistration(
software_release_url=software_release)
self.assertEqual("draft",
self.upgrade_decision.getSimulationState())
self.upgrade_decision.confirm()
self.tic()
self.upgrade_decision.reviewRegistration(
software_release_url=software_release)
self.assertEqual("cancelled",
self.upgrade_decision.getSimulationState())
def test_upgrade_decision_reviewRegistration_rejected(self):
self._addUpgradeLine(self.compute_node)
software_release = self.generateNewSoftwareReleaseUrl()
self.upgrade_decision.reviewRegistration(
software_release_url=software_release)
self.assertEqual("draft",
self.upgrade_decision.getSimulationState())
self.upgrade_decision.reject()
self.tic()
self.upgrade_decision.reviewRegistration(
software_release_url=software_release)
self.assertEqual("rejected",
self.upgrade_decision.getSimulationState())
def test_upgrade_decision_reviewRegistration_same_url(self):
self._addUpgradeLine(self.compute_node)
self.upgrade_decision.reviewRegistration(
software_release_url=self.software_release.getUrlString())
self.assertEqual("draft",
self.upgrade_decision.getSimulationState())
self.upgrade_decision.plan()
self.tic()
self.upgrade_decision.reviewRegistration(
software_release_url=self.software_release.getUrlString())
self.assertEqual("planned",
self.upgrade_decision.getSimulationState())
def test_upgrade_decision_reviewRegistration_confirm_same_url(self):
self._addUpgradeLine(self.compute_node)
self.upgrade_decision.reviewRegistration(
software_release_url=self.software_release.getUrlString())
self.assertEqual("draft",
self.upgrade_decision.getSimulationState())
self.upgrade_decision.confirm()
self.tic()
self.upgrade_decision.reviewRegistration(
software_release_url=self.software_release.getUrlString())
self.assertEqual("confirmed",
self.upgrade_decision.getSimulationState())
def test_upgrade_decision_reviewRegistration_rejected_same_url(self):
self._addUpgradeLine(self.compute_node)
self.upgrade_decision.reviewRegistration(
software_release_url=self.software_release.getUrlString())
self.assertEqual("draft",
self.upgrade_decision.getSimulationState())
self.upgrade_decision.reject()
self.tic()
self.upgrade_decision.reviewRegistration(
software_release_url=self.software_release.getUrlString())
self.assertEqual("rejected",
self.upgrade_decision.getSimulationState())
def test_upgrade_decision_reviewRegistration_started(self):
self._addUpgradeLine(self.compute_node)
software_release = self.generateNewSoftwareReleaseUrl()
self.upgrade_decision.reviewRegistration(
software_release_url=software_release)
self.assertEqual("draft",
self.upgrade_decision.getSimulationState())
self.upgrade_decision.plan()
self.upgrade_decision.start()
self.tic()
self.upgrade_decision.reviewRegistration(
software_release_url=software_release)
self.assertEqual("started",
self.upgrade_decision.getSimulationState())
def test_upgrade_decision_reviewRegistration_instance_tree(self):
self._makeTree()
self._addUpgradeLine(self.instance_tree)
self.upgrade_decision.reviewRegistration(
software_release_url=self.instance_tree.getUrlString())
self.assertEqual("draft",
self.upgrade_decision.getSimulationState())
self.upgrade_decision.plan()
self.tic()
self.upgrade_decision.reviewRegistration(
software_release_url=self.instance_tree.getUrlString())
self.assertEqual("cancelled",
self.upgrade_decision.getSimulationState())
def test_upgrade_decision_reviewRegistration_instance_tree_confirmed(self):
self._makeTree()
self._addUpgradeLine(self.instance_tree)
self.upgrade_decision.reviewRegistration(
software_release_url=self.instance_tree.getUrlString())
self.assertEqual("draft",
self.upgrade_decision.getSimulationState())
self.upgrade_decision.confirm()
self.tic()
self.upgrade_decision.reviewRegistration(
software_release_url=self.instance_tree.getUrlString())
self.assertEqual("cancelled",
self.upgrade_decision.getSimulationState())
def test_upgrade_decision_reviewRegistration_instance_tree_started(self):
self._makeTree()
self._addUpgradeLine(self.instance_tree)
self.upgrade_decision.reviewRegistration(
software_release_url=self.instance_tree.getUrlString())
self.assertEqual("draft",
self.upgrade_decision.getSimulationState())
self.upgrade_decision.start()
self.tic()
self.upgrade_decision.reviewRegistration(
software_release_url=self.instance_tree.getUrlString())
self.assertEqual("started",
self.upgrade_decision.getSimulationState())
@simulate('InstanceTree_isUpgradePossible', @simulate('InstanceTree_isUpgradePossible',
'software_release_url', 'return 1') 'software_release_url', 'return 1')
def test_upgrade_decision_requestUpgrade_instance_tree(self): def test_upgrade_decision_requestUpgrade_instance_tree(self):
......
upgrade_decision = state_change["object"]
from DateTime import DateTime
cancellable_state_list = ['confirmed', 'planned']
require_state_list = ['rejected', 'confirmed', 'planned']
simulation_state = upgrade_decision.getSimulationState()
# Get required arguments
kwargs = state_change.kwargs
# Required args
# Raise TypeError if all parameters are not provided
try:
software_release_url = kwargs['software_release_url']
except KeyError:
raise TypeError("UpgradeDecision_reviewRegistration takes exactly 1 arguments")
if simulation_state in require_state_list:
current_release = upgrade_decision.UpgradeDecision_getAggregateValue("Software Release")
if not current_release:
# This upgrade decision is not valid
return
instance_tree = upgrade_decision.UpgradeDecision_getAggregateValue("Instance Tree")
if instance_tree is not None:
current_instance_tree_release = instance_tree.getUrlString()
if current_instance_tree_release == software_release_url:
if simulation_state in cancellable_state_list:
upgrade_decision.cancel(comment="Instance tree is already upgraded.")
return
if current_release.getUrlString() == software_release_url:
# Cannot cancel because the software releases are the same
return False
if simulation_state in cancellable_state_list:
upgrade_decision.cancel()
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>script_UpgradeDecision_reviewRegistration</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Script</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>UpgradeDecision_reviewRegistration</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
<string>destination/portal_workflow/upgrade_slap_interface_workflow/transition_approve_registration</string> <string>destination/portal_workflow/upgrade_slap_interface_workflow/transition_approve_registration</string>
<string>destination/portal_workflow/upgrade_slap_interface_workflow/transition_notify</string> <string>destination/portal_workflow/upgrade_slap_interface_workflow/transition_notify</string>
<string>destination/portal_workflow/upgrade_slap_interface_workflow/transition_request_upgrade</string> <string>destination/portal_workflow/upgrade_slap_interface_workflow/transition_request_upgrade</string>
<string>destination/portal_workflow/upgrade_slap_interface_workflow/transition_review_registration</string>
<string>destination/portal_workflow/upgrade_slap_interface_workflow/transition_review_upgrade</string> <string>destination/portal_workflow/upgrade_slap_interface_workflow/transition_review_upgrade</string>
</tuple> </tuple>
</value> </value>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Transition" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>action_name</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/workflow</string>
<string>before_script/portal_workflow/upgrade_slap_interface_workflow/script_UpgradeDecision_checkConsistency</string>
<string>after_script/portal_workflow/upgrade_slap_interface_workflow/script_UpgradeDecision_reviewRegistration</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Cancel if the current upgrade isn\'t valid anymore. </string> </value>
</item>
<item>
<key> <string>guard_permission</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>transition_review_registration</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Transition</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Review Registration</string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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