Name
sn_itom_licensing.ITOMVisibilityLicenseCounterWithServicesStore
Description
No description available
Script
var ITOMVisibilityLicenseCounterWithServicesStore = Class.create();
ITOMVisibilityLicenseCounterWithServicesStore.prototype = Object.extendsObject(ITOMVisibilityLicenseCounterStore,{
initialize: function() {
ITOMVisibilityLicenseCounterStore.prototype.initialize.call(this);
this.licensingUtil = new global.SMLicensingUtilWrapper();
this.licensableTypes = gs.getProperty('itom.visibility.licensable_service_types', '').split(',');
},
// @Override
_addCountConditions: function(gr, allowedSources, dateFilter) {
// build the AND conditions for getting the count of CIs
var conditions = [
this._getSourceCondition('sys_id', allowedSources, dateFilter)
];
// now lets add our services condition ... (this will be an OR from the previous conditions)
this.licensingUtil.addServiceAssociationCondition(gr, conditions, this.licensableTypes, "sys_id");
//now lets add standard SU filtering condition on top of the GlideRecord we get
this._getCountCondition(gr);
},
/*******************************************************
**** EX END RESULT SQL QUERY Updated AFTER Adding
OT Condition, Exclusion Table and Install Status Condition:
********************************************************
SELECT … FROM ( cmdb cmdb0 LEFT JOIN (license_exclusion_list sj0 INNER JOIN itom_license_e7n_metadata itom_license_exclusion_metada2 ON sj0.`exclusion_reason` = itom_license_exclusion_metada2.`sys_id` AND
((((((((itom_license_exclusion_metada2.`category` = 'Containers' OR itom_license_exclusion_metada2.`category` = 'All') AND itom_license_exclusion_metada2.`active` = 1 AND itom_license_exclusion_metada2.`sku_type` LIKE '5beb6b53c7601046dfddeeff7b120a%' AND
(itom_license_exclusion_metada2.`value_stream` = 'Visibility' OR itom_license_exclusion_metada2.`value_stream` = 'All'))))))) ON sj0.`ci`=cmdb0.`sys_id` ) WHERE
cmdb0.`sys_class_path` LIKE '/!!/#E%' AND (cmdb0.`sys_id` IN (SELECT ... FROM sys_object_source sys_object_source0 WHERE ((sys_object_source0.`last_scan` >= '2022-11-11 08:00:00' AND sys_object_source0.`last_scan` <= '2023-02-10 07:59:59') AND
sys_object_source0.`name` IN ('Service-now' , 'SG-OT MSFT D4IoT' , 'ServiceNow' , 'ServiceWatch' , 'ACC-Visibility' , 'AgentClientCollector' , 'SG-OT Excel Import'))) OR
cmdb0.`sys_id` IN (SELECT ... FROM svc_model_assoc_ci svc_model_assoc_ci0 WHERE svc_model_assoc_ci0.`environment` IN (SELECT ... FROM svc_layer svc_layer0 WHERE svc_layer0.`sys_id` IN (SELECT ... FROM cmdb cmdb0 WHERE cmdb0.`sys_class_path` LIKE '/!!/!7/!(/!!%' AND cmdb0.`a_int_12` = 4))))
AND (cmdb0.`duplicate_of` IS NULL AND (cmdb0.`install_status` IS NULL OR cmdb0.`install_status` NOT IN (7 , 8 , 100))) AND cmdb_par10.`cmdb_ot_entity` IS NULL GROUP BY cmdb0.`sys_id` HAVING count(sj0.`sys_id`) = 0
*******************************************************/
/*******************************************************
**** LIST OF QUERY CONDITIONS
*******************************************************/
_getCountCondition: function(gr) {
var qc = gr.addQuery('duplicate_of', 'NULL');
this._getInstallStatusCondition(qc);
return qc;
},
_getSourceCondition: function(ref, allowedSources, dateFilter) {
// Using some helper GlideRecord, otherwise the query will not be built as expected
var helperGr = new GlideRecord('cmdb_ci_server');
var qc = helperGr.addJoinQuery('sys_object_source', ref, 'target_sys_id');
qc.addCondition('name', 'IN', allowedSources.join(","));
qc.addCondition('last_scan', 'ON', dateFilter);
return qc;
},
_getInstallStatusCondition : function(queryCondition) {
var installStatusValuesToExclude = gs.getProperty("sn_itom_licensing.install_status_values_to_exclude", '7,8,100'); // RETIRED, STOLEN, ABSENT
var excludedStatus = installStatusValuesToExclude.replaceAll(' ', '').split(',');
if (excludedStatus.indexOf('NULL') == -1) {
queryCondition.addCondition('install_status', 'NULL').addOrCondition('install_status', 'NOT IN', excludedStatus);
} else {
excludedStatus = excludedStatus.filter(function(ele) {
return ele != 'NULL';
});
queryCondition.addCondition('install_status', 'NOT IN', excludedStatus);
}
},
type: 'ITOMVisibilityLicenseCounterWithServicesStore'
});
Sys ID
e4db44c0b7c6301046df8985de11a9a3