Tag Archives: vcloud

Open Source VMware PHP API experiment

I think this post is not useful anymore, now that VMware release their first PHP API for vCloud, anyway I’ve this little code I wrote as an experiment a few months ago that maybe could be used by someone having an old vCloud (the code you’ll see is wrote to work with VMware’s vCloud 2.5) or maybe who needs a simpler implementation.

I only wrote a few methods:

  • login to the VMware server
  • get info about all VMs
  • get info about a single VM
  • create a new VM setting the RAM amount, CPUs number, disk capacity
  • a useful methods that waits till a task (like a VM creation) is completed

The code you’ll download uses the old nusoap library and directly sends the raw XML to the server ’cause no other SOAP libraries/implementations were working at that time and for the time the experiment lived (I never used vCloud systems and I worked on this project less than a couple of days so…).

Here you have a set of sample calls to the library:

require “vim25.php”;
$vim25 = new vim25(“ip-address-of-the-vcloud-server”, “username”, “password”);

$service_content = $vim25->retrieveServiceContent();
$all_vm_info = $vim25->getAllVMInfo($service_content[“rootFolder”], VIM25_SUB_INFO_ALL);
$vm_info = $vim25->getVMInfo(“vm-16”, VIM25_SUB_INFO_GUEST);

$debug = $vim25->createVM(
“vm name”,
2, // num CPU
512, // RAM
10485760 // disk capacity in kB (10GB)


If you want to give a try to the code:

  • download the library code
  • rename to vim25.php
  • download and install nusoap in the “nusoap” folder (at the same level of the vim25.php file)
  • use the code above to script the vim25 class
  • extend it and use it :-)

This work is public domain thus do whatever you want with it and enjoy.