The CreatorCon Call for Content is officially open! Get started here.

ESX Servers have been linked to the Location where the vCenter rather than the physical Location

Rejeesh
Tera Contributor

how can we have the correct physical location tied to the vCenter and ES

1 REPLY 1

Tam_s Ujj1
Tera Contributor

Please find my solution blow:

Note that below solution does NOT apply to patterns only for probes and sensors (the old way of discovery)

The OOB functionality ties the discovered vCenter CIs to the location of the discovery schedule that discovers the vCenter. I struggled a lot to find an easy solution for this and in the end I ended up modifying the JsonCI() script include. Modifying the cidata object in DiscoverySensor, or in the script field of the sensor, did not help.

I then realized that each sensor has a script include named the same as the sensor. e.g.: VCenterVMsSensor() that processes VM related data. Here you can modify data prior updating the VM. The functions call the JsonCI script include in which the discoveryPreWrite() function you can see the OOB location logic: 

if (location)gr.location = location; Meaning that the actual CI will get the value from the location variable, that in many steps inherits it from the discovery schedule.
My modification is as follows:
var changeLocation = new MyScriptInclude().shouldChangeLocation(gr.sys_class_name+'');
if(changeLocation){
var newLocation = new MyScriptInclude().getLocationFromDiscovery(some parameters);
if(newLocation){location = newLocation;}
}
if (location)
gr.location = location;
 
First I check whether location change is needed, in our case it depends on the ci class. if yes I call another logic that calculates the logic and finally passess it to the gr which is the actual discovered CI. For the classes this custom logic is not needed the OOB are being applied.
This of course means that from now on the JsonCI is our responsibilty.