The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Varsha Srinivas
ServiceNow Employee
ServiceNow Employee

Issue: When the ESX server is removed/deleted from the vCenter, vCenter discovery marks the status of the ESX server as "Retired" but the same status change is not recorded in the audit history table.

 

Root Cause and Fix: Discovery updates the status of the ESX server record to Retired using GlideMultipleUpdate.execute() (as Batch update) inVCenterDatacentersSensor script include. GlideMultipleUpdate.execute() do not create the audit records. Hence it is changed to GlideRecord.updateMultiple() which creates the audit record whenever the status is changed to Retired.

The issue is fixed in the Rome release. To fix it in previous versions, change the code from 

// Mark stale ESX servers as 'retired'
esxGr = new GlideMultipleUpdate('cmdb_ci_esx_server');
esxGr.addQuery('vcenter_ref', vCenterSysId);
esxGr.addQuery('object_id', 'NOT IN', output.hosts);
esxGr.addQuery('install_status', '!=', '7');
esxGr.setValue('install_status', '7'); //Retired = 7
esxGr.setValue('sys_updated_on', gs.nowNoTZ());
esxGr.execute();

TO

// Mark stale ESX servers as 'retired'
esxGr = new GlideRecord('cmdb_ci_esx_server');
esxGr.addQuery('vcenter_ref', vCenterSysId);
esxGr.addQuery('object_id', 'NOT IN', output.hosts);
esxGr.addQuery('install_status', '!=', '7');
esxGr.setValue('install_status', '7'); //Retired = 7
esxGr.updateMultiple();
 
Version history
Last update:
‎04-14-2021 01:13 AM
Updated by: