VMware {code} Community
DeepakMishra
Contributor
Contributor

Get the list of virtual machine and its details

Hi,

I have following requirements in my project.

1. Connect to an ESX host and get the list of virtual machines and its complete detail (ipaddress, fqdn, mac address and memory).

2. Connect to a Virtual Center and get the list of all Virtual Machines and its complete detail (ipaddress, fqdn, mac address, memory and the detail of esx to which it is connected).

3. Connect to an ESX host and get its performance detail (memory Usage, CPU usage) of Memory Usage since a given time.

4. Connect to a Virtual Center and the Performance detail of all managed ESX hosts under this.

Can any one please tell me how to achive above using VI SDK 4.0.

Thank You,

Deepak

Reply
0 Kudos
1 Reply
lamw
Community Manager
Community Manager

First off, if you're new to the VMware and vSphere SDK/APIs, please spend some time going over: . This will help you understand the various components and how to get started selecting one of the language bindings to the vSphere API.

Also you'll want to familiarize yourself with the vSphere API reference documentation: http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/index.html

1) and 2) are redundant, you can just go to your vCenter to collect all managed ESX(i) host and traverse through each host extracting the properties you required .... unless you have ESX(i) hosts that are not being managed by vCenter.

Here's an example using vSphere SDK for Perl on listing VMs from either ESX(i) or vCenter system:

Here's a script that shows how you can extract the various properties from your vCenter, ESX(i) hosts, VMs,etc.:

(this might be complicated if you're new to the API, so I suggest you start small and understand the basics)

For a VM information, you'll want to take a look at: http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.VirtualMachine.html

3) For host information, you'll want to take a look at: http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.HostSystem.html

4) For performance/hardware gathering take a look at:

Lot of information, take some time to throughly go through it and try some of the sample code/scripts provided by each of the languages bindings to the vSphere API. There are also lots of webinars and videos at: http://communities.vmware.com/community/developer/learn which can be leveraged.

good luck and happy scripting/programming

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

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

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

VMware Developer Comuunity

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

Reply
0 Kudos