Commit e3e3ae9e authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_crm: Improve search by project and instances by using group by

   The goal here is:
       - Only check projects that have (at least one) monitored computers
       - Only check Instance Trees that have  (at least one) instance
parent 6e6e62f5
Pipeline #37236 failed with stage
in 0 seconds
portal = context.getPortalObject()
monitor_enabled_category = portal.restrictedTraverse(
"portal_categories/monitor_scope/enabled", None)
portal = context.getPortalObject()
portal.portal_catalog.searchAndActivate(
portal_type='Project',
portal_type='Compute Node',
validation_state='validated',
method_id='Project_checkMonitoringState',
method_id='ComputeNode_checkProjectMontoringState',
monitor_scope__uid=monitor_enabled_category.getUid(),
group_by=['follow_up_uid'],
activate_kw={'tag': tag}
)
context.activate(after_tag=tag).getId()
......@@ -2,11 +2,14 @@ portal = context.getPortalObject()
monitor_enabled_category = portal.restrictedTraverse(
"portal_categories/monitor_scope/enabled", None)
if context.Project_isSupportRequestCreationClosed():
project = context.getFollowUpValue(portal_type='Project')
assert project is not None
if project.Project_isSupportRequestCreationClosed():
return
if monitor_enabled_category is not None:
project_uid = context.getUid()
project_uid = project.getUid()
portal.portal_catalog.searchAndActivate(
portal_type='Compute Node',
validation_state='validated',
......@@ -17,10 +20,12 @@ if monitor_enabled_category is not None:
)
portal.portal_catalog.searchAndActivate(
portal_type='Instance Tree',
# Slave is required due unallocated use case
portal_type=['Software Instance' 'Slave Instance'],
validation_state='validated',
follow_up__uid=project_uid,
method_id='InstanceTree_checkMonitoringState',
group_by=['specialise_uid'],
method_id='SoftwareInstance_checkInstanceTreeMonitoringState',
activate_kw = {'tag':tag}
)
......
......@@ -54,7 +54,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Project_checkMontoringState</string> </value>
<value> <string>ComputeNode_checkProjectMontoringState</string> </value>
</item>
</dictionary>
</pickle>
......
from DateTime import DateTime
from erp5.component.module.DateUtils import addToDate
instance_tree = context
portal = context.getPortalObject()
instance_tree = context.getSpecialiseValue(portal_type="Instance Tree")
assert instance_tree is not None
project = context.getFollowUpValue()
if project.Project_isSupportRequestCreationClosed():
return
......
......@@ -54,7 +54,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>InstanceTree_checkMonitoringState</string> </value>
<value> <string>SoftwareInstance_checkInstanceTreeMonitoringState</string> </value>
</item>
</dictionary>
</pickle>
......
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