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