Commit ae4ce9c6 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_cloud: Handle capacity scope for all open allocation the same

   There is no reason to handle capacity in a different way for personal or friend. This comply with the future design, so keep all consistent by only differentiating Open and Close allocation scope whenever update capacity.
parent d84c2d18
portal = context.getPortalObject() portal = context.getPortalObject()
category_list = [portal.restrictedTraverse("portal_categories/allocation_scope/open/public", None), category_list = [portal.restrictedTraverse("portal_categories/allocation_scope/open/public", None),
portal.restrictedTraverse("portal_categories/allocation_scope/open/subscription", None)] portal.restrictedTraverse("portal_categories/allocation_scope/open/subscription", None),
portal.restrictedTraverse("portal_categories/allocation_scope/open/friend", None),
portal.restrictedTraverse("portal_categories/allocation_scope/open/personal", None)]
category_uid_list = [ i.getUid() for i in category_list if i is not None] category_uid_list = [ i.getUid() for i in category_list if i is not None]
......
...@@ -4,8 +4,8 @@ from zExceptions import Unauthorized ...@@ -4,8 +4,8 @@ from zExceptions import Unauthorized
if REQUEST is not None: if REQUEST is not None:
raise Unauthorized raise Unauthorized
if compute_node.getAllocationScope() not in ['open/public', 'open/subscription']: if compute_node.getAllocationScope() not in ['open/public', 'open/subscription', 'open/personal', 'open/friend']:
# Don't update non public compute_node # Don't update non closed computers
return return
can_allocate = True can_allocate = True
......
...@@ -147,8 +147,7 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin): ...@@ -147,8 +147,7 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
server.edit( server.edit(
allocation_scope='open/public') allocation_scope='open/public')
self.assertEqual('open/public', server.getAllocationScope()) self.assertEqual('open/public', server.getAllocationScope())
self.assertEqual('close', server.getCapacityScope()) self.assertEqual('open', server.getCapacityScope())
server.edit(capacity_scope='open')
self.tic() self.tic()
@changeSkin('RJS') @changeSkin('RJS')
...@@ -156,8 +155,7 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin): ...@@ -156,8 +155,7 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
server.edit( server.edit(
allocation_scope='open/subscription') allocation_scope='open/subscription')
self.assertEqual('open/subscription', server.getAllocationScope()) self.assertEqual('open/subscription', server.getAllocationScope())
self.assertEqual('close', server.getCapacityScope()) self.assertEqual('open', server.getCapacityScope())
server.edit(capacity_scope='open')
self.tic() self.tic()
@changeSkin('RJS') @changeSkin('RJS')
......
...@@ -429,14 +429,15 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S ...@@ -429,14 +429,15 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
'Visited by SoftwareInstance_tryToGarbageCollect', 'Visited by SoftwareInstance_tryToGarbageCollect',
self.software_instance.workflow_history['edit_workflow'][-1]['comment']) self.software_instance.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSUpdateComputeNodeCapacityScopeAlarm(SlapOSTestCaseMixin): class TestSlapOSComputeNode_checkAndUpdateCapacityScope(SlapOSTestCaseMixin):
allocation_scope_to_test = 'open/public'
def afterSetUp(self): def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self) SlapOSTestCaseMixin.afterSetUp(self)
self.compute_node = self.portal.compute_node_module.template_compute_node\ self.compute_node = self.portal.compute_node_module.template_compute_node\
.Base_createCloneDocument(batch_mode=1) .Base_createCloneDocument(batch_mode=1)
self.compute_node.edit( self.compute_node.edit(
allocation_scope='open/public', allocation_scope=self.allocation_scope_to_test,
reference='TESTC-%s' % self.generateNewId(), reference='TESTC-%s' % self.generateNewId(),
) )
self.compute_node.edit(capacity_scope='open') self.compute_node.edit(capacity_scope='open')
...@@ -548,11 +549,29 @@ class TestSlapOSUpdateComputeNodeCapacityScopeAlarm(SlapOSTestCaseMixin): ...@@ -548,11 +549,29 @@ class TestSlapOSUpdateComputeNodeCapacityScopeAlarm(SlapOSTestCaseMixin):
self.assertEqual("Compute Node reported an error", self.assertEqual("Compute Node reported an error",
self.compute_node.workflow_history['edit_workflow'][-1]['comment']) self.compute_node.workflow_history['edit_workflow'][-1]['comment'])
def test_ComputeNode_checkAndUpdateCapacityScope_with_error_non_public(self): class TestSlapOSComputeNode_checkAndUpdateCapacityScopeSubscription(TestSlapOSComputeNode_checkAndUpdateCapacityScope):
self.compute_node.setAccessStatus('#error not ok') allocation_scope_to_test = 'open/subscription'
self.compute_node.edit(allocation_scope='open/personal')
self.compute_node.ComputeNode_checkAndUpdateCapacityScope() class TestSlapOSComputeNode_checkAndUpdateCapacityScopePersonal(TestSlapOSComputeNode_checkAndUpdateCapacityScope):
self.assertEqual('open', self.compute_node.getCapacityScope()) allocation_scope_to_test = 'open/personal'
class TestSlapOSComputeNode_checkAndUpdateCapacityScopeFriend(TestSlapOSComputeNode_checkAndUpdateCapacityScope):
allocation_scope_to_test = 'open/friend'
class TestSlapOSUpdateComputeNodeCapacityScopeAlarm(SlapOSTestCaseMixin):
def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
self.compute_node = self.portal.compute_node_module.template_compute_node\
.Base_createCloneDocument(batch_mode=1)
self.compute_node.edit(
allocation_scope='open/public',
reference='TESTC-%s' % self.generateNewId(),
)
self.compute_node.edit(capacity_scope='open')
self.compute_node.validate()
self.compute_node.setAccessStatus("#access ok")
transaction.commit()
def _simulateComputeNode_checkAndUpdateCapacityScope(self): def _simulateComputeNode_checkAndUpdateCapacityScope(self):
script_name = 'ComputeNode_checkAndUpdateCapacityScope' script_name = 'ComputeNode_checkAndUpdateCapacityScope'
...@@ -584,8 +603,20 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C ...@@ -584,8 +603,20 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C
'Visited by ComputeNode_checkAndUpdateCapacityScope', 'Visited by ComputeNode_checkAndUpdateCapacityScope',
self.compute_node.workflow_history['edit_workflow'][-1]['comment']) self.compute_node.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_non_public(self): def test_alarm_subscription(self):
self.compute_node.edit(allocation_scope='open/subscription')
self.test_alarm()
def test_alarm_personal(self):
self.compute_node.edit(allocation_scope='open/personal') self.compute_node.edit(allocation_scope='open/personal')
self.test_alarm()
def test_alarm_friend(self):
self.compute_node.edit(allocation_scope='open/friend')
self.test_alarm()
def test_alarm_closed(self):
self.compute_node.edit(allocation_scope='close/outdated')
self.tic() self.tic()
self._simulateComputeNode_checkAndUpdateCapacityScope() self._simulateComputeNode_checkAndUpdateCapacityScope()
try: try:
......
...@@ -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>testSlapOSCloudAlarm</string> </value> <value> <string>testSlapOSCloudAlarm</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>
......
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