NAME
VMware::vCloud - VMware vCloud Director
SYNOPSIS
my $vcd = new VMware::vCloud ( $hostname, $username, $password, $orgname, { debug => 1 } );
my %vapps = $vcd->list_vapps();
my $vappid = $vapps{'My Personal vApp'};
my $vapp = $vcd->get_vapp($vappid);
my $ret = $vapp->power_on();
DESCRIPTION
This module provides a Perl interface to VMware's vCloud Director.
It's intention is to provide a high-level perl-style interface to vCloud Director actions.
If you are looking for a direct and low-level access to the vCloud API, you may want to look at VMware::API::vCloud, which is packaged and used by this module.
EXAMPLE SCRIPTS
Included in the distribution of this module are several example scripts. Hopefully they provide an illustrative example of the use of vCloud Director. All scripts have their own POD and accept command line parameters in a similar way to the VIPERL SDK utilities and vghetto scripts.
login.pl - An example script that demonstrates logging in to the server.
org_get.pl - Selects a random organization and prints a Data::Dumper dump of it's information.
list-vapps.pl - Prints a list of all VMs the user has access to.
MODULE METHODS
new($host,$user,$pass,$org,$conf)
This method instances the VMware::vCloud object and verifies the user can log onto the server.
$host, $user, and $pass are required. They should contain the login information for the vCloud server.
$org and $conf are optional.
$org is the vCloud Organization to connect to. If $org is not given, the default of 'System' is used.
$conf is an optional hasref containing tuneable parameters:
* debug - set to a true value to turn on STDERR debugging statements.
debug(1|0)
This turns debugging on and off programatically. An argument of '1' for debugging, '0' for no debugging.
login()
This method is deprecated and will be removed in later releases.
This method roughly emulates the default login action of the API: It returns information on which organizations are accessible to the user.
It is a synonym for list_orgs() and all details on return values should be take from that method's documentation.
purge()
This method clears the in-module caching of API responses.
This module caches many API calls to reduce response times and load on the server. This cache is automatically cleared when a method that changes the status of the VCD server is called. However, there may be times when you have a lon running process, or wish to manually clear the cache yourself.
VAPP METHODS
create_vapp_from_template($name,$vdcid,$tmplid,$netid)
Given a name, VDC, template and network, instantiate the template with the given settings and other defaults.
Details of the create task will be returned.
get_vapp($vappid)
Given an vApp id, it returns a vApp object for that vApp.
See the documentation on VMware::vCloud::vApp for full details on this object type.
list_vapps()
This method returns a hash or hashref of Template names and IDs the user has access too.
TEMPLATE METHODS
get_template($templateid)
Given an organization id, it returns a hash of data for that organization.
list_templates()
This method returns a hash or hashref of Template names and IDs the user has access too.
CATALOG METHODS
create_catalog($org_href,$conf)
This method creates a new, empty catalog in the given organization.
$conf is a hashref that can contain:
name
description
is_published
Org HREF example: http://example.vcd.server/api/admin/org/{id}
delete_catalog($catalog_href)
Given the org HREF, call a delete on it.
ORG METHODS
create_org(\%conf)
delete_org($org_href)
Given the org HREF, call a delete on it.
delete_org_network($org_network_href)
Given the org network HREF, call a delete on it.
disable_org($org_href)
Given a Org href, call the disable action on it.
enable_org($org_href)
Given a Org href, call the enable action on it.
get_org($org_href)
Given an organization id, it returns a hash or hashref of data for that organization. Returned data:
name - Name of the organization
description - Description field of the organization
href - anchor HREF for the organization in the API
id - UUID identified in the href.
contains - A hashref of contained objects
catalogs = references to the catalogs within the org
vdcs - references to the org VDCs within the org
raw - The raw returned XML structure for the organization from the API
list_orgs()
This method returns a hash or hashref of Organization names and IDs.
ORG VDC METHODS
create_vdc($org_url,$conf)
delete_vdc($vdc_href);
Given the org VDC HREF, call a delete on it.
disable_vdc($vdc_href)
Given a VDC href, call the disable action on it.
enable_vdc($vdc_href)
Given a VDC href, call the enable action on it.
get_vdc($vdc_href)
Given an VDC href, it returns a hash of data for that vDC.
list_vdcs() | list_vdcs($orgid)
This method returns a hash or hashref of VDC names and IDs the user has access too.
The optional argument of an $orgname will limit the returned list of VDCs in that Organization.
PROVIDER VDC METHODS
get_pvdc($pvdc_href)
Returns a hashref of the information on the PVDC
NETWORK METHODS
create_org_network
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
list_networks() | list_networks($vdcid)
This method returns a hash or hashref of network names and IDs.
Given an optional VDCid it will return only the networks available in that VDC.
ADMINISTRATIVE METHODS
admin_urls()
Returns the list of administrative action URLs available to the user.
create_external_network($name,$gateway,$netmask,$dns1,$dns2,$suffix,$vimref,$moref,$objtype)
extensions()
Returns the data structure for the admin extensions available.
list_external_networks()
Returns a hash or hasref of all available external networks.
list_portgroups()
Returns a hash or hashref of available portgroups on the first associated vcenter server.
vimserver()
Returns a reference to the first associated vcenter server.
webclienturl($type,$moref)
Give the vimserver type and managed object reference, this method returns the URL for viewing the object via the vSphere Web client. This is handy for finding further details on objects within vSphere.
NOTES
ID VERSUS HREF
Tl;DR - Use HREFs and not IDs.
Internally, objects are identified in the vCloud Director API via either an UUID or a HREF that references that object.
According to the API documentation, (as of 5.1) UUIDs are not guaranteed to always be consistent between connections, but HREFs are considered permanent.
Consequently, it is considered a best practice to use HREFs as the unique identifier of an object. This module implements this best practice.
VERSION
Version: v2.29 (2013/03/25)
AUTHOR
Phillip Pollard, <bennie@cpan.org>
CONTRIBUTIONS
A strong thanks to all people who have helped me with direction, ideas, patches and other such items.
Dave Gress, <dgress@vmware.com> - Handling org admin issues and metadata
Stuart Johnston, <sjohnston@cpan.org> - authentication and XML on API v1.0
DEPENDENCIES
Cache::Bounded
VMware::API::vCloud
LICENSE AND COPYRIGHT
Released under Perl Artistic License