Hello,
I am trying to find a way to extract the vCenter(VC) associated with a particular ESXi hosts?
I can find the VC:HostSystem but cannot seem to figure out how to link this back to the vCenter. I cannot use "EsxiHost.parent.parent.parent" as the host might not be part of a cluster. Might only be under a DC. I looked under the HostConfig, About, Summary but could not find anything related to VC.
I could find all the hosts of a VC and then compare that array with my array of hosts but, that is ugly.
I did find an option to get the managedserverip which is the Ip of VC and then do a nslookup but, again ugly.
Any suggestions would be great. I am writing this workflow in JS.
Thanks
B
Hi,
Registered vCenters are represented in vRO by VC:SdkConnection objects.
If you want to get the VC:SdkConnection associated with your host system, you can use the following code (it is a property of most managed objects):
var sdkConnection = host.sdkConnection;
System.log("SDK Connection: " + sdkConnection);
If you want to get vCenter's FQDN or instance name, you can use the following code:
var sdkConnection = host.sdkConnection;
var optionManager = sdkConnection.optionManager;
var vCenterInstanceName = optionManager.queryOptions("VirtualCenter.InstanceName").shift().value;
var vCenterFqdn = optionManager.queryOptions("VirtualCenter.FQDN").shift().value;
System.log("vCenter Instance Name: " + vCenterInstanceName);
System.log("vCenter FQDN: " + vCenterFqdn);
In both code snippets, the input parameter is host of type VC:HostSystem
Are you trying this with PowerCli ?
If you view the content of file /etc/vmware/vpxa/vpxa/cfg
on a particular host then you will find associated vCenter IP in parameters with ServerIP.
<serverIp>10.0.0.26</serverIp>
Hi,
Registered vCenters are represented in vRO by VC:SdkConnection objects.
If you want to get the VC:SdkConnection associated with your host system, you can use the following code (it is a property of most managed objects):
var sdkConnection = host.sdkConnection;
System.log("SDK Connection: " + sdkConnection);
If you want to get vCenter's FQDN or instance name, you can use the following code:
var sdkConnection = host.sdkConnection;
var optionManager = sdkConnection.optionManager;
var vCenterInstanceName = optionManager.queryOptions("VirtualCenter.InstanceName").shift().value;
var vCenterFqdn = optionManager.queryOptions("VirtualCenter.FQDN").shift().value;
System.log("vCenter Instance Name: " + vCenterInstanceName);
System.log("vCenter FQDN: " + vCenterFqdn);
In both code snippets, the input parameter is host of type VC:HostSystem