Hi guys,
i search for a better way to get all datacenters from a specific vCenter Server (I have serveral vCenter Server in my Orchestrator inventory.).
For example, we have one vCenter in Europe and one in Asia, both vCenter's have a "Datacenter" with the name "DEV" and I want to get the one in Asia. I figured out this code, but maybe there is a better way for doing this (since the UUID is not guaranteed to be available)?
function getDatacenter(name) {
/*if (typeof(name) != "string")
throw new TypeError("Function parameter is invalid");
*/
var myDatacenters = VcPlugin.getAllDatacenters();
for (var i = 0; i < myDatacenters.length; i++ ) {
if ( (myDatacenters[i].name.toLowerCase() == name.toLowerCase()) &&
(myDatacenters[i].sdkConnection.about.instanceUuid == "57042EB3-128A-4810-9F26-31EC0A080863") )
return myDatacenters[i];
}
return null;
}
http://www.vmware.com/support/orchestrator/doc/vco_vsphere41_api/html/VcSdkConnection.html
http://www.vmware.com/support/orchestrator/doc/vco_vsphere41_api/html/_VcPlugin.html#field-detail
http://www.vmware.com/support/orchestrator/doc/vco_vsphere41_api/html/VcDatacenter.html
Thanks in advance,
Stephan