vCloud SDK for Java Developer's Guide
orgName is the name of the organization to which the user is authenticating.
vdcName is the name of a vDC in that organization where the user can upload the OVF and deploy the
vApp.
ovfFileLocation is the full pathname to the OVF descriptor on the local disk.
vmdkFileLocation is the full pathname to the vmdk file referenced in the OVF descriptor.
vmdkFileName is the file name of the vmdk file.
catalogName is the name of the catalog in which the vApp template will be catalogued.
For example:
java HellovCloud https://vcloud/api/versions 1.0 user@SampleOrg Pa55w0rd SampleOrg SampleVdc
C:\descriptor.ovf C:\disk.vmdk disk.vmdk SampleCatalog
Logging In and Getting an Organization List
Most vCloud API requests must be authenticated by a login request that supplies user credentials in the form
required by Basic HTTP authentication (MIME Base64 encoding of a string having the form
user@vcloud‐organization:password). The VcloudClient class implements a login method that takes two
parameters:
userName: supplied in the form user@vcloud‐organization
password: the user's password
As shown in the excerpt in Example
The vCloud API returns a list of the organizations to which the user has access, and the login method in
HellovCloud.java prints this list. In the typical case, this list has a single member, the organization that was
supplied in the userName parameter.
Example 3-1. Logging In and Getting an Organization List
public static void login(String vCloudVersionsURL, String versionId,String username, String
password) ...
{
...
System.out.println("Organizations:");
System.out.println("-------------");
for (String organizationName : organizationsMap.keySet())
System.out.println("" + organizationName);
} else {
System.out.println(Try Logging in with valid details");
System.exit(0);
}
Getting References to the vDC and Catalog
To instantiate a vApp template and operate the resulting vApp, you need the object references (href values)
for the catalog in which the vApp template will be entered and the vDC in which the vApp will be deployed.
The Organization class implements several methods that return references to vDCs and catalogs.
HellovCloud.java uses these methods as shown in Example
Example 3-2. Getting References to the vDC and Catalog
public static Vdc findVdc(String orgName, String vdcName) throws VCloudException {
ReferenceType orgRef = vcloudClient.getOrgRefByName(orgName);
Organization org = Organization.getOrganizationByReference(vcloudClient, orgRef);
ReferenceType vdcRef = org.getVdcRefByName(vdcName);
return Vdc.getVdcByReference(vcloudClient, vdcRef);
}
...
14
3‐1, HellovCloud.java uses this method to authenticate to the cloud.
3‐2.
VMware, Inc.