VMware::API::vCloud - The VMware vCloud API


  my $api = new VMware::API::vCloud (
    $hostname, $username, $password, $orgname
  my $raw_login_data = $vcd->login;


This module provides a bare interface to VMware's vCloud REST API.

VMware::vCloud is designed for high level usage with vCloud Director. This module, however, provides a more low-level access to the REST interface.

Responses received from vCloud are in XML. They are translated via XML::Simple with ForceArray set for consistency in nesting. This is the object returned.

Aside from the translation of XML into a perl data structure, no further alteration is performed on the data.

HTTP errors are automatically parsed and die() is called. If you need to perform a dangerous action, do so in an eval block and evaluate $@.


These methods are not API calls. They represent the methods that create this module as a "wrapper" for the vCloud API.


This method creates the vCloud object.


  • hostname

  • username

  • password

  • organization


  $vcd->config( debug => 1 );
debug - 1 to turn on debugging. 0 for none. Defaults to 0.
die_on_fault - 1 to cause the program to die verbosely on a soap fault. 0 for the fault object to be returned on the call and for die() to not be called. Defaults to 1. If you choose not to die_on_fault (for example, if you are writing a CGI) you will want to check all return objects to see if they are fault objects or not.
ssl_timeout - seconds to wait for timeout. Defaults to 3600. (1hr) This is how long a transaction response will be waited for once submitted. For slow storage systems and full clones, you may want to up this higher. If you find yourself setting this to more than 6 hours, your vCloud setup is probably not in the best shape.
hostname, orgname, username and password - All of these values can be changed from the original settings on new(). This is handing for performing multiple transactions across organizations.


These are direct access to the REST web methods.


Performs a DELETE action on the given URL, and returns the parsed XML response.


Performs a GET action on the given URL, and returns the parsed XML response.


Performs a GET action on the given URL, and returns the unparsed HTTP::Request object.


Performs a POST action on the given URL, and returns the parsed XML response.

The optional value for $type is set as the Content Type for the transaction.

The optional value for $content is used as the content of the post.



* Relative URL: /api/versions

This call queries the server for the current version of the API supported. It is implicitly called when library is instanced.


* Relative URL: dynamic, but usually: /login/

This call takes the username and password provided in the config() and creates an authentication token from the server. If successful, it returns the login data returned by the server.

In the 5.1 version of the API, this is a list of several access URLs.


Removes the current login session on the server.


* Relative URL: dynamic admin URL, usually /api/admin/

Parses the admin API URL to build and return a hash reference of key URLs for the API.


* Relative URL: dynamic admin URL followed by "/extension"




$conf is a hashref that can contain:

  • name

  • description

  • is_published

Org HREF example: http://example.vcd.server/api/admin/org/{id}

catalog_get($catid or $caturl)

As a parameter, this method thakes the raw numeric id of the catalog or the full URL detailed for the catalog from the login catalog.

It returns the requested catalog.


HREF example: http://example.vcd.server/api/org/{id}/catalog/{catalogId}/action/controlAccess


The sets the "organizational" sharing for a catalog.

  • is_shared - 1 or 0

  • level - one of: FullControl, Change, ReadOnly

HREF example: http://example.vcd.server/api/org/{id}/catalog/{catalogId}/action/controlAccess


Create an organization.

  • name

  • desc

  • fullname

  • is_enabled

  • can_publish

  • deployed

  • stored

  • ldap_mode: NONE, SYSTEM or CUSTOM - Custom requires further parameters not implemented yet. Default is NONE

org_get($orgid or $orgurl)

As a parameter, this method takes the raw numeric id of the organization or the full URL detailed for the organization from the login catalog.

It returns the requested organization.


Returns the full list of available organizations.


Create an org network

The conf hash reference can contain:

  • name

  • desc

  • gateway

  • netmask

  • dns1

  • dns2

  • dnssuffix

  • is_enabled

  • is_shared

  • start_ip

  • end_ip


Create an org VDC

The conf hash reference can contain:

  • name

  • desc

  • np_href

  • sp_enabled

  • sp_units

  • sp_limit

  • sp_default

  • sp_href

  • allocation_model

  • cpu_unit

  • cpu_alloc

  • cpu_limit

  • mem_unit

  • mem_alloc

  • mem_limit

  • nic_quota

  • net_quota

  • ResourceGuaranteedMemory

  • ResourceGuaranteedCpu

  • VCpuInMhz

  • is_thin_provision

  • pvdc_name

  • pvdc_href

  • use_fast_provisioning


template_get($templateid or $templateurl)

As a parameter, this method thakes the raw numeric id of the template or the full URL.

It returns the requested template.


Returns the response for metadata for the given template href.

HREF example: http://example.vcd.server/api/vAppTemplate/{uuid}

vdc_get($vdcid or $vdcurl)

As a parameter, this method thakes the raw numeric id of the virtual data center or the full URL detailed a catalog.

It returns the requested VDC.


Returns the full list of available VDCs.

vapp_get($vappid or $vapp_href)

As a parameter, this method thakes the raw numeric id of the vApp or the full URL.

It returns the requested vApp.


Returns the response for metadata for the given vApp href.

HREF example: http://example.vcd.server/api/vApp/{uuid}


LoginUrl error.

In both version 1.5 and 5.1 of the API, the "LoginUrl" returned upon log has the value of 'https://HOSTNAME/api/sessions'

To actually succeed with an API log out, however, the URL has to be "session" - singular - 'https://HOSTNAME/api/session'

This module works around this issue.

Template name validation.

Most names in the GUI (for vApps, VMs, Templates, and Catalogs) are limited to 128 characters, and are restricted to being composed of alpha numerics and standard keyboard punctuations. Notably, spaces and tabs are NOT allowed to be entered in the GUI. However, you can upload a template in the API with a space in the name. It will only be visable or usable some of the time in the GUI. Apparently there is a bug in name validation via the API.


If someone from VMware is reading this, and has control of the API, I would dearly love a few changes, that might help things:

Statistics & Dogfooding - There is an implied contract in the API. That is, anything I can see and do in the GUI I should also be able to do via the API. There are no per-VM statistics available in the API. But the statistics are shown in the GUI. Please offer per-VM statistics in the API. Crosswalking the VM name and trying to find the data in the vSphere API to do this is a pain.
System - It would really help if in the API guide it mentions early on that the organization to connect as an administrator account, IE: the macro organization to which all other orgs descend from is called "System." That helps a lot.
External vs External - When you have the concept of a "fenced" network for a vApp, one of the most confusing points is the local network that is natted to the outside is referred to as "External" as is the outside IPs that the network is routed to. Walk a new user through some of the Org creation wizards and watch the confusion. Bad choice of names.


  Version: v2.29 (2013/03/25)


  Phillip Pollard, <>


A strong thanks to all people who have helped me with direction, ideas, patches and other such items.

  Dave Gress, <> - Handling org admin issues and metadata
  Stuart Johnston, <> - authentication and XML on API v1.0




  Released under Perl Artistic License


 VMware vCloud Director Publications

 VMware vCloud API Programming Guide v5.1
 vCloud API and Admin API v5.1 schema definition files
 VMware vCloud API Communities

 VMware vCloud API Specification v1.5