Hi,
Am new to VRO and trying to get the esxi host connection state and the ping result. below is what I have tried but it just gives me undefined output
website = "myvcenter.abc.com"
Esxname = "myesxi.abc.com"
var sdkUrl = "https:" + "//"+ website + ":443/sdk"
var allSdk = VcPlugin.allSdkConnections;
var vcs = [];
for (var i in allSdk) {
if (allSdk[i].displayName == sdkUrl){
vcs.push(allSdk[i]);
}
}
if(vcs > 1){
System.error("!!!!!!!!! To Many vCenter Found");
throw exception;
}else if(vcs < 1){
System.error("!!!!!!!!! No vCenter Found");
throw exception;
} else {
System.log("Found a Valid vCenter);
}
var vCenter = vcs[0];
var hostsystem = System.getModule('com.vmware.library.vc.host').getAllHostSystemsMatchingRegexp(Esxiname)
var thost = hostsystem
System.log(thost.state)
[I] Found a Valid vCenter
[I] undefined
###### is there a way for me to find my esxi host from sdkconnection ?
###### how to get the connection status of the Esxi host ?
For Ping check
var pingchek = System.isHostReachable(Esxiname, 1000)
System.log("Ping Result " + pingchek )
Even if the host is up it gives result as false.
TIA
It seem the VcHostSystem type for vCenter plug-in in vRO 6.0.5 does not have such attribute state.
You should be able to get the same information if you replace state with summary.runtime.connectionState
Hi,
There are a few errors in your scripting code.
1) When you iterate over the connections, you need to use name instead of displayName in the comparison, so the code should become
if (allSdk[i].name == sdkUrl){
2) You are passing Esxiname as an argument when calling the action getAllHostSystemsMatchingRegexp(), but at begining of the code the variable name is Esxname
3) The action getAllHostSystemsMatchingRegexp() returns an array of objects, not a single object, so the expression thost.state is not valid (arrays do not have aan attribute state). To get the state of the first found host, you can use something like:
thost[0].state
I Still get the same output
When I do "getAllHostSystemsMatchingRegexp(Esxname)", it filter's out only the esxi that matches the variable Esxname. and it returns only a single object.
var vCenter = vcs[0];
var hostsystem = System.getModule('com.vmware.library.vc.host').getAllHostSystemsMatchingRegexp(Esxname)
var thost = hostsystem
System.log(thost[0].state)
System.log(thost.lenght)
[I] undefined
[I] 1
What versions of vRO and vCenter plug-in do you use? What's the real state of this host - is it it connected to the vCenter and is it working properly?
Could you try to log not only the state property, but also other properties of this host? Also, could you try to log the whole thost[0] object?
version 6.0.5
Host is connected to vCenter
whole thost[0] = DynamicWrapper (Instance) : [VcHostSystem]-[class com.vmware.vmo.plugin.vi4.model.VimHostSystem] -- VALUE : HostSystem<host-xx>'myesxi.abc.com'
I think I managed to reproduce the same behavior in my lab.
With vRO 6.0.5, host state is shown as undefined. With vRO 7.3, however, the host state is correctly shown as connected (both 6.0.5 and 7.3 were configured with the same vCenter 6 instance).
Could be some issue with the vCenter plug-in build bundled with vRO 6.0.5. vRO 7.3 uses a different implementation of vCenter plug-in.
It seem the VcHostSystem type for vCenter plug-in in vRO 6.0.5 does not have such attribute state.
You should be able to get the same information if you replace state with summary.runtime.connectionState
Thanks llian.
how can I check what are all the properties available ?
In vRO client UI, open the menu 'Tools' > 'API Explorer....'
This will open a new window with vRO API documentation; there you can search for a given type (or method, or attribute) like VcHostSystem and see its available properties/arguments.
There is also a third-party site - http://vroapi.com/