Commit a9a36b73 authored by Romain Courteaud's avatar Romain Courteaud

slapos_pdm:

* update xml format
* optional_variation_base_category_list are not set in variation_base_category_list
* force software change from Upgrade Decision
* drop template_instance_tree
* allow to force upgrade to a specific release
* rely on self instead of one a global
* drop view_related_upgrade_decision on Compute Node
  Deprecated for a long time
parent 9b30c305
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_view</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_view</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>view_related_upgrade_decision</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>6.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Upgrade Decision</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/ComputeNode_viewUpgradeDecision</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -56,7 +56,7 @@ class SoftwareProduct(ERP5SoftwareProduct):
# valid type by default.
content_type = ''
variation_base_category_list = ('software_release', 'software_type', )
variation_base_category_list = ('software_type', )
optional_variation_base_category_list = ('software_release', )
default_category_list = (
......@@ -83,7 +83,7 @@ class SoftwareProduct(ERP5SoftwareProduct):
# Force getting default_category_list
# if not category from this base_category is set
base_category_dict = {}
for category in SoftwareProduct.default_category_list:
for category in self.default_category_list:
base_category = category.split('/', 1)[0]
if base_category in base_category_dict:
base_category_dict[base_category].append(category)
......
......@@ -68,12 +68,6 @@
<tuple/>
</value>
</item>
<item>
<key> <string>type_mixin</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
......
......@@ -68,12 +68,6 @@
<tuple/>
</value>
</item>
<item>
<key> <string>type_mixin</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
......
......@@ -6,6 +6,13 @@ instance_tree = context
if instance_tree.getSlapState() == "destroy_requested":
return
if (target_software_release is not None) or (target_software_type is not None):
# Those parameters will be use to force an upgrade decision
# to a specific release / type
# used by Remote Node for example
assert target_software_release is not None
assert target_software_type is not None
if portal.portal_catalog.getResultValue(
portal_type='Upgrade Decision',
aggregate__uid=instance_tree.getUid(),
......@@ -59,8 +66,8 @@ if person is None:
# XXX search only for the main node
allocation_cell_list = software_product.getFollowUpValue().Project_getSoftwareProductPredicateList(
software_product=software_product,
software_product_type=software_type,
#software_product_release=software_release,
software_product_type=target_software_type or software_type,
software_product_release=target_software_release,
destination_value=person,
node_value=compute_node,
predicate_portal_type='Allocation Supply Cell'
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
<value> <string>target_software_release=None, target_software_type=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -11,9 +11,13 @@
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple/>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
......
......@@ -33,7 +33,8 @@ else:
instance_xml=instance_tree.getTextContent(),
sla_xml=instance_tree.getSlaXml(),
shared=instance_tree.isRootSlave(),
project_reference=instance_tree.getFollowUpReference()
project_reference=instance_tree.getFollowUpReference(),
force_software_change=True
)
upgrade_decision.stop(
......
......@@ -14,8 +14,8 @@ class TestSlapOSUpgradeDecisionProcess(SlapOSTestCaseMixin):
def _makeInstanceTree(self, slap_state="start_requested"):
instance_tree = self.portal\
.instance_tree_module.template_instance_tree\
.Base_createCloneDocument(batch_mode=1)
.instance_tree_module\
.newContent(portal_type="Instance Tree")
instance_tree.validate()
new_id = self.generateNewId()
instance_tree.edit(
......
......@@ -311,6 +311,39 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(SlapOSTestCaseMixin):
instance_tree, software_product, new_release_variation, type_variation
)
def test_createUpgradeDecision_allocatedOnComputeNode_newReleaseOnComputeNodeAndCorrectTarget(self):
software_product, _, type_variation, compute_node, _, instance_tree = self.bootstrapAllocableInstanceTree(allocation_state='allocated')
new_release_variation = self._makeSoftwareRelease(software_product)
self.addAllocationSupply("for compute node", compute_node, software_product,
new_release_variation, type_variation, disable_alarm=True)
self.tic()
self.checkCreatedUpgradeDecision(
instance_tree.InstanceTree_createUpgradeDecision(
target_software_release=new_release_variation,
target_software_type=type_variation
),
instance_tree, software_product, new_release_variation, type_variation
)
def test_createUpgradeDecision_allocatedOnComputeNode_newReleaseOnComputeNodeAndIncorrectTarget(self):
software_product, _, type_variation, compute_node, _, instance_tree = self.bootstrapAllocableInstanceTree(allocation_state='allocated')
new_release_variation = self._makeSoftwareRelease(software_product)
incorrect_release_variation = self._makeSoftwareRelease(software_product)
self.addAllocationSupply("for compute node", compute_node, software_product,
new_release_variation, type_variation, disable_alarm=True)
self.tic()
self.assertEqual(
None,
instance_tree.InstanceTree_createUpgradeDecision(
target_software_release=incorrect_release_variation,
target_software_type=type_variation
)
)
def test_createUpgradeDecision_allocatedOnComputeNode_twoRelease(self):
software_product, release_variation, type_variation, compute_node, _, instance_tree = self.bootstrapAllocableInstanceTree(allocation_state='allocated')
self.tic()
......@@ -325,6 +358,47 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(SlapOSTestCaseMixin):
self.assertEqual(None, instance_tree.InstanceTree_createUpgradeDecision())
def test_createUpgradeDecision_allocatedOnComputeNode_twoReleaseAndCorrectTarget(self):
software_product, release_variation, type_variation, compute_node, _, instance_tree = self.bootstrapAllocableInstanceTree(allocation_state='allocated')
self.tic()
self.addAllocationSupply(
"for compute node", compute_node, software_product,
release_variation, type_variation, disable_alarm=True)
new_release_variation = self._makeSoftwareRelease(software_product)
self.addAllocationSupply("for compute node 2", compute_node, software_product,
new_release_variation, type_variation, disable_alarm=True)
self.tic()
self.checkCreatedUpgradeDecision(
instance_tree.InstanceTree_createUpgradeDecision(
target_software_release=new_release_variation,
target_software_type=type_variation
),
instance_tree, software_product, new_release_variation, type_variation
)
def test_createUpgradeDecision_allocatedOnComputeNode_twoReleaseAndIncorrectTarget(self):
software_product, release_variation, type_variation, compute_node, _, instance_tree = self.bootstrapAllocableInstanceTree(allocation_state='allocated')
self.tic()
self.addAllocationSupply(
"for compute node", compute_node, software_product,
release_variation, type_variation, disable_alarm=True)
new_release_variation = self._makeSoftwareRelease(software_product)
incorrect_release_variation = self._makeSoftwareRelease(software_product)
self.addAllocationSupply("for compute node 2", compute_node, software_product,
new_release_variation, type_variation, disable_alarm=True)
self.tic()
self.assertEqual(
instance_tree.InstanceTree_createUpgradeDecision(
target_software_release=incorrect_release_variation,
target_software_type=type_variation
),
None
)
##########################################################################
# Shared allocated on Compute Node
##########################################################################
......
Compute Node | view_related_upgrade_decision
Instance Tree | view_upgrade
Software Product Individual Variation | view
Software Product Release Variation | view
......
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