aswani521
Contributor
Contributor

List of VMs on an ESX Host

Jump to solution

Is there a method in the sdk which lists out all the VMs on an esx host ?

0 Kudos
1 Solution

Accepted Solutions
lamw
Community Manager
Community Manager

You just need to get a reference to a HostSystem and it has an array property called vm http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.HostSystem.html which gives you an array reference to all the VMs on that particular host.

Here is a Perl script sample that shows how to retrieve all VMs for a specific host and some attributes of the VM:

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

Twitter: @lamw

If you find this information useful, please award points for "correct" or "helpful".

View solution in original post

0 Kudos
4 Replies
lamw
Community Manager
Community Manager

You just need to get a reference to a HostSystem and it has an array property called vm http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.HostSystem.html which gives you an array reference to all the VMs on that particular host.

Here is a Perl script sample that shows how to retrieve all VMs for a specific host and some attributes of the VM:

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

Twitter: @lamw

If you find this information useful, please award points for "correct" or "helpful".

View solution in original post

0 Kudos
aswani521
Contributor
Contributor

Is there any Equalent of " find_entity_views " in C# SDK ?

0 Kudos
lamw
Community Manager
Community Manager

Yes, find_entity_views is just a Perl subroutine that uses RetrieveProperties() http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vmodl.query.PropertyColle...

If you're interested to see how this is implemented, take a look at some of the VMware Perl Modules that were written at /usr/lib/perl5/5.8.8/VMware if you have vCLI installed and specifically VICommon.pm which contains the subroutine definition. You definitely can write one for C# using the vSphere SDK

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

Twitter: @lamw

If you find this information useful, please award points for "correct" or "helpful".

0 Kudos
aswani521
Contributor
Contributor

The AppUtil class provided in the sample sdk has the function getdescendentmoref() which fetches the ManagedObjectReferences to all the VMs on the host.

0 Kudos