Commit e7816dd6 authored by Romain Courteaud's avatar Romain Courteaud

Desactivate public computer if it didn't contact for more than 10 minutes.

parent d053716e
......@@ -87,6 +87,9 @@ if can_allocate:\n
can_allocate = False\n
comment = \'Computer reported an error\'\n
# XXX TODO: compare creation date of #ok message\n
elif int(DateTime()) - int(DateTime(log_dict.get(\'created_at\'))) > 600:\n
can_allocate = False\n
comment = "Computer didn\'t contact for more than 10 minutes"\n
\n
if can_allocate:\n
# Check the computer capacity.\n
......
......@@ -8,6 +8,7 @@ import json
from zExceptions import Unauthorized
from DateTime import DateTime
from Products.ERP5Type.DateUtils import addToDate
from App.Common import rfc1123_date
class TestSlapOSCorePromiseSlapOSModuleIdGeneratorAlarm(testSlapOSMixin):
def test_Module_assertIdGenerator(self):
......@@ -1067,7 +1068,8 @@ class TestSlapOSUpdateComputerCapacityScopeAlarm(testSlapOSMixin):
key_prefix='slap_tool',
plugin_path='portal_memcached/default_memcached_plugin')
memcached_dict[self.computer.getReference()] = json.dumps({
'text': '#access ok'
'text': '#access ok',
'created_at': rfc1123_date(DateTime())
})
transaction.commit()
......@@ -1075,6 +1077,20 @@ class TestSlapOSUpdateComputerCapacityScopeAlarm(testSlapOSMixin):
self.computer.Computer_checkAndUpdateCapacityScope()
self.assertEqual('open', self.computer.getCapacityScope())
def test_Computer_checkAndUpdateCapacityScope_with_old_access(self):
memcached_dict = self.portal.portal_memcached.getMemcachedDict(
key_prefix='slap_tool',
plugin_path='portal_memcached/default_memcached_plugin')
memcached_dict[self.computer.getReference()] = json.dumps({
'text': '#access ok',
'created_at': rfc1123_date(addToDate(DateTime(),
to_add={'minute': -11}))
})
self.computer.Computer_checkAndUpdateCapacityScope()
self.assertEqual('close', self.computer.getCapacityScope())
self.assertEqual("Computer didn't contact for more than 10 minutes",
self.computer.workflow_history['edit_workflow'][-1]['comment'])
def test_Computer_checkAndUpdateCapacityScope_no_capacity_quantity(self):
self._makeTree()
self.computer.edit(capacity_quantity=1)
......
268
\ No newline at end of file
269
\ No newline at end of file
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