Hi, how do you get all esx hosts from a vcenter? I can navigate via MOB (/mob/?moid=HostProfileManager) which lists my clusters and I can then click through on those to see the hosts but I cant work out how to use the api to do this?
I dont need code examples just a top level of what method needs to be called will suffice!
Thanks
You need to use the vSphere Web Services SDK to navigate through the vSphere objects hierarchy. Or you can use the simpler but unsupported ViJava API from Steve Jin.
As Laurent pointed out, open source vijava can help that with one line like the following:
ManagedEntity[] mes = new InventoryNavigator(rootFolder).searchManagedEntities("HostSystem");
Check out more with the Hello World sample:
http://sourceforge.net/p/vijava/code/HEAD/tree/trunk/src/com/vmware/vim25/mo/samples/HelloVM.java
For the support, you can try the commercial version vijavaNG:
Good luck!
Steve
Thanks for the answers, I'm using the WSDL API. Can I access the hosts using the SearchIndex managed object or do I have to use the HostSystem managed object? When I use searchIndex with FindByPath at the top level datacenter it only shows vms, templates etc never hosts