Commit 9c5a6155 authored by Romain Courteaud's avatar Romain Courteaud

slapos_cloud:

* force open order to be created to allocate
* only check validated open order
* check open order consistency before allocating
* call script on the real web section
parent ef4d3319
......@@ -22,6 +22,25 @@ def assignComputePartition(software_instance, instance_tree):
if instance_tree is None:
raise ValueError('%s does not have related instance tree' % software_instance.getRelativeUrl())
# allocation must be based on the Open Order related to the Instance Tree
# it is unrelated to the Person document
# Migrating all the code is needed
# Step1: force open order to be created to allocated
# Step2: XXX
open_order_line_list = instance_tree.getPortalObject().portal_catalog(
aggregate__uid=instance_tree.getUid(),
portal_type="Open Sale Order Line",
validation_state="validated",
limit=2
)
if len(open_order_line_list) == 1:
try:
open_order_line_list[0].getParentValue().Base_checkConsistency()
except ValidationFailed:
raise Unauthorized("Open Order is not consistent")
else:
raise Unauthorized("No Open Order")
person = instance_tree.getDestinationSectionValue(portal_type='Person')
if person is None:
raise ValueError('%s does not have person related' % instance_tree.getRelativeUrl())
......
......@@ -97,7 +97,7 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
join_key = to_click_url.split('=')[-1]
self.assertNotEqual(join_key, None)
web_site.ERP5Site_activeLogin(key=join_key)
web_site.hateoas.connection.ERP5Site_activeLogin(key=join_key)
self.assertEqual(self.portal.REQUEST.RESPONSE.getStatus(), 303)
self.assertIn(self.web_site.getId() + "/%23%21login%3Fp.page%3Dslapos%7B%26n.me%7D",
......
......@@ -302,6 +302,9 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
self.portal.portal_workflow._jumpToStateFor(self.requested_software_instance, 'start_requested')
self.requested_software_instance.validate()
self.tic()
# XXX Not part of slapos cloud
self.portal.portal_alarms.slapos_request_update_instance_tree_open_sale_order.activeSense()
self.tic()
def _makeSlaveTree(self, requested_template_id='template_slave_instance'):
return self._makeTree(requested_template_id=requested_template_id)
......
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