This document describes the vSphere Automation SDK for Java samples that use the vSphere Automation Java client library (vsphereautomation-client-sdk-6.5.0.jar) and vAPI runtime library (vapi-runtime-2.5.0.jar). Additionally, some of the samples demonstrate the combined use of the vSphere Automation SDK APIs and the vSphere Web Services API. To support this combined use, the vSphere Automation SDK for Java includes the vSphere Management SDK jar (vim25.jar). The examples have been developed to work with JDK 1.8. The following sections provide information about using the samples..Sample PackagingThe sample sub-directories show the organization of the samples Java packages. The samples are organized into the following capabilities:
Running the samplesWhen running the samples, parameters can be provided either on the command line, in a configuration file (using the --config-file parameter), or a combination of both. The parameter values specified on the command line will override those specified in the configuration file. When using a configuration file, each required parameter for the sample must be specified either in the configuration file or as a command line parameter. Each parameter specified in the configuration file should be in the "key=value" format. For example: vmname=TestVM cluster=Cluster1To display the usage information for a sample, run the sample without specifying any parameters. The SDK provides the command line scripts
Examples of running a sample and providing parameters on the command lineUse a command like the following to display usage information for a sample:
$./run.sh vmware.samples.tagging.workflow.TaggingWorkflow
usage:
./run.sh | run.bat packagename.SampleClassName [--config-file <CONFIGURATION FILE>] --server <SERVER> --username <USERNAME> --password <PASSWORD>
--cluster <CLUSTER> [--truststorepath <ABSOLUTE PATH OF JAVA TRUSTSTORE FILE>] [--truststorepassword <JAVA TRUSTSTORE PASSWORD>] [--cleardata]
[--skip-server-verification]
Sample Options:
--config-file <CONFIGURATION FILE> OPTIONAL: Absolute path to the configuration file containing the sample options.
NOTE: Parameters can be specified either in the configuration file or on the command
line. Command line parameters will override values specified in the configuration file.
--server <SERVER> hostname of vcenter server
--username <USERNAME> username to login to the vcenter server
--password <PASSWORD> password to login to the vcenter server
--cluster <CLUSTER> The name of the cluster to be tagged
--truststorepath <ABSOLUTE PATH OF JAVA TRUSTSTORE FILE> Specify the absolute path to the file containing the trusted server certificates. This
option can be skipped if the parameter skip-server-verification is specified.
--truststorepassword <JAVA TRUSTSTORE PASSWORD> Specify the password for the java truststore. This option can be skipped if the
parameter skip-server-verification is specified.
--cleardata OPTIONAL: Specify this option to undo all persistent results of running the sample.
--skip-server-verification OPTIONAL: Specify this option if you do not want to perform SSL certificate
verification.
NOTE: Circumventing SSL trust in this manner is unsafe and should not be used with
production code. This is ONLY FOR THE PURPOSE OF DEVELOPMENT ENVIRONMENT.
Use a command like the following to run a sample using only command line
parameters:
$./run.sh vmware.samples.tagging.taggingworkflow.TaggingWorkflow --server servername --username administrator@vsphere.local --password password --cluster vAPISDKCluster --cleardata true --skip-server-verification Examples of running a sample and providing parameters in a configuration fileUse a command like the following to run a sample using only a configuration file: $./run.sh vmware.samples.tagging.workflow.TaggingWorkflow --config-file sample.properties Use the following command to run the sample using a combination of configuration file and command line parameters: $./run.sh vmware.samples.tagging.workflow.TaggingWorkflow --config-file sample.properties --cluster Cluster1 Importing the samples project in Eclipse
The samples directory contains
|