Commit 3244ebb0 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_crm: Use helper script rather them repeat the API from memcached

parent 0ee7f875
......@@ -10,7 +10,6 @@ if portal.ERP5Site_isSupportRequestCreationClosed():
if context.getMonitorScope() == "disabled":
return
software_installation_list = portal.portal_catalog(
portal_type='Software Installation',
default_aggregate_uid=context.getUid(),
......@@ -23,10 +22,7 @@ computer_reference = context.getReference()
computer_title = context.getTitle()
should_notify = True
memcached_dict = context.getPortalObject().portal_memcached.getMemcachedDict(
key_prefix='slap_tool',
plugin_path='portal_memcached/default_memcached_plugin')
memcached_dict = context.Base_getSlapToolMemcachedDict()
tolerance = DateTime()-0.5
for software_installation in software_installation_list:
should_notify = False
......
......@@ -21,10 +21,7 @@ description = ""
should_notify = True
last_contact = "No Contact Information"
memcached_dict = context.getPortalObject().portal_memcached.getMemcachedDict(
key_prefix='slap_tool',
plugin_path='portal_memcached/default_memcached_plugin')
memcached_dict = context.Base_getSlapToolMemcachedDict()
try:
d = memcached_dict[reference]
d = json.loads(d)
......
......@@ -7,10 +7,7 @@ if (now_date - computer.getCreationDate()) < maximum_days:
# This computer was created recently skip
return True
memcached_dict = portal.portal_memcached.getMemcachedDict(
key_prefix='slap_tool',
plugin_path='portal_memcached/default_memcached_plugin')
memcached_dict = context.Base_getSlapToolMemcachedDict()
# Check if there is some information in memcached
try:
d = memcached_dict[computer.getReference()]
......
from DateTime import DateTime
import json
memcached_dict = context.getPortalObject().portal_memcached.getMemcachedDict(
key_prefix='slap_tool',
plugin_path='portal_memcached/default_memcached_plugin')
memcached_dict = context.Base_getSlapToolMemcachedDict()
try:
d = memcached_dict[context.getReference()]
except KeyError:
......
from DateTime import DateTime
import json
memcached_dict = context.getPortalObject().portal_memcached.getMemcachedDict(
key_prefix='slap_tool',
plugin_path='portal_memcached/default_memcached_plugin')
if context.getAggregateValue(portal_type="Computer Partition") is not None:
memcached_dict = context.Base_getSlapToolMemcachedDict()
try:
d = memcached_dict[context.getReference()]
except KeyError:
......@@ -15,12 +12,12 @@ if context.getAggregateValue(portal_type="Computer Partition") is not None:
d = json.loads(d)
result = d['text']
last_contact = DateTime(d.get('created_at'))
# Optimise by checking memcache information first.
if result.startswith('#error '):
return result
#last_contact = DateTime(d.get('created_at'))
# XXX time limit of 48 hours for run at least once.
if include_message:
......
......@@ -17,10 +17,7 @@ if document is None:
return True
aggregate_portal_type = document.getPortalType()
memcached_dict = context.getPortalObject().portal_memcached.getMemcachedDict(
key_prefix='slap_tool',
plugin_path='portal_memcached/default_memcached_plugin')
memcached_dict = context.Base_getSlapToolMemcachedDict()
if aggregate_portal_type == "Computer":
try:
......
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