VMware {code} Community
paul_xtravirt
Expert
Expert

Desperate - trying to get information about datastores through web services

Hi all,

Can some one please help me Smiley Sad I have spent hours today and am still stuck. I am trying to retrieve the datastores for a datacenter, with information about the datastores (for example, capacity and free space) and which hosts are connected to them. I am trying to do this in module1, in the datastores() sub. I have searched teh forums but have not found anything that really helps me out. Can someone please put me out of my misery? I have attached my code to this post.

Oh, this is in vb.net by the way using the latest vsphere SDK. I will award points Smiley Happy

If you found this helpful, please consider awarding points

If you found this helpful, please consider awarding some points
0 Kudos
6 Replies
admin
Immortal
Immortal

You must iterate through the inventory to find out the datastores in a datacenter. Datacenter has a property "datastore" which list all the datastores associated with that datacenter. Please follow the attached Java sample for quick reference on how to retrieve the information. The attached sample uses vSphere SDK libraries.

0 Kudos
paul_xtravirt
Expert
Expert

Hi,

Thanks for the reply, but I dont understand java - I know what I need to do but dont know how to construct it in visual basic. Can you provide a VB sample please?

If you found this helpful, please consider awarding points

If you found this helpful, please consider awarding some points
0 Kudos
lamw
Community Manager
Community Manager

Here is another sample using Perl (sorry can't provide .vb example)

As mentioned, if you're able to get a reference to the cluster you're interested in, you'll be able to get a reference to list of the datastores the cluster can see and from that, you'll loop through the array and be able to get information regarding each datastore http://www.vmware.com/support/developer/vc-sdk/visdk25pubs/ReferenceGuide/vim.ComputeResource.html

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

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

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

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

paul_xtravirt
Expert
Expert

Thanks lamw - still struggling over here. I cannot believe that there are not more people interested in the SDK that use VB.Net ??? We have the one great sample, but thats all. If someone had a vb.net sample on how to do this, then that pretty much gives a complete picture of what we need to get going under vb.net ?:|

If you found this helpful, please consider awarding points

If you found this helpful, please consider awarding some points
0 Kudos
heyitspablo
VMware Employee
VMware Employee

Folks - Let us know if there is interest for a Sample Code community dedicated to VB.NET ? Think it might be useful for folks using VB.NET but not sure level of interest from wider community.. ..

regards,

Pablo

Keep up with latest info on vSphere PowerCLI http://blogs.vmware.com/vipowershell - Follow me on Twitter @heyitspablo
0 Kudos
paul_xtravirt
Expert
Expert

Well,

It gets my vote. There is already a single sample piece of code provided by Richard (http://communities.vmware.com/community/developer/codecentral/vsphere_ws_vb?view=overview). It would be good to get some basic pieces of code in there. In the past people have complained about a lack of support for vb.net, although I know that others (Mr Sloof!) do use it. Even if some other basic examples were provided that would be a great start for people. Examples such as:

1. obtain datastore information

2. obtain networking configuration for hosts and guests

I would certainly place code snippets up there for other people once I know what I am doing :smileycool:

If you found this helpful, please consider awarding points

If you found this helpful, please consider awarding some points
0 Kudos