Commit 58419b68 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_crm: Define 30 days tolerance before create a ticket for the hosting subscription

parent fcec90a2
......@@ -40,7 +40,7 @@ for instance in software_instance_list:
has_newest_allocated_instance = True
if instance.getPortalType() == "Software Instance" and \
computer_partition.getParentValue().getMonitorScope() == "enabled" and \
instance.SoftwareInstance_hasReportedError():
instance.SoftwareInstance_hasReportedError(tolerance=30):
return context.HostingSubscription_createSupportRequestEvent(
instance, 'slapos-crm-hosting-subscription-instance-state.notification')
else:
......
......@@ -13,18 +13,23 @@ if context.getAggregateValue(portal_type="Computer Partition") is not None:
d = json.loads(d)
result = d['text']
last_contact = DateTime(d.get('created_at'))
since = DateTime(d.get('since'))
# Optimise by checking memcache information first.
if result.startswith('#error '):
if include_created_at:
return result, last_contact
return result
if ((DateTime()-since)*24*60) > tolerance:
if include_created_at and not include_since:
return result, last_contact
elif include_created_at and include_since:
return result, last_contact, since
return result
# XXX time limit of 48 hours for run at least once.
if include_message and include_created_at:
if include_message and include_created_at and not include_since:
return result, last_contact
if include_message and not include_created_at:
elif include_message and include_created_at and include_since:
return result, last_contact, since
elif include_message and not include_created_at:
return result
return None
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>include_message=False, include_created_at=False</string> </value>
<value> <string>include_message=False, include_created_at=False, include_since=False, tolerance=0</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
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