VMware Storage Policy SDK: JAX-WS Samples Readme |
|
VMware Storage Policy SDK Readme
This document describes the VMware Storage Policy SDK samples that use the JAX-WS bindings
for the vSphere API. The examples have been developed to work with the JAX-WS bundled with
the JDK 1.8.
The following sections describe how to build and run the vSphere Web Services SDK
JAX-WS samples.
Sample Directories
The VMware Storage Policy SDK samples are located
in the following vSphere Management SDK directory:
.../SDK/spbm/java/JAXWS/samples/com/vmware/spbm/samples/
The following table contains a brief description of the samples.
| Sample | Description |
| AboutInfo.java |
Demonstrates how to retrieve information about the Storage Policy service. |
| CheckCompliance.java |
Demonstrates how to check compliance of a profile with its associated entity. |
| CreateProfile.java |
Demonstrates how to create a requirements profile based on tag-defined capabilities. |
| CreateVSANProfile.java |
Demonstrates how to create a requirements profile based on VSAN-defined capabilities. |
| DeleteProfile.java |
Demonstrates how to delete an existing storage profile. |
| EditProfile.java |
Demonstrates how to add a subprofile to a storage profile. |
| ListProfiles.java |
Demonstrates how to retrieve the list of storage profiles and display profile metadata. |
| ViewProfiles.java |
Demonstrates how to display the contents of a storage profile. |
| VMClone.java |
Demonstrates how to associate a storage profile with a virtual machine clone. |
| VMCreate.java |
Demonstrates how to create a virtual machine and associate a storage profile with it. |
The VMware Storage Policy SDK also contains sample connection code that is located in the
following directory:
SDK/spbm/java/JAXWS/samples/com/vmware/spbm/connection/
The connection class samples demonstrate how to use the vCenter session cookie to establish
a connection with the Storage Policy service.
Sample Program Structure
Every VMware Storage Policy SDK application performs the following basic tasks:
- Obtains the vCenter session cookie.
- Uses the vCenter session cookie to establish an SPBM session.
- Calls methods to manage storage profiles.
The samples use custom Java annotations to organize these tasks. These annotations
are @Before, @Action, and @After.
The SDK sample code includes a samples framework that runs the samples and executes the sample code.
- Each sample extends the class
ConnectedServiceBase
(.../SDK/spbm/java/JAXWS/samples/com/vmware/spbm/connection/ConnectedServiceBase.java).
This class contains the @Before and @After declarations.
The @Before code connects to the vCenter Server,
and obtains access to the vSphere methods.
The @After code disconnects from the Server.
- Each sample file contains the
@Action declaration, which contains the code
that performs the capability of the particular sample.
For example, the AboutInfo sample
contains the @Action code. This code retrieves the current time
from the vCenter Server, and it retrieves the Storage Policy service name and version, and the
storage vendor providers from the Storage Policy server.
Building the Sample Programs
To build the sample programs, you must define the JAVA_HOME environment variable
and execute the build script to generate client stubs and compile the samples.
JAVA_HOME Environment Variable
You must set the JAVA_HOME environment variable to the base directory of a JDK.
Build Scripts
The following table shows the build files located in the
SDK/spbm/java/JAX-WS/ directory.
| Build Task | Files |
| Generate JAX-WS client stubs and compile samples. |
build.bat |
| System property specification. | sample.properties |
| Run a sample. | run.bat run.sh |
Converting Shell Scripts for Linux
The shell script (run.sh) has DOS-style line endings.
These do not work when running these scripts on Linux. Use the Linux command
dos2unix to convert this file before you use it.
To run these scripts, set the Execute permission on the files:
chmod a+x *.sh
Building Sample Programs
The build script (build.bat) generates Storage Policy API Java stubs from
the Storage Policy API WSDL, compiles the generated stubs, and compiles the sample programs.
You can specify the following command line options to control stub generation and
compilation.
build -w - Compiles sample programs but does
not generate or compile stubs.
build -c - Compiles stubs and sample programs;
does not generate stubs.
WSDL File Dependency
JAX-WS requires a WSDL file for stub generation and compilation.
To manage this dependency, the build script performs the following operations:
- Uses the JDK tool
wsimport to generate the Storage Policy Web services Java stubs
from the Storage Policy API WSDL file (pbmService.wsdl).
- Specifies the
-wsdlLocation command line option to wsimport
to identify the WSDL file location.
- Copies the WSDL file and related schema files into the
pbm.jar file.
To compile Java code that imports the generated stubs and uses the pbm.jar built
by the build script, the WSDL file must be in the same location that was specified in the
-wsdlLocation command line option. To establish this location, the build
script modifies the pbmService class to reference the WSDL location inside the JAR file.
You only need to add the pbm.jar file to your class path.
Running a Sample
The samples framework is designed to execute any of the samples provided in the kit.
To run a sample, you must specify authentication parameters and server URLs.
- Username and password for authentication with the VMware SSO Server.
- URLs for the VMware SSO Server and vCenter Server.
You can specify these in the sample properties file:
.../SDK/vsphere-ws/java/JAXWS/samples.properties
You can specify the vCenter Server URL, username and password in the sample.properties
file, or you can specify them on the command line when you execute a sample program.
These properties are declared as input options, using the @Option declarations
and implementation in the following files:
/SDK/spbm/java/JAXWS/samples/com/vmware/spbm/connection/Connection.java
/SDK/spbm/java/JAXWS/samples/com/vmware/spbm/connection/SsoConnection.java
When you execute a sample, the samples framework will resolve the input values from the appropriate source.
Samples Documentation
To print help about a sample, specify --help on the command line.
You can also find information about the samples in the
JAX-WS Samples Reference Documentation.
Each package has a class summary that describes one or more samples.
|
Copyright © 2013-2016 VMware, Inc. All rights not expressly granted herein are reserved.
|
Last updated: 15 Nov 2016 | VMware Storage Policy SDK |
|