Commit b0223fd4 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_crm: Use monitor scope instead allocation scope to generate tickets

parent cd350882
portal = context.getPortalObject() portal = context.getPortalObject()
public_category_uid = portal.restrictedTraverse(
"portal_categories/allocation_scope/open/public", None).getUid()
friend_category_uid = portal.restrictedTraverse( if portal.ERP5Site_isSupportRequestCreationClosed():
"portal_categories/allocation_scope/open/friend", None).getUid() # Stop process alarm if there are too many tickets
return
monitor_enabled_category = portal.restrictedTraverse(
"portal_categories/monitor_scope/enabled", None)
if None not in [friend_category_uid, public_category_uid]: if monitor_enabled_category is not None:
portal.portal_catalog.searchAndActivate( portal.portal_catalog.searchAndActivate(
portal_type = 'Computer', portal_type = 'Computer',
validation_state = 'validated', validation_state = 'validated',
default_allocation_scope_uid = [public_category_uid, friend_category_uid], default_monitor_scope_uid = monitor_enabled_category.getUid(),
method_id = 'Computer_checkState', method_id = 'Computer_checkState',
activate_kw = {'tag':tag} activate_kw = {'tag':tag}
) )
context.activate(after_tag=tag).getId() context.activate(after_tag=tag).getId()
portal = context.getPortalObject() portal = context.getPortalObject()
if portal.ERP5Site_isSupportRequestCreationClosed():
# Stop verification if there are too much tickets
return
monitor_disabled_category = portal.restrictedTraverse(
"portal_categories/monitor_scope/disabled", None)
from Products.ZSQLCatalog.SQLCatalog import Query, NegatedQuery
portal.portal_catalog.searchAndActivate( portal.portal_catalog.searchAndActivate(
portal_type='Hosting Subscription', portal_type='Hosting Subscription',
validation_state='validated', validation_state='validated',
default_monitor_scope_uid = NegatedQuery(Query(monitor_disabled_category.getUid())),
method_id='HostingSubscription_checkSoftwareInstanceState', method_id='HostingSubscription_checkSoftwareInstanceState',
activate_kw = {'tag':tag} activate_kw = {'tag':tag}
) )
......
portal = context.getPortalObject() portal = context.getPortalObject()
public_category_uid = portal.restrictedTraverse(
"portal_categories/allocation_scope/open/public", None).getUid()
friend_category_uid = portal.restrictedTraverse( if portal.ERP5Site_isSupportRequestCreationClosed():
"portal_categories/allocation_scope/open/friend", None).getUid() # Stop process alarm if there are too many tickets
return
monitor_enabled_category = portal.restrictedTraverse(
"portal_categories/monitor_scope/enabled", None)
if None not in [friend_category_uid, public_category_uid]: if monitor_enabled_category is not None:
portal.portal_catalog.searchAndActivate( portal.portal_catalog.searchAndActivate(
portal_type = 'Computer', portal_type = 'Computer',
validation_state = 'validated', validation_state = 'validated',
default_allocation_scope_uid = [public_category_uid, friend_category_uid], default_monitor_scope_uid = monitor_enabled_category.getUid(),
method_id = 'Computer_checkSoftwareInstallationState', method_id = 'Computer_checkSoftwareInstallationState',
activate_kw = {'tag':tag} activate_kw = {'tag':tag}
) )
......
...@@ -18,8 +18,10 @@ if (date_check_limit - hosting_subscription.Base_getCachedCreationDate()) < 0: ...@@ -18,8 +18,10 @@ if (date_check_limit - hosting_subscription.Base_getCachedCreationDate()) < 0:
# Too early to check # Too early to check
return return
software_instance_list = hosting_subscription.getSpecialiseRelatedValueList( software_instance_list = context.portal_catalog(
portal_type=["Software Instance", "Slave Instance"]) portal_type=["Software Instance", "Slave Instance"],
specialise_uid=hosting_subscription.getUid(),
**{"slapos_item.slap_state": ["start_requested"]})
has_newest_allocated_instance = False has_newest_allocated_instance = False
has_unallocated_instance = False has_unallocated_instance = False
...@@ -27,9 +29,6 @@ failing_instance = None ...@@ -27,9 +29,6 @@ failing_instance = None
# Check if at least one software Instance is Allocated # Check if at least one software Instance is Allocated
for instance in software_instance_list: for instance in software_instance_list:
if instance.getSlapState() not in ["start_requested", "stop_requested"]:
continue
if (date_check_limit - instance.Base_getCachedCreationDate()) < 0: if (date_check_limit - instance.Base_getCachedCreationDate()) < 0:
continue continue
...@@ -37,8 +36,7 @@ for instance in software_instance_list: ...@@ -37,8 +36,7 @@ for instance in software_instance_list:
if computer_partition is not None: if computer_partition is not None:
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().getAllocationScope() in ["open/friend", "open/public"] and \ computer_partition.getParentValue().getMonitorScope() == "enabled" and \
instance.getSlapState() == "start_requested" and \
instance.SoftwareInstance_hasReportedError(): instance.SoftwareInstance_hasReportedError():
return context.HostingSubscription_createSupportRequestEvent( return context.HostingSubscription_createSupportRequestEvent(
instance, 'slapos-crm-hosting-subscription-instance-state.notification') instance, 'slapos-crm-hosting-subscription-instance-state.notification')
......
from DateTime import DateTime from DateTime import DateTime
import json import json
from Products.ERP5Type.DateUtils import addToDate
portal = context.getPortalObject() portal = context.getPortalObject()
if context.getSimulationState() == "invalidated": if context.getSimulationState() == "invalidated":
return return
computer = context.getAggregateValue() computer = context.getAggregateValue(portal_type="Computer")
if computer is not None and computer.getPortalType() == "Computer": if computer is not None:
memcached_dict = context.getPortalObject().portal_memcached.getMemcachedDict( memcached_dict = context.getPortalObject().portal_memcached.getMemcachedDict(
key_prefix='slap_tool', key_prefix='slap_tool',
plugin_path='portal_memcached/default_memcached_plugin') plugin_path='portal_memcached/default_memcached_plugin')
......
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