VMware {code} Community
aceishigh
Contributor
Contributor

How to get list of all virtual machines and snapshots with c#?

Hi All,

I have ESXi 4.0 server with vSphere 4.0 installed. I'm writing a web application in C# and I need to be able to display all the available vm machines and all snapshots, as well as their current state (shut down, started, etc.)

Can someone give me some same code to do this? I've tried reading the documentation on vmware site but found it very confusing.

Thanks to you all for your time.

A.

0 Kudos
3 Replies
admin
Immortal
Immortal

Hi A,

The best place to get your hands on vSphere SDK is : http://communities.vmware.com/docs/DOC-7270

Basically to retrieve all the VMs and their corresponding snapshots, you would need to use PropertyCollector managed object and fetch all the VMs. To retrieve the snapshots, you would need to retrieve the snapshot property of the VM managed object. There are sample codes available in C#, which will do help you to perform these mentioned things.

http://communities.vmware.com/docs/DOC-10028

http://communities.vmware.com/docs/DOC-10030

I hope this will help you to understand SDK better.

Angela.

aceishigh
Contributor
Contributor

Thanks very much Angela, this is what I was after. I'll download the SDK and update this post on my progress.

Your help is much appreciated.

A.

0 Kudos
aceishigh
Contributor
Contributor

Update: I downloaded the SDK for Web Services and found that the sample simpleclient actually does what I want - connect to the ESXi server and return a list of all objects there. Thanks again.

John

0 Kudos