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()
public_category_uid = portal.restrictedTraverse(
"portal_categories/allocation_scope/open/public", None).getUid()
friend_category_uid = portal.restrictedTraverse(
"portal_categories/allocation_scope/open/friend", None).getUid()
if portal.ERP5Site_isSupportRequestCreationClosed():
# 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_type = 'Computer',
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',
activate_kw = {'tag':tag}
)
......
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_type='Hosting Subscription',
validation_state='validated',
default_monitor_scope_uid = NegatedQuery(Query(monitor_disabled_category.getUid())),
method_id='HostingSubscription_checkSoftwareInstanceState',
activate_kw = {'tag':tag}
)
......
portal = context.getPortalObject()
public_category_uid = portal.restrictedTraverse(
"portal_categories/allocation_scope/open/public", None).getUid()
friend_category_uid = portal.restrictedTraverse(
"portal_categories/allocation_scope/open/friend", None).getUid()
if portal.ERP5Site_isSupportRequestCreationClosed():
# 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_type = 'Computer',
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',
activate_kw = {'tag':tag}
)
......
......@@ -18,8 +18,10 @@ if (date_check_limit - hosting_subscription.Base_getCachedCreationDate()) < 0:
# Too early to check
return
software_instance_list = hosting_subscription.getSpecialiseRelatedValueList(
portal_type=["Software Instance", "Slave Instance"])
software_instance_list = context.portal_catalog(
portal_type=["Software Instance", "Slave Instance"],
specialise_uid=hosting_subscription.getUid(),
**{"slapos_item.slap_state": ["start_requested"]})
has_newest_allocated_instance = False
has_unallocated_instance = False
......@@ -27,9 +29,6 @@ failing_instance = None
# Check if at least one software Instance is Allocated
for instance in software_instance_list:
if instance.getSlapState() not in ["start_requested", "stop_requested"]:
continue
if (date_check_limit - instance.Base_getCachedCreationDate()) < 0:
continue
......@@ -37,8 +36,7 @@ for instance in software_instance_list:
if computer_partition is not None:
has_newest_allocated_instance = True
if instance.getPortalType() == "Software Instance" and \
computer_partition.getParentValue().getAllocationScope() in ["open/friend", "open/public"] and \
instance.getSlapState() == "start_requested" and \
computer_partition.getParentValue().getMonitorScope() == "enabled" and \
instance.SoftwareInstance_hasReportedError():
return context.HostingSubscription_createSupportRequestEvent(
instance, 'slapos-crm-hosting-subscription-instance-state.notification')
......
from DateTime import DateTime
import json
from Products.ERP5Type.DateUtils import addToDate
portal = context.getPortalObject()
if context.getSimulationState() == "invalidated":
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(
key_prefix='slap_tool',
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