Commit a918262b authored by Romain Courteaud's avatar Romain Courteaud

slapos_pdm: update not allocated in there is instance node supply

parent c78fce70
......@@ -66,9 +66,12 @@ allocation_cell_list = software_product.getFollowUpValue().Project_getSoftwarePr
predicate_portal_type='Allocation Supply Cell'
)
if (root_instance.getPortalType() == 'Slave Instance') and \
(compute_node is None):
allocation_cell_list = [x for x in allocation_cell_list if ("Remote Node" in [y.getPortalType() for y in x.getParentValue().getParentValue().getAggregateValueList()])]
if compute_node is None:
allocation_cell_node_list = [(x, [y.getPortalType() for y in x.getParentValue().getParentValue().getAggregateValueList()]) for x in allocation_cell_list]
if (root_instance.getPortalType() == 'Slave Instance'):
allocation_cell_list = [x for x, y in allocation_cell_node_list if ("Remote Node" in y) or ("Instance Node" in y)]
elif (root_instance.getPortalType() == 'Software Instance'):
allocation_cell_list = [x for x, y in allocation_cell_node_list if ("Remote Node" in y) or ("Compute Node" in y)]
# Only upgrade if there is no doubt (ie, only 1 url is allowed)
if len(allocation_cell_list) == 1:
......
......@@ -59,6 +59,11 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
portal_type="Remote Node",
follow_up_value=project
)
elif node == "instance":
compute_node = self.portal.compute_node_module.newContent(
portal_type="Instance Node",
follow_up_value=project
)
else:
raise ValueError("Unsupported node value: %s" % node)
......@@ -76,6 +81,8 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
instance_tree = self.portal.REQUEST.get('request_instance_tree')
if is_allocated:
if node == "instance":
raise NotImplementedError('can not allocate on instance node')
partition = compute_node.newContent(portal_type='Compute Partition')
instance = instance_tree.getSuccessorValue()
instance.edit(aggregate_value=partition)
......@@ -90,7 +97,7 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
software_product, _, type_variation, compute_node, instance_tree = self.bootstrapAllocableInstanceTree()
new_release_variation = self._makeSoftwareRelease(software_product)
self.addAllocationSupply("for compute node 2", compute_node, software_product,
self.addAllocationSupply("for compute node", compute_node, software_product,
new_release_variation, type_variation)
self.tic()
......@@ -101,13 +108,23 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
software_product, _, type_variation, compute_node, instance_tree = self.bootstrapAllocableInstanceTree(node="remote")
new_release_variation = self._makeSoftwareRelease(software_product)
self.addAllocationSupply("for remote node 2", compute_node, software_product,
self.addAllocationSupply("for remote node", compute_node, software_product,
new_release_variation, type_variation)
self.tic()
upgrade_decision = instance_tree.InstanceTree_createUpgradeDecision()
self.assertEqual('started', upgrade_decision.getSimulationState())
def test_createUpgradeDecision_notAllocated_newReleaseOnInstanceNode(self):
software_product, _, type_variation, compute_node, instance_tree = self.bootstrapAllocableInstanceTree(node="instance")
new_release_variation = self._makeSoftwareRelease(software_product)
self.addAllocationSupply("for instance node", compute_node, software_product,
new_release_variation, type_variation)
self.tic()
self.assertEqual(None, instance_tree.InstanceTree_createUpgradeDecision())
def test_createUpgradeDecision_notAllocated_sameRelease(self):
software_product, release_variation, type_variation, compute_node, instance_tree = self.bootstrapAllocableInstanceTree()
......@@ -198,6 +215,17 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
upgrade_decision = instance_tree.InstanceTree_createUpgradeDecision()
self.assertEqual('started', upgrade_decision.getSimulationState())
def test_createUpgradeDecision_sharedNotAllocated_newReleaseOnInstanceNode(self):
software_product, _, type_variation, compute_node, instance_tree = self.bootstrapAllocableInstanceTree(shared=True, node="instance")
new_release_variation = self._makeSoftwareRelease(software_product)
self.addAllocationSupply("for instance node", compute_node, software_product,
new_release_variation, type_variation)
self.tic()
upgrade_decision = instance_tree.InstanceTree_createUpgradeDecision()
self.assertEqual('started', upgrade_decision.getSimulationState())
##########################################################################
# Allocated on Compute Node
##########################################################################
......@@ -358,3 +386,4 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
self.tic()
self.assertEqual(None, instance_tree.InstanceTree_createUpgradeDecision())
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