1. This document describes how to build and run the VMware sample code that uses the AXIS2 bindings for the Site Recovery Manager Appliance Management API.
   The samples have been developed to work with the AXIS2 version axis2-1.7.9, as for the JAVA use JDK 1.8.0_202. The samples are located in sub-directories contained in the
   following SDK directory:

      SDK/samples/drconfig/Axis/java/com/vmware/samples

   The following sections contain information about building and running the Site Recovery Manager Appliance Management API samples.

      Building Sample Programs
      Sample Applications

2. Building Sample Programs

   The build scripts (build.bat or build.sh) generate Site Recovery Manager Appliance Management API Java stubs from the Site Recovery Manager Appliance Management API WSDL, compile the generated stubs, and compile the sample programs.

   JAVAHOME Environment Variable:
   You must set the JAVAHOME environment variable to the base directory of a JDK 1.8.0_202.
   Example: JAVAHOME -> "C:\Program Files\Java\jdk1.8.0_202"

   AXIS2_HOME Environment Variable:
   You must set the AXIS2_HOME environment variable to the base of the AXIS2-1.7.9 directory
   Example: AXIS2_HOME -> "C:\apache\axis2-1.7.9"

   VMKEYSTORE Environment Variable (Optional, when running the samples if you are going to use your own certificates):
   You must set the VMKEYSTORE environment variable to your Java keystore location.
   Example: VMKEYSTORE -> "C:\Program Files\Java\jdk1.8.0_202\jre\lib\security\cacerts"
                          This is a default location for the Java keystore, you can import your certificates here and
                          use it, or setup your own location.

   WSDL File Dependency
   AXIS2 requires a WSDL file for stub generation and compilation. To manage this dependency, the build script performs the following operations:

      Uses the AXIS2 tool "org.apache.axis2.wsdl.WSDL2Java" to generate the client stubs from the Site Recovery Manager Appliance Management API WSDL file (drconfig-service.wsdl).
      Copies the generated .class files from drconfig folder to drconfig.jar file.
      Copies the generated .class files from vim25 to vim25.jar file
      The Samples are compiled into samples.jar, and the util files used by the samples are in apputils.jar


3. Sample Applications

   The SDK package includes generated Reference Guide for the available sample applications and helper classes, in this path:

      SDK/samples/drconfig/Axis/java/README.txt

   If the relative link above does not work, manually navigate to the sub-directory.

   Sample  |  Usage and Description
           |   Configure the Site Recovery Manager using the ConfigSpec
           |   Command line syntax:
   ConfigureSrm      |  run.bat com.vmware.samples.drconfig.ConfigureAppliance configure --drconfigaddr https://FQDN_or_IP_Address:5480/configureserver/sdk --drconfiguser admin --pscuri pscfqdn:443 --pscuser Administrator@vsphere.local

           |  Usage and Description
           |  Clear Site Recovery Manager configuration
           |  Command line syntax:
   ClearSrmConfiguration   | run.bat com.vmware.samples.drconfig.ConfigureAppliance clear --drconfigaddr https://FQDN_or_IP_Address:5480/configureserver/sdk --drconfiguser admin --pscuser Administrator@vsphere.local

            | Usage and Description
            | Read and print the current Site Recovery Manager Configuration parameters
            | Command line syntax:
   ReadCurrentConfig  | run.bat com.vmware.samples.drconfig.ConfigureAppliance get-config --drconfigaddr https://FQDN_or_IP_Address:5480/configureserver/sdk --drconfiguser admin

4. Build and Execute alternatively:
   You can create a Eclipse java project and add the .java classes from the SDK/samples/drconfig/Axis/java/com/vmware/drconfig generated folder and the .java classes from SDK/samples/drconfig/Axis/java/com/vmware/vim25 generated folder to the eclipse project as packages. Then add SDK/samples/drconfig/Axis/java/com/vmware/samples/... connection and drconfig .java classes to that project. To run the samples use JDK 1.8.0_202 to build the project, after that you need to configure the arguments for the program... Right-Click ConfigureAppliance.java -> Run As -> Run Configurations -> Java Application -> ConfigureAppliance -> Arguments:
      1. (Step 1) Program arguments enter command that you want to execute on the appliance:
         Program Arguments example:
           Example1: clear ... Example2: configure ... Example3: get-config ..., or use --help for more information
      2. (Step 2) If you are going to use your own certificate on the appliance you need to setup the Eclipse keystore, which will point to the java keystore:
         VM arguments:
            -Djavax.net.ssl.trustStore="my_java_keysrore_location" (This is the "VMKEYSTORE" environment variable that is set to your java keystore location, this is the same path as the environment variable
                                                                    Example: "C:\Program Files\Java\jdk1.8.0_202\jre\lib\security\cacerts")
            -Djavax.net.ssl.trustStorePassword="changeit" (This is the default java keystore password, use your own if you have changed it)
      3. (Step 3) You have the option to ignore the certificate, which will result in no checks whatsoever (meaning Step 2 is ignored, no need to enter anything in the VM arguments):
         Program Arguments (Adding "--ignorecerts" will ignore certificate checks):
           Example: clear ...  --ignorecerts


All samples print a usage summary if you do not specify any options or if you specify --help on the command line.
