Knowledgebase/Blog

Example Perl API code

Andy Powell
posted this on Jan 31 11:39

I've put some example code for accessing the vCloud Director API in a new 'umf-cloud-pilot' project on Google Code. Browse the Source 'trunk' area to see the files.

The code is written in Perl, which has the advantage that you can see exactly what is going on. Run the commands with a --debug option if you really want to see the details.

There are four commands: create.pl, start.pl, stop.pl and delete.pl which do pretty much what they say on the tin. They all take various arguments. Here's an example of their usage:

$ create.pl --server vcloud.cloud.eduserv.org.uk --organization Eduserv_Public --user ap --orgvdc Eduserv_Public_PAYG_1 --catalog Eduserv_Private --vapptemplate "Test vApp Template" --vappname APTest --vappnetwork Eduserv_Public_Ext
$ start.pl --server vcloud.cloud.eduserv.org.uk --organization Eduserv_Public --user ap --orgvdc Eduserv_Public_PAYG_1 --vappname APTest
$ stop.pl --server vcloud.cloud.eduserv.org.uk --organization Eduserv_Public --user ap --orgvdc Eduserv_Public_PAYG_1 --vappname APTest
$ delete.pl --server vcloud.cloud.eduserv.org.uk --organization Eduserv_Public --user ap --orgvdc Eduserv_Public_PAYG_1 --vappname APTest

which creates a new vApp called APTest in the Eduserv_Public_PAYG_1 virtual datacenter based on the Test vApp Template in our private catalog, then starts it, then stops it, and finally deletes it.