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