VMware {code} Community
Dreamer732
Contributor
Contributor

Perf Issue (taking 8 minutes:() while getting hosts of virtual machine using following query (traversal spec)...

Hi,

What is wrong with the below (query) or traversal? For some vms it takes ~30sec and for some its taking ~8mins

Any help or thoughts are greatly appreciated as i have no clue how to proceed further...:(

resourcePoolMOR = (ManagedObjectReference)d.val;

PropertyFilterSpec propFilterSpec = new PropertyFilterSpec();

propFilterSpec.propSet = new PropertySpec[] { new PropertySpec() };

propFilterSpec.propSet[0].all = false;

propFilterSpec.propSet[0].type = "HostSystem";

propFilterSpec.propSet[0].pathSet = new string[] { "name", "summary", "config" };

propFilterSpec.objectSet = new ObjectSpec[] { new ObjectSpec() };

propFilterSpec.objectSet[0].skip = false;

propFilterSpec.objectSet[0].obj = resourcePoolMOR; //MOR

propFilterSpec.objectSet[0].selectSet = new SelectionSpec[] { TraversalSpecs.GetVmResourcePoolToEsxHostTraversalSpec() };

ObjectContent[] hosts = this.ServiceUtil.GetConnection().Service .RetrieveProperties(this.ServiceUtil.GetConnection().PropCol,

       new PropertyFilterSpec[] { propFilterSpec }); //taking 8 minuetes for some VMs...

Sample log:

Type : HostSystem. Time: 00:07:19.7404095. Properties: config, name, summary. Getting contents from the VimService.

Vm : {VM1}. Time: 00:07:19.7433390. Thread: (Name: , id: 88). Operation: Getting ESX Hosts of VM.

Type : HostSystem. Time: 00:00:31.4042400. Properties: config, name, summary. Getting contents from the VimService.

Vm : {Vm2}. Time: 00:00:31.4081460. Thread: (Name: , id: 6). Operation: Getting ESX Hosts of VM.

And the traversla spec:

public

static TraversalSpec GetVmResourcePoolToEsxHostTraversalSpec()

{

TraversalSpec computeResourceHostTraversalSpec = new TraversalSpec();

computeResourceHostTraversalSpec.type ="ComputeResource";

computeResourceHostTraversalSpec.name ="computeResourceHostTraversalSpec";

computeResourceHostTraversalSpec.path ="host";

computeResourceHostTraversalSpec.skip =false;

TraversalSpec resourcePoolToComputeResourceTraversalSpec = new TraversalSpec();

resourcePoolToComputeResourceTraversalSpec.type ="ResourcePool";

resourcePoolToComputeResourceTraversalSpec.name ="resourcePoolToComputeResourceTraversalSpec";

resourcePoolToComputeResourceTraversalSpec.path ="owner";

resourcePoolToComputeResourceTraversalSpec.skip =false;

resourcePoolToComputeResourceTraversalSpec.selectSet =

new SelectionSpec[] { computeResourceHostTraversalSpec };

return resourcePoolToComputeResourceTraversalSpec;

}

Regards,

Dreamer

0 Kudos
1 Reply
Steve_Jin
Expert
Expert

I don't think I understand what you wanted to achieve here, but I guess you want to get the host that runs a virtual machine. If that is the case, you shouldn't use TraversalSpec, which is intended to search through the inventory tree for multiple managed entities.

Vijava API source code is a good sample illustrating TraversalSpec if you are intested to dig down:

http://vijava.svn.sourceforge.net/viewvc/vijava/trunk/src/com/vmware/vim25/mo/util/PropertyCollector...

Steve

Steve JIN Author of VMware VI and vSphere SDK; Creator of open source VI Java API (http://vijava.sf.net); Blogger at http://www.doublecloud.org
0 Kudos