Commit 042211ab authored by Rafael Monnerat's avatar Rafael Monnerat

Upgrade legacy software

See merge request nexedi/slapos.core!402
parents 83510d52 25ba8655
Pipeline #22689 failed with stage
...@@ -8,7 +8,9 @@ release = portal.portal_catalog.getResultValue( ...@@ -8,7 +8,9 @@ release = portal.portal_catalog.getResultValue(
url_string=url_string, url_string=url_string,
) )
if release is not None: if release is not None:
software_product = release.getAggregateValue() software_product = release.getAggregateValue(
checked_permission='Access contents information')
if software_product is not None:
image_url = software_product.getDefaultImageAbsoluteUrl() image_url = software_product.getDefaultImageAbsoluteUrl()
return image_url return image_url
...@@ -26,7 +26,7 @@ else: ...@@ -26,7 +26,7 @@ else:
product_list = portal.portal_catalog( product_list = portal.portal_catalog(
portal_type='Software Product', portal_type='Software Product',
reference=software_product_reference, reference=software_product_reference,
validation_state='published', validation_state=['published', 'validated'],
limit=2) limit=2)
if not product_list: if not product_list:
...@@ -39,11 +39,16 @@ software_release_list = product_list[0].getAggregateRelatedValueList() ...@@ -39,11 +39,16 @@ software_release_list = product_list[0].getAggregateRelatedValueList()
def sortkey(software_release): def sortkey(software_release):
publication_date = software_release.getEffectiveDate() publication_date = software_release.getEffectiveDate()
delta = 0
if software_release.getValidationState() == "archived":
# Decrease 80 years, to be sure it goes last but still on the list
delta = 365*80
if publication_date: if publication_date:
if (publication_date - DateTime()) > 0: if (publication_date - DateTime()) > 0:
return DateTime('1900/05/02') # Decrease 100 years, to be sure it goes at the end of the queue
return publication_date delta = 365*100
return software_release.getCreationDate() return publication_date - delta
return software_release.getCreationDate() - delta
software_release_list = sorted( software_release_list = sorted(
software_release_list, software_release_list,
...@@ -52,5 +57,4 @@ software_release_list = sorted( ...@@ -52,5 +57,4 @@ software_release_list = sorted(
return [software_release for software_release in software_release_list return [software_release for software_release in software_release_list
if software_release.getValidationState() in if software_release.getValidationState() in
["published", "published_alive"] ["published", "published_alive", "archived"]]
]
...@@ -14,7 +14,7 @@ for decision_line in decision_line_in_progress_list: ...@@ -14,7 +14,7 @@ for decision_line in decision_line_in_progress_list:
release_list = decision_line.getAggregateValueList(portal_type="Software Release") release_list = decision_line.getAggregateValueList(portal_type="Software Release")
if len(release_list) > 1: if len(release_list) > 1:
continue continue
if not release_list[0]: if not release_list:
continue continue
# If the current sr in rejected we must prevent creation of new upgrade decision for this sr # If the current sr in rejected we must prevent creation of new upgrade decision for this sr
if simulation_state == 'rejected' and \ if simulation_state == 'rejected' and \
......
...@@ -1336,16 +1336,22 @@ ${new_software_release_url}""", ...@@ -1336,16 +1336,22 @@ ${new_software_release_url}""",
def testUpgradeDecisionLine_cancel_archived_software_release(self): def testUpgradeDecisionLine_cancel_archived_software_release(self):
software_release = self._makeSoftwareRelease() software_release = self._makeSoftwareRelease()
software_product = self._makeSoftwareProduct()
upgrade_decision = self._makeUpgradeDecision() upgrade_decision = self._makeUpgradeDecision()
upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision) upgrade_decision_line = self._makeUpgradeDecisionLine(upgrade_decision)
upgrade_decision_line.setAggregateValueList([software_release]) upgrade_decision_line.setAggregateValueList([software_release])
software_release.setAggregateValue(software_product)
self.tic() self.tic()
software_release.archive() software_release.archive()
upgrade_decision_line.UpgradeDecisionLine_cancel()
self.assertEqual('draft', upgrade_decision.getSimulationState())
software_product.invalidate()
upgrade_decision_line.UpgradeDecisionLine_cancel() upgrade_decision_line.UpgradeDecisionLine_cancel()
self.assertEqual('cancelled', upgrade_decision.getSimulationState()) self.assertEqual('cancelled', upgrade_decision.getSimulationState())
workflow_history_list = upgrade_decision.Base_getWorkflowHistoryItemList('upgrade_decision_workflow', display=0) workflow_history_list = upgrade_decision.Base_getWorkflowHistoryItemList('upgrade_decision_workflow', display=0)
self.assertEqual("Software Release is archived.", workflow_history_list[-1].comment) self.assertEqual("Software Product is invalidated.", workflow_history_list[-1].comment)
@simulate('NotificationTool_getDocumentValue', @simulate('NotificationTool_getDocumentValue',
'reference=None', 'reference=None',
...@@ -1445,6 +1451,8 @@ ${new_software_release_url}""", ...@@ -1445,6 +1451,8 @@ ${new_software_release_url}""",
'context.REQUEST["testUpgradeDecisionLine_cancel_destroyed_hs_archived_sr"])') 'context.REQUEST["testUpgradeDecisionLine_cancel_destroyed_hs_archived_sr"])')
def testUpgradeDecisionLine_cancel_destroyed_hs_archived_sr(self): def testUpgradeDecisionLine_cancel_destroyed_hs_archived_sr(self):
software_release = self._makeSoftwareRelease() software_release = self._makeSoftwareRelease()
software_product = self._makeSoftwareProduct()
software_release.setAggregateValue(software_product)
instance_tree = self._makeFullInstanceTree(software_release.getUrlString()) instance_tree = self._makeFullInstanceTree(software_release.getUrlString())
upgrade_decision = self._makeUpgradeDecision() upgrade_decision = self._makeUpgradeDecision()
...@@ -1478,9 +1486,10 @@ ${new_software_release_url}""", ...@@ -1478,9 +1486,10 @@ ${new_software_release_url}""",
) )
instance_tree.requestDestroy(**kw) instance_tree.requestDestroy(**kw)
software_release.archive() software_release.archive()
software_product.invalidate()
self.tic() self.tic()
upgrade_decision_line.UpgradeDecisionLine_cancel() upgrade_decision_line.UpgradeDecisionLine_cancel()
self.assertEqual('cancelled', upgrade_decision.getSimulationState()) self.assertEqual('cancelled', upgrade_decision.getSimulationState())
workflow_history_list = upgrade_decision.Base_getWorkflowHistoryItemList('upgrade_decision_workflow', display=0) workflow_history_list = upgrade_decision.Base_getWorkflowHistoryItemList('upgrade_decision_workflow', display=0)
self.assertEqual("Software Release is archived.", workflow_history_list[-1].comment) self.assertEqual("Software Product is invalidated.", workflow_history_list[-1].comment)
...@@ -6,12 +6,6 @@ ...@@ -6,12 +6,6 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>testSlapOSPDMSkins</string> </value> <value> <string>testSlapOSPDMSkins</string> </value>
...@@ -55,28 +49,13 @@ ...@@ -55,28 +49,13 @@
<item> <item>
<key> <string>workflow_history</string> </key> <key> <string>workflow_history</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="PersistentMapping" module="Persistence.mapping"/> <global name="PersistentMapping" module="Persistence.mapping"/>
</pickle> </pickle>
...@@ -89,7 +68,7 @@ ...@@ -89,7 +68,7 @@
<item> <item>
<key> <string>component_validation_workflow</string> </key> <key> <string>component_validation_workflow</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -98,7 +77,7 @@ ...@@ -98,7 +77,7 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="4" aka="AAAAAAAAAAQ="> <record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
......
...@@ -10,7 +10,10 @@ if upgrade_decision.getSimulationState() == "cancelled": ...@@ -10,7 +10,10 @@ if upgrade_decision.getSimulationState() == "cancelled":
return return
if software_release.getValidationState() == "archived": if software_release.getValidationState() == "archived":
upgrade_decision.cancel(comment="Software Release is archived.") software_product = software_release.getAggregateValue()
if software_product is not None and \
software_product.getValidationState() == "invalidated":
upgrade_decision.cancel(comment="Software Product is invalidated.")
return return
if instance_tree is not None: if instance_tree is not 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