Commit 456864a4 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_erp5: No need to auto close capacity except for close allocation scope

parent ae4ce9c6
...@@ -37,6 +37,19 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope( ...@@ -37,6 +37,19 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
self.commit() self.commit()
self.assertEqual(compute_node.getCapacityScope(), 'close') self.assertEqual(compute_node.getCapacityScope(), 'close')
self.assertEqual(compute_node.getMonitorScope(), 'enabled') self.assertEqual(compute_node.getMonitorScope(), 'enabled')
self.commit()
compute_node.edit(allocation_scope=None)
self.commit()
compute_node.edit(capacity_scope="open", monitor_scope='enabled')
self.commit()
compute_node.edit(allocation_scope=allocation_scope)
self.commit()
self.assertEqual(compute_node.getCapacityScope(), 'open')
self.assertEqual(compute_node.getMonitorScope(), 'enabled')
return compute_node return compute_node
def test_ComputeNode_setAllocationScope_public_no_source_adm(self): def test_ComputeNode_setAllocationScope_public_no_source_adm(self):
...@@ -82,6 +95,18 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope( ...@@ -82,6 +95,18 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
compute_node.edit(allocation_scope='open/personal') compute_node.edit(allocation_scope='open/personal')
self.commit() self.commit()
self.assertEqual(compute_node.getCapacityScope(), 'close')
self.assertEqual(compute_node.getMonitorScope(), 'disabled')
self.commit()
compute_node.edit(allocation_scope=None)
self.commit()
compute_node.edit(capacity_scope="open")
self.commit()
compute_node.edit(allocation_scope='open/personal')
self.commit()
self.assertEqual(compute_node.getCapacityScope(), 'open') self.assertEqual(compute_node.getCapacityScope(), 'open')
self.assertEqual(compute_node.getMonitorScope(), 'disabled') self.assertEqual(compute_node.getMonitorScope(), 'disabled')
return compute_node return compute_node
...@@ -132,6 +157,18 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope( ...@@ -132,6 +157,18 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
compute_node.edit(allocation_scope='open/friend') compute_node.edit(allocation_scope='open/friend')
self.commit() self.commit()
self.assertEqual(compute_node.getCapacityScope(), 'close')
self.assertEqual(compute_node.getMonitorScope(), 'enabled')
self.commit()
compute_node.edit(allocation_scope=None)
self.commit()
compute_node.edit(capacity_scope="open")
self.commit()
compute_node.edit(allocation_scope='open/friend')
self.commit()
self.assertEqual(compute_node.getCapacityScope(), 'open') self.assertEqual(compute_node.getCapacityScope(), 'open')
self.assertEqual(compute_node.getMonitorScope(), 'enabled') self.assertEqual(compute_node.getMonitorScope(), 'enabled')
return compute_node return compute_node
...@@ -179,6 +216,19 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope( ...@@ -179,6 +216,19 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
compute_node.edit(allocation_scope=allocation_scope) compute_node.edit(allocation_scope=allocation_scope)
self.commit() self.commit()
self.assertEqual(compute_node.getCapacityScope(), 'close')
self.assertEqual(compute_node.getMonitorScope(), 'disabled')
self.commit()
compute_node.edit(allocation_scope=None)
self.commit()
compute_node.edit(capacity_scope="open")
self.commit()
compute_node.edit(allocation_scope=allocation_scope)
self.commit()
self.assertEqual(compute_node.getCapacityScope(), 'close') self.assertEqual(compute_node.getCapacityScope(), 'close')
self.assertEqual(compute_node.getMonitorScope(), 'disabled') self.assertEqual(compute_node.getMonitorScope(), 'disabled')
return compute_node return compute_node
......
...@@ -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>testSlapOSERP5InteractionWorkflow</string> </value> <value> <string>testSlapOSERP5InteractionWorkflow</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>
......
compute_node = state_object["object"] compute_node = state_object["object"]
allocation_scope = compute_node.getAllocationScope() allocation_scope = compute_node.getAllocationScope()
if allocation_scope in ['open/public', 'open/subscription']: edit_kw = {}
# Public compute_node capacity is handle by an alarm
capacity_scope = 'close' if compute_node.getCapacityScope() is None:
monitor_scope = 'enabled' edit_kw['capacity_scope'] = 'close'
elif allocation_scope == 'open/friend':
# Capacity is not handled for 'private' compute_nodes if allocation_scope in ['open/public', 'open/subscription', 'open/friend']:
capacity_scope = 'open'
monitor_scope = 'enabled' monitor_scope = 'enabled'
elif allocation_scope == 'open/personal': elif allocation_scope == 'open/personal':
capacity_scope = 'open'
# Keep the same.
monitor_scope = compute_node.getMonitorScope("disabled") monitor_scope = compute_node.getMonitorScope("disabled")
else: else:
monitor_scope = 'disabled' monitor_scope = 'disabled'
capacity_scope = 'close' edit_kw['capacity_scope'] = 'close'
edit_kw = { edit_kw['monitor_scope'] = monitor_scope
'capacity_scope': capacity_scope,
'monitor_scope': monitor_scope
}
self_person = compute_node.getSourceAdministrationValue(portal_type="Person") self_person = compute_node.getSourceAdministrationValue(portal_type="Person")
if self_person is None: if self_person is 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