VMware {code} Community
rbmadison
Contributor
Contributor

Enumerate VC VMs via Web

Is there any way I can enumerate the VMs from my VC using the web browser? I know if I browses to my VC and click "Browse objects managed by VirtualCenter" I can look at the VC objects. Is there any way to enumerate all the VMs via this method from a script? If there is another way to enumerate all VC VMs please let me know. Examples would be very appreciated.

Thanks

Reply
0 Kudos
4 Replies
StefanPahrmann

Hello,

it's possible with a webserver that supports perl and the VI Perl Toolkit. With this you can build your own solutions with the webbrowser as interface. Is it something like that you want?

Regards

Stefan

Reply
0 Kudos
tos2k
Expert
Expert

Yes, you are right. The functions provided by the "Managed Object Browser" (MOB) is the same that is used for/from the VimSDK. The VimSdk gives you access to all the functionality provided by VC/VC Client. It is available for .NET, Java and Perl (perlToolkit).

Sou you are really free to choose a,ong these to build you own web based application Smiley Wink

Good luck!

Tos2k

Reply
0 Kudos
rbmadison
Contributor
Contributor

Thanks for the information. I have written a VBS script that works with VCB to backup our guests. I want to enumerate all of the VMs within the data center so. Is there any way I can pass a URL to the MOB interface to enumerate the guests in the data center? I can parse the results then to do the work I need in the script. Or is there an easier way to enumerate these?

Thanks

Reply
0 Kudos
jrackliffe
Hot Shot
Hot Shot

Well I won't say it will be easy, but if you already parsing the mob results and handling the auth then I guess it wouldn't be too crazy.

To get the vms in a datacenter you should be able to do it in a couple mob calls.

  1. Load /mob/?moid=ServiceInstance&doPath=content (to get your serviceContent)

  2. Parse out the MoRef id or URL for your rootFolder (may be always d1, but unsure)

  3. Load results of above step to get the rootFolder

  4. Parse results for the datacenters that should be in the childEntity property as URLs

    1. Note that may mean you need to load each DC and get it's Name to find your target if you don't know its moRef id

  5. Load the target DC URL

  6. Parse the result for the vmFolder property and grab the URL

  7. Load the vmFolder URL

    1. This should be the system's "vm" folder which is sort of a hidden folder

  8. Parse and load URL for childEntity

  9. Now you should be able to parse and present all of the VMs that are present in childEntity

Now that won't be easy, but I think it should work for you. Now you may want to look at the beta of the PowerShell kit that is running, assuming you could install the PS underpinnings, as it would offer this type of solution in far fewer steps. See the VI Toolkit for Windows community for more info.

J

Reply
0 Kudos