This document describes the vCloud Suite SDK Java samples that use the vCloud Suite Java client library (vcloudsuite-client-sdk-6.0.0.jar) and vAPI runtime library (vapi-runtime-1.0.0.jar). Additionally, some of the samples demonstrate the combined use of the Lookup Service, Tagging and Content Library and the vSphere API. To support this combined use, the vCloud Suite SDK Java includes the vSphere Management SDK jars (vim25.jar, pbm.jar). The examples have been developed to work with the JDK 1.7. The following sections provide information about using the samples..
Sample DirectoriesThe sample sub-directories show the organization of the samples Java packages. The samples are organized into the following capabilities:
Sample Program StructureThe vCloud Suite SDK Java samples use a framework to facilitate different aspects of using the samples. Some of the framework capabilities are:
@Before , @Action , and @After .
The framework imposes a unified structure on the samples so that it is easier to find specific
code fragments. The samples annotations and framework are already integrated into the vCloud
Suite Java samples project.
To work with the VMWare-supported deployment configurations of Platform Services Controllers (Single Sign-On) and vCenter Servers, applications need to dynamically discover service URLs to make service requests. Before making service requests, applications need to authenticate with the Single Sign-On service. Most of the vCloud Suite client application performs the following basic tasks to connect to the vAPI and vim service endpoint (on a management node) and accomplish Platform Services initialization.
The list of operations shown above are implemented in the LookupServiceHelper, PlatformServiceController and ServiceManager classes which are part of the vCloud Suite SDK for Java samples framework. These classes are located under
The following is the code snippet from public abstract void setup() throws Exception; public abstract void run() throws Exception; public abstract void cleanup() throws Exception; @Before public void init() throws Exception { platformServiceController = new PlatformServiceController(lookupServiceUrl); SSOConnection ssoConnection = platformServiceController.getSsoConnection(ssoUsername, ssoPassword); managementNode = platformServiceController.getManagementNode(mgmtInstanceName); managementNode.connect(ssoConnection); setup(); } @Action public void execute() throws Exception { run(); } @After public void after() throws Exception { try { if (clearData) { cleanup(); } } finally { managementNode.disconnect(); } } Running the samplesThe samples framework is designed to execute any of the samples provided in the kit. To run a sample, you must at least specify authentication parameters and lookup service endpoint url.
You can specify the lookup service API endpoint url, Single Sign-On username and password in the Running the samples from command line
You can run the samples from the command line.
The SDK provides the command line scripts $run.sh com.vmware.samples.packagename.SampleClassName --lookupserviceurl lsurl --ssousername username --ssopassword passwordExample: $run.sh TaggingWorkflow --lookupserviceurl https://endpoint.domain/lookupservice/sdk --ssousername [email protected] --ssopassword password --clustername vAPISDKCluster --cleardata true Script parameters: TaggingWorkflow (M) - sample class name. lookupserviceurl(M) - lookup service SDK Url. ssousername (M) - Single Sign-On user name. ssopassword (M) - Single Sign-On user password. clustername (M) - The name of the cluster to be tagged. cleardata (O) - True, if if you want the framework to delete the sample data after the sample finishes.Use the --help option to print information about a sample. The following example shows the help for the Tagging work flow sample. ./run.sh TaggingWorkflow --help -- VMware samples in Java -- TaggingWorkflow Demonstrates tagging CRUD operations. Step 1: Create a Tag category called �Asset�. Step 2: Create a Tag called �Server� under the category �Asset�. Step 3: Retrieve an existing Cluster using VIM APIs. Step 4: Translates the Cluster's MoRef into vAPI ID. Step 5: Assign �Server� tag to the Cluster using the ID. Additional steps when clearData flag is set to TRUE: Step 6: Detach the tag from the Cluster. Step 7: Delete the tag �Server�. Step 8: Delete the tag category �Asset�. Note: the sample needs an existing Cluster --lookupserviceurl <lookupserviceurl> [required] lookup service SDK Url --mgmtinstancename <mgmtinstancename> [optional] management node's instance name. Ex: IP/FQDN of the node --multiplemgmtnode &multiplemgmtnode> [optional] set to true while running a sample against multiple management nodes. --ssousername <ssousername> [required] Single Sign-On user name --ssopassword <ssopassword> [required] Single Sign-On user password --cleardata <cleardata> optional set to true to clear up all the sample data after the run. --clustername <clustername> [required] The name of the Cluster to be tagged. Importing the samples project in Eclipse
The samples directory contains
|