Hi. I'm using VMware vSphere Web Services SDK (c#).
I'm trying, without success, to use the PropertyCollector.getHosts().
It retrives 0 objects (ObjectContent[]).
To me there is something strange in the "ComputeResource" TraversalSpec
(that is infact declared but never used).
Unfortunatly I'm not familiar with PropertyCollector so I cannot figure out what's wrong
(ah, same behaviour connecting to a single ESXi and to a vCenter server provided with 3 ESXi).
Thanks for your support and patience.
Lorenzo
PS: below the code, coming from the SDK examples
static ObjectContent[] getHosts(ManagedObjectReference dcMoRef) {
// PropertySpec specifies what properties to
// retrieve from what type of Managed Object
PropertySpec pSpec = new PropertySpec();
pSpec.type="HostSystem";
pSpec.pathSet=new String[]
{ "name", "runtime.connectionState" };
SelectionSpec recurseFolders = new SelectionSpec();
recurseFolders.name="folder2childEntity";
TraversalSpec computeResource2host = new TraversalSpec();
computeResource2host.type="ComputeResource";
computeResource2host.path="host";
TraversalSpec folder2childEntity = new TraversalSpec();
folder2childEntity.type="Folder";
folder2childEntity.path="childEntity";
folder2childEntity.name=recurseFolders.name;
// Add BOTH of the specifications to this specification
folder2childEntity.selectSet=new SelectionSpec[]
{ recurseFolders};
// Traverse from a Datacenter through
// the 'hostFolder' property
TraversalSpec dc2hostFolder = new TraversalSpec();
dc2hostFolder.type="Datacenter";
dc2hostFolder.path="hostFolder";
dc2hostFolder.selectSet=new SelectionSpec[]
{ folder2childEntity };
ObjectSpec oSpec = new ObjectSpec();
oSpec.obj=dcMoRef;
oSpec.skip= true;
oSpec.selectSet=new SelectionSpec[] { dc2hostFolder };
PropertyFilterSpec pfSpec = new PropertyFilterSpec();
pfSpec.propSet=new PropertySpec[] { pSpec };
pfSpec.objectSet=new ObjectSpec[] { oSpec };
return _service.RetrieveProperties(
_sic.propertyCollector,
new PropertyFilterSpec[] { pfSpec });
}
Hello.
For those interested onto the issue, I solved changing the function in this way
it works on both esxi 4.1 stand alone, and on vCenter Server with more than one hypervisor