Add support for OpenStack V3 Identity Service 67/18167/3
authorRY303T <RY303T@att.com>
Wed, 11 Oct 2017 06:16:18 +0000 (02:16 -0400)
committerRY303T <RY303T@att.com>
Wed, 11 Oct 2017 15:58:16 +0000 (11:58 -0400)
replaced ServiceCatalog with a factory to select correct version
ServiceCatalogV2 contains code previously found in ServiceCatalog
add ServiceCatalogV3 implementation of V3 connector

Issue-ID: APPC-259
Change-Id: Iba7d98cfc9e50914b8063be0b35494a9d0fea793
Signed-off-by: RY303T <RY303T@att.com>
63 files changed:
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/AppcProviderAdapterActivator.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/ProviderAdapter.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/IdentityURL.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/ProviderAdapterImpl.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/ProviderCache.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/RequestContext.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/RequestFailedException.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/ServiceCatalog.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/ServiceCatalogFactory.java [new file with mode: 0644]
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/ServiceCatalogV2.java [new file with mode: 0644]
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/ServiceCatalogV3.java [new file with mode: 0644]
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/TenantCache.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/VMURL.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/api/IProviderOperation.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/api/ProviderOperationFactory.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/common/constants/Property.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/common/enums/Operation.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/common/enums/Outcome.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/CreateSnapshot.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/EvacuateServer.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/LookupServer.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/MigrateServer.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/RebuildServer.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/RestartServer.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/RestoreStack.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/SnapshotStack.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/StartServer.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/StopServer.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/TerminateServer.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/TerminateStack.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/VmStatuschecker.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/base/ProviderOperation.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/base/ProviderServerOperation.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/base/ProviderStackOperation.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/SnapshotResource.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/StackResource.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/CreateSnapshotParams.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Data.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Environment.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Properties.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/ResourceData.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/ResourceRegistry.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Resources_.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Resources__.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Snapshot.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/SnapshotDetails.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/SnapshotRestoreResponse.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Template.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Volume.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Volume_.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestIdentityUrl.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestProviderAdapterImpl.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestProviderOperation.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestRequestContext.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestServiceCatalog.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestServiceCatalogFactory.java [new file with mode: 0644]
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestServiceCatalogV2.java [new file with mode: 0644]
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestServiceCatalogV3.java [new file with mode: 0644]
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestVMURL.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/test/ExecutorHarness.java
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/test/InterceptLogger.java
appc-common/src/main/java/org/openecomp/appc/i18n/Msg.java
appc-common/src/main/resources/org/openecomp/appc/i18n/MessageResources.properties

index 75dadae..f17584e 100644 (file)
@@ -32,7 +32,6 @@ import org.openecomp.appc.i18n.Msg;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
-
 import com.att.eelf.configuration.EELFLogger;
 import com.att.eelf.configuration.EELFManager;
 
@@ -83,12 +82,10 @@ public class AppcProviderAdapterActivator implements BundleActivator {
      * This method must complete and return to its caller in a timely manner.
      * </p>
      * 
-     * @param context
-     *            The execution context of the bundle being started.
-     * @throws java.lang.Exception
-     *             If this method throws an exception, this bundle is marked as stopped and the Framework will remove
-     *             this bundle's listeners, unregister all services registered by this bundle, and release all services
-     *             used by this bundle.
+     * @param context The execution context of the bundle being started.
+     * @throws java.lang.Exception If this method throws an exception, this bundle is marked as stopped and the
+     *         Framework will remove this bundle's listeners, unregister all services registered by this bundle, and
+     *         release all services used by this bundle.
      * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
      */
     @Override
@@ -100,14 +97,14 @@ public class AppcProviderAdapterActivator implements BundleActivator {
         logger.info(Msg.COMPONENT_INITIALIZING, appName, "IAAS adapter");
         try {
             adapter = new ProviderAdapterImpl(configuration.getProperties());
-        } catch(Exception e){
-            logger.error("Error initializing APPC IAAS ProviderAdapterImpl",e);
+        } catch (Exception e) {
+            logger.error("Error initializing APPC IAAS ProviderAdapterImpl", e);
             throw e;
         }
-         
+
         if (registration == null) {
             logger.info(Msg.REGISTERING_SERVICE, appName, adapter.getAdapterName(),
-                ProviderAdapter.class.getSimpleName());
+                    ProviderAdapter.class.getSimpleName());
             registration = context.registerService(ProviderAdapter.class, adapter, null);
         }
 
@@ -123,12 +120,10 @@ public class AppcProviderAdapterActivator implements BundleActivator {
      * This method must complete and return to its caller in a timely manner.
      * </p>
      * 
-     * @param context
-     *            The execution context of the bundle being stopped.
-     * @throws java.lang.Exception
-     *             If this method throws an exception, the bundle is still marked as stopped, and the Framework will
-     *             remove the bundle's listeners, unregister all services registered by the bundle, and release all
-     *             services used by the bundle. *
+     * @param context The execution context of the bundle being stopped.
+     * @throws java.lang.Exception If this method throws an exception, the bundle is still marked as stopped, and the
+     *         Framework will remove the bundle's listeners, unregister all services registered by the bundle, and
+     *         release all services used by the bundle. *
      * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
      */
     @Override
index 5135243..06a190c 100644 (file)
@@ -25,7 +25,6 @@
 package org.openecomp.appc.adapter.iaas;
 
 import java.util.Map;
-
 import org.openecomp.appc.exceptions.APPCException;
 import org.openecomp.appc.exceptions.UnknownProviderException;
 import com.att.cdp.zones.model.Image;
@@ -68,17 +67,17 @@ public interface ProviderAdapter extends SvcLogicJavaPlugin {
      * The fully-qualified URL of the instance to be manipulated as it is known to the provider.
      */
     static final String PROPERTY_IDENTITY_URL = "org.openecomp.appc.identity.url";
-    
+
     /**
      * The Rebuild VM flag is an optional payload parameter for the Evacuate API.
      */
     static final String PROPERTY_REBUILD_VM = "org.openecomp.appc.rebuildvm";
-    
+
     /**
      * The target host id is an optional payload parameter for the Evacuate API.
      */
     static final String PROPERTY_TARGETHOST_ID = "org.openecomp.appc.targethost.id";
-    
+
     /**
      * heat stack id to perform operation on stack
      */
@@ -89,7 +88,7 @@ public interface ProviderAdapter extends SvcLogicJavaPlugin {
     static final String PROPERTY_INPUT_SNAPSHOT_ID = "org.openecomp.appc.snapshot.id";
 
     static final String DG_OUTPUT_PARAM_NAMESPACE = "output.";
-    
+
     static final String SKIP_HYPERVISOR_CHECK = "org.openecomp.appc.skiphypervisorcheck";
 
     /**
@@ -109,16 +108,13 @@ public interface ProviderAdapter extends SvcLogicJavaPlugin {
      * </dl>
      * </p>
      *
-     * @param properties
-     *            A map of name-value pairs that supply the parameters needed by this method. The properties needed are
-     *            defined above.
-     * @param context
-     *            The service logic context of the graph being executed.
+     * @param properties A map of name-value pairs that supply the parameters needed by this method. The properties
+     *        needed are defined above.
+     * @param context The service logic context of the graph being executed.
      * @return The <code>Server</code> object that represents the VM being restarted. The returned server object can be
      *         inspected for the final state of the server once the restart has been completed. The method does not
      *         return until the restart has either completed or has failed.
-     * @throws APPCException
-     *             If the server cannot be restarted for some reason
+     * @throws APPCException If the server cannot be restarted for some reason
      */
     Server restartServer(Map<String, String> properties, SvcLogicContext context) throws APPCException;
 
@@ -139,16 +135,13 @@ public interface ProviderAdapter extends SvcLogicJavaPlugin {
      * </dl>
      * </p>
      *
-     * @param properties
-     *            A map of name-value pairs that supply the parameters needed by this method. The properties needed are
-     *            defined above.
-     * @param context
-     *            The service logic context of the graph being executed.
+     * @param properties A map of name-value pairs that supply the parameters needed by this method. The properties
+     *        needed are defined above.
+     * @param context The service logic context of the graph being executed.
      * @return The <code>Server</code> object that represents the VM being stopped. The returned server object can be
      *         inspected for the final state of the server once the stop has been completed. The method does not return
      *         until the stop has either completed or has failed.
-     * @throws APPCException
-     *             If the server cannot be stopped for some reason
+     * @throws APPCException If the server cannot be stopped for some reason
      */
     Server stopServer(Map<String, String> properties, SvcLogicContext context) throws APPCException;
 
@@ -169,16 +162,13 @@ public interface ProviderAdapter extends SvcLogicJavaPlugin {
      * </dl>
      * </p>
      *
-     * @param properties
-     *            A map of name-value pairs that supply the parameters needed by this method. The properties needed are
-     *            defined above.
-     * @param context
-     *            The service logic context of the graph being executed.
+     * @param properties A map of name-value pairs that supply the parameters needed by this method. The properties
+     *        needed are defined above.
+     * @param context The service logic context of the graph being executed.
      * @return The <code>Server</code> object that represents the VM being started. The returned server object can be
      *         inspected for the final state of the server once the start has been completed. The method does not return
      *         until the start has either completed or has failed.
-     * @throws APPCException
-     *             If the server cannot be started for some reason
+     * @throws APPCException If the server cannot be started for some reason
      */
     Server startServer(Map<String, String> properties, SvcLogicContext context) throws APPCException;
 
@@ -199,16 +189,13 @@ public interface ProviderAdapter extends SvcLogicJavaPlugin {
      * </dl>
      * </p>
      *
-     * @param properties
-     *            A map of name-value pairs that supply the parameters needed by this method. The properties needed are
-     *            defined above.
-     * @param context
-     *            The service logic context of the graph being executed.
+     * @param properties A map of name-value pairs that supply the parameters needed by this method. The properties
+     *        needed are defined above.
+     * @param context The service logic context of the graph being executed.
      * @return The <code>Server</code> object that represents the VM being rebuilt. The returned server object can be
      *         inspected for the final state of the server once the rebuild has been completed. The method does not
      *         return until the rebuild has either completed or has failed.
-     * @throws APPCException
-     *             If the server cannot be rebuilt for some reason
+     * @throws APPCException If the server cannot be rebuilt for some reason
      */
     Server rebuildServer(Map<String, String> properties, SvcLogicContext context) throws APPCException;
 
@@ -229,16 +216,13 @@ public interface ProviderAdapter extends SvcLogicJavaPlugin {
      * </dl>
      * </p>
      *
-     * @param properties
-     *            A map of name-value pairs that supply the parameters needed by this method. The properties needed are
-     *            defined above.
-     * @param context
-     *            The service logic context of the graph being executed.
+     * @param properties A map of name-value pairs that supply the parameters needed by this method. The properties
+     *        needed are defined above.
+     * @param context The service logic context of the graph being executed.
      * @return The <code>Server</code> object that represents the VM being rebuilt. The returned server object can be
      *         inspected for the final state of the server once the rebuild has been completed. The method does not
      *         return until the rebuild has either completed or has failed.
-     * @throws APPCException
-     *             If the server cannot be terminate for some reason
+     * @throws APPCException If the server cannot be terminate for some reason
      */
     Server terminateServer(Map<String, String> properties, SvcLogicContext context) throws APPCException;
 
@@ -278,32 +262,26 @@ public interface ProviderAdapter extends SvcLogicJavaPlugin {
      * </dl>
      * </p>
      *
-     * @param properties
-     *            A map of name-value pairs that supply the parameters needed by this method. The properties needed are
-     *            defined above.
-     * @param context
-     *            The service logic context of the graph being executed.
+     * @param properties A map of name-value pairs that supply the parameters needed by this method. The properties
+     *        needed are defined above.
+     * @param context The service logic context of the graph being executed.
      * @return The <code>Server</code> object that represents the VM being rebuilt. The returned server object can be
      *         inspected for the final state of the server once the rebuild has been completed. The method does not
      *         return until the rebuild has either completed or has failed.
-     * @throws APPCException
-     *             If the server cannot be found for some reason
+     * @throws APPCException If the server cannot be found for some reason
      */
     Server lookupServer(Map<String, String> properties, SvcLogicContext context) throws APPCException;
 
     /**
      * The
      *
-     * @param params
-     *            A map of name-value pairs that supply the parameters needed by this method. The properties needed are
-     *            defined above.
-     * @param ctx
-     *            The service logic context of the graph being executed.
+     * @param params A map of name-value pairs that supply the parameters needed by this method. The properties needed
+     *        are defined above.
+     * @param ctx The service logic context of the graph being executed.
      * @return The <code>Image</code> object that represents the VM being restarted. The returned server object can be
      *         inspected for the final state of the server once the restart has been completed. The method does not
      *         return until the restart has either completed or has failed.
-     * @throws APPCException
-     *             If the server cannot be restarted for some reason
+     * @throws APPCException If the server cannot be restarted for some reason
      */
     Image createSnapshot(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
 
index 327191a..038b8de 100644 (file)
@@ -75,15 +75,14 @@ public class IdentityURL {
      * This static method is used to parse the provided server URL string and return a parse results object (VMURL)
      * which represents the state of the parse.
      * 
-     * @param serverUrl
-     *            The server URL to be parsed
+     * @param serverUrl The server URL to be parsed
      * @return The VMURL parse results object, or null if the URL was not valid or null.
      */
-    public static IdentityURL parseURL(String serverUrl) {
+    public static IdentityURL parseURL(String identUrl) {
         IdentityURL obj = null;
-        if (serverUrl != null) {
-            Matcher matcher = pattern.matcher(serverUrl.trim());
-            if (matcher.matches()) {
+        if (identUrl != null) {
+            Matcher matcher = pattern.matcher(identUrl.trim()); // http://msb.onap.org:80/api/multicloud/v0/cloudowner_region/identity/v3
+            if (matcher.matches()) { // (\\p{Alnum}+)://([^/:]+)(?::([0-9]+))?(/.*)?/(v[0-9\\.]+)/?"
                 obj = new IdentityURL();
                 obj.scheme = matcher.group(1);
                 obj.host = matcher.group(2);
index 37ff3d7..95e8e27 100644 (file)
@@ -43,7 +43,6 @@ import com.att.cdp.zones.model.Stack;
 import com.att.eelf.configuration.EELFLogger;
 import com.att.eelf.configuration.EELFManager;
 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -58,6 +57,10 @@ import java.util.Properties;
  */
 @SuppressWarnings("javadoc")
 public class ProviderAdapterImpl implements ProviderAdapter {
+    /**
+     * The default domain name for authentication
+     */
+    public static final String DEFAULT_DOMAIN_NAME = "Default";
 
     /**
      * The logger to be used
@@ -79,10 +82,11 @@ public class ProviderAdapterImpl implements ProviderAdapter {
     private Map<String /* provider name */, ProviderCache> providerCache;
 
     /**
-     * The username and password to use for dynamically created connections
+     * The username, password, and domain to use for dynamically created connections
      */
     private static String DEFAULT_USER;
     private static String DEFAULT_PASS;
+    private static String DEFAULT_DOMAIN;
 
 
     /**
@@ -98,8 +102,7 @@ public class ProviderAdapterImpl implements ProviderAdapter {
      * This constructor is used primarily in the test cases to bypass initialization of the adapter for isolated,
      * disconnected testing
      *
-     * @param initialize
-     *            True if the adapter is to be initialized, can false if not
+     * @param initialize True if the adapter is to be initialized, can false if not
      */
     @SuppressWarnings("all")
     public ProviderAdapterImpl(boolean initialize) {
@@ -110,8 +113,7 @@ public class ProviderAdapterImpl implements ProviderAdapter {
     }
 
     /**
-     * @param props
-     *            not used
+     * @param props not used
      */
     public ProviderAdapterImpl(@SuppressWarnings("unused") Properties props) {
         initialize();
@@ -125,6 +127,7 @@ public class ProviderAdapterImpl implements ProviderAdapter {
         op.setProviderCache(this.providerCache);
         op.setDefaultPass(DEFAULT_PASS);
         op.setDefaultUser(DEFAULT_USER);
+        op.setDefaultDomain(DEFAULT_DOMAIN);
         return (Server) op.doOperation(params, context);
     }
 
@@ -135,6 +138,7 @@ public class ProviderAdapterImpl implements ProviderAdapter {
         op.setProviderCache(this.providerCache);
         op.setDefaultPass(DEFAULT_PASS);
         op.setDefaultUser(DEFAULT_USER);
+        op.setDefaultDomain(DEFAULT_DOMAIN);
         return (Server) op.doOperation(params, context);
     }
 
@@ -145,6 +149,7 @@ public class ProviderAdapterImpl implements ProviderAdapter {
         op.setProviderCache(this.providerCache);
         op.setDefaultPass(DEFAULT_PASS);
         op.setDefaultUser(DEFAULT_USER);
+        op.setDefaultDomain(DEFAULT_DOMAIN);
         return (Server) op.doOperation(params, context);
     }
 
@@ -155,6 +160,7 @@ public class ProviderAdapterImpl implements ProviderAdapter {
         op.setProviderCache(this.providerCache);
         op.setDefaultPass(DEFAULT_PASS);
         op.setDefaultUser(DEFAULT_USER);
+        op.setDefaultDomain(DEFAULT_DOMAIN);
         return (Server) op.doOperation(params, context);
     }
 
@@ -165,6 +171,7 @@ public class ProviderAdapterImpl implements ProviderAdapter {
         op.setProviderCache(this.providerCache);
         op.setDefaultPass(DEFAULT_PASS);
         op.setDefaultUser(DEFAULT_USER);
+        op.setDefaultDomain(DEFAULT_DOMAIN);
         return (Server) op.doOperation(params, context);
     }
 
@@ -175,6 +182,7 @@ public class ProviderAdapterImpl implements ProviderAdapter {
         op.setProviderCache(this.providerCache);
         op.setDefaultPass(DEFAULT_PASS);
         op.setDefaultUser(DEFAULT_USER);
+        op.setDefaultDomain(DEFAULT_DOMAIN);
         // pass this object's reference to EvacuateServer to allow rebuild after evacuate
         ((EvacuateServer) op).setProvideAdapterRef(this);
         return (Server) op.doOperation(params, context);
@@ -187,6 +195,7 @@ public class ProviderAdapterImpl implements ProviderAdapter {
         op.setProviderCache(this.providerCache);
         op.setDefaultPass(DEFAULT_PASS);
         op.setDefaultUser(DEFAULT_USER);
+        op.setDefaultDomain(DEFAULT_DOMAIN);
         return (Server) op.doOperation(params, context);
     }
 
@@ -197,6 +206,7 @@ public class ProviderAdapterImpl implements ProviderAdapter {
         op.setProviderCache(this.providerCache);
         op.setDefaultPass(DEFAULT_PASS);
         op.setDefaultUser(DEFAULT_USER);
+        op.setDefaultDomain(DEFAULT_DOMAIN);
         return (Server) op.doOperation(params, context);
     }
 
@@ -207,6 +217,7 @@ public class ProviderAdapterImpl implements ProviderAdapter {
         op.setProviderCache(this.providerCache);
         op.setDefaultPass(DEFAULT_PASS);
         op.setDefaultUser(DEFAULT_USER);
+        op.setDefaultDomain(DEFAULT_DOMAIN);
         return (Stack) op.doOperation(params, context);
     }
 
@@ -217,6 +228,7 @@ public class ProviderAdapterImpl implements ProviderAdapter {
         op.setProviderCache(this.providerCache);
         op.setDefaultPass(DEFAULT_PASS);
         op.setDefaultUser(DEFAULT_USER);
+        op.setDefaultDomain(DEFAULT_DOMAIN);
         return (Stack) op.doOperation(params, context);
     }
 
@@ -227,6 +239,7 @@ public class ProviderAdapterImpl implements ProviderAdapter {
         op.setProviderCache(this.providerCache);
         op.setDefaultPass(DEFAULT_PASS);
         op.setDefaultUser(DEFAULT_USER);
+        op.setDefaultDomain(DEFAULT_DOMAIN);
         return (Stack) op.doOperation(params, context);
     }
 
@@ -237,6 +250,7 @@ public class ProviderAdapterImpl implements ProviderAdapter {
         op.setProviderCache(this.providerCache);
         op.setDefaultPass(DEFAULT_PASS);
         op.setDefaultUser(DEFAULT_USER);
+        op.setDefaultDomain(DEFAULT_DOMAIN);
         return (Server) op.doOperation(params, context);
     }
 
@@ -247,6 +261,7 @@ public class ProviderAdapterImpl implements ProviderAdapter {
         op.setProviderCache(this.providerCache);
         op.setDefaultPass(DEFAULT_PASS);
         op.setDefaultUser(DEFAULT_USER);
+        op.setDefaultDomain(DEFAULT_DOMAIN);
         return (Image) op.doOperation(params, context);
     }
 
@@ -273,27 +288,15 @@ public class ProviderAdapterImpl implements ProviderAdapter {
          * property set, where the names form a hierarchical name space (dotted notation, such as one.two.three). Each
          * name in the name space can also be serialized by appending a sequence number. All nodes at the same level
          * with the same serial number are grouped together in the namespace hierarchy. This allows a hierarchical
-         * multi-valued property to be defined, which can then be used to setup the provider and tenant caches.
-         * <p>
-         * For example, the following definitions show how the namespace hierarchy is defined for two providers, with
-         * two tenants on the first provider and a single tenant for the second provider. <pre>
-         * provider1.type=OpenStackProvider
-         * provider1.name=ILAB
-         * provider1.identity=http://provider1:5000/v2.0
-         * provider1.tenant1.name=CDP-ONAP-APPC
-         * provider1.tenant1.userid=testUser
-         * provider1.tenant1.password=testPassword
-         * provider1.tenant2.name=TEST-TENANT
-         * provider1.tenant2.userid=testUser
-         * provider1.tenant2.password=testPassword
-         * provider2.type=OpenStackProvider
-         * provider2.name=PDK1
-         * provider2.identity=http://provider2:5000/v2.0
-         * provider2.tenant1.name=someName
-         * provider2.tenant1.userid=someUser
-         * provider2.tenant1.password=somePassword
-         * </pre>
-         * </p>
+         * multi-valued property to be defined, which can then be used to setup the provider and tenant caches. <p> For
+         * example, the following definitions show how the namespace hierarchy is defined for two providers, with two
+         * tenants on the first provider and a single tenant for the second provider. <pre>
+         * provider1.type=OpenStackProvider provider1.name=ILAB provider1.identity=http://provider1:5000/v2.0
+         * provider1.tenant1.name=CDP-ONAP-APPC provider1.tenant1.userid=testUser
+         * provider1.tenant1.password=testPassword provider1.tenant2.name=TEST-TENANT provider1.tenant2.userid=testUser
+         * provider1.tenant2.password=testPassword provider2.type=OpenStackProvider provider2.name=PDK1
+         * provider2.identity=http://provider2:5000/v2.0 provider2.tenant1.name=someName
+         * provider2.tenant1.userid=someUser provider2.tenant1.password=somePassword </pre> </p>
          */
         providerCache = new HashMap<>();
         Properties properties = configuration.getProperties();
@@ -312,6 +315,8 @@ public class ProviderAdapterImpl implements ProviderAdapter {
                     String tenantName = null;
                     String userId = null;
                     String password = null;
+                    // domain is not required so set a default
+                    String domain = DEFAULT_DOMAIN_NAME;
                     for (Node node2 : node.getChildren()) {
                         switch (node2.getName()) {
                             case Property.PROVIDER_TENANT_NAME:
@@ -325,10 +330,14 @@ public class ProviderAdapterImpl implements ProviderAdapter {
                                 password = node2.getValue();
                                 DEFAULT_PASS = node2.getValue();
                                 break;
+                            case Property.PROVIDER_TENANT_DOMAIN:
+                                domain = node2.getValue();
+                                DEFAULT_DOMAIN = node2.getValue();
+                                break;
                         }
                     }
-                    
-                    cache.addTenant(null, tenantName, userId, password);
+
+                    cache.addTenant(null, tenantName, userId, password, domain);
                 }
             }
 
index ffbdaf0..bbf85a7 100644 (file)
@@ -72,14 +72,13 @@ public class ProviderCache {
      * discover all of the regions supported on the provider, and load all of the service catalogs for each provider.
      */
     public void initialize() {
-        for (Map.Entry<String, TenantCache> entry: tenants.entrySet()) { 
-            entry.getValue().initialize(); 
+        for (Map.Entry<String, TenantCache> entry : tenants.entrySet()) {
+            entry.getValue().initialize();
         }
     }
 
     /**
-     * @param providerType
-     *            the value for providerType
+     * @param providerType the value for providerType
      */
     public void setProviderType(String providerType) {
         this.providerType = providerType;
@@ -93,8 +92,7 @@ public class ProviderCache {
     }
 
     /**
-     * @param identityURL
-     *            the value for identityURL
+     * @param identityURL the value for identityURL
      */
     public void setIdentityURL(String identityURL) {
         this.identityURL = identityURL;
@@ -108,8 +106,7 @@ public class ProviderCache {
     }
 
     /**
-     * @param providerName
-     *            the value for providerName
+     * @param providerName the value for providerName
      */
     public void setProviderName(String providerName) {
         this.providerName = providerName;
@@ -121,42 +118,43 @@ public class ProviderCache {
     public Map<String, TenantCache> getTenants() {
         return tenants;
     }
-    
+
     /**
      * This method is a helper to return a specific TenantCache
      * 
-        * @param tenantId
-        * @return
+     * @param tenantId
+     * @return
      */
-    public TenantCache getTenant(String tenantId){        
-        return tenants.get(tenantId);       
+    public TenantCache getTenant(String tenantId) {
+        return tenants.get(tenantId);
     }
-    
+
     // Previously there was no way to add additional tenants to the tenant cache
     /**
      * This method is used to add a tenant to the provider cache
      * 
-        * @param tenantId
-        * @param UserId
-        * @param password
-        * @return the new initialized TenantCache or null if unsuccessful
-        */
-    public TenantCache addTenant(String tenantId, String tenantName, String userId, String password){
-        if(tenantId != null || tenantName != null && userId != null && password != null){        
+     * @param tenantId
+     * @param UserId
+     * @param password
+     * @return the new initialized TenantCache or null if unsuccessful
+     */
+    public TenantCache addTenant(String tenantId, String tenantName, String userId, String password, String domain) {
+        if (tenantId != null || tenantName != null && userId != null && password != null) {
             TenantCache tenant = new TenantCache(this);
-            if(tenantId != null){
+            if (tenantId != null) {
                 tenant.setTenantId(tenantId);
             }
-            if(tenantName != null){
+            if (tenantName != null) {
                 tenant.setTenantName(tenantName);
             }
             tenant.setUserid(userId);
             tenant.setPassword(password);
-            
-            if(identityURL != null){
+            tenant.setDomain(domain);
+
+            if (identityURL != null) {
                 tenant.initialize();
             }
-            
+
             if (tenant.isInitialized()) {
                 tenants.put(tenant.getTenantId(), tenant);
                 return tenant;
index f96002f..cec0926 100644 (file)
@@ -91,8 +91,7 @@ public class RequestContext {
     /**
      * Creates the request context
      * 
-     * @param context
-     *            The service logic (SLI) context associated with the current DG
+     * @param context The service logic (SLI) context associated with the current DG
      */
     public RequestContext(SvcLogicContext context) {
         setSvcLogicContext(context);
@@ -219,8 +218,7 @@ public class RequestContext {
     /**
      * Sets the time to live to the value, expressed in seconds
      * 
-     * @param time
-     *            The time to live, in seconds
+     * @param time The time to live, in seconds
      */
     public void setTimeToLiveSeconds(int time) {
         setTimeToLiveMS(time * 1000L);
@@ -229,8 +227,7 @@ public class RequestContext {
     /**
      * Sets the time to live to the value, expressed in milliseconds
      * 
-     * @param time
-     *            The time to live, in milliseconds
+     * @param time The time to live, in milliseconds
      */
     public void setTimeToLiveMS(long time) {
         this.timeToLive = time;
@@ -244,8 +241,7 @@ public class RequestContext {
     }
 
     /**
-     * @param svcLogicContext
-     *            The service logic context to be associated with this request
+     * @param svcLogicContext The service logic context to be associated with this request
      */
     public void setSvcLogicContext(SvcLogicContext svcLogicContext) {
         this.svcLogicContext = svcLogicContext;
index 32ff302..614f4bb 100644 (file)
@@ -81,8 +81,7 @@ public class RequestFailedException extends Exception {
     }
 
     /**
-     * @param message
-     *            The error message
+     * @param message The error message
      */
     public RequestFailedException(String message) {
         super(message);
@@ -92,14 +91,10 @@ public class RequestFailedException extends Exception {
      * Construct the request failed exception with the operation being performed, reason for the failure, http status
      * code that is most appropriate, and the server we were processing.
      * 
-     * @param operation
-     *            The operation being performed
-     * @param reason
-     *            The reason that the operation was failed
-     * @param status
-     *            The http status code that is most appropriate
-     * @param server
-     *            The server that we were processing
+     * @param operation The operation being performed
+     * @param reason The reason that the operation was failed
+     * @param status The http status code that is most appropriate
+     * @param server The server that we were processing
      */
     @SuppressWarnings("nls")
     public RequestFailedException(String operation, String reason, HttpStatus status, Server server) {
@@ -118,14 +113,10 @@ public class RequestFailedException extends Exception {
      * Construct the request failed exception with the operation being performed, reason for the failure, http status
      * code that is most appropriate, and the stack we were processing.
      *
-     * @param operation
-     *            The operation being performed
-     * @param reason
-     *            The reason that the operation was failed
-     * @param status
-     *            The http status code that is most appropriate
-     * @param stack
-     *            The stack that we were processing
+     * @param operation The operation being performed
+     * @param reason The reason that the operation was failed
+     * @param status The http status code that is most appropriate
+     * @param stack The stack that we were processing
      */
     @SuppressWarnings("nls")
     public RequestFailedException(String operation, String reason, HttpStatus status, Stack stack) {
@@ -143,16 +134,11 @@ public class RequestFailedException extends Exception {
      * Construct the request failed exception with the operation being performed, reason for the failure, http status
      * code that is most appropriate, and the server we were processing.
      * 
-     * @param ex
-     *            The exception that we are wrapping
-     * @param operation
-     *            The operation being performed
-     * @param reason
-     *            The reason that the operation was failed
-     * @param status
-     *            The http status code that is most appropriate
-     * @param server
-     *            The server that we were processing
+     * @param ex The exception that we are wrapping
+     * @param operation The operation being performed
+     * @param reason The reason that the operation was failed
+     * @param status The http status code that is most appropriate
+     * @param server The server that we were processing
      */
     @SuppressWarnings("nls")
     public RequestFailedException(Throwable ex, String operation, String reason, HttpStatus status, Server server) {
@@ -167,33 +153,27 @@ public class RequestFailedException extends Exception {
     }
 
     /**
-     * @param message
-     *            The error message
-     * @param cause
-     *            A nested exception
+     * @param message The error message
+     * @param cause A nested exception
      */
     public RequestFailedException(String message, Throwable cause) {
         super(message, cause);
     }
 
     /**
-     * @param message
-     *            The error message
-     * @param cause
-     *            A nested exception
-     * @param enableSuppression
-     *            whether or not suppression is enabled or disabled
-     * @param writableStackTrace
-     *            whether or not the stack trace should be writable
+     * @param message The error message
+     * @param cause A nested exception
+     * @param enableSuppression whether or not suppression is enabled or disabled
+     * @param writableStackTrace whether or not the stack trace should be writable
      */
-    public RequestFailedException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
+    public RequestFailedException(String message, Throwable cause, boolean enableSuppression,
+            boolean writableStackTrace) {
         super(message, cause, enableSuppression, writableStackTrace);
     }
 
     /**
-     * @param cause
-     *            the cause (which is saved for later retrieval by the {@link #getCause()} method). (A null value is
-     *            permitted, and indicates that the cause is nonexistent or unknown.)
+     * @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method). (A null value is
+     *        permitted, and indicates that the cause is nonexistent or unknown.)
      */
     public RequestFailedException(Throwable cause) {
         super(cause);
@@ -235,24 +215,21 @@ public class RequestFailedException extends Exception {
     }
 
     /**
-     * @param operation
-     *            The operation being performed
+     * @param operation The operation being performed
      */
     public void setOperation(String operation) {
         this.operation = operation;
     }
 
     /**
-     * @param reason
-     *            The reason for the failure
+     * @param reason The reason for the failure
      */
     public void setReason(String reason) {
         this.reason = reason;
     }
 
     /**
-     * @param server
-     *            The server being operated upon
+     * @param server The server being operated upon
      */
     public void setServer(Server server) {
         this.server = server;
@@ -262,16 +239,14 @@ public class RequestFailedException extends Exception {
     }
 
     /**
-     * @param serverId
-     *            The id of the server being operated upon
+     * @param serverId The id of the server being operated upon
      */
     public void setServerId(String serverId) {
         this.serverId = serverId;
     }
 
     /**
-     * @param status
-     *            The status of the request
+     * @param status The status of the request
      */
     public void setStatus(HttpStatus status) {
         this.status = status;
index 702542d..917d6f4 100644 (file)
@@ -38,7 +38,6 @@ import java.util.Set;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReadWriteLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
-
 import com.att.cdp.exceptions.ContextConnectionException;
 import com.att.cdp.exceptions.ZoneException;
 import com.att.cdp.openstack.util.ExceptionMapper;
@@ -46,8 +45,9 @@ import com.att.cdp.pal.util.Time;
 import com.att.cdp.zones.ContextFactory;
 import com.att.cdp.zones.spi.AbstractService;
 import com.att.cdp.zones.spi.RequestState;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
 import com.att.cdp.zones.spi.AbstractService.State;
-
 import com.woorea.openstack.base.client.OpenStackBaseException;
 import com.woorea.openstack.base.client.OpenStackClientConnector;
 import com.woorea.openstack.base.client.OpenStackResponseException;
@@ -87,13 +87,21 @@ import com.woorea.openstack.keystone.model.authentication.UsernamePassword;
  * caching the full service catalog since there is no way to list only a portion of it.
  * </p>
  */
-public class ServiceCatalog {
+public abstract class ServiceCatalog {
+    /**
+     * The openstack connector version to use
+     */
+    public static final String CLIENT_CONNECTOR_CLASS = "com.woorea.openstack.connector.JaxRs20Connector";
 
     /**
      * The service name for the compute service endpoint
      */
     public static final String COMPUTE_SERVICE = "compute"; //$NON-NLS-1$
 
+    /**
+     * The default domain for authentication
+     */
+    public static final String DEFAULT_DOMAIN = "Default";
     /**
      * The service name for the identity service endpoint
      */
@@ -104,11 +112,21 @@ public class ServiceCatalog {
      */
     public static final String IMAGE_SERVICE = "image"; //$NON-NLS-1$
 
+    /**
+     * The service name for the metering service endpoint
+     */
+    public static final String METERING_SERVICE = "metering"; //$NON-NLS-1$
+
     /**
      * The service name for the network service endpoint
      */
     public static final String NETWORK_SERVICE = "network"; //$NON-NLS-1$
 
+    /**
+     * The service name for the persistent object service endpoint
+     */
+    public static final String OBJECT_SERVICE = "object-store"; //$NON-NLS-1$
+
     /**
      * The service name for the orchestration service endpoint
      */
@@ -120,176 +138,98 @@ public class ServiceCatalog {
     public static final String VOLUME_SERVICE = "volume"; //$NON-NLS-1$
 
     /**
-     * The service name for the persistent object service endpoint
+     * The logger to be used
      */
-    public static final String OBJECT_SERVICE = "object-store"; //$NON-NLS-1$
+    protected static final EELFLogger logger = EELFManager.getInstance().getLogger(ServiceCatalog.class);
 
     /**
-     * The service name for the metering service endpoint
+     * The password for authentication
      */
-    public static final String METERING_SERVICE = "metering"; //$NON-NLS-1$
+    protected String credential;
 
     /**
-     * The Openstack Access object that manages the authenticated token and access control
+     * The domain for authentication
      */
-    private Access access;
-
+    protected String domain;
     /**
      * The time (local) that the token expires and we need to re-authenticate
      */
-    @SuppressWarnings("unused")
-    private long expiresLocal;
+    protected long expiresLocal;
 
     /**
-     * The set of all regions that have been defined
+     * The url of the identity service
      */
-    private Set<String> regions;
+    protected String identityURL;
 
     /**
-     * The read/write lock used to protect the cache contents
+     * The user id for authentication
      */
-    private ReadWriteLock rwLock;
+    protected String principal;
 
     /**
-     * A map of endpoints for each service organized by service type
+     * The project or tenant identifier
      */
-    private Map<String /* Service Type */, List<Service.Endpoint>> serviceEndpoints;
+    protected String projectIdentifier;
 
     /**
-     * A map of service types that are published
+     * Properties for proxy information
      */
-    private Map<String /* Service Type */, Service> serviceTypes;
+    protected Properties properties;
 
     /**
-     * The tenant that we are accessing
+     * The set of all regions that have been defined
      */
-    private Tenant tenant;
+    protected Set<String> regions;
 
     /**
-     * A "token provider" that manages the authentication token that we obtain when logging in
+     * The read/write lock used to protect the cache contents
      */
-    private OpenStackSimpleTokenProvider tokenProvider;
-
-    public static final String CLIENT_CONNECTOR_CLASS = "com.woorea.openstack.connector.JaxRs20Connector";
+    protected ReadWriteLock rwLock;
 
     /**
-     * Create the ServiceCatalog cache and load it from the specified provider
+     * Create the ServiceCatalog cache
      * 
-     * @param identityURL
-     *            The identity service URL to connect to
-     * @param tenantIdentifier
-     *            The name or id of the tenant to authenticate with. If the ID is a UUID format (32-character
-     *            hexadecimal string), then the authentication is done using the tenant ID, otherwise it is done using
-     *            the name.
-     * @param principal
-     *            The user id to authenticate to the provider
-     * @param credential
-     *            The password to authenticate to the provider
-     * @param properties
-     *            Additional properties used to configure the connection, such as proxy and trusted hosts lists
+     * @param identityURL The identity service URL to connect to
+     * @param tenantIdentifier The name or id of the tenant to authenticate with. If the ID is a UUID format
+     *        (32-character hexadecimal string), then the authentication is done using the tenant ID, otherwise it is
+     *        done using the name.
+     * @param principal The user id to authenticate to the provider
+     * @param credential The password to authenticate to the provider
+     * @param properties Additional properties used to configure the connection, such as proxy and trusted hosts lists
      * @throws ZoneException
      * @throws ClassNotFoundException
      * @throws IllegalAccessException
      * @throws InstantiationException
      */
-    public ServiceCatalog(String identityURL, String tenantIdentifier, String principal, String credential,
-                          Properties properties) throws ZoneException {
+    public ServiceCatalog(String identityURL, String projectIdentifier, String principal, String credential,
+            String domain, Properties properties) {
+        this.identityURL = identityURL;
+        this.projectIdentifier = projectIdentifier;
+        this.principal = principal;
+        this.credential = credential;
+        this.domain = domain;
+        this.properties = properties;
         rwLock = new ReentrantReadWriteLock();
-        serviceTypes = new HashMap<>();
-        serviceEndpoints = new HashMap<>();
         regions = new HashSet<>();
-
-        Class<?> connectorClass;
-        OpenStackClientConnector connector;
-        try {
-            connectorClass = Class.forName(CLIENT_CONNECTOR_CLASS);
-            connector = (OpenStackClientConnector) connectorClass.newInstance();
-        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
-            e.printStackTrace();
-            return;
-        }
-        Keystone keystone = new Keystone(identityURL, connector);
-
-        String proxyHost = properties.getProperty(ContextFactory.PROPERTY_PROXY_HOST);
-        String proxyPort = properties.getProperty(ContextFactory.PROPERTY_PROXY_PORT);
-        String trustedHosts = properties.getProperty(ContextFactory.PROPERTY_TRUSTED_HOSTS, ""); //$NON-NLS-1$
-        if (proxyHost != null && proxyHost.length() > 0) {
-            keystone.getProperties().setProperty(com.woorea.openstack.common.client.Constants.PROXY_HOST, proxyHost);
-            keystone.getProperties().setProperty(com.woorea.openstack.common.client.Constants.PROXY_PORT, proxyPort);
-        }
-        if (trustedHosts != null) {
-            keystone.getProperties().setProperty(com.woorea.openstack.common.client.Constants.TRUST_HOST_LIST,
-                trustedHosts);
-        }
-
-        Authentication authentication = new UsernamePassword(principal, credential);
-        TokensResource tokens = keystone.tokens();
-        TokensResource.Authenticate authenticate = tokens.authenticate(authentication);
-        if (tenantIdentifier.length() == 32 && tenantIdentifier.matches("[0-9a-fA-F]+")) { //$NON-NLS-1$
-            authenticate = authenticate.withTenantId(tenantIdentifier);
-        } else {
-            authenticate = authenticate.withTenantName(tenantIdentifier);
-        }
-
-        /*
-         * We have to set up the TrackRequest TLS collection for the ExceptionMapper
-         */
-        trackRequest();
-        RequestState.put(RequestState.PROVIDER, "OpenStackProvider");
-        RequestState.put(RequestState.TENANT, tenantIdentifier);
-        RequestState.put(RequestState.PRINCIPAL, principal);
-
-        try {
-            access = authenticate.execute();
-            expiresLocal = getLocalExpiration(access);
-            tenant = access.getToken().getTenant();
-            tokenProvider = new OpenStackSimpleTokenProvider(access.getToken().getId());
-            keystone.setTokenProvider(tokenProvider);
-            parseServiceCatalog(access.getServiceCatalog());
-        } catch (OpenStackBaseException e) {
-            ExceptionMapper.mapException(e);
-        } catch (Exception ex) {
-            throw new ContextConnectionException(ex.getMessage());
-        }
     }
 
     /**
      * Returns the list of service endpoints for the published service type
      * 
-     * @param serviceType
-     *            The service type to obtain the endpoints for
+     * @param serviceType The service type to obtain the endpoints for
      * @return The list of endpoints for the service type, or null if none exist
      */
-    public List<Service.Endpoint> getEndpoints(String serviceType) {
-        Lock readLock = rwLock.readLock();
-        readLock.lock();
-        try {
-            return serviceEndpoints.get(serviceType);
-        } finally {
-            readLock.unlock();
-        }
-    }
+    public abstract List<?> getEndpoints(String serviceType);
 
     /**
-     * Computes the local time when the access token will expire, after which we will need to re-login to access the
-     * provider.
-     * 
-     * @param accessKey
-     *            The access key used to access the provider
-     * @return The local time the key expires
+     * @return The project or tenant id
      */
-    private static long getLocalExpiration(Access accessKey) {
-        Date now = Time.getCurrentUTCDate();
-        if (accessKey != null && accessKey.getToken() != null) {
-            Calendar issued = accessKey.getToken().getIssued_at();
-            Calendar expires = accessKey.getToken().getExpires();
-            if (issued != null && expires != null) {
-                long tokenLife = expires.getTimeInMillis() - issued.getTimeInMillis();
-                return now.getTime() + tokenLife;
-            }
-        }
-        return now.getTime();
-    }
+    public abstract String getProjectId();
+
+    /**
+     * @return The project or tenant name
+     */
+    public abstract String getProjectName();
 
     /**
      * @return The set of all regions that are defined
@@ -307,98 +247,31 @@ public class ServiceCatalog {
     /**
      * @return A list of service types that are published
      */
-    public List<String> getServiceTypes() {
-        Lock readLock = rwLock.readLock();
-        readLock.lock();
-        try {
-            ArrayList<String> result = new ArrayList<>();
-            result.addAll(serviceTypes.keySet());
-            return result;
-        } finally {
-            readLock.unlock();
-        }
-    }
+    public abstract List<String> getServiceTypes();
 
     /**
-     * @return The tenant id
+     * This method accepts a fully qualified compute node URL and uses that to determine which region of the provider
+     * hosts that compute node.
+     *
+     * @param url The parsed URL of the compute node
+     * @return The region name, or null if no region of this tenant hosts that compute node.
      */
-    public String getTenantId() {
-        Lock readLock = rwLock.readLock();
-        readLock.lock();
-        try {
-            return tenant.getId();
-        } finally {
-            readLock.unlock();
-        }
-    }
-
-    /**
-     * @return The tenant name
-     */
-    public String getTenantName() {
-        Lock readLock = rwLock.readLock();
-        readLock.lock();
-        try {
-            return tenant.getName();
-        } finally {
-            readLock.unlock();
-        }
-    }
+    public abstract String getVMRegion(VMURL url);
 
     /**
      * Returns an indication if the specified service type is published by this provider
      * 
-     * @param serviceType
-     *            The service type to check for
+     * @param serviceType The service type to check for
      * @return True if a service of that type is published
      */
-    public boolean isServicePublished(String serviceType) {
-        Lock readLock = rwLock.readLock();
-        readLock.lock();
-        try {
-            return serviceTypes.containsKey(serviceType);
-        } finally {
-            readLock.unlock();
-        }
-    }
+    public abstract boolean isServicePublished(String serviceType);
 
     /**
-     * Parses the service catalog and caches the results
+     * Load the Service Catalog from the specified provider
      * 
-     * @param services
-     *            The list of services published by this provider
+     * @throws ZoneException
      */
-    private void parseServiceCatalog(List<Service> services) {
-        Lock lock = rwLock.writeLock();
-        lock.lock();
-        try {
-            serviceTypes.clear();
-            serviceEndpoints.clear();
-            regions.clear();
-
-            for (Service service : services) {
-                String type = service.getType();
-                serviceTypes.put(type, service);
-
-                List<Service.Endpoint> endpoints = service.getEndpoints();
-                for (Service.Endpoint endpoint : endpoints) {
-                    List<Service.Endpoint> endpointList = serviceEndpoints.get(type);
-                    if (endpointList == null) {
-                        endpointList = new ArrayList<>();
-                        serviceEndpoints.put(type, endpointList);
-                    }
-                    endpointList.add(endpoint);
-
-                    String region = endpoint.getRegion();
-                    if (!regions.contains(region)) {
-                        regions.add(region);
-                    }
-                }
-            }
-        } finally {
-            lock.unlock();
-        }
-    }
+    public abstract void init() throws ZoneException;
 
     /**
      * This method is used to provide a diagnostic listing of the service catalog
@@ -406,38 +279,7 @@ public class ServiceCatalog {
      * @see java.lang.Object#toString()
      */
     @Override
-    public String toString() {
-
-        StringBuilder builder = new StringBuilder();
-        Lock lock = rwLock.readLock();
-        lock.lock();
-        try {
-            builder.append(String.format("Service Catalog: tenant %s, id[%s], description[%s]\n", tenant.getName(), //$NON-NLS-1$
-                tenant.getId(), tenant.getDescription()));
-            if (regions != null && !regions.isEmpty()) {
-                builder.append(String.format("%d regions:\n", regions.size())); //$NON-NLS-1$
-                for (String region : regions) {
-                    builder.append("\t" + region + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
-                }
-            }
-            builder.append(String.format("%d services:\n", serviceEndpoints.size())); //$NON-NLS-1$
-            for (String serviceType : serviceEndpoints.keySet()) {
-                List<Endpoint> endpoints = serviceEndpoints.get(serviceType);
-                Service service = serviceTypes.get(serviceType);
-
-                builder.append(String.format("\t%s [%s] - %d endpoints\n", service.getType(), service.getName(), //$NON-NLS-1$
-                    endpoints.size()));
-                for (Endpoint endpoint : endpoints) {
-                    builder.append(String.format("\t\tRegion [%s], public URL [%s]\n", endpoint.getRegion(), //$NON-NLS-1$
-                        endpoint.getPublicURL()));
-                }
-            }
-        } finally {
-            lock.unlock();
-        }
-
-        return builder.toString();
-    }
+    public abstract String toString();
 
     /**
      * Initializes the request state for the current requested service.
@@ -451,9 +293,8 @@ public class ServiceCatalog {
      * up one more call and assumes that method is the request that we are "tracking".
      * </p>
      * 
-     * @param states
-     *            A variable argument list of additional state values that the caller wants to add to the request state
-     *            thread-local object to track the context.
+     * @param states A variable argument list of additional state values that the caller wants to add to the request
+     *        state thread-local object to track the context.
      */
     protected void trackRequest(State... states) {
         RequestState.clear();
@@ -469,7 +310,7 @@ public class ServiceCatalog {
             StackTraceElement element = null;
             for (; index < stack.length; index++) {
                 element = stack[index];
-                if ("trackRequest".equals(element.getMethodName())) {  //$NON-NLS-1$
+                if ("trackRequest".equals(element.getMethodName())) { //$NON-NLS-1$
                     break;
                 }
             }
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/ServiceCatalogFactory.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/ServiceCatalogFactory.java
new file mode 100644 (file)
index 0000000..63d4a31
--- /dev/null
@@ -0,0 +1,57 @@
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP : APPC\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Copyright (C) 2017 Amdocs\r
+ * =============================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * \r
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package org.openecomp.appc.adapter.iaas.impl;\r
+\r
+import java.util.Properties;\r
+\r
+public class ServiceCatalogFactory {\r
+\r
+    /**\r
+     * This method accepts a fully qualified identity service URL and uses that to determine which version of the\r
+     * serviceCatalog to load.\r
+     *\r
+     * @param url The parsed URL of the identity service\r
+     * @param projectIdentifier The project or tenant to be used to connect to the service\r
+     * @param principal The principal or user to be used to connect to the service\r
+     * @param ceredential The credential or password to be used to connect to the service\r
+     * @param properties Properties object for proxy information\r
+     * @return The serviceCatalog for identity service version specified in the url, null if not supported.\r
+     */\r
+    public static ServiceCatalog getServiceCatalog(String url, String projectIdentifier, String principal,\r
+            String credential, String domain, Properties properties) {\r
+        String version = IdentityURL.parseURL(url).getVersion();\r
+        String prefix = version.split("\\.")[0];\r
+\r
+        if (prefix != null) {\r
+            switch (prefix) {\r
+                case "v2":\r
+                    return new ServiceCatalogV2(url, projectIdentifier, principal, credential, properties);\r
+                case "v3":\r
+                    return new ServiceCatalogV3(url, projectIdentifier, principal, credential, domain, properties);\r
+            }\r
+        }\r
+        return null;\r
+    }\r
+}\r
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/ServiceCatalogV2.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/ServiceCatalogV2.java
new file mode 100644 (file)
index 0000000..8890355
--- /dev/null
@@ -0,0 +1,380 @@
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP : APPC\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Copyright (C) 2017 Amdocs\r
+ * =============================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * \r
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package org.openecomp.appc.adapter.iaas.impl;\r
+\r
+import com.att.cdp.exceptions.ContextConnectionException;\r
+import com.att.cdp.exceptions.ZoneException;\r
+import com.att.cdp.openstack.util.ExceptionMapper;\r
+import com.att.cdp.pal.util.Time;\r
+import com.att.cdp.zones.ContextFactory;\r
+import com.att.cdp.zones.spi.RequestState;\r
+import com.woorea.openstack.base.client.OpenStackBaseException;\r
+import com.woorea.openstack.base.client.OpenStackClientConnector;\r
+import com.woorea.openstack.base.client.OpenStackSimpleTokenProvider;\r
+import com.woorea.openstack.keystone.Keystone;\r
+import com.woorea.openstack.keystone.api.TokensResource;\r
+import com.woorea.openstack.keystone.model.Access;\r
+import com.woorea.openstack.keystone.model.Access.Service;\r
+import com.woorea.openstack.keystone.model.Access.Service.Endpoint;\r
+import com.woorea.openstack.keystone.model.Authentication;\r
+import com.woorea.openstack.keystone.model.Tenant;\r
+import com.woorea.openstack.keystone.model.authentication.UsernamePassword;\r
+import java.util.ArrayList;\r
+import java.util.Calendar;\r
+import java.util.Date;\r
+import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Properties;\r
+import java.util.Set;\r
+import java.util.concurrent.locks.Lock;\r
+import java.util.regex.Matcher;\r
+import java.util.regex.Pattern;\r
+\r
+/**\r
+ * This class is used to capture and cache the service catalog for a specific OpenStack provider.\r
+ * <p>\r
+ * This is needed because the way the servers are represented in the ECOMP product is as their fully qualified URL's.\r
+ * This is very problematic, because we cant identify their region from the URL, URL's change, and we cant identify the\r
+ * versions of the service implementations. In otherwords, the URL does not provide us enough information.\r
+ * </p>\r
+ * <p>\r
+ * The zone abstraction layer is designed to detect the versions of the services dynamically, and step up or down to\r
+ * match those reported versions. In order to do that, we need to know before hand what region we are accessing (since\r
+ * the supported versions may be different by regions). We will need to authenticate to the identity service in order to\r
+ * do this, plus we have to duplicate the code supporting proxies and trusted hosts that exists in the abstraction\r
+ * layer, but that cant be helped.\r
+ * </p>\r
+ * <p>\r
+ * What we do to circumvent this is connect to the provider using the lowest supported identity api, and read the entire\r
+ * service catalog into this object. Then, we parse the vm URL to extract the host and port and match that to the\r
+ * compute services defined in the catalog. When we find a compute service that has the same host name and port,\r
+ * whatever region that service is supporting is the region for that server.\r
+ * </p>\r
+ * <p>\r
+ * While we really only need to do this for compute nodes, there is no telling what other situations may arise where the\r
+ * full service catalog may be needed. Also, there is very little additional cost (additional RAM) associated with\r
+ * caching the full service catalog since there is no way to list only a portion of it.\r
+ * </p>\r
+ */\r
+public class ServiceCatalogV2 extends ServiceCatalog {\r
+\r
+    /**\r
+     * The Openstack Access object that manages the authenticated token and access control\r
+     */\r
+    private Access access;\r
+\r
+    /**\r
+     * A map of endpoints for each service organized by service type\r
+     */\r
+    private Map<String /* Service Type */, List<Service.Endpoint>> serviceEndpoints;\r
+\r
+    /**\r
+     * A map of service types that are published\r
+     */\r
+    private Map<String /* Service Type */, Service> serviceTypes;\r
+\r
+    /**\r
+     * The tenant that we are accessing\r
+     */\r
+    private Tenant tenant;\r
+\r
+    /**\r
+     * A "token provider" that manages the authentication token that we obtain when logging in\r
+     */\r
+    private OpenStackSimpleTokenProvider tokenProvider;\r
+\r
+    public ServiceCatalogV2(String identityURL, String tenantIdentifier, String principal, String credential,\r
+            Properties properties) {\r
+        super(identityURL, tenantIdentifier, principal, credential, null, properties);\r
+    }\r
+\r
+    @Override\r
+    public void init() throws ZoneException {\r
+        serviceTypes = new HashMap<>();\r
+        serviceEndpoints = new HashMap<>();\r
+        Class<?> connectorClass;\r
+        OpenStackClientConnector connector;\r
+        try {\r
+            connectorClass = Class.forName(CLIENT_CONNECTOR_CLASS);\r
+            connector = (OpenStackClientConnector) connectorClass.newInstance();\r
+        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {\r
+            e.printStackTrace();\r
+            return;\r
+        }\r
+        Keystone keystone = new Keystone(identityURL, connector);\r
+\r
+        String proxyHost = properties.getProperty(ContextFactory.PROPERTY_PROXY_HOST);\r
+        String proxyPort = properties.getProperty(ContextFactory.PROPERTY_PROXY_PORT);\r
+        String trustedHosts = properties.getProperty(ContextFactory.PROPERTY_TRUSTED_HOSTS, ""); //$NON-NLS-1$\r
+        if (proxyHost != null && proxyHost.length() > 0) {\r
+            keystone.getProperties().setProperty(com.woorea.openstack.common.client.Constants.PROXY_HOST, proxyHost);\r
+            keystone.getProperties().setProperty(com.woorea.openstack.common.client.Constants.PROXY_PORT, proxyPort);\r
+        }\r
+        if (trustedHosts != null) {\r
+            keystone.getProperties().setProperty(com.woorea.openstack.common.client.Constants.TRUST_HOST_LIST,\r
+                    trustedHosts);\r
+        }\r
+\r
+        Authentication authentication = new UsernamePassword(principal, credential);\r
+        TokensResource tokens = keystone.tokens();\r
+        TokensResource.Authenticate authenticate = tokens.authenticate(authentication);\r
+        if (projectIdentifier.length() == 32 && projectIdentifier.matches("[0-9a-fA-F]+")) { //$NON-NLS-1$\r
+            authenticate = authenticate.withTenantId(projectIdentifier);\r
+        } else {\r
+            authenticate = authenticate.withTenantName(projectIdentifier);\r
+        }\r
+\r
+        /*\r
+         * We have to set up the TrackRequest TLS collection for the ExceptionMapper\r
+         */\r
+        trackRequest();\r
+        RequestState.put(RequestState.PROVIDER, "OpenStackProvider");\r
+        RequestState.put(RequestState.TENANT, projectIdentifier);\r
+        RequestState.put(RequestState.PRINCIPAL, principal);\r
+\r
+        try {\r
+            access = authenticate.execute();\r
+            expiresLocal = getLocalExpiration(access);\r
+            tenant = access.getToken().getTenant();\r
+            tokenProvider = new OpenStackSimpleTokenProvider(access.getToken().getId());\r
+            keystone.setTokenProvider(tokenProvider);\r
+            parseServiceCatalog(access.getServiceCatalog());\r
+        } catch (OpenStackBaseException e) {\r
+            ExceptionMapper.mapException(e);\r
+        } catch (Exception ex) {\r
+            throw new ContextConnectionException(ex.getMessage());\r
+        }\r
+    }\r
+\r
+    /**\r
+     * {@inheritDoc}\r
+     */\r
+    @Override\r
+    public List<Service.Endpoint> getEndpoints(String serviceType) {\r
+        Lock readLock = rwLock.readLock();\r
+        readLock.lock();\r
+        try {\r
+            return serviceEndpoints.get(serviceType);\r
+        } finally {\r
+            readLock.unlock();\r
+        }\r
+    }\r
+\r
+    /**\r
+     * {@inheritDoc}\r
+     */\r
+    @Override\r
+    public String getProjectId() {\r
+        Lock readLock = rwLock.readLock();\r
+        readLock.lock();\r
+        try {\r
+            return tenant.getId();\r
+        } finally {\r
+            readLock.unlock();\r
+        }\r
+    }\r
+\r
+    /**\r
+     * {@inheritDoc}\r
+     */\r
+    @Override\r
+    public String getProjectName() {\r
+        Lock readLock = rwLock.readLock();\r
+        readLock.lock();\r
+        try {\r
+            return tenant.getName();\r
+        } finally {\r
+            readLock.unlock();\r
+        }\r
+    }\r
+\r
+    /**\r
+     * {@inheritDoc}\r
+     */\r
+    @Override\r
+    public Set<String> getRegions() {\r
+        Lock readLock = rwLock.readLock();\r
+        readLock.lock();\r
+        try {\r
+            return regions;\r
+        } finally {\r
+            readLock.unlock();\r
+        }\r
+    }\r
+\r
+    /**\r
+     * {@inheritDoc}\r
+     */\r
+    @Override\r
+    public List<String> getServiceTypes() {\r
+        Lock readLock = rwLock.readLock();\r
+        readLock.lock();\r
+        try {\r
+            ArrayList<String> result = new ArrayList<>();\r
+            result.addAll(serviceTypes.keySet());\r
+            return result;\r
+        } finally {\r
+            readLock.unlock();\r
+        }\r
+    }\r
+\r
+    /**\r
+     * {@inheritDoc}\r
+     */\r
+    @Override\r
+    public String getVMRegion(VMURL url) {\r
+        String region = null;\r
+        Pattern urlPattern = Pattern.compile("[^:]+://([^:/]+)(?::([0-9]+)).*");\r
+\r
+        if (url != null) {\r
+            for (Endpoint endpoint : getEndpoints(ServiceCatalog.COMPUTE_SERVICE)) {\r
+                String endpointUrl = endpoint.getPublicURL();\r
+                Matcher matcher = urlPattern.matcher(endpointUrl);\r
+                if (matcher.matches()) {\r
+                    if (url.getHost().equals(matcher.group(1))) {\r
+                        if (url.getPort() != null) {\r
+                            if (!url.getPort().equals(matcher.group(2))) {\r
+                                continue;\r
+                            }\r
+                        }\r
+\r
+                        region = endpoint.getRegion();\r
+                        break;\r
+                    }\r
+                }\r
+            }\r
+        }\r
+        return region;\r
+    }\r
+\r
+    /**\r
+     * {@inheritDoc}\r
+     */\r
+    @Override\r
+    public boolean isServicePublished(String serviceType) {\r
+        Lock readLock = rwLock.readLock();\r
+        readLock.lock();\r
+        try {\r
+            return serviceTypes.containsKey(serviceType);\r
+        } finally {\r
+            readLock.unlock();\r
+        }\r
+    }\r
+\r
+    /**\r
+     * {@inheritDoc}\r
+     */\r
+    @Override\r
+    public String toString() {\r
+\r
+        StringBuilder builder = new StringBuilder();\r
+        Lock lock = rwLock.readLock();\r
+        lock.lock();\r
+        try {\r
+            builder.append(String.format("Service Catalog: tenant %s, id[%s], description[%s]\n", tenant.getName(), //$NON-NLS-1$\r
+                    tenant.getId(), tenant.getDescription()));\r
+            if (regions != null && !regions.isEmpty()) {\r
+                builder.append(String.format("%d regions:\n", regions.size())); //$NON-NLS-1$\r
+                for (String region : regions) {\r
+                    builder.append("\t" + region + "\n"); //$NON-NLS-1$ //$NON-NLS-2$\r
+                }\r
+            }\r
+            builder.append(String.format("%d services:\n", serviceEndpoints.size())); //$NON-NLS-1$\r
+            for (String serviceType : serviceEndpoints.keySet()) {\r
+                List<Service.Endpoint> endpoints = serviceEndpoints.get(serviceType);\r
+                Service service = serviceTypes.get(serviceType);\r
+\r
+                builder.append(String.format("\t%s [%s] - %d endpoints\n", service.getType(), service.getName(), //$NON-NLS-1$\r
+                        endpoints.size()));\r
+                for (Service.Endpoint endpoint : endpoints) {\r
+                    builder.append(String.format("\t\tRegion [%s], public URL [%s]\n", endpoint.getRegion(), //$NON-NLS-1$\r
+                            endpoint.getPublicURL()));\r
+                }\r
+            }\r
+        } finally {\r
+            lock.unlock();\r
+        }\r
+\r
+        return builder.toString();\r
+    }\r
+\r
+    /**\r
+     * Parses the service catalog and caches the results\r
+     * \r
+     * @param services The list of services published by this provider\r
+     */\r
+    private void parseServiceCatalog(List<Service> services) {\r
+        Lock lock = rwLock.writeLock();\r
+        lock.lock();\r
+        try {\r
+            serviceTypes.clear();\r
+            serviceEndpoints.clear();\r
+            regions.clear();\r
+\r
+            for (Service service : services) {\r
+                String type = service.getType();\r
+                serviceTypes.put(type, service);\r
+\r
+                List<Service.Endpoint> endpoints = service.getEndpoints();\r
+                for (Service.Endpoint endpoint : endpoints) {\r
+                    List<Service.Endpoint> endpointList = serviceEndpoints.get(type);\r
+                    if (endpointList == null) {\r
+                        endpointList = new ArrayList<>();\r
+                        serviceEndpoints.put(type, endpointList);\r
+                    }\r
+                    endpointList.add(endpoint);\r
+\r
+                    String region = endpoint.getRegion();\r
+                    if (!regions.contains(region)) {\r
+                        regions.add(region);\r
+                    }\r
+                }\r
+            }\r
+        } finally {\r
+            lock.unlock();\r
+        }\r
+    }\r
+\r
+    /**\r
+     * Computes the local time when the access token will expire, after which we will need to re-login to access the\r
+     * provider.\r
+     * \r
+     * @param accessKey The access key used to access the provider\r
+     * @return The local time the key expires\r
+     */\r
+    private static long getLocalExpiration(Access accessKey) {\r
+        Date now = Time.getCurrentUTCDate();\r
+        if (accessKey != null && accessKey.getToken() != null) {\r
+            Calendar issued = accessKey.getToken().getIssued_at();\r
+            Calendar expires = accessKey.getToken().getExpires();\r
+            if (issued != null && expires != null) {\r
+                long tokenLife = expires.getTimeInMillis() - issued.getTimeInMillis();\r
+                return now.getTime() + tokenLife;\r
+            }\r
+        }\r
+        return now.getTime();\r
+    }\r
+}\r
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/ServiceCatalogV3.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/ServiceCatalogV3.java
new file mode 100644 (file)
index 0000000..9cd6799
--- /dev/null
@@ -0,0 +1,402 @@
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP : APPC\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Copyright (C) 2017 Amdocs\r
+ * =============================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * \r
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package org.openecomp.appc.adapter.iaas.impl;\r
+\r
+import com.att.cdp.exceptions.ContextConnectionException;\r
+import com.att.cdp.exceptions.ZoneException;\r
+import com.att.cdp.openstack.util.ExceptionMapper;\r
+import com.att.cdp.pal.util.Time;\r
+import com.att.cdp.zones.ContextFactory;\r
+import com.att.cdp.zones.spi.RequestState;\r
+import com.woorea.openstack.base.client.OpenStackBaseException;\r
+import com.woorea.openstack.base.client.OpenStackClientConnector;\r
+import com.woorea.openstack.base.client.OpenStackSimpleTokenProvider;\r
+import com.woorea.openstack.keystone.v3.Keystone;\r
+import com.woorea.openstack.keystone.v3.api.TokensResource;\r
+import com.woorea.openstack.keystone.v3.model.Authentication;\r
+import com.woorea.openstack.keystone.v3.model.Authentication.Identity;\r
+import com.woorea.openstack.keystone.v3.model.Authentication.Scope;\r
+import com.woorea.openstack.keystone.v3.model.Token;\r
+import com.woorea.openstack.keystone.v3.model.Token.Project;\r
+import com.woorea.openstack.keystone.v3.model.Token.Service;\r
+import com.woorea.openstack.keystone.v3.model.Token.Service.Endpoint;\r
+import java.util.ArrayList;\r
+import java.util.Calendar;\r
+import java.util.Date;\r
+import java.util.HashMap;\r
+import java.util.HashSet;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Properties;\r
+import java.util.Set;\r
+import java.util.concurrent.locks.Lock;\r
+import java.util.concurrent.locks.ReentrantReadWriteLock;\r
+import java.util.regex.Matcher;\r
+import java.util.regex.Pattern;\r
+\r
+/**\r
+ * This class is used to capture and cache the service catalog for a specific OpenStack provider.\r
+ * <p>\r
+ * This is needed because the way the servers are represented in the ECOMP product is as their fully qualified URL's.\r
+ * This is very problematic, because we cant identify their region from the URL, URL's change, and we cant identify the\r
+ * versions of the service implementations. In otherwords, the URL does not provide us enough information.\r
+ * </p>\r
+ * <p>\r
+ * The zone abstraction layer is designed to detect the versions of the services dynamically, and step up or down to\r
+ * match those reported versions. In order to do that, we need to know before hand what region we are accessing (since\r
+ * the supported versions may be different by regions). We will need to authenticate to the identity service in order to\r
+ * do this, plus we have to duplicate the code supporting proxies and trusted hosts that exists in the abstraction\r
+ * layer, but that cant be helped.\r
+ * </p>\r
+ * <p>\r
+ * What we do to circumvent this is connect to the provider using the lowest supported identity api, and read the entire\r
+ * service catalog into this object. Then, we parse the vm URL to extract the host and port and match that to the\r
+ * compute services defined in the catalog. When we find a compute service that has the same host name and port,\r
+ * whatever region that service is supporting is the region for that server.\r
+ * </p>\r
+ * <p>\r
+ * While we really only need to do this for compute nodes, there is no telling what other situations may arise where the\r
+ * full service catalog may be needed. Also, there is very little additional cost (additional RAM) associated with\r
+ * caching the full service catalog since there is no way to list only a portion of it.\r
+ * </p>\r
+ */\r
+public class ServiceCatalogV3 extends ServiceCatalog {\r
+\r
+    /**\r
+     * The project that we are accessing\r
+     */\r
+    private Project project;\r
+\r
+    /**\r
+     * A map of endpoints for each service organized by service type\r
+     */\r
+    private Map<String /* Service Type */, List<Service.Endpoint>> serviceEndpoints;\r
+\r
+    /**\r
+     * A map of service types that are published\r
+     */\r
+    private Map<String /* Service Type */, Service> serviceTypes;\r
+\r
+    /**\r
+     * The Openstack Access object that manages the authenticated token and access control\r
+     */\r
+    private Token token;\r
+\r
+    /**\r
+     * A "token provider" that manages the authentication token that we obtain when logging in\r
+     */\r
+    private OpenStackSimpleTokenProvider tokenProvider;\r
+\r
+    /**\r
+     * {@inheritDoc}\r
+     */\r
+    public ServiceCatalogV3(String identityURL, String projectIdentifier, String principal, String credential,\r
+            String domain, Properties properties) {\r
+        super(identityURL, projectIdentifier, principal, credential, domain, properties);\r
+    }\r
+\r
+    /**\r
+     * {@inheritDoc}\r
+     */\r
+    @Override\r
+    public void init() throws ZoneException {\r
+        rwLock = new ReentrantReadWriteLock();\r
+        serviceTypes = new HashMap<>();\r
+        serviceEndpoints = new HashMap<>();\r
+        regions = new HashSet<>();\r
+        Class<?> connectorClass;\r
+        OpenStackClientConnector connector;\r
+        try {\r
+            connectorClass = Class.forName(CLIENT_CONNECTOR_CLASS);\r
+            connector = (OpenStackClientConnector) connectorClass.newInstance();\r
+        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {\r
+            e.printStackTrace();\r
+            return;\r
+        }\r
+        Keystone keystone = new Keystone(identityURL, connector);\r
+\r
+        String proxyHost = properties.getProperty(ContextFactory.PROPERTY_PROXY_HOST);\r
+        String proxyPort = properties.getProperty(ContextFactory.PROPERTY_PROXY_PORT);\r
+        String trustedHosts = properties.getProperty(ContextFactory.PROPERTY_TRUSTED_HOSTS, ""); //$NON-NLS-1$\r
+        if (proxyHost != null && proxyHost.length() > 0) {\r
+            keystone.getProperties().setProperty(com.woorea.openstack.common.client.Constants.PROXY_HOST, proxyHost);\r
+            keystone.getProperties().setProperty(com.woorea.openstack.common.client.Constants.PROXY_PORT, proxyPort);\r
+        }\r
+        if (trustedHosts != null) {\r
+            keystone.getProperties().setProperty(com.woorea.openstack.common.client.Constants.TRUST_HOST_LIST,\r
+                    trustedHosts);\r
+        }\r
+\r
+        // create identity\r
+        Identity identity = Identity.password(domain, principal, credential);\r
+\r
+        // create scope\r
+        Scope scope = null;\r
+        if (projectIdentifier.length() == 32 && projectIdentifier.matches("[0-9a-fA-F]+")) { //$NON-NLS-1$\r
+            // authenticate = authenticate.withTenantId(projectIdentifier);\r
+            scope = Scope.project(projectIdentifier);\r
+        } else {\r
+            // authenticate = authenticate.withTenantName(projectIdentifier);\r
+            scope = Scope.project(domain, projectIdentifier);\r
+        }\r
+\r
+        Authentication authentication = new Authentication();\r
+        authentication.setIdentity(identity);\r
+        authentication.setScope(scope);\r
+\r
+        TokensResource tokens = keystone.tokens();\r
+        TokensResource.Authenticate authenticate = tokens.authenticate(authentication);\r
+\r
+        /*\r
+         * We have to set up the TrackRequest TLS collection for the ExceptionMapper\r
+         */\r
+        trackRequest();\r
+        RequestState.put(RequestState.PROVIDER, "OpenStackProvider");\r
+        RequestState.put(RequestState.TENANT, projectIdentifier);\r
+        RequestState.put(RequestState.PRINCIPAL, principal);\r
+\r
+        try {\r
+            token = authenticate.execute();\r
+            expiresLocal = getLocalExpiration(token);\r
+            project = token.getProject();\r
+            tokenProvider = new OpenStackSimpleTokenProvider(token.getId());\r
+            keystone.setTokenProvider(tokenProvider);\r
+            parseServiceCatalog(token.getCatalog());\r
+        } catch (OpenStackBaseException e) {\r
+            ExceptionMapper.mapException(e);\r
+        } catch (Exception ex) {\r
+            throw new ContextConnectionException(ex.getMessage());\r
+        }\r
+    }\r
+\r
+    /**\r
+     * {@inheritDoc}\r
+     */\r
+    @Override\r
+    public List<Service.Endpoint> getEndpoints(String serviceType) {\r
+        Lock readLock = rwLock.readLock();\r
+        readLock.lock();\r
+        try {\r
+            return serviceEndpoints.get(serviceType);\r
+        } finally {\r
+            readLock.unlock();\r
+        }\r
+    }\r
+\r
+    /**\r
+     * {@inheritDoc}\r
+     */\r
+    @Override\r
+    public String getProjectId() {\r
+        Lock readLock = rwLock.readLock();\r
+        readLock.lock();\r
+        try {\r
+            return project.getId();\r
+        } finally {\r
+            readLock.unlock();\r
+        }\r
+    }\r
+\r
+    /**\r
+     * {@inheritDoc}\r
+     */\r
+    @Override\r
+    public String getProjectName() {\r
+        Lock readLock = rwLock.readLock();\r
+        readLock.lock();\r
+        try {\r
+            return project.getName();\r
+        } finally {\r
+            readLock.unlock();\r
+        }\r
+    }\r
+\r
+    /**\r
+     * {@inheritDoc}\r
+     */\r
+    @Override\r
+    public Set<String> getRegions() {\r
+        Lock readLock = rwLock.readLock();\r
+        readLock.lock();\r
+        try {\r
+            return regions;\r
+        } finally {\r
+            readLock.unlock();\r
+        }\r
+    }\r
+\r
+    /**\r
+     * {@inheritDoc}\r
+     */\r
+    @Override\r
+    public List<String> getServiceTypes() {\r
+        Lock readLock = rwLock.readLock();\r
+        readLock.lock();\r
+        try {\r
+            ArrayList<String> result = new ArrayList<>();\r
+            result.addAll(serviceTypes.keySet());\r
+            return result;\r
+        } finally {\r
+            readLock.unlock();\r
+        }\r
+    }\r
+\r
+    /**\r
+     * {@inheritDoc}\r
+     */\r
+    @Override\r
+    public String getVMRegion(VMURL url) {\r
+        String region = null;\r
+        Pattern urlPattern = Pattern.compile("[^:]+://([^:/]+)(?::([0-9]+)).*");\r
+\r
+        if (url != null) {\r
+            for (Endpoint endpoint : getEndpoints(ServiceCatalog.COMPUTE_SERVICE)) {\r
+                String endpointUrl = endpoint.getUrl();\r
+                Matcher matcher = urlPattern.matcher(endpointUrl);\r
+                if (matcher.matches()) {\r
+                    if (url.getHost().equals(matcher.group(1))) {\r
+                        if (url.getPort() != null) {\r
+                            if (!url.getPort().equals(matcher.group(2))) {\r
+                                continue;\r
+                            }\r
+                        }\r
+\r
+                        region = endpoint.getRegion();\r
+                        break;\r
+                    }\r
+                }\r
+            }\r
+        }\r
+        return region;\r
+    }\r
+\r
+    /**\r
+     * {@inheritDoc}\r
+     */\r
+    @Override\r
+    public boolean isServicePublished(String serviceType) {\r
+        Lock readLock = rwLock.readLock();\r
+        readLock.lock();\r
+        try {\r
+            return serviceTypes.containsKey(serviceType);\r
+        } finally {\r
+            readLock.unlock();\r
+        }\r
+    }\r
+\r
+    /**\r
+     * {@inheritDoc}\r
+     */\r
+    @Override\r
+    public String toString() {\r
+\r
+        StringBuilder builder = new StringBuilder();\r
+        Lock lock = rwLock.readLock();\r
+        lock.lock();\r
+        try {\r
+            builder.append(String.format("Service Catalog: tenant %s, id[%s]\n", project.getName(), //$NON-NLS-1$\r
+                    project.getId()));\r
+            if (regions != null && !regions.isEmpty()) {\r
+                builder.append(String.format("%d regions:\n", regions.size())); //$NON-NLS-1$\r
+                for (String region : regions) {\r
+                    builder.append("\t" + region + "\n"); //$NON-NLS-1$ //$NON-NLS-2$\r
+                }\r
+            }\r
+            builder.append(String.format("%d services:\n", serviceEndpoints.size())); //$NON-NLS-1$\r
+            for (String serviceType : serviceEndpoints.keySet()) {\r
+                List<Service.Endpoint> endpoints = serviceEndpoints.get(serviceType);\r
+                Service service = serviceTypes.get(serviceType);\r
+\r
+                builder.append(String.format("\t%s - %d endpoints\n", service.getType(), //$NON-NLS-1$\r
+                        endpoints.size()));\r
+                for (Service.Endpoint endpoint : endpoints) {\r
+                    builder.append(String.format("\t\tRegion [%s], public URL [%s]\n", endpoint.getRegion(), //$NON-NLS-1$\r
+                            endpoint.getUrl()));\r
+                }\r
+            }\r
+        } finally {\r
+            lock.unlock();\r
+        }\r
+\r
+        return builder.toString();\r
+    }\r
+\r
+    /**\r
+     * Parses the service catalog and caches the results\r
+     * \r
+     * @param services The list of services published by this provider\r
+     */\r
+    private void parseServiceCatalog(List<Service> services) {\r
+        Lock lock = rwLock.writeLock();\r
+        lock.lock();\r
+        try {\r
+            serviceTypes.clear();\r
+            serviceEndpoints.clear();\r
+            regions.clear();\r
+\r
+            for (Service service : services) {\r
+                String type = service.getType();\r
+                serviceTypes.put(type, service);\r
+\r
+                List<Service.Endpoint> endpoints = service.getEndpoints();\r
+                for (Service.Endpoint endpoint : endpoints) {\r
+                    List<Service.Endpoint> endpointList = serviceEndpoints.get(type);\r
+                    if (endpointList == null) {\r
+                        endpointList = new ArrayList<>();\r
+                        serviceEndpoints.put(type, endpointList);\r
+                    }\r
+                    endpointList.add(endpoint);\r
+\r
+                    String region = endpoint.getRegion();\r
+                    if (!regions.contains(region)) {\r
+                        regions.add(region);\r
+                    }\r
+                }\r
+            }\r
+        } finally {\r
+            lock.unlock();\r
+        }\r
+    }\r
+\r
+    /**\r
+     * Computes the local time when the access token will expire, after which we will need to re-login to access the\r
+     * provider.\r
+     * \r
+     * @param accessKey The access key used to access the provider\r
+     * @return The local time the key expires\r
+     */\r
+    private static long getLocalExpiration(Token accessToken) {\r
+        Date now = Time.getCurrentUTCDate();\r
+        if (accessToken != null) {\r
+            Calendar issued = accessToken.getIssuedAt();\r
+            Calendar expires = accessToken.getExpiresAt();\r
+            if (issued != null && expires != null) {\r
+                long tokenLife = expires.getTimeInMillis() - issued.getTimeInMillis();\r
+                return now.getTime() + tokenLife;\r
+            }\r
+        }\r
+        return now.getTime();\r
+    }\r
+}\r
index db04948..ff349c7 100644 (file)
@@ -30,7 +30,6 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
-
 import org.openecomp.appc.Constants;
 import org.openecomp.appc.configuration.Configuration;
 import org.openecomp.appc.configuration.ConfigurationFactory;
@@ -47,7 +46,7 @@ import com.att.cdp.zones.Provider;
 import com.att.eelf.configuration.EELFLogger;
 import com.att.eelf.configuration.EELFManager;
 import com.woorea.openstack.connector.JaxRs20Connector;
-//import com.sun.jersey.api.client.ClientHandlerException;
+// import com.sun.jersey.api.client.ClientHandlerException;
 import com.woorea.openstack.keystone.model.Access.Service.Endpoint;
 
 /**
@@ -63,8 +62,14 @@ public class TenantCache implements Allocator<Context>, Destructor<Context> {
 
     public static final String POOL_PROVIDER_NAME = "pool.provider.name";
     public static final String POOL_TENANT_NAME = "pool.tenant.name";
-    //public static final String CLIENT_CONNECTOR_CLASS = "com.woorea.openstack.connector.JerseyConnector";
+    // public static final String CLIENT_CONNECTOR_CLASS =
+    // "com.woorea.openstack.connector.JerseyConnector";
     public static final String CLIENT_CONNECTOR_CLASS = "com.woorea.openstack.connector.JaxRs20Connector";
+    /**
+     * The domain to use to authenticate
+     */
+    private String domain;
+
     /**
      * The provider we are part of
      */
@@ -118,8 +123,7 @@ public class TenantCache implements Allocator<Context>, Destructor<Context> {
     /**
      * Construct the cache of tenants for the specified provider
      *
-     * @param provider
-     *            The provider
+     * @param provider The provider
      */
     public TenantCache(ProviderCache provider) {
         configuration = ConfigurationFactory.getConfiguration();
@@ -165,13 +169,19 @@ public class TenantCache implements Allocator<Context>, Destructor<Context> {
         String url = provider.getIdentityURL();
         String tenant = tenantName == null ? tenantId : tenantName;
         Properties properties = configuration.getProperties();
+        catalog = ServiceCatalogFactory.getServiceCatalog(url, tenant, userid, password, domain, properties);
+
+        if (catalog == null) {
+            logger.error(Msg.IAAS_UNSUPPORTED_IDENTITY_SERVICE, url);
+            return;
+        }
 
         int attempt = 1;
         while (attempt <= limit) {
             try {
-                catalog = new ServiceCatalog(url, tenant, userid, password, properties);
-                tenantId = catalog.getTenantId();
-                tenantName = catalog.getTenantName();
+                catalog.init();
+                tenantId = catalog.getProjectId();
+                tenantName = catalog.getProjectName();
 
                 for (String region : catalog.getRegions()) {
                     try {
@@ -180,13 +190,13 @@ public class TenantCache implements Allocator<Context>, Destructor<Context> {
                         pool.setProperty(ContextFactory.PROPERTY_TENANT, tenantName);
                         pool.setProperty(ContextFactory.PROPERTY_CLIENT_CONNECTOR_CLASS, CLIENT_CONNECTOR_CLASS);
                         pool.setProperty(ContextFactory.PROPERTY_RETRY_DELAY,
-                            configuration.getProperty(Constants.PROPERTY_RETRY_DELAY));
+                                configuration.getProperty(Constants.PROPERTY_RETRY_DELAY));
                         pool.setProperty(ContextFactory.PROPERTY_RETRY_LIMIT,
-                            configuration.getProperty(Constants.PROPERTY_RETRY_LIMIT));
+                                configuration.getProperty(Constants.PROPERTY_RETRY_LIMIT));
                         pool.setProperty(ContextFactory.PROPERTY_REGION, region);
                         if (properties.getProperty(ContextFactory.PROPERTY_TRUSTED_HOSTS) != null) {
                             pool.setProperty(ContextFactory.PROPERTY_TRUSTED_HOSTS,
-                                properties.getProperty(ContextFactory.PROPERTY_TRUSTED_HOSTS));
+                                    properties.getProperty(ContextFactory.PROPERTY_TRUSTED_HOSTS));
                         }
                         pool.setAllocator(this);
                         pool.setDestructor(this);
@@ -202,7 +212,8 @@ public class TenantCache implements Allocator<Context>, Destructor<Context> {
             } catch (ContextConnectionException e) {
                 attempt++;
                 if (attempt <= limit) {
-                    logger.error(Msg.CONNECTION_FAILED_RETRY, provider.getProviderName(), url, tenantName, tenantId, e.getMessage(), Integer.toString(delay), Integer.toString(attempt),
+                    logger.error(Msg.CONNECTION_FAILED_RETRY, provider.getProviderName(), url, tenantName, tenantId,
+                            e.getMessage(), Integer.toString(delay), Integer.toString(attempt),
                             Integer.toString(limit));
 
                     try {
@@ -211,7 +222,7 @@ public class TenantCache implements Allocator<Context>, Destructor<Context> {
                         // ignore
                     }
                 }
-            } catch ( ZoneException e) {
+            } catch (ZoneException e) {
                 logger.error(e.getMessage());
                 break;
             }
@@ -226,37 +237,30 @@ public class TenantCache implements Allocator<Context>, Destructor<Context> {
      * This method accepts a fully qualified compute node URL and uses that to determine which region of the provider
      * hosts that compute node.
      *
-     * @param url
-     *            The parsed URL of the compute node
+     * @param url The parsed URL of the compute node
      * @return The region name, or null if no region of this tenant hosts that compute node.
      */
     public String determineRegion(VMURL url) {
         logger.debug(String.format("Attempting to determine VM region for %s", url));
-        String region = null;
-        Pattern urlPattern = Pattern.compile("[^:]+://([^:/]+)(?::([0-9]+)).*");
-
-        if (url != null) {
-            for (Endpoint endpoint : catalog.getEndpoints(ServiceCatalog.COMPUTE_SERVICE)) {
-                String endpointUrl = endpoint.getPublicURL();
-                Matcher matcher = urlPattern.matcher(endpointUrl);
-                if (matcher.matches()) {
-                    if (url.getHost().equals(matcher.group(1))) {
-                        if (url.getPort() != null) {
-                            if (!url.getPort().equals(matcher.group(2))) {
-                                continue;
-                            }
-                        }
-
-                        region = endpoint.getRegion();
-                        break;
-                    }
-                }
-            }
-        }
+        String region = catalog.getVMRegion(url);
         logger.debug(String.format("Region for %s is %s", url, region));
         return region;
     }
 
+    /**
+     * @return the value of the domain
+     */
+    public String getDomain() {
+        return domain;
+    }
+
+    /**
+     * @param domain the value for domain
+     */
+    public void setDomain(String domain) {
+        this.domain = domain;
+    }
+
     /**
      * @return the value of provider
      */
@@ -265,8 +269,7 @@ public class TenantCache implements Allocator<Context>, Destructor<Context> {
     }
 
     /**
-     * @param provider
-     *            the value for provider
+     * @param provider the value for provider
      */
     public void setProvider(ProviderCache provider) {
         this.provider = provider;
@@ -280,8 +283,7 @@ public class TenantCache implements Allocator<Context>, Destructor<Context> {
     }
 
     /**
-     * @param password
-     *            the value for password
+     * @param password the value for password
      */
     public void setPassword(String password) {
         this.password = password;
@@ -295,8 +297,7 @@ public class TenantCache implements Allocator<Context>, Destructor<Context> {
     }
 
     /**
-     * @param tenantId
-     *            the value for tenantId
+     * @param tenantId the value for tenantId
      */
     public void setTenantId(String tenantId) {
         this.tenantId = tenantId;
@@ -310,8 +311,7 @@ public class TenantCache implements Allocator<Context>, Destructor<Context> {
     }
 
     /**
-     * @param tenantName
-     *            the value for tenantName
+     * @param tenantName the value for tenantName
      */
     public void setTenantName(String tenantName) {
         this.tenantName = tenantName;
@@ -325,8 +325,7 @@ public class TenantCache implements Allocator<Context>, Destructor<Context> {
     }
 
     /**
-     * @param userid
-     *            the value for userid
+     * @param userid the value for userid
      */
     public void setUserid(String userid) {
         this.userid = userid;
index d9c9c7b..2860b5a 100644 (file)
@@ -36,8 +36,8 @@ public class VMURL {
      * The regular expression pattern used to parse the URL. Capturing groups are used to identify and extract the
      * various component parts of the URL.
      */
-    private static Pattern pattern = Pattern
-        .compile("(\\p{Alnum}+)://([^/:]+)(?::([0-9]+))?(/.*)?/(v[0-9\\.]+)/([^/]+)/servers/([^/]+)");
+    private static Pattern pattern =
+            Pattern.compile("(\\p{Alnum}+)://([^/:]+)(?::([0-9]+))?(/.*)?/(v[0-9\\.]+)/([^/]+)/servers/([^/]+)");
 
     /**
      * The URL scheme or protocol, such as HTTP or HTTPS
@@ -87,8 +87,7 @@ public class VMURL {
      * This static method is used to parse the provided server URL string and return a parse results object (VMURL)
      * which represents the state of the parse.
      * 
-     * @param serverUrl
-     *            The server URL to be parsed
+     * @param serverUrl The server URL to be parsed
      * @return The VMURL parse results object, or null if the URL was not valid or null.
      */
     public static VMURL parseURL(String serverUrl) {
@@ -153,7 +152,7 @@ public class VMURL {
     }
 
     /**
-     * @return The version of the service 
+     * @return The version of the service
      */
     public String getVersion() {
         return version;
index 349fa19..6a14597 100644 (file)
@@ -28,7 +28,6 @@ import org.openecomp.appc.adapter.iaas.impl.ProviderCache;
 import org.openecomp.appc.exceptions.APPCException;
 import com.att.cdp.zones.model.ModelObject;
 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-
 import java.util.Map;
 
 /**
@@ -38,26 +37,37 @@ public interface IProviderOperation {
 
     /**
      * perform specific provider operation
+     * 
      * @param params
      * @param context
      * @return Object represents Stack, Server Or Image
      */
-    ModelObject doOperation(Map<String,String> params, SvcLogicContext context) throws APPCException;
+    ModelObject doOperation(Map<String, String> params, SvcLogicContext context) throws APPCException;
 
     /**
      * sets a cache of providers that are predefined.
+     * 
      * @param providerCache
      */
     void setProviderCache(Map<String /* provider name */, ProviderCache> providerCache);
 
     /**
      * should be initialized by user
+     * 
+     * @param defaultDomain
+     */
+    void setDefaultDomain(String defaultDomain);
+
+    /**
+     * should be initialized by user
+     * 
      * @param defaultUser
      */
     void setDefaultUser(String defaultUser);
 
     /**
      * should be initialized by user
+     * 
      * @param defaultPass
      */
     void setDefaultPass(String defaultPass);
index 22109a4..39ef4a8 100644 (file)
@@ -27,12 +27,12 @@ package org.openecomp.appc.adapter.iaas.provider.operation.api;
 import org.openecomp.appc.adapter.iaas.provider.operation.impl.*;
 import org.openecomp.appc.adapter.iaas.provider.operation.common.enums.Operation;
 import org.openecomp.appc.exceptions.APPCException;
-
 import java.util.HashMap;
 import java.util.Map;
 
 /**
  * Singleton factory of provider operations objects with cache
+ * 
  * @since September 26, 2016
  */
 public class ProviderOperationFactory {
@@ -115,7 +115,7 @@ public class ProviderOperationFactory {
                 default:
                     throw new APPCException("Unsupported provider operation.");
             }
-            operations.put(op,opObject);
+            operations.put(op, opObject);
         }
         return opObject;
     }
index de1cf81..9a02494 100644 (file)
@@ -32,6 +32,7 @@ public class Property {
     public static final String PROVIDER = "provider";
     public static final String PROVIDER_IDENTITY = "identity";
     public static final String PROVIDER_TENANT = "tenant";
+    public static final String PROVIDER_TENANT_DOMAIN = "Default";
     public static final String PROVIDER_TENANT_NAME = "name";
     public static final String PROVIDER_TENANT_PASSWORD = "password";
     public static final String PROVIDER_TENANT_USERID = "userid";
index 759d8e8..857c7a7 100644 (file)
@@ -29,67 +29,67 @@ package org.openecomp.appc.adapter.iaas.provider.operation.common.enums;
  */
 public enum Operation {
     EVACUATE_SERVICE {
-        public String toString(){
+        public String toString() {
             return "evacuateServer";
         }
     },
     MIGRATE_SERVICE {
-        public String toString(){
+        public String toString() {
             return "migrateServer";
         }
     },
     REBUILD_SERVICE {
-        public String toString(){
+        public String toString() {
             return "rebuildServer";
         }
     },
     RESTART_SERVICE {
-        public String toString(){
+        public String toString() {
             return "restartServer";
         }
     },
     VMSTATUSCHECK_SERVICE {
-        public String toString(){
+        public String toString() {
             return "vmStatuschecker";
         }
     },
     SNAPSHOT_SERVICE {
-        public String toString(){
+        public String toString() {
             return "createSnapshot";
         }
     },
     TERMINATE_STACK {
-        public String toString(){
+        public String toString() {
             return "terminateStack";
         }
     },
     SNAPSHOT_STACK {
-        public String toString(){
+        public String toString() {
             return "snapshotStack";
         }
     },
     START_SERVICE {
-        public String toString(){
+        public String toString() {
             return "startServer";
         }
     },
     STOP_SERVICE {
-        public String toString(){
+        public String toString() {
             return "stopServer";
         }
     },
     TERMINATE_SERVICE {
-        public String toString(){
+        public String toString() {
             return "terminateServer";
         }
     },
     LOOKUP_SERVICE {
-        public String toString(){
+        public String toString() {
             return "lookupServer";
         }
     },
-    RESTORE_STACK{
-        public String toString(){
+    RESTORE_STACK {
+        public String toString() {
             return "restoreStack";
         }
     }
index 4007b26..c62c1b2 100644 (file)
@@ -29,12 +29,12 @@ package org.openecomp.appc.adapter.iaas.provider.operation.common.enums;
  */
 public enum Outcome {
     FAILURE {
-        public String toString(){
+        public String toString() {
             return "failure";
         }
     },
     SUCCESS {
-        public String toString(){
+        public String toString() {
             return "success";
         }
     }
index e54ed86..b4c5525 100644 (file)
@@ -51,13 +51,11 @@ import org.openecomp.appc.configuration.ConfigurationFactory;
 import org.openecomp.appc.exceptions.APPCException;
 import org.openecomp.appc.i18n.Msg;
 import org.slf4j.MDC;
-
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.Map;
 import java.util.TimeZone;
-
 import static org.openecomp.appc.adapter.iaas.provider.operation.common.constants.Constants.DATE_FORMAT;
 import static org.openecomp.appc.adapter.utils.Constants.ADAPTER_NAME;
 
@@ -72,7 +70,7 @@ public class CreateSnapshot extends ProviderServerOperation {
 
         SimpleDateFormat df = new SimpleDateFormat(DATE_FORMAT);
         metricsLogger.info("Snapshot Name Generated: Snapshot of %s at %s", server, df.format(new Date()));
-        
+
         return String.format("Snapshot of %s at %s", server, df.format(new Date()));
     }
 
@@ -85,10 +83,10 @@ public class CreateSnapshot extends ProviderServerOperation {
 
         setTimeForMetricsLogger();
 
-        logger.info(String.format("Creating snapshot of server %s (%s) with name %s",
-                server.getName(), server.getId(), snapshotName));
-        metricsLogger.info(String.format("Creating snapshot of server %s (%s) with name %s",
-                server.getName(), server.getId(), snapshotName));
+        logger.info(String.format("Creating snapshot of server %s (%s) with name %s", server.getName(), server.getId(),
+                snapshotName));
+        metricsLogger.info(String.format("Creating snapshot of server %s (%s) with name %s", server.getName(),
+                server.getId(), snapshotName));
 
         // Request Snapshot
         String msg;
@@ -161,7 +159,8 @@ public class CreateSnapshot extends ProviderServerOperation {
             String appName = configuration.getProperty(Constants.PROPERTY_APPLICATION_NAME);
             String vm_url = params.get(ProviderAdapter.PROPERTY_INSTANCE_URL);
             VMURL vm = VMURL.parseURL(vm_url);
-            if (validateVM(rc, appName, vm_url, vm)) return null;
+            if (validateVM(rc, appName, vm_url, vm))
+                return null;
 
             IdentityURL ident = IdentityURL.parseURL(params.get(ProviderAdapter.PROPERTY_IDENTITY_URL));
             String identStr = (ident == null) ? null : ident.toString();
@@ -177,8 +176,8 @@ public class CreateSnapshot extends ProviderServerOperation {
                         snapshot = createSnapshot(rc, server);
                         doSuccess(rc);
                     } else {
-                        msg = EELFResourceManager.format(Msg.REBUILD_SERVER_FAILED,
-                                server.getName(), server.getId(), "Accessing Image Service Failed");
+                        msg = EELFResourceManager.format(Msg.REBUILD_SERVER_FAILED, server.getName(), server.getId(),
+                                "Accessing Image Service Failed");
                         logger.error(msg);
                         metricsLogger.error(msg);
                         doFailure(rc, HttpStatus.FORBIDDEN_403, msg);
@@ -212,7 +211,7 @@ public class CreateSnapshot extends ProviderServerOperation {
         setTimeForMetricsLogger();
 
         metricsLogger.info("Executing Provider Operation: Create Snapshot");
-        
+
         return createSnapshot(params, context);
     }
 
index f2466d3..45473e3 100644 (file)
@@ -55,7 +55,6 @@ import com.att.eelf.i18n.EELFResourceManager;
 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
 import org.glassfish.grizzly.http.util.HttpStatus;
 import org.slf4j.MDC;
-
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Arrays;
@@ -63,7 +62,6 @@ import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.TimeZone;
-
 import static org.openecomp.appc.adapter.utils.Constants.ADAPTER_NAME;
 
 public class EvacuateServer extends ProviderServerOperation {
@@ -92,7 +90,8 @@ public class EvacuateServer extends ProviderServerOperation {
                         Server.Status.SUSPENDED, Server.Status.PAUSED);
             }
         } catch (RequestFailedException e) {
-            // evacuate is a special case. If the server is still in a Pending state, we want to continue with evacuate
+            // evacuate is a special case. If the server is still in a Pending state, we want to
+            // continue with evacuate
             logger.info("Evacuate server - ignore RequestFailedException from waitForStateChange() ...");
         }
 
@@ -105,8 +104,8 @@ public class EvacuateServer extends ProviderServerOperation {
                     logger.debug("Calling CDP moveServer - server id = " + server.getId());
                     service.moveServer(server.getId(), target_host);
                     // Wait for completion, expecting the server to go to a non pending state
-                    waitForStateChange(rc, server, Server.Status.READY, Server.Status.RUNNING,
-                            Server.Status.ERROR, Server.Status.SUSPENDED, Server.Status.PAUSED);
+                    waitForStateChange(rc, server, Server.Status.READY, Server.Status.RUNNING, Server.Status.ERROR,
+                            Server.Status.SUSPENDED, Server.Status.PAUSED);
                     break;
                 } catch (ContextConnectionException e) {
                     msg = EELFResourceManager.format(Msg.CONNECTION_FAILED_RETRY, provider.getName(), service.getURL(),
@@ -120,8 +119,8 @@ public class EvacuateServer extends ProviderServerOperation {
             }
 
         } catch (ZoneException e) {
-            msg = EELFResourceManager.format(Msg.EVACUATE_SERVER_FAILED,
-                    server.getName(), server.getId(), e.getMessage());
+            msg = EELFResourceManager.format(Msg.EVACUATE_SERVER_FAILED, server.getName(), server.getId(),
+                    e.getMessage());
             logger.error(msg);
             metricsLogger.error(msg);
             throw new RequestFailedException("Evacute Server", msg, HttpStatus.BAD_GATEWAY_502, server);
@@ -138,7 +137,8 @@ public class EvacuateServer extends ProviderServerOperation {
 
 
     /**
-     * @see org.openecomp.appc.adapter.iaas.ProviderAdapter#evacuateServer(java.util.Map, org.openecomp.sdnc.sli.SvcLogicContext)
+     * @see org.openecomp.appc.adapter.iaas.ProviderAdapter#evacuateServer(java.util.Map,
+     *      org.openecomp.sdnc.sli.SvcLogicContext)
      */
     private Server evacuateServer(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
         Server server = null;
@@ -156,7 +156,8 @@ public class EvacuateServer extends ProviderServerOperation {
             String appName = configuration.getProperty(Constants.PROPERTY_APPLICATION_NAME);
             String vm_url = params.get(ProviderAdapter.PROPERTY_INSTANCE_URL);
             VMURL vm = VMURL.parseURL(vm_url);
-            if (validateVM(rc, appName, vm_url, vm)) return null;
+            if (validateVM(rc, appName, vm_url, vm))
+                return null;
 
             IdentityURL ident = IdentityURL.parseURL(params.get(ProviderAdapter.PROPERTY_IDENTITY_URL));
             String identStr = (ident == null) ? null : ident.toString();
@@ -175,8 +176,8 @@ public class EvacuateServer extends ProviderServerOperation {
 
                     // check target host status
                     if (isComputeNodeDown(context, targethost_id)) {
-                        msg = EELFResourceManager.format(Msg.EVACUATE_SERVER_FAILED, server.getName(),
-                                server.getId(), "Target host " + targethost_id + " status is not UP/ENABLED");
+                        msg = EELFResourceManager.format(Msg.EVACUATE_SERVER_FAILED, server.getName(), server.getId(),
+                                "Target host " + targethost_id + " status is not UP/ENABLED");
                         logger.error(msg);
                         metricsLogger.error(msg);
                         throw new RequestFailedException("Evacuate Server", msg, HttpStatus.BAD_REQUEST_400, server);
@@ -192,34 +193,35 @@ public class EvacuateServer extends ProviderServerOperation {
                     logger.debug("Hostname before evacuate: " + hypervisor + ", After evacuate: "
                             + hypervisor_after_evacuate);
 
-                    // check hypervisor host name after evacuate. If it is unchanged, the evacuate failed.
+                    // check hypervisor host name after evacuate. If it is unchanged, the evacuate
+                    // failed.
                     if ((hypervisor != null) && (hypervisor.equals(hypervisor_after_evacuate))) {
-                        msg = EELFResourceManager.format(Msg.EVACUATE_SERVER_FAILED, server.getName(),
-                                server.getId(), "Hypervisor host " + hypervisor
+                        msg = EELFResourceManager.format(Msg.EVACUATE_SERVER_FAILED, server.getName(), server.getId(),
+                                "Hypervisor host " + hypervisor
                                         + " after evacuate is the same as before evacuate. Provider (ex. Openstack) recovery actions may be needed.");
                         logger.error(msg);
                         metricsLogger.error(msg);
-                        throw new RequestFailedException("Evacuate Server", msg,
-                                HttpStatus.INTERNAL_SERVER_ERROR_500, server);
+                        throw new RequestFailedException("Evacuate Server", msg, HttpStatus.INTERNAL_SERVER_ERROR_500,
+                                server);
 
                     }
 
                     // check VM status after evacuate
                     if (server.getStatus() == Server.Status.ERROR) {
-                        msg = EELFResourceManager.format(Msg.EVACUATE_SERVER_FAILED, server.getName(),
-                                server.getId(),
+                        msg = EELFResourceManager.format(Msg.EVACUATE_SERVER_FAILED, server.getName(), server.getId(),
                                 "VM is in ERROR state after evacuate. Provider (ex. Openstack) recovery actions may be needed.");
                         logger.error(msg);
                         metricsLogger.error(msg);
-                        throw new RequestFailedException("Evacuate Server", msg,
-                                HttpStatus.INTERNAL_SERVER_ERROR_500, server);
+                        throw new RequestFailedException("Evacuate Server", msg, HttpStatus.INTERNAL_SERVER_ERROR_500,
+                                server);
                     }
 
                     context.close();
                     doSuccess(rc);
                     ctx.setAttribute("EVACUATE_STATUS", "SUCCESS");
 
-                    // If a snapshot exists, do a rebuild to apply the latest snapshot to the evacuated server.
+                    // If a snapshot exists, do a rebuild to apply the latest snapshot to the
+                    // evacuated server.
                     // This is the default behavior unless the optional parameter is set to FALSE.
                     if ((rebuild_vm == null) || !(rebuild_vm.equalsIgnoreCase("false"))) {
                         List<Image> snapshots = server.getSnapshots();
@@ -238,14 +240,15 @@ public class EvacuateServer extends ProviderServerOperation {
                                     if (error_code != HttpStatus.OK_200.getStatusCode()) {
                                         logger.debug("Rebuild after evacuate failed - error code=" + error_code
                                                 + ", message=" + ctx.getAttribute(
-                                                org.openecomp.appc.Constants.ATTRIBUTE_ERROR_MESSAGE));
+                                                        org.openecomp.appc.Constants.ATTRIBUTE_ERROR_MESSAGE));
                                         msg = EELFResourceManager.format(Msg.EVACUATE_SERVER_REBUILD_FAILED,
                                                 server.getName(), hypervisor, hypervisor_after_evacuate,
                                                 ctx.getAttribute(org.openecomp.appc.Constants.ATTRIBUTE_ERROR_MESSAGE));
                                         logger.error(msg);
                                         metricsLogger.error(msg);
                                         ctx.setAttribute("EVACUATE_STATUS", "ERROR");
-                                        // update error message while keeping the error code the same as before
+                                        // update error message while keeping the error code the
+                                        // same as before
                                         doFailure(rc, HttpStatus.getHttpStatus(error_code), msg);
                                     }
                                 } catch (NumberFormatException e) {
@@ -265,8 +268,8 @@ public class EvacuateServer extends ProviderServerOperation {
                 doFailure(rc, e.getStatus(), e.getMessage());
             } catch (Exception e1) {
                 msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, e1, e1.getClass().getSimpleName(),
-                        Operation.EVACUATE_SERVICE.toString(),
-                        vm_url, context == null ? "Unknown" : context.getTenantName());
+                        Operation.EVACUATE_SERVICE.toString(), vm_url,
+                        context == null ? "Unknown" : context.getTenantName());
                 logger.error(msg, e1);
                 metricsLogger.error(msg, e1);
                 doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg);
@@ -284,14 +287,13 @@ public class EvacuateServer extends ProviderServerOperation {
     /*
      * Check if a Compute node is down.
      * 
-     * This method attempts to find a given host in the list of hypervisors for a given
-     * context. The only case where a node is considered down is if a matching hypervisor
-     * is found and it's state and status are not UP/ENABLED.
+     * This method attempts to find a given host in the list of hypervisors for a given context. The only case where a
+     * node is considered down is if a matching hypervisor is found and it's state and status are not UP/ENABLED.
+     * 
+     * @param context The current context
+     * 
+     * @param host The host name (short or fully qualified) of a compute node
      * 
-     * @param context
-     *             The current context
-     * @param host
-     *             The host name (short or fully qualified) of a compute node
      * @return true if the node is determined as down, false for all other cases
      */
     private boolean isComputeNodeDown(Context context, String host) throws ZoneException {
@@ -299,7 +301,7 @@ public class EvacuateServer extends ProviderServerOperation {
         boolean node_down = false;
 
         // Check host status. A node is considered down only if a matching target host is
-        //  found and it's state/status is not UP/ENABLED.
+        // found and it's state/status is not UP/ENABLED.
         if ((host != null) && !(host.isEmpty())) {
             List<Hypervisor> hypervisors = service.getHypervisors();
             logger.debug("List of Hypervisors retrieved: " + Arrays.toString(hypervisors.toArray()));
@@ -308,8 +310,8 @@ public class EvacuateServer extends ProviderServerOperation {
                     // host matches one of the hypervisors
                     State hstate = h.getState();
                     Status hstatus = h.getStatus();
-                    logger.debug("Host matching hypervisor: " + h.getHostName() + ", State/Status: "
-                            + hstate.toString() + "/" + hstatus.toString());
+                    logger.debug("Host matching hypervisor: " + h.getHostName() + ", State/Status: " + hstate.toString()
+                            + "/" + hstatus.toString());
                     if (hstate != State.UP || hstatus != Status.ENABLED) {
                         node_down = true;
                     }
index 0152fc6..4c5c616 100644 (file)
@@ -44,10 +44,8 @@ import com.att.eelf.configuration.EELFManager;
 import com.att.eelf.i18n.EELFResourceManager;
 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
 import org.glassfish.grizzly.http.util.HttpStatus;
-
 import java.io.IOException;
 import java.util.Map;
-
 import static org.openecomp.appc.adapter.utils.Constants.ADAPTER_NAME;
 
 public class LookupServer extends ProviderServerOperation {
@@ -59,11 +57,11 @@ public class LookupServer extends ProviderServerOperation {
     public Server lookupServer(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
         Server server = null;
         RequestContext rc = new RequestContext(ctx);
-        rc.isAlive(); //should we test the return and fail if false?
+        rc.isAlive(); // should we test the return and fail if false?
 
         String vm_url = null;
         try {
-            //process vm_url
+            // process vm_url
             validateParametersExist(params, ProviderAdapter.PROPERTY_INSTANCE_URL,
                     ProviderAdapter.PROPERTY_PROVIDER_NAME);
 
@@ -74,33 +72,31 @@ public class LookupServer extends ProviderServerOperation {
                 return null;
             }
 
-            //use try with resource to ensure context is closed (returned to pool)
+            // use try with resource to ensure context is closed (returned to pool)
             try (Context context = resolveContext(rc, params, appName, vm_url)) {
-                //resloveContext & getContext call doFailure and log errors before returning null
-                if (context != null){
+                // resloveContext & getContext call doFailure and log errors before returning null
+                if (context != null) {
                     rc.reset();
                     server = lookupServer(rc, context, vm.getServerId());
                     logger.debug(Msg.SERVER_FOUND, vm_url, context.getTenantName(), server.getStatus().toString());
                     ctx.setAttribute("serverFound", "success");
-                    String msg =
-                            EELFResourceManager.format(Msg.SUCCESS_EVENT_MESSAGE, "LookupServer", vm_url);
+                    String msg = EELFResourceManager.format(Msg.SUCCESS_EVENT_MESSAGE, "LookupServer", vm_url);
                     ctx.setAttribute(org.openecomp.appc.Constants.ATTRIBUTE_SUCCESS_MESSAGE, msg);
                     doSuccess(rc);
                 }
             } catch (ZoneException e) {
-                //server not found
+                // server not found
                 String msg = EELFResourceManager.format(Msg.SERVER_NOT_FOUND, e, vm_url);
                 logger.error(msg);
                 doFailure(rc, HttpStatus.NOT_FOUND_404, msg);
                 ctx.setAttribute("serverFound", "failure");
-            }  catch (IOException e) {
-                //exception closing context
+            } catch (IOException e) {
+                // exception closing context
                 String msg = EELFResourceManager.format(Msg.CLOSE_CONTEXT_FAILED, e, vm_url);
                 logger.error(msg);
             } catch (Exception e1) {
-                String msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION,
-                        e1, e1.getClass().getSimpleName(),
-                        Operation.LOOKUP_SERVICE.toString(), vm_url,  "Unknown" );
+                String msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, e1,
+                        e1.getClass().getSimpleName(), Operation.LOOKUP_SERVICE.toString(), vm_url, "Unknown");
                 logger.error(msg, e1);
                 doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg);
             }
index e45bdfa..2477c9a 100644 (file)
@@ -49,7 +49,6 @@ import org.openecomp.appc.exceptions.APPCException;
 import org.openecomp.appc.i18n.Msg;
 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
 import org.slf4j.MDC;
-
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Arrays;
@@ -57,7 +56,6 @@ import java.util.Collection;
 import java.util.Date;
 import java.util.Map;
 import java.util.TimeZone;
-
 import static org.openecomp.appc.adapter.iaas.provider.operation.common.enums.Operation.MIGRATE_SERVICE;
 import static org.openecomp.appc.adapter.utils.Constants.ADAPTER_NAME;
 
@@ -104,8 +102,8 @@ public class MigrateServer extends ProviderServerOperation {
         setTimeForMetricsLogger();
 
         // Is the skip Hypervisor check attribute populated?
-        String skipHypervisorCheck = null;
-        if (svcCtx != null) {
+        String skipHypervisorCheck = configuration.getProperty("org.openecomp.appc.iaas.skiphypervisorchek");
+        if (skipHypervisorCheck == null && svcCtx != null) {
             skipHypervisorCheck = svcCtx.getAttribute(ProviderAdapter.SKIP_HYPERVISOR_CHECK);
         }
 
@@ -154,7 +152,8 @@ public class MigrateServer extends ProviderServerOperation {
     }
 
     /**
-     * @see org.openecomp.appc.adapter.iaas.ProviderAdapter#migrateServer(java.util.Map, org.openecomp.sdnc.sli.SvcLogicContext)
+     * @see org.openecomp.appc.adapter.iaas.ProviderAdapter#migrateServer(java.util.Map,
+     *      org.openecomp.sdnc.sli.SvcLogicContext)
      */
     private Server migrateServer(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
         Server server = null;
@@ -171,7 +170,8 @@ public class MigrateServer extends ProviderServerOperation {
 
             String appName = configuration.getProperty(Constants.PROPERTY_APPLICATION_NAME);
             VMURL vm = VMURL.parseURL(vm_url);
-            if (validateVM(rc, appName, vm_url, vm)) return null;
+            if (validateVM(rc, appName, vm_url, vm))
+                return null;
 
             IdentityURL ident = IdentityURL.parseURL(params.get(ProviderAdapter.PROPERTY_IDENTITY_URL));
             String identStr = (ident == null) ? null : ident.toString();
index 0f089b1..ad7d15b 100644 (file)
@@ -54,14 +54,12 @@ import org.openecomp.appc.exceptions.APPCException;
 import org.openecomp.appc.i18n.Msg;
 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
 import org.slf4j.MDC;
-
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.TimeZone;
-
 import static org.openecomp.appc.adapter.iaas.provider.operation.common.enums.Operation.STOP_SERVICE;
 import static org.openecomp.appc.adapter.utils.Constants.ADAPTER_NAME;
 
@@ -75,10 +73,9 @@ public class RebuildServer extends ProviderServerOperation {
      * Rebuild the indicated server with the indicated image. This method assumes the server has been determined to be
      * in the correct state to do the rebuild.
      *
-     * @param rc     The request context that manages the state and recovery of the request for the life of
-     *               its processing.
+     * @param rc The request context that manages the state and recovery of the request for the life of its processing.
      * @param server the server to be rebuilt
-     * @param image  The image to be used (or snapshot)
+     * @param image The image to be used (or snapshot)
      * @throws RequestFailedException if the server does not change state in the allotted time
      */
     @SuppressWarnings("nls")
@@ -88,8 +85,8 @@ public class RebuildServer extends ProviderServerOperation {
         String msg;
         Context context = server.getContext();
         Provider provider = context.getProvider();
-        ComputeService service = context.getComputeService();  
-        
+        ComputeService service = context.getComputeService();
+
         /*
          * Set Time for Metrics Logger
          */
@@ -121,8 +118,8 @@ public class RebuildServer extends ProviderServerOperation {
                 metricsLogger.trace("Sleep threw interrupted exception, should never occur");
             }
         } catch (ZoneException e) {
-            msg = EELFResourceManager.format(Msg.REBUILD_SERVER_FAILED,
-                    server.getName(), server.getId(), e.getMessage());
+            msg = EELFResourceManager.format(Msg.REBUILD_SERVER_FAILED, server.getName(), server.getId(),
+                    e.getMessage());
             logger.error(msg);
             metricsLogger.error(msg);
             throw new RequestFailedException("Rebuild Server", msg, HttpStatus.BAD_GATEWAY_502, server);
@@ -151,10 +148,9 @@ public class RebuildServer extends ProviderServerOperation {
      * a VM from a bootable volume, where the bootable volume itself is not rebuilt, serves no purpose.
      * </p>
      *
-     * @param rc     The request context that manages the state and recovery of the request for the life of
-     *               its processing.
+     * @param rc The request context that manages the state and recovery of the request for the life of its processing.
      * @param server The server to be rebuilt
-     * @throws ZoneException          When error occurs
+     * @throws ZoneException When error occurs
      * @throws RequestFailedException When server status is error
      */
     @SuppressWarnings("nls")
@@ -179,11 +175,9 @@ public class RebuildServer extends ProviderServerOperation {
         }
 
         /*
-         * Pending is a bit of a special case. If we find the server is in a
-         * pending state, then the provider is in the process of changing state
-         * of the server. So, lets try to wait a little bit and see if the state
-         * settles down to one we can deal with. If not, then we have to fail
-         * the request.
+         * Pending is a bit of a special case. If we find the server is in a pending state, then the provider is in the
+         * process of changing state of the server. So, lets try to wait a little bit and see if the state settles down
+         * to one we can deal with. If not, then we have to fail the request.
          */
         Context context = server.getContext();
         Provider provider = context.getProvider();
@@ -195,8 +189,8 @@ public class RebuildServer extends ProviderServerOperation {
         }
 
         // Is the skip Hypervisor check attribute populated?
-        String skipHypervisorCheck = null;
-        if (ctx != null) {
+        String skipHypervisorCheck = configuration.getProperty("org.openecomp.appc.iaas.skiphypervisorchek");
+        if (skipHypervisorCheck == null && ctx != null) {
             skipHypervisorCheck = ctx.getAttribute(ProviderAdapter.SKIP_HYPERVISOR_CHECK);
         }
 
@@ -208,10 +202,8 @@ public class RebuildServer extends ProviderServerOperation {
         }
 
         /*
-         * Get the image to use. This is determined by the presence or
-         * absence of snapshot images. If any snapshots exist, then the
-         * latest snapshot is used, otherwise the image used to construct
-         * the VM is used.
+         * Get the image to use. This is determined by the presence or absence of snapshot images. If any snapshots
+         * exist, then the latest snapshot is used, otherwise the image used to construct the VM is used.
          */
         List<Image> snapshots = server.getSnapshots();
         String imageToUse;
@@ -225,16 +217,16 @@ public class RebuildServer extends ProviderServerOperation {
                 while (rc.attempt()) {
                     try {
                         /*
-                         * We are just trying to make sure that the image exists.
-                         * We arent interested in the details at this point.
+                         * We are just trying to make sure that the image exists. We arent interested in the details at
+                         * this point.
                          */
                         imageService.getImage(imageToUse);
                         break;
                     } catch (ContextConnectionException e) {
                         msg = EELFResourceManager.format(Msg.CONNECTION_FAILED_RETRY, provider.getName(),
                                 imageService.getURL(), context.getTenant().getName(), context.getTenant().getId(),
-                                e.getMessage(), Long.toString(rc.getRetryDelay()),
-                                Integer.toString(rc.getAttempts()), Integer.toString(rc.getRetryLimit()));
+                                e.getMessage(), Long.toString(rc.getRetryDelay()), Integer.toString(rc.getAttempts()),
+                                Integer.toString(rc.getRetryLimit()));
                         logger.error(msg, e);
                         metricsLogger.error(msg);
                         rc.delay();
@@ -335,7 +327,8 @@ public class RebuildServer extends ProviderServerOperation {
     }
 
     /**
-     * @see org.openecomp.appc.adapter.iaas.ProviderAdapter#rebuildServer(java.util.Map, org.openecomp.sdnc.sli.SvcLogicContext)
+     * @see org.openecomp.appc.adapter.iaas.ProviderAdapter#rebuildServer(java.util.Map,
+     *      org.openecomp.sdnc.sli.SvcLogicContext)
      */
     @SuppressWarnings("nls")
     public Server rebuildServer(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
@@ -353,7 +346,8 @@ public class RebuildServer extends ProviderServerOperation {
             String appName = configuration.getProperty(Constants.PROPERTY_APPLICATION_NAME);
             String vm_url = params.get(ProviderAdapter.PROPERTY_INSTANCE_URL);
             VMURL vm = VMURL.parseURL(vm_url);
-            if (validateVM(rc, appName, vm_url, vm)) return null;
+            if (validateVM(rc, appName, vm_url, vm))
+                return null;
 
             IdentityURL ident = IdentityURL.parseURL(params.get(ProviderAdapter.PROPERTY_IDENTITY_URL));
             String identStr = (ident == null) ? null : ident.toString();
@@ -373,8 +367,8 @@ public class RebuildServer extends ProviderServerOperation {
                         doSuccess(rc);
                         ctx.setAttribute("REBUILD_STATUS", "SUCCESS");
                     } else {
-                        msg = EELFResourceManager.format(Msg.REBUILD_SERVER_FAILED,
-                                server.getName(), server.getId(), "Accessing Image Service Failed");
+                        msg = EELFResourceManager.format(Msg.REBUILD_SERVER_FAILED, server.getName(), server.getId(),
+                                "Accessing Image Service Failed");
                         logger.error(msg);
                         metricsLogger.error(msg);
                         doFailure(rc, HttpStatus.FORBIDDEN_403, msg);
index 33c4c6b..5adb7f3 100644 (file)
@@ -45,13 +45,11 @@ import org.openecomp.appc.exceptions.UnknownProviderException;
 import org.openecomp.appc.i18n.Msg;
 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
 import org.slf4j.MDC;
-
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.Map;
 import java.util.TimeZone;
-
 import static org.openecomp.appc.adapter.iaas.provider.operation.common.enums.Operation.RESTART_SERVICE;
 import static org.openecomp.appc.adapter.utils.Constants.ADAPTER_NAME;
 
@@ -65,8 +63,7 @@ public class RestartServer extends ProviderServerOperation {
      * This method handles the case of restarting a server once we have found the server and have obtained the abstract
      * representation of the server via the context (i.e., the "Server" object from the CDP-Zones abstraction).
      *
-     * @param rc     The request context that manages the state and recovery of the request for the life of
-     *               its processing.
+     * @param rc The request context that manages the state and recovery of the request for the life of its processing.
      * @param server The server object representing the server we want to operate on
      * @throws ZoneException when error occurs.
      * @throws RequestFailedException when server status is error.
@@ -75,11 +72,9 @@ public class RestartServer extends ProviderServerOperation {
     private void restartServer(RequestContext rc, Server server, SvcLogicContext ctx)
             throws ZoneException, RequestFailedException {
         /*
-         * Pending is a bit of a special case. If we find the server is in a
-         * pending state, then the provider is in the process of changing state
-         * of the server. So, lets try to wait a little bit and see if the state
-         * settles down to one we can deal with. If not, then we have to fail
-         * the request.
+         * Pending is a bit of a special case. If we find the server is in a pending state, then the provider is in the
+         * process of changing state of the server. So, lets try to wait a little bit and see if the state settles down
+         * to one we can deal with. If not, then we have to fail the request.
          */
         String msg;
         if (server.getStatus().equals(Server.Status.PENDING)) {
@@ -89,8 +84,8 @@ public class RestartServer extends ProviderServerOperation {
 
         setTimeForMetricsLogger("restart server");
 
-        String skipHypervisorCheck = null;
-        if (ctx != null) {
+        String skipHypervisorCheck = configuration.getProperty("org.openecomp.appc.iaas.skiphypervisorchek");
+        if (skipHypervisorCheck == null && ctx != null) {
             skipHypervisorCheck = ctx.getAttribute(ProviderAdapter.SKIP_HYPERVISOR_CHECK);
         }
 
@@ -168,16 +163,20 @@ public class RestartServer extends ProviderServerOperation {
      * This method is used to restart an existing virtual machine given the fully qualified URL of the machine.
      * <p>
      * The fully qualified URL contains enough information to locate the appropriate server. The URL is of the form
+     * 
      * <pre>
      *  [scheme]://[host[:port]] / [path] / [tenant_id] / servers / [vm_id]
-     * </pre> Where the various parts of the URL can be parsed and extracted and used to locate the appropriate service
-     * in the provider service catalog. This then allows us to open a context using the CDP abstraction, obtain the
-     * server by its UUID, and then perform the restart.
+     * </pre>
+     * 
+     * Where the various parts of the URL can be parsed and extracted and used to locate the appropriate service in the
+     * provider service catalog. This then allows us to open a context using the CDP abstraction, obtain the server by
+     * its UUID, and then perform the restart.
      * </p>
      *
      * @throws UnknownProviderException If the provider cannot be found
      * @throws IllegalArgumentException if the expected argument(s) are not defined or are invalid
-     * @see org.openecomp.appc.adapter.iaas.ProviderAdapter#restartServer(java.util.Map, org.openecomp.sdnc.sli.SvcLogicContext)
+     * @see org.openecomp.appc.adapter.iaas.ProviderAdapter#restartServer(java.util.Map,
+     *      org.openecomp.sdnc.sli.SvcLogicContext)
      */
     @SuppressWarnings("nls")
     private Server restartServer(Map<String, String> params, SvcLogicContext ctx)
@@ -201,7 +200,8 @@ public class RestartServer extends ProviderServerOperation {
             String vm_url = params.get(ProviderAdapter.PROPERTY_INSTANCE_URL);
 
             VMURL vm = VMURL.parseURL(vm_url);
-            if (validateVM(rc, appName, vm_url, vm)) return null;
+            if (validateVM(rc, appName, vm_url, vm))
+                return null;
 
             IdentityURL ident = IdentityURL.parseURL(params.get(ProviderAdapter.PROPERTY_IDENTITY_URL));
             String identStr = (ident == null) ? null : ident.toString();
@@ -218,8 +218,7 @@ public class RestartServer extends ProviderServerOperation {
                     context.close();
                     doSuccess(rc);
                     ctx.setAttribute("RESTART_STATUS", "SUCCESS");
-                    String msg = EELFResourceManager.format(Msg.SUCCESS_EVENT_MESSAGE,
-                            "RestartServer", vm_url);
+                    String msg = EELFResourceManager.format(Msg.SUCCESS_EVENT_MESSAGE, "RestartServer", vm_url);
                     ctx.setAttribute(org.openecomp.appc.Constants.ATTRIBUTE_SUCCESS_MESSAGE, msg);
                 }
             } catch (RequestFailedException e) {
@@ -230,8 +229,9 @@ public class RestartServer extends ProviderServerOperation {
                 metricsLogger.error(msg);
                 doFailure(rc, HttpStatus.NOT_FOUND_404, msg);
             } catch (Exception e1) {
-                String msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, e1, e1.getClass().getSimpleName(),
-                        RESTART_SERVICE.toString(), vm_url, context == null ? "Unknown" : context.getTenantName());
+                String msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, e1,
+                        e1.getClass().getSimpleName(), RESTART_SERVICE.toString(), vm_url,
+                        context == null ? "Unknown" : context.getTenantName());
                 logger.error(msg, e1);
                 metricsLogger.error(msg, e1);
                 doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg);
index 83dfb92..397f63a 100644 (file)
@@ -50,9 +50,7 @@ import org.openecomp.appc.adapter.openstack.heat.StackResource;
 import org.openecomp.appc.exceptions.APPCException;
 import org.openecomp.appc.i18n.Msg;
 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-
 import java.util.Map;
-
 import static org.openecomp.appc.adapter.utils.Constants.ADAPTER_NAME;
 
 public class RestoreStack extends ProviderStackOperation {
@@ -62,10 +60,10 @@ public class RestoreStack extends ProviderStackOperation {
     private void restoreStack(Stack stack, String snapshotId) throws ZoneException, RequestFailedException {
         Context context = stack.getContext();
 
-        OpenStackContext osContext = (OpenStackContext)context;
+        OpenStackContext osContext = (OpenStackContext) context;
 
         final HeatConnector heatConnector = osContext.getHeatConnector();
-        ((OpenStackContext)context).refreshIfStale(heatConnector);
+        ((OpenStackContext) context).refreshIfStale(heatConnector);
 
         trackRequest(context);
         RequestState.put("SERVICE", "Orchestration");
@@ -105,10 +103,8 @@ public class RestoreStack extends ProviderStackOperation {
 
         try {
 
-            validateParametersExist(params,
-                    ProviderAdapter.PROPERTY_INSTANCE_URL,
-                    ProviderAdapter.PROPERTY_PROVIDER_NAME,
-                    ProviderAdapter.PROPERTY_STACK_ID,
+            validateParametersExist(params, ProviderAdapter.PROPERTY_INSTANCE_URL,
+                    ProviderAdapter.PROPERTY_PROVIDER_NAME, ProviderAdapter.PROPERTY_STACK_ID,
                     ProviderAdapter.PROPERTY_INPUT_SNAPSHOT_ID);
 
             String stackId = params.get(ProviderAdapter.PROPERTY_STACK_ID);
@@ -118,13 +114,13 @@ public class RestoreStack extends ProviderStackOperation {
             context = resolveContext(rc, params, appName, vm_url);
 
             if (context != null) {
-                    stack = lookupStack(rc, context, stackId);
-                    logger.debug(Msg.STACK_FOUND, vm_url, context.getTenantName(), stack.getStatus().toString());
-                    logger.info(EELFResourceManager.format(Msg.TERMINATING_STACK, stack.getName()));
-                    restoreStack(stack, snapshotId);
-                    logger.info(EELFResourceManager.format(Msg.TERMINATE_STACK, stack.getName()));
-                    context.close();
-                    doSuccess(rc);
+                stack = lookupStack(rc, context, stackId);
+                logger.debug(Msg.STACK_FOUND, vm_url, context.getTenantName(), stack.getStatus().toString());
+                logger.info(EELFResourceManager.format(Msg.TERMINATING_STACK, stack.getName()));
+                restoreStack(stack, snapshotId);
+                logger.info(EELFResourceManager.format(Msg.TERMINATE_STACK, stack.getName()));
+                context.close();
+                doSuccess(rc);
             } else {
                 ctx.setAttribute(Constants.DG_ATTRIBUTE_STATUS, "failure");
             }
@@ -134,12 +130,10 @@ public class RestoreStack extends ProviderStackOperation {
             logger.error(msg);
             doFailure(rc, HttpStatus.NOT_FOUND_404, msg, e);
         } catch (RequestFailedException e) {
-            logger.error(EELFResourceManager.format(Msg.MISSING_PARAMETER_IN_REQUEST,
-                    e.getReason(), "restoreStack"));
+            logger.error(EELFResourceManager.format(Msg.MISSING_PARAMETER_IN_REQUEST, e.getReason(), "restoreStack"));
             doFailure(rc, e.getStatus(), e.getMessage(), e);
         } catch (Exception e1) {
-            String msg = EELFResourceManager.format(Msg.STACK_OPERATION_EXCEPTION,
-                    e1, e1.getClass().getSimpleName(),
+            String msg = EELFResourceManager.format(Msg.STACK_OPERATION_EXCEPTION, e1, e1.getClass().getSimpleName(),
                     "restoreStack", vm_url, null == context ? "n/a" : context.getTenantName());
             logger.error(msg, e1);
             doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg, e1);
index c53b9c1..97ac5c8 100644 (file)
@@ -53,13 +53,11 @@ import org.openecomp.appc.exceptions.APPCException;
 import org.openecomp.appc.i18n.Msg;
 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
 import org.slf4j.MDC;
-
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.Map;
 import java.util.TimeZone;
-
 import static org.openecomp.appc.adapter.utils.Constants.ADAPTER_NAME;
 
 public class SnapshotStack extends ProviderStackOperation {
@@ -73,10 +71,10 @@ public class SnapshotStack extends ProviderStackOperation {
         Snapshot snapshot = new Snapshot();
         Context context = stack.getContext();
 
-        OpenStackContext osContext = (OpenStackContext)context;
+        OpenStackContext osContext = (OpenStackContext) context;
 
         final HeatConnector heatConnector = osContext.getHeatConnector();
-        ((OpenStackContext)context).refreshIfStale(heatConnector);
+        ((OpenStackContext) context).refreshIfStale(heatConnector);
 
         trackRequest(context);
         RequestState.put("SERVICE", "Orchestration");
@@ -133,8 +131,8 @@ public class SnapshotStack extends ProviderStackOperation {
 
                 Snapshot snapshot = snapshotStack(rc, stack);
 
-                ctx.setAttribute(ProviderAdapter.DG_OUTPUT_PARAM_NAMESPACE +
-                        ProviderAdapter.PROPERTY_SNAPSHOT_ID, snapshot.getId());
+                ctx.setAttribute(ProviderAdapter.DG_OUTPUT_PARAM_NAMESPACE + ProviderAdapter.PROPERTY_SNAPSHOT_ID,
+                        snapshot.getId());
 
                 logger.info(EELFResourceManager.format(Msg.STACK_SNAPSHOTED, stack.getName(), snapshot.getId()));
                 metricsLogger.info(EELFResourceManager.format(Msg.STACK_SNAPSHOTED, stack.getName(), snapshot.getId()));
@@ -150,14 +148,12 @@ public class SnapshotStack extends ProviderStackOperation {
             metricsLogger.error(msg);
             doFailure(rc, HttpStatus.NOT_FOUND_404, msg, e);
         } catch (RequestFailedException e) {
-            logger.error(EELFResourceManager.format(Msg.MISSING_PARAMETER_IN_REQUEST,
-                    e.getReason(), "snapshotStack"));
-            metricsLogger.error(EELFResourceManager.format(Msg.MISSING_PARAMETER_IN_REQUEST,
-                    e.getReason(), "snapshotStack"));
+            logger.error(EELFResourceManager.format(Msg.MISSING_PARAMETER_IN_REQUEST, e.getReason(), "snapshotStack"));
+            metricsLogger.error(
+                    EELFResourceManager.format(Msg.MISSING_PARAMETER_IN_REQUEST, e.getReason(), "snapshotStack"));
             doFailure(rc, e.getStatus(), e.getMessage(), e);
         } catch (Exception e1) {
-            String msg = EELFResourceManager.format(Msg.STACK_OPERATION_EXCEPTION,
-                    e1, e1.getClass().getSimpleName(),
+            String msg = EELFResourceManager.format(Msg.STACK_OPERATION_EXCEPTION, e1, e1.getClass().getSimpleName(),
                     "snapshotStack", vm_url, null == context ? "n/a" : context.getTenantName());
             logger.error(msg, e1);
             metricsLogger.error(msg);
index b5379b8..09781a2 100644 (file)
@@ -43,9 +43,7 @@ import com.att.eelf.configuration.EELFManager;
 import com.att.eelf.i18n.EELFResourceManager;
 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
 import org.glassfish.grizzly.http.util.HttpStatus;
-
 import java.util.Map;
-
 import static org.openecomp.appc.adapter.iaas.provider.operation.common.enums.Operation.START_SERVICE;
 import static org.openecomp.appc.adapter.utils.Constants.ADAPTER_NAME;
 
@@ -54,7 +52,8 @@ public class StartServer extends ProviderServerOperation {
     private static final EELFLogger logger = EELFManager.getInstance().getLogger(StartServer.class);
 
     /**
-     * @see org.openecomp.appc.adapter.iaas.ProviderAdapter#startServer(java.util.Map, org.openecomp.sdnc.sli.SvcLogicContext)
+     * @see org.openecomp.appc.adapter.iaas.ProviderAdapter#startServer(java.util.Map,
+     *      org.openecomp.sdnc.sli.SvcLogicContext)
      */
     @SuppressWarnings("nls")
     public Server startServer(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
@@ -71,7 +70,8 @@ public class StartServer extends ProviderServerOperation {
             String vm_url = params.get(ProviderAdapter.PROPERTY_INSTANCE_URL);
 
             VMURL vm = VMURL.parseURL(vm_url);
-            if (validateVM(rc, appName, vm_url, vm)) return null;
+            if (validateVM(rc, appName, vm_url, vm))
+                return null;
 
             IdentityURL ident = IdentityURL.parseURL(params.get(ProviderAdapter.PROPERTY_IDENTITY_URL));
             String identStr = (ident == null) ? null : ident.toString();
@@ -91,11 +91,9 @@ public class StartServer extends ProviderServerOperation {
                      */
 
                     /*
-                     * Pending is a bit of a special case. If we find the server is in a
-                     * pending state, then the provider is in the process of changing state
-                     * of the server. So, lets try to wait a little bit and see if the state
-                     * settles down to one we can deal with. If not, then we have to fail
-                     * the request.
+                     * Pending is a bit of a special case. If we find the server is in a pending state, then the
+                     * provider is in the process of changing state of the server. So, lets try to wait a little bit and
+                     * see if the state settles down to one we can deal with. If not, then we have to fail the request.
                      */
 
                     if (server.getStatus().equals(Server.Status.PENDING)) {
@@ -106,11 +104,11 @@ public class StartServer extends ProviderServerOperation {
                     switch (server.getStatus()) {
                         case DELETED:
                             // Nothing to do, the server is gone
-                            msg = EELFResourceManager.format(Msg.SERVER_DELETED,
-                                    server.getName(), server.getId(), server.getTenantId(), "started");
+                            msg = EELFResourceManager.format(Msg.SERVER_DELETED, server.getName(), server.getId(),
+                                    server.getTenantId(), "started");
                             logger.error(msg);
-                            throw new RequestFailedException(
-                                    "Start Server", msg, HttpStatus.METHOD_NOT_ALLOWED_405, server);
+                            throw new RequestFailedException("Start Server", msg, HttpStatus.METHOD_NOT_ALLOWED_405,
+                                    server);
 
                         case RUNNING:
                             // Nothing to do, the server is already running
@@ -119,11 +117,11 @@ public class StartServer extends ProviderServerOperation {
 
                         case ERROR:
                             // Server is in error state
-                            msg = EELFResourceManager.format(Msg.SERVER_ERROR_STATE,
-                                    server.getName(), server.getId(), server.getTenantId(), "start");
+                            msg = EELFResourceManager.format(Msg.SERVER_ERROR_STATE, server.getName(), server.getId(),
+                                    server.getTenantId(), "start");
                             logger.error(msg);
-                            throw new RequestFailedException(
-                                    "Start Server", msg, HttpStatus.METHOD_NOT_ALLOWED_405, server);
+                            throw new RequestFailedException("Start Server", msg, HttpStatus.METHOD_NOT_ALLOWED_405,
+                                    server);
 
                         case READY:
                             // Server is stopped attempt to start the server
@@ -149,15 +147,13 @@ public class StartServer extends ProviderServerOperation {
                                     server.getTenantId(), server.getStatus().name());
                             generateEvent(rc, false, msg);
                             logger.error(msg);
-                            throw new RequestFailedException(
-                                    "Start Server", msg, HttpStatus.METHOD_NOT_ALLOWED_405, server);
+                            throw new RequestFailedException("Start Server", msg, HttpStatus.METHOD_NOT_ALLOWED_405,
+                                    server);
                     }
                     context.close();
                     doSuccess(rc);
                     ctx.setAttribute("START_STATUS", "SUCCESS");
-                }
-                else
-                {
+                } else {
                     ctx.setAttribute("START_STATUS", "CONTEXT_NOT_FOUND");
                 }
             } catch (ResourceNotFoundException e) {
@@ -165,8 +161,9 @@ public class StartServer extends ProviderServerOperation {
                 logger.error(msg);
                 doFailure(rc, HttpStatus.NOT_FOUND_404, msg);
             } catch (Exception e1) {
-                String msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, e1, e1.getClass().getSimpleName(),
-                        START_SERVICE.toString(), vm_url, context == null ? "Unknown" : context.getTenantName());
+                String msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, e1,
+                        e1.getClass().getSimpleName(), START_SERVICE.toString(), vm_url,
+                        context == null ? "Unknown" : context.getTenantName());
                 logger.error(msg, e1);
                 doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg);
             }
index ae61099..0587061 100644 (file)
@@ -43,9 +43,7 @@ import com.att.eelf.configuration.EELFManager;
 import com.att.eelf.i18n.EELFResourceManager;
 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
 import org.glassfish.grizzly.http.util.HttpStatus;
-
 import java.util.Map;
-
 import static org.openecomp.appc.adapter.iaas.provider.operation.common.enums.Operation.STOP_SERVICE;
 import static org.openecomp.appc.adapter.utils.Constants.ADAPTER_NAME;
 
@@ -55,7 +53,8 @@ public class StopServer extends ProviderServerOperation {
     private static EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
 
     /**
-     * @see org.openecomp.appc.adapter.iaas.ProviderAdapter#stopServer(java.util.Map, org.openecomp.sdnc.sli.SvcLogicContext)
+     * @see org.openecomp.appc.adapter.iaas.ProviderAdapter#stopServer(java.util.Map,
+     *      org.openecomp.sdnc.sli.SvcLogicContext)
      */
     @SuppressWarnings("nls")
     public Server stopServer(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
@@ -73,7 +72,8 @@ public class StopServer extends ProviderServerOperation {
             ctx.setAttribute("STOP_STATUS", "SUCCESS");
 
             VMURL vm = VMURL.parseURL(vm_url);
-            if (validateVM(rc, appName, vm_url, vm)) return null;
+            if (validateVM(rc, appName, vm_url, vm))
+                return null;
 
             IdentityURL ident = IdentityURL.parseURL(params.get(ProviderAdapter.PROPERTY_IDENTITY_URL));
             String identStr = (ident == null) ? null : ident.toString();
@@ -86,18 +86,16 @@ public class StopServer extends ProviderServerOperation {
                     rc.reset();
                     server = lookupServer(rc, context, vm.getServerId());
                     logger.debug(Msg.SERVER_FOUND, vm_url, context.getTenantName(), server.getStatus().toString());
-                    
+
                     String msg;
                     /*
                      * We determine what to do based on the current state of the server
                      */
 
                     /*
-                     * Pending is a bit of a special case. If we find the server is in a
-                     * pending state, then the provider is in the process of changing state
-                     * of the server. So, lets try to wait a little bit and see if the state
-                     * settles down to one we can deal with. If not, then we have to fail
-                     * the request.
+                     * Pending is a bit of a special case. If we find the server is in a pending state, then the
+                     * provider is in the process of changing state of the server. So, lets try to wait a little bit and
+                     * see if the state settles down to one we can deal with. If not, then we have to fail the request.
                      */
 
                     if (server.getStatus().equals(Server.Status.PENDING)) {
@@ -108,13 +106,13 @@ public class StopServer extends ProviderServerOperation {
                     switch (server.getStatus()) {
                         case DELETED:
                             // Nothing to do, the server is gone
-                            msg = EELFResourceManager.format(Msg.SERVER_DELETED,
-                                    server.getName(), server.getId(), server.getTenantId(), "stopped");
+                            msg = EELFResourceManager.format(Msg.SERVER_DELETED, server.getName(), server.getId(),
+                                    server.getTenantId(), "stopped");
                             generateEvent(rc, false, msg);
                             logger.error(msg);
                             metricsLogger.error(msg);
-                            throw new RequestFailedException(
-                                    "Stop Server", msg, HttpStatus.METHOD_NOT_ALLOWED_405, server);
+                            throw new RequestFailedException("Stop Server", msg, HttpStatus.METHOD_NOT_ALLOWED_405,
+                                    server);
 
                         case RUNNING:
                             // Attempt to stop the server
@@ -125,13 +123,13 @@ public class StopServer extends ProviderServerOperation {
 
                         case ERROR:
                             // Server is in error state
-                            msg = EELFResourceManager.format(Msg.SERVER_ERROR_STATE,
-                                    server.getName(), server.getId(), server.getTenantId(), "stop");
+                            msg = EELFResourceManager.format(Msg.SERVER_ERROR_STATE, server.getName(), server.getId(),
+                                    server.getTenantId(), "stop");
                             generateEvent(rc, false, msg);
                             logger.error(msg);
                             metricsLogger.error(msg);
-                            throw new RequestFailedException(
-                                    "Stop Server", msg, HttpStatus.METHOD_NOT_ALLOWED_405, server);
+                            throw new RequestFailedException("Stop Server", msg, HttpStatus.METHOD_NOT_ALLOWED_405,
+                                    server);
 
                         case READY:
                             // Nothing to do, the server was already stopped
@@ -158,13 +156,13 @@ public class StopServer extends ProviderServerOperation {
 
                         default:
                             // Hmmm, unknown status, should never occur
-                            msg = EELFResourceManager.format(Msg.UNKNOWN_SERVER_STATE,
-                                    server.getName(), server.getId(), server.getTenantId(), server.getStatus().name());
+                            msg = EELFResourceManager.format(Msg.UNKNOWN_SERVER_STATE, server.getName(), server.getId(),
+                                    server.getTenantId(), server.getStatus().name());
                             generateEvent(rc, false, msg);
                             logger.error(msg);
                             metricsLogger.error(msg);
-                            throw new RequestFailedException(
-                                    "Stop Server", msg, HttpStatus.METHOD_NOT_ALLOWED_405, server);
+                            throw new RequestFailedException("Stop Server", msg, HttpStatus.METHOD_NOT_ALLOWED_405,
+                                    server);
                     }
                     context.close();
                     doSuccess(rc);
@@ -172,7 +170,7 @@ public class StopServer extends ProviderServerOperation {
                     msg = EELFResourceManager.format(Msg.SUCCESS_EVENT_MESSAGE, "StopServer", vm_url);
                     ctx.setAttribute(org.openecomp.appc.Constants.ATTRIBUTE_SUCCESS_MESSAGE, msg);
 
-                }else{
+                } else {
                     ctx.setAttribute("STOP_STATUS", "CONTEXT_NOT_FOUND");
                 }
             } catch (ResourceNotFoundException e) {
@@ -180,14 +178,14 @@ public class StopServer extends ProviderServerOperation {
                 logger.error(msg);
                 doFailure(rc, HttpStatus.NOT_FOUND_404, msg);
             } catch (Exception e1) {
-                String msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, e1, e1.getClass().getSimpleName(),
-                        STOP_SERVICE.toString(), vm_url, context == null ? "Unknown" : context.getTenantName());
+                String msg =
+                        EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, e1, e1.getClass().getSimpleName(),
+                                STOP_SERVICE.toString(), vm_url, context == null ? "Unknown" : context.getTenantName());
                 logger.error(msg, e1);
                 doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg);
             }
         } catch (RequestFailedException e) {
-            logger.error(EELFResourceManager.format(Msg.STOP_SERVER_FAILED,
-                    appName, "n/a", "n/a", e.getMessage()));
+            logger.error(EELFResourceManager.format(Msg.STOP_SERVER_FAILED, appName, "n/a", "n/a", e.getMessage()));
             doFailure(rc, e.getStatus(), e.getMessage());
         }
 
index b3d34bc..5100060 100644 (file)
@@ -47,9 +47,7 @@ import org.openecomp.appc.adapter.iaas.provider.operation.impl.base.ProviderServ
 import org.openecomp.appc.exceptions.UnknownProviderException;
 import org.openecomp.appc.i18n.Msg;
 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-
 import java.util.Map;
-
 import static org.openecomp.appc.adapter.iaas.provider.operation.common.enums.Operation.RESTART_SERVICE;
 import static org.openecomp.appc.adapter.iaas.provider.operation.common.enums.Operation.TERMINATE_SERVICE;
 import static org.openecomp.appc.adapter.utils.Constants.ADAPTER_NAME;
@@ -61,10 +59,8 @@ public class TerminateServer extends ProviderServerOperation {
     /**
      * Start the server and wait for it to enter a running state
      *
-     * @param rc
-     *            The request context that manages the state and recovery of the request for the life of its processing.
-     * @param server
-     *            The server to be started
+     * @param rc The request context that manages the state and recovery of the request for the life of its processing.
+     * @param server The server to be started
      * @throws ZoneException when error occurs
      * @throws RequestFailedException when request failed
      */
@@ -100,10 +96,8 @@ public class TerminateServer extends ProviderServerOperation {
      * This method handles the case of restarting a server once we have found the server and have obtained the abstract
      * representation of the server via the context (i.e., the "Server" object from the CDP-Zones abstraction).
      *
-     * @param rc
-     *            The request context that manages the state and recovery of the request for the life of its processing.
-     * @param server
-     *            The server object representing the server we want to operate on
+     * @param rc The request context that manages the state and recovery of the request for the life of its processing.
+     * @param server The server object representing the server we want to operate on
      * @throws ZoneException when error occurs
      */
     @SuppressWarnings("nls")
@@ -167,18 +161,20 @@ public class TerminateServer extends ProviderServerOperation {
      * This method is used to delete an existing virtual machine given the fully qualified URL of the machine.
      * <p>
      * The fully qualified URL contains enough information to locate the appropriate server. The URL is of the form
+     * 
      * <pre>
      *  [scheme]://[host[:port]] / [path] / [tenant_id] / servers / [vm_id]
-     * </pre> Where the various parts of the URL can be parsed and extracted and used to locate the appropriate service
-     * in the provider service catalog. This then allows us to open a context using the CDP abstraction, obtain the
-     * server by its UUID, and then perform the restart.
+     * </pre>
+     * 
+     * Where the various parts of the URL can be parsed and extracted and used to locate the appropriate service in the
+     * provider service catalog. This then allows us to open a context using the CDP abstraction, obtain the server by
+     * its UUID, and then perform the restart.
      * </p>
      *
-     * @throws UnknownProviderException
-     *             If the provider cannot be found
-     * @throws IllegalArgumentException
-     *             if the expected argument(s) are not defined or are invalid
-     * @see org.openecomp.appc.adapter.iaas.ProviderAdapter#terminateServer(java.util.Map, org.openecomp.sdnc.sli.SvcLogicContext)
+     * @throws UnknownProviderException If the provider cannot be found
+     * @throws IllegalArgumentException if the expected argument(s) are not defined or are invalid
+     * @see org.openecomp.appc.adapter.iaas.ProviderAdapter#terminateServer(java.util.Map,
+     *      org.openecomp.sdnc.sli.SvcLogicContext)
      */
     @SuppressWarnings("nls")
     public Server terminateServer(Map<String, String> params, SvcLogicContext ctx)
@@ -197,7 +193,8 @@ public class TerminateServer extends ProviderServerOperation {
             ctx.setAttribute("TERMINATE_STATUS", "SUCCESS");
 
             VMURL vm = VMURL.parseURL(vm_url);
-            if (validateVM(rc, appName, vm_url, vm)) return null;
+            if (validateVM(rc, appName, vm_url, vm))
+                return null;
 
             IdentityURL ident = IdentityURL.parseURL(params.get(ProviderAdapter.PROPERTY_IDENTITY_URL));
             String identStr = (ident == null) ? null : ident.toString();
@@ -222,15 +219,15 @@ public class TerminateServer extends ProviderServerOperation {
                 doFailure(rc, HttpStatus.NOT_FOUND_404, msg);
                 ctx.setAttribute("TERMINATE_STATUS", "SERVER_NOT_FOUND");
             } catch (Exception e1) {
-                String msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION,
-                        e1, e1.getClass().getSimpleName(), RESTART_SERVICE.toString(),
-                        vm_url, context == null ? "Unknown" : context.getTenantName());
+                String msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, e1,
+                        e1.getClass().getSimpleName(), RESTART_SERVICE.toString(), vm_url,
+                        context == null ? "Unknown" : context.getTenantName());
                 logger.error(msg, e1);
                 doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg);
             }
         } catch (RequestFailedException e) {
-            logger.error(EELFResourceManager.format(Msg.TERMINATE_SERVER_FAILED,
-                    appName, "n/a", "n/a", e.getMessage()));
+            logger.error(
+                    EELFResourceManager.format(Msg.TERMINATE_SERVER_FAILED, appName, "n/a", "n/a", e.getMessage()));
             doFailure(rc, e.getStatus(), e.getMessage());
             ctx.setAttribute("TERMINATE_STATUS", "ERROR");
         }
@@ -243,6 +240,6 @@ public class TerminateServer extends ProviderServerOperation {
             throws UnknownProviderException {
         setMDC(TERMINATE_SERVICE.toString(), "App-C IaaS Adapter:Terminate", ADAPTER_NAME);
         logOperation(Msg.TERMINATING_SERVER, params, context);
-        return terminateServer(params,context);
+        return terminateServer(params, context);
     }
 }
index a8987bb..a9ee122 100644 (file)
@@ -43,9 +43,7 @@ import com.att.eelf.configuration.EELFManager;
 import com.att.eelf.i18n.EELFResourceManager;
 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
 import org.glassfish.grizzly.http.util.HttpStatus;
-
 import java.util.Map;
-
 import static org.openecomp.appc.adapter.utils.Constants.ADAPTER_NAME;
 
 public class TerminateStack extends ProviderStackOperation {
@@ -99,8 +97,7 @@ public class TerminateStack extends ProviderStackOperation {
                     logger.info(EELFResourceManager.format(Msg.TERMINATE_STACK, stack.getName()));
                     context.close();
                     doSuccess(rc);
-                    String msg = EELFResourceManager.format(Msg.SUCCESS_EVENT_MESSAGE,
-                            "TerminateStack", vm_url);
+                    String msg = EELFResourceManager.format(Msg.SUCCESS_EVENT_MESSAGE, "TerminateStack", vm_url);
                     ctx.setAttribute(org.openecomp.appc.Constants.ATTRIBUTE_SUCCESS_MESSAGE, msg);
                 }
             } catch (ResourceNotFoundException e) {
@@ -108,8 +105,9 @@ public class TerminateStack extends ProviderStackOperation {
                 logger.error(msg);
                 doFailure(rc, HttpStatus.NOT_FOUND_404, msg);
             } catch (Exception e1) {
-                String msg = EELFResourceManager.format(Msg.STACK_OPERATION_EXCEPTION, e1, e1.getClass().getSimpleName(),
-                        Operation.TERMINATE_STACK.toString(), vm_url, context.getTenantName());
+                String msg =
+                        EELFResourceManager.format(Msg.STACK_OPERATION_EXCEPTION, e1, e1.getClass().getSimpleName(),
+                                Operation.TERMINATE_STACK.toString(), vm_url, context.getTenantName());
                 logger.error(msg, e1);
                 doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg);
             }
index 68fa454..8175a14 100644 (file)
@@ -46,9 +46,7 @@ import org.openecomp.appc.configuration.ConfigurationFactory;
 import org.openecomp.appc.exceptions.UnknownProviderException;
 import org.openecomp.appc.i18n.Msg;
 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-
 import java.util.Map;
-
 import static org.openecomp.appc.adapter.iaas.provider.operation.common.enums.Operation.RESTART_SERVICE;
 import static org.openecomp.appc.adapter.utils.Constants.ADAPTER_NAME;
 
@@ -75,7 +73,8 @@ public class VmStatuschecker extends ProviderServerOperation {
             String vm_url = params.get(ProviderAdapter.PROPERTY_INSTANCE_URL);
 
             VMURL vm = VMURL.parseURL(vm_url);
-            if (validateVM(rc, appName, vm_url, vm)) return null;
+            if (validateVM(rc, appName, vm_url, vm))
+                return null;
 
             IdentityURL ident = IdentityURL.parseURL(params.get(ProviderAdapter.PROPERTY_IDENTITY_URL));
             String identStr = (ident == null) ? null : ident.toString();
@@ -137,9 +136,9 @@ public class VmStatuschecker extends ProviderServerOperation {
                 logger.error(msg);
                 doFailure(rc, HttpStatus.NOT_FOUND_404, msg);
             } catch (Exception e1) {
-                String msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION,
-                        e1, e1.getClass().getSimpleName(), RESTART_SERVICE.toString(),
-                        vm_url, context == null ? "Unknown" : context.getTenantName());
+                String msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, e1,
+                        e1.getClass().getSimpleName(), RESTART_SERVICE.toString(), vm_url,
+                        context == null ? "Unknown" : context.getTenantName());
                 logger.error(msg, e1);
                 doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg);
             }
index 8ae0753..02226bb 100644 (file)
@@ -44,19 +44,14 @@ import com.att.eelf.i18n.EELFResourceManager;
 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
 import org.glassfish.grizzly.http.util.HttpStatus;
 import org.slf4j.MDC;
-
 import java.net.URI;
 import java.util.Map;
 import java.util.Set;
 import java.util.regex.Pattern;
-
 import static org.openecomp.appc.adapter.iaas.provider.operation.common.constants.Constants.MDC_ADAPTER;
 import static org.openecomp.appc.adapter.iaas.provider.operation.common.constants.Constants.MDC_SERVICE;
 import static com.att.eelf.configuration.Configuration.MDC_SERVICE_NAME;
 
-/**
- * @since September 26, 2016
- */
 public abstract class ProviderOperation implements IProviderOperation {
 
     private static final EELFLogger logger = EELFManager.getInstance().getLogger(ProviderOperation.class);
@@ -80,20 +75,27 @@ public abstract class ProviderOperation implements IProviderOperation {
         DEFAULT_PASS = defaultPass;
     }
 
+    @Override
+    public void setDefaultDomain(String defaultDomain) {
+        DEFAULT_DOMAIN = defaultDomain;
+    }
+
     /**
      * The username and password to use for dynamically created connections
      */
     private static String DEFAULT_USER;
     private static String DEFAULT_PASS;
+    private static String DEFAULT_DOMAIN;
 
 
     /**
      * set MDC props
+     * 
      * @param service
      * @param serviceName
      * @param adapterName
      */
-    protected void setMDC(String service, String serviceName, String adapterName){
+    protected void setMDC(String service, String serviceName, String adapterName) {
         MDC.put(MDC_ADAPTER, adapterName);
         MDC.put(MDC_SERVICE, service);
         MDC.put(MDC_SERVICE_NAME, serviceName);
@@ -101,11 +103,12 @@ public abstract class ProviderOperation implements IProviderOperation {
 
     /**
      * initial log of the operation
+     * 
      * @param msg
      * @param params
      * @param context
      */
-    protected void logOperation(Msg msg, Map<String, String> params, SvcLogicContext context){
+    protected void logOperation(Msg msg, Map<String, String> params, SvcLogicContext context) {
 
         String appName = configuration.getProperty(org.openecomp.appc.Constants.PROPERTY_APPLICATION_NAME);
         logger.info(msg, appName);
@@ -117,8 +120,7 @@ public abstract class ProviderOperation implements IProviderOperation {
     /**
      * This method is used to dump the value of the parameters to the log for debugging purposes.
      *
-     * @param parameters
-     *            The parameters to be printed to the log
+     * @param parameters The parameters to be printed to the log
      */
     private void debugParameters(Map<String, String> parameters) {
         for (String key : parameters.keySet()) {
@@ -129,12 +131,9 @@ public abstract class ProviderOperation implements IProviderOperation {
     /**
      * This method is used to create a diagnostic dump of the context for the log
      *
-     * @param context
-     *            The context to be dumped
+     * @param context The context to be dumped
      */
-    @SuppressWarnings({
-            "nls", "static-method"
-    })
+    @SuppressWarnings({"nls", "static-method"})
     private void debugContext(SvcLogicContext context) {
         Set<String> keys = context.getAttributeKeySet();
         StringBuilder builder = new StringBuilder();
@@ -171,17 +170,15 @@ public abstract class ProviderOperation implements IProviderOperation {
      * This method is used to validate that the parameters contain all required property names, and that the values are
      * non-null and non-empty strings. We are still not ensured that the value is valid, but at least it exists.
      *
-     * @param parameters
-     *            The parameters to be checked
-     * @param propertyNames
-     *            The list of property names that are required to be present.
-     * @throws RequestFailedException
-     *             If the parameters are not valid
+     * @param parameters The parameters to be checked
+     * @param propertyNames The list of property names that are required to be present.
+     * @throws RequestFailedException If the parameters are not valid
      */
     protected void validateParametersExist(Map<String, String> parameters, String... propertyNames)
             throws RequestFailedException {
         boolean success = true;
-        StringBuilder msg = new StringBuilder(EELFResourceManager.format(Msg.MISSING_REQUIRED_PROPERTIES, MDC.get(MDC_SERVICE)));
+        StringBuilder msg =
+                new StringBuilder(EELFResourceManager.format(Msg.MISSING_REQUIRED_PROPERTIES, MDC.get(MDC_SERVICE)));
         msg.append(Constants.NL);
         for (String propertyName : propertyNames) {
             String value = parameters.get(propertyName);
@@ -196,20 +193,21 @@ public abstract class ProviderOperation implements IProviderOperation {
 
         if (!success) {
             logger.error(msg.toString());
-            throw new RequestFailedException("Check Parameters", msg.toString(), HttpStatus.BAD_REQUEST_400, (Server)null);
+            throw new RequestFailedException("Check Parameters", msg.toString(), HttpStatus.BAD_REQUEST_400,
+                    (Server) null);
         }
     }
 
     /**
-     * @param rc
-     *            The request context that manages the state and recovery of the request for the life of its processing.
+     * @param rc The request context that manages the state and recovery of the request for the life of its processing.
      * @param code
      * @param message
      */
     protected void doFailure(RequestContext rc, HttpStatus code, String message) {
         try {
             doFailure(rc, code, message, null);
-        } catch (APPCException ignored) {/* never happens */}
+        } catch (APPCException ignored) {
+            /* never happens */}
     }
 
     protected void doFailure(RequestContext rc, HttpStatus code, String message, Throwable cause) throws APPCException {
@@ -228,18 +226,19 @@ public abstract class ProviderOperation implements IProviderOperation {
         svcLogic.setAttribute(org.openecomp.appc.Constants.ATTRIBUTE_ERROR_CODE, status);
         svcLogic.setAttribute(org.openecomp.appc.Constants.ATTRIBUTE_ERROR_MESSAGE, msg);
 
-        if (null != cause) throw new APPCException(cause);
+        if (null != cause)
+            throw new APPCException(cause);
     }
 
     /**
-     * @param rc
-     *            The request context that manages the state and recovery of the request for the life of its processing.
+     * @param rc The request context that manages the state and recovery of the request for the life of its processing.
      */
     @SuppressWarnings("static-method")
     protected void doSuccess(RequestContext rc) {
         SvcLogicContext svcLogic = rc.getSvcLogicContext();
         svcLogic.setStatus(Outcome.SUCCESS.toString());
-        svcLogic.setAttribute(org.openecomp.appc.Constants.ATTRIBUTE_ERROR_CODE, Integer.toString(HttpStatus.OK_200.getStatusCode()));
+        svcLogic.setAttribute(org.openecomp.appc.Constants.ATTRIBUTE_ERROR_CODE,
+                Integer.toString(HttpStatus.OK_200.getStatusCode()));
     }
 
     protected boolean validateVM(RequestContext rc, String appName, String vm_url, VMURL vm)
@@ -265,7 +264,7 @@ public abstract class ProviderOperation implements IProviderOperation {
         // This will probably never get hit bc of an earlier check while parsing
         // the string to a VMURL
         try {
-            //noinspection ResultOfMethodCallIgnored
+            // noinspection ResultOfMethodCallIgnored
             URI.create(vm.toString());
         } catch (Exception e) {
             throw new RequestFailedException(
@@ -294,7 +293,7 @@ public abstract class ProviderOperation implements IProviderOperation {
             cache.setProviderName(ident.toString());
             // cache.setProviderType("OpenStack");
 
-            TenantCache tenant = cache.addTenant(vm.getTenantId(),null, DEFAULT_USER, DEFAULT_PASS);
+            TenantCache tenant = cache.addTenant(vm.getTenantId(), null, DEFAULT_USER, DEFAULT_PASS, DEFAULT_DOMAIN);
 
             // Make sure we could initialize the the cache otherwise return null
             if (tenant != null && tenant.isInitialized()) {
@@ -309,12 +308,9 @@ public abstract class ProviderOperation implements IProviderOperation {
      * supported provider, regardless of region(s), and to return an opened context that can be used to access that
      * server.
      *
-     * @param rc
-     *            The request context that wraps and manages the state of the request
-     * @param selfLinkURL
-     *            The fully-qualified self-link URL of the server
-     * @param providerName
-     *            The name of the provider to be searched
+     * @param rc The request context that wraps and manages the state of the request
+     * @param selfLinkURL The fully-qualified self-link URL of the server
+     * @param providerName The name of the provider to be searched
      * @return The context that can be used to access the server, or null if not found.
      */
     @SuppressWarnings("nls")
@@ -346,8 +342,8 @@ public abstract class ProviderOperation implements IProviderOperation {
             if (cache != null) {
                 providerCache.put(cache.getProviderName(), cache);
             } else {
-                String msg =
-                        EELFResourceManager.format(Msg.UNKNOWN_PROVIDER, providerName, providerCache.keySet().toString());
+                String msg = EELFResourceManager.format(Msg.UNKNOWN_PROVIDER, providerName,
+                        providerCache.keySet().toString());
                 logger.error(msg);
                 doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg);
                 return null;
@@ -355,8 +351,8 @@ public abstract class ProviderOperation implements IProviderOperation {
         }
 
         if (providerName == null) {
-            logger
-                    .debug(String.format("Using the default provider cache [%s] since no valid identity url was passed in.",
+            logger.debug(
+                    String.format("Using the default provider cache [%s] since no valid identity url was passed in.",
                             cache.getIdentityURL()));
         }
 
@@ -364,12 +360,12 @@ public abstract class ProviderOperation implements IProviderOperation {
         String identityURL = cache.getIdentityURL();
         TenantCache tenantCache = cache.getTenant(vm.getTenantId());
 
-        if(tenantCache == null){
-            //no tenantCache matching tenant, add tenant to the provider cache
-            tenantCache = cache.addTenant(vm.getTenantId(),null,DEFAULT_USER, DEFAULT_PASS);
+        if (tenantCache == null) {
+            // no tenantCache matching tenant, add tenant to the provider cache
+            tenantCache = cache.addTenant(vm.getTenantId(), null, DEFAULT_USER, DEFAULT_PASS, DEFAULT_DOMAIN);
 
-            if(tenantCache == null){
-                //tenant not found
+            if (tenantCache == null) {
+                // tenant not found
                 String msg = EELFResourceManager.format(Msg.SERVER_NOT_FOUND, selfLinkURL);
                 logger.error(msg);
                 doFailure(rc, HttpStatus.NOT_FOUND_404, msg);
@@ -377,7 +373,7 @@ public abstract class ProviderOperation implements IProviderOperation {
             }
         }
 
-        //reserve the context
+        // reserve the context
         String tenantName = tenantCache.getTenantName();
         String tenantId = tenantCache.getTenantId();
         String region = tenantCache.determineRegion(vm);
@@ -390,8 +386,8 @@ public abstract class ProviderOperation implements IProviderOperation {
                     Context context = pool.reserve();
 
                     /*
-                     * Insert logic here to test the context for connectivity because we may have gotten one from
-                     * the pool that was previously created.
+                     * Insert logic here to test the context for connectivity because we may have gotten one from the
+                     * pool that was previously created.
                      */
                     if (context.isStale()) {
                         context.relogin();
@@ -446,15 +442,12 @@ public abstract class ProviderOperation implements IProviderOperation {
 
 
 
-
-
-
-
-    protected abstract ModelObject executeProviderOperation(Map<String, String> params, SvcLogicContext context) throws APPCException;
+    protected abstract ModelObject executeProviderOperation(Map<String, String> params, SvcLogicContext context)
+            throws APPCException;
 
     @Override
     public ModelObject doOperation(Map<String, String> params, SvcLogicContext context) throws APPCException {
 
-        return executeProviderOperation(params,context);
+        return executeProviderOperation(params, context);
     }
 }
index b7ad626..d2c34d0 100644 (file)
@@ -52,24 +52,19 @@ import java.util.List;
 /**
  * @since September 29, 2016
  */
-public abstract class ProviderServerOperation extends ProviderOperation{
+public abstract class ProviderServerOperation extends ProviderOperation {
 
     private static final EELFLogger logger = EELFManager.getInstance().getLogger(ProviderServerOperation.class);
 
     /**
      * Looks up the indicated server using the provided context and returns the server to the caller
      *
-     * @param rc
-     *            The request context
-     * @param context
-     *            The provider context
-     * @param id
-     *            The id of the server
+     * @param rc The request context
+     * @param context The provider context
+     * @param id The id of the server
      * @return The server, or null if there is a problem
-     * @throws ZoneException
-     *             If the server cannot be found
-     * @throws RequestFailedException
-     *             If the server cannot be found because we cant connect to the provider
+     * @throws ZoneException If the server cannot be found
+     * @throws RequestFailedException If the server cannot be found because we cant connect to the provider
      */
     @SuppressWarnings("nls")
     protected Server lookupServer(RequestContext rc, Context context, String id)
@@ -106,10 +101,8 @@ public abstract class ProviderServerOperation extends ProviderOperation{
     /**
      * Resume a suspended server and wait for it to enter a running state
      *
-     * @param rc
-     *            The request context that manages the state and recovery of the request for the life of its processing.
-     * @param server
-     *            The server to be resumed
+     * @param rc The request context that manages the state and recovery of the request for the life of its processing.
+     * @param server The server to be resumed
      * @throws ZoneException
      * @throws RequestFailedException
      */
@@ -167,14 +160,10 @@ public abstract class ProviderServerOperation extends ProviderOperation{
      * exceptions are thrown from this method.
      * </p>
      *
-     * @param rc
-     *            The request context that manages the state and recovery of the request for the life of its processing.
-     * @param image
-     *            The server to wait on
-     * @param desiredStates
-     *            A variable list of desired states, any one of which is allowed.
-     * @throws RequestFailedException
-     *             If the request times out or fails for some reason
+     * @param rc The request context that manages the state and recovery of the request for the life of its processing.
+     * @param image The server to wait on
+     * @param desiredStates A variable list of desired states, any one of which is allowed.
+     * @throws RequestFailedException If the request times out or fails for some reason
      * @throws NotLoggedInException
      */
     @SuppressWarnings("nls")
@@ -246,14 +235,10 @@ public abstract class ProviderServerOperation extends ProviderOperation{
      * exceptions are thrown from this method.
      * </p>
      *
-     * @param rc
-     *            The request context that manages the state and recovery of the request for the life of its processing.
-     * @param server
-     *            The server to wait on
-     * @param desiredStates
-     *            A variable list of desired states, any one of which is allowed.
-     * @throws RequestFailedException
-     *             If the request times out or fails for some reason
+     * @param rc The request context that manages the state and recovery of the request for the life of its processing.
+     * @param server The server to wait on
+     * @param desiredStates A variable list of desired states, any one of which is allowed.
+     * @throws RequestFailedException If the request times out or fails for some reason
      */
     @SuppressWarnings("nls")
     protected void waitForStateChange(RequestContext rc, Server server, Server.Status... desiredStates)
@@ -291,8 +276,8 @@ public abstract class ProviderServerOperation extends ProviderOperation{
                     list.add(desiredState.name());
                 }
                 String reason = EELFResourceManager.format(Msg.STATE_CHANGE_EXCEPTION, e.getClass().getSimpleName(),
-                        "server", server.getName(), server.getId(), StringHelper.asList(list), server.getStatus().name(),
-                        e.getMessage());
+                        "server", server.getName(), server.getId(), StringHelper.asList(list),
+                        server.getStatus().name(), e.getMessage());
                 logger.error(reason);
                 logger.error(EELFResourceManager.format(e));
 
@@ -317,10 +302,8 @@ public abstract class ProviderServerOperation extends ProviderOperation{
     /**
      * Stop the specified server and wait for it to stop
      *
-     * @param rc
-     *            The request context that manages the state and recovery of the request for the life of its processing.
-     * @param server
-     *            The server to be stopped
+     * @param rc The request context that manages the state and recovery of the request for the life of its processing.
+     * @param server The server to be stopped
      * @throws ZoneException
      * @throws RequestFailedException
      */
@@ -357,10 +340,8 @@ public abstract class ProviderServerOperation extends ProviderOperation{
     /**
      * Start the server and wait for it to enter a running state
      *
-     * @param rc
-     *            The request context that manages the state and recovery of the request for the life of its processing.
-     * @param server
-     *            The server to be started
+     * @param rc The request context that manages the state and recovery of the request for the life of its processing.
+     * @param server The server to be started
      * @throws ZoneException
      * @throws RequestFailedException
      */
@@ -397,10 +378,8 @@ public abstract class ProviderServerOperation extends ProviderOperation{
     /**
      * Un-Pause a paused server and wait for it to enter a running state
      *
-     * @param rc
-     *            The request context that manages the state and recovery of the request for the life of its processing.
-     * @param server
-     *            The server to be un-paused
+     * @param rc The request context that manages the state and recovery of the request for the life of its processing.
+     * @param server The server to be un-paused
      * @throws ZoneException
      * @throws RequestFailedException
      */
@@ -438,153 +417,143 @@ public abstract class ProviderServerOperation extends ProviderOperation{
     /**
      * Generates the event indicating what happened
      *
-     * @param rc
-     *            The request context that manages the state and recovery of the request for the life of its processing.
-     * @param success
-     *            True if the event represents a successful outcome
-     * @param msg
-     *            The detailed message
+     * @param rc The request context that manages the state and recovery of the request for the life of its processing.
+     * @param success True if the event represents a successful outcome
+     * @param msg The detailed message
      */
-    protected void generateEvent(@SuppressWarnings("unused") RequestContext rc, @SuppressWarnings("unused") boolean success, @SuppressWarnings("unused") String msg) {
+    protected void generateEvent(@SuppressWarnings("unused") RequestContext rc,
+            @SuppressWarnings("unused") boolean success, @SuppressWarnings("unused") String msg) {
         // indication to the DG to generate the event?
     }
-    
+
     /**
      * Checks if the VM is connected to the Virtual Network and reachable
      *
-     * @param rc
-     *            The request context that manages the state and recovery of the request for the life of its processing.
-     * @param server
-     *             The server object representing the server we want to operate on
-     * @param context
-     *            The interface cloud service provider to access services or the object model, or both
-
+     * @param rc The request context that manages the state and recovery of the request for the life of its processing.
+     * @param server The server object representing the server we want to operate on
+     * @param context The interface cloud service provider to access services or the object model, or both
+     * 
      */
-       protected void checkVirtualMachineNetworkStatus(RequestContext rc, Server server, Context context)
-                       throws ZoneException, RequestFailedException {
-
-               logger.info("Performing the VM Server networking status checks...");
-               List<Port> ports = server.getPorts();
-
-               NetworkService netSvc = context.getNetworkService();
-
-               String msg;
-               for (Port port : ports) {
-
-                       switch (port.getPortState().toString().toUpperCase()) {
-                       /**
-                        * The port is connected, configured, and usable for communication
-                        */
-                       case "ONLINE":
-                               Network network = netSvc.getNetworkById(port.getNetwork());
-                               // Subnet subnet = netSvc.getSubnetById(port.getSubnetId());
-                               if (!network.getStatus().equals(Network.Status.ACTIVE.toString())) {
-                                       msg = EELFResourceManager.format(Msg.SERVER_NETWORK_ERROR, server.getName(), port.getId());
-                                       logger.error(msg);
-                                       doFailure(rc, HttpStatus.PRECONDITION_FAILED_412, msg);
-                                       throw new RequestFailedException("VM Server Network is DOWN", msg.toString(), HttpStatus.PRECONDITION_FAILED_412,
-                                                       server);
-                               }
-                               break;
-
-                       /**
-                        * The port is disconnected or powered-off and cannot be used for
-                        * communication
-                        */
-                       case "OFFLINE":
-                               msg = EELFResourceManager.format(Msg.SERVER_NETWORK_ERROR, server.getName(), port.getId());
-                               logger.error(msg);
-                               doFailure(rc, HttpStatus.PRECONDITION_FAILED_412, msg);
-                               throw new RequestFailedException("VM Server Port status is OFFLINE", msg.toString(), HttpStatus.PRECONDITION_FAILED_412,
-                                               server);
-
-                       /**
-                        * The port's status is changing because of some event or operation.
-                        * The final state is yet to be determined.
-                        */
-                       case "PENDING":
-                               msg = EELFResourceManager.format(Msg.SERVER_NETWORK_ERROR, server.getName(), port.getId());
-                               logger.error(msg);
-                               doFailure(rc, HttpStatus.PRECONDITION_FAILED_412, msg);
-                               throw new RequestFailedException("VM Server Port status is PENDING", msg.toString(), HttpStatus.PRECONDITION_FAILED_412,
-                                               server);
-
-                       /**
-                        * The port is in an unknown state and cannot be used.
-                        */
-                       case "UNKNOWN":
-                               msg = EELFResourceManager.format(Msg.SERVER_NETWORK_ERROR, server.getName(), port.getId());
-                               logger.error(msg);
-                               doFailure(rc, HttpStatus.PRECONDITION_FAILED_412, msg);
-                               throw new RequestFailedException("VM Server Port status is UNKNOWN", msg.toString(), HttpStatus.PRECONDITION_FAILED_412,
-                                               server);
-                       }
-
-               }
-               logger.info("Passed the VM Server the Hypervisor status checks..");
-
-       }
-    
-       /**
+    protected void checkVirtualMachineNetworkStatus(RequestContext rc, Server server, Context context)
+            throws ZoneException, RequestFailedException {
+
+        logger.info("Performing the VM Server networking status checks...");
+        List<Port> ports = server.getPorts();
+
+        NetworkService netSvc = context.getNetworkService();
+
+        String msg;
+        for (Port port : ports) {
+
+            switch (port.getPortState().toString().toUpperCase()) {
+                /**
+                 * The port is connected, configured, and usable for communication
+                 */
+                case "ONLINE":
+                    Network network = netSvc.getNetworkById(port.getNetwork());
+                    // Subnet subnet = netSvc.getSubnetById(port.getSubnetId());
+                    if (!network.getStatus().equals(Network.Status.ACTIVE.toString())) {
+                        msg = EELFResourceManager.format(Msg.SERVER_NETWORK_ERROR, server.getName(), port.getId());
+                        logger.error(msg);
+                        doFailure(rc, HttpStatus.PRECONDITION_FAILED_412, msg);
+                        throw new RequestFailedException("VM Server Network is DOWN", msg.toString(),
+                                HttpStatus.PRECONDITION_FAILED_412, server);
+                    }
+                    break;
+
+                /**
+                 * The port is disconnected or powered-off and cannot be used for communication
+                 */
+                case "OFFLINE":
+                    msg = EELFResourceManager.format(Msg.SERVER_NETWORK_ERROR, server.getName(), port.getId());
+                    logger.error(msg);
+                    doFailure(rc, HttpStatus.PRECONDITION_FAILED_412, msg);
+                    throw new RequestFailedException("VM Server Port status is OFFLINE", msg.toString(),
+                            HttpStatus.PRECONDITION_FAILED_412, server);
+
+                    /**
+                     * The port's status is changing because of some event or operation. The final state is yet to be
+                     * determined.
+                     */
+                case "PENDING":
+                    msg = EELFResourceManager.format(Msg.SERVER_NETWORK_ERROR, server.getName(), port.getId());
+                    logger.error(msg);
+                    doFailure(rc, HttpStatus.PRECONDITION_FAILED_412, msg);
+                    throw new RequestFailedException("VM Server Port status is PENDING", msg.toString(),
+                            HttpStatus.PRECONDITION_FAILED_412, server);
+
+                    /**
+                     * The port is in an unknown state and cannot be used.
+                     */
+                case "UNKNOWN":
+                    msg = EELFResourceManager.format(Msg.SERVER_NETWORK_ERROR, server.getName(), port.getId());
+                    logger.error(msg);
+                    doFailure(rc, HttpStatus.PRECONDITION_FAILED_412, msg);
+                    throw new RequestFailedException("VM Server Port status is UNKNOWN", msg.toString(),
+                            HttpStatus.PRECONDITION_FAILED_412, server);
+            }
+
+        }
+        logger.info("Passed the VM Server the Hypervisor status checks..");
+
+    }
+
+    /**
      * Checks if the VM is connected to the Virtual Network and reachable
      *
-     * @param server
-     *             The server object representing the server we want to operate on
+     * @param server The server object representing the server we want to operate on
      */
-       protected void checkHypervisor(Server server)
-                       throws ZoneException, RequestFailedException {
-
-               logger.info("Performing the Hypervisor status checks..");
-               
-               String msg = null;
-               if(server.getHypervisor() != null && server.getHypervisor().getStatus() != null && server.getHypervisor().getState() != null)
-               {
-                       String status = null, state = null;
-               
-                       status = server.getHypervisor().getStatus().toString();
-                       state = server.getHypervisor().getState().toString();
-               
-                       if (!status.equals(Hypervisor.Status.ENABLED.toString()) || !state.equals(Hypervisor.State.UP.toString())) 
-                       {
-                               msg = EELFResourceManager.format(Msg.HYPERVISOR_DOWN_ERROR, server.getHypervisor().getHostName(), server.getName());
-                               logger.error(msg.toString());
-               
-                               //doFailure(rc, HttpStatus.PRECONDITION_FAILED_412, msg);
-                               throw new RequestFailedException("Hypervisor status DOWN or NOT ENABLED", msg.toString(), HttpStatus.PRECONDITION_FAILED_412,
-                                       server);
-
-                       }
-               }
-               else
-               {
-                       msg = EELFResourceManager.format(Msg.HYPERVISOR_STATUS_UKNOWN, server.getName());
-                       logger.error(msg.toString());
-       
-                       throw new RequestFailedException("Unable to determine Hypervisor status", msg.toString(), HttpStatus.PRECONDITION_FAILED_412,
-                               server);
-               }
-               
-               logger.info("Passed the Hypervisor status checks..");
-               
-       }
-
-       /**
+    protected void checkHypervisor(Server server) throws ZoneException, RequestFailedException {
+
+        logger.info("Performing the Hypervisor status checks..");
+
+        String msg = null;
+        if (server.getHypervisor() != null && server.getHypervisor().getStatus() != null
+                && server.getHypervisor().getState() != null) {
+            String status = null, state = null;
+
+            status = server.getHypervisor().getStatus().toString();
+            state = server.getHypervisor().getState().toString();
+
+            if (!status.equals(Hypervisor.Status.ENABLED.toString()) || !state.equals(Hypervisor.State.UP.toString())) {
+                msg = EELFResourceManager.format(Msg.HYPERVISOR_DOWN_ERROR, server.getHypervisor().getHostName(),
+                        server.getName());
+                logger.error(msg.toString());
+
+                // doFailure(rc, HttpStatus.PRECONDITION_FAILED_412, msg);
+                throw new RequestFailedException("Hypervisor status DOWN or NOT ENABLED", msg.toString(),
+                        HttpStatus.PRECONDITION_FAILED_412, server);
+
+            }
+        } else {
+            msg = EELFResourceManager.format(Msg.HYPERVISOR_STATUS_UKNOWN, server.getName());
+            logger.error(msg.toString());
+
+            throw new RequestFailedException("Unable to determine Hypervisor status", msg.toString(),
+                    HttpStatus.PRECONDITION_FAILED_412, server);
+        }
+
+        logger.info("Passed the Hypervisor status checks..");
+
+    }
+
+    /**
      * Checks if a Host machine is reachable
      *
-     * @param ipAddress
-     *            IP Address of the Host Machine.
-     * @param server
-     *             The server object representing the Virtual Machine server
+     * @param ipAddress IP Address of the Host Machine.
+     * @param server The server object representing the Virtual Machine server
      * @return boolean
-     *            
+     * 
      */
-       /*private boolean isHostReachable(String ipAddress) throws IOException {
-               
-               InetAddress address = InetAddress.getByName(ipAddress);
-               
-               return address.isReachable(15000); 
-               
-
-       }*/
-    
+    /*
+     * private boolean isHostReachable(String ipAddress) throws IOException {
+     * 
+     * InetAddress address = InetAddress.getByName(ipAddress);
+     * 
+     * return address.isReachable(15000);
+     * 
+     * 
+     * }
+     */
+
 }
index 9579fec..fa59ffb 100644 (file)
@@ -45,13 +45,9 @@ import com.att.eelf.i18n.EELFResourceManager;
 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
 import com.woorea.openstack.base.client.OpenStackBaseException;
 import org.glassfish.grizzly.http.util.HttpStatus;
-
 import java.util.List;
 
-/**
- * @since September 29, 2016
- */
-public abstract class ProviderStackOperation extends ProviderOperation{
+public abstract class ProviderStackOperation extends ProviderOperation {
 
     private static final EELFLogger logger = EELFManager.getInstance().getLogger(ProviderStackOperation.class);
 
@@ -59,7 +55,8 @@ public abstract class ProviderStackOperation extends ProviderOperation{
     protected void trackRequest(Context context, AbstractService.State... states) {
         RequestState.clear();
 
-        if (null == states) return;
+        if (null == states)
+            return;
         for (AbstractService.State state : states) {
             RequestState.put(state.getName(), state.getValue());
         }
@@ -71,7 +68,7 @@ public abstract class ProviderStackOperation extends ProviderOperation{
             StackTraceElement element;
             for (; index < stack.length; index++) {
                 element = stack[index];
-                if ("trackRequest".equals(element.getMethodName())) {  //$NON-NLS-1$
+                if ("trackRequest".equals(element.getMethodName())) { //$NON-NLS-1$
                     break;
                 }
             }
@@ -90,7 +87,9 @@ public abstract class ProviderStackOperation extends ProviderOperation{
         }
     }
 
-/* Changed the 'pollInterval' type as long. Thread.sleep method needs 'long millis' as an argument */
+    /*
+     * Changed the 'pollInterval' type as long. Thread.sleep method needs 'long millis' as an argument
+     */
     private boolean checkStatus(String expectedStatus, long pollInterval, String actualStatus) {
         if (actualStatus.toUpperCase().equals(expectedStatus)) {
             return true;
@@ -112,8 +111,10 @@ public abstract class ProviderStackOperation extends ProviderOperation{
         while (System.currentTimeMillis() < maxTimeToWait) {
             String stackStatus = stackResource.show(stack.getName(), stack.getId()).execute().getStackStatus();
             logger.debug("Stack status : " + stackStatus);
-            if (stackStatus.toUpperCase().contains("FAILED")) return false;
-            if(checkStatus(expectedStatus, pollInterval, stackStatus)) return true;
+            if (stackStatus.toUpperCase().contains("FAILED"))
+                return false;
+            if (checkStatus(expectedStatus, pollInterval, stackStatus))
+                return true;
         }
         throw new TimeoutException("Timeout waiting for stack status change");
     }
@@ -158,11 +159,14 @@ public abstract class ProviderStackOperation extends ProviderOperation{
     }
 
 
-    protected boolean waitForStackStatus(RequestContext rc, Stack stack, Stack.Status expectedStatus) throws ZoneException, RequestFailedException {
+    protected boolean waitForStackStatus(RequestContext rc, Stack stack, Stack.Status expectedStatus)
+            throws ZoneException, RequestFailedException {
         SvcLogicContext ctx = rc.getSvcLogicContext();
         Context context = stack.getContext();
         StackService stackService = context.getStackService();
-/* Changed the 'pollInterval' type as long. Thread.sleep method needs 'long millis' as an argument */
+        /*
+         * Changed the 'pollInterval' type as long. Thread.sleep method needs 'long millis' as an argument
+         */
         long pollInterval = configuration.getIntegerProperty(Constants.PROPERTY_OPENSTACK_POLL_INTERVAL);
         int timeout = configuration.getIntegerProperty(Constants.PROPERTY_STACK_STATE_CHANGE_TIMEOUT);
         long maxTimeToWait = System.currentTimeMillis() + (long) timeout * 1000;
index ff3f95d..0446818 100644 (file)
@@ -26,7 +26,6 @@ package org.openecomp.appc.adapter.openstack.heat;
 
 import org.openecomp.appc.adapter.openstack.heat.model.CreateSnapshotParams;
 import org.openecomp.appc.adapter.openstack.heat.model.Snapshot;
-
 import com.woorea.openstack.base.client.Entity;
 import com.woorea.openstack.base.client.HttpMethod;
 import com.woorea.openstack.base.client.OpenStackClient;
@@ -55,19 +54,22 @@ public class SnapshotResource {
 
     public class CreateSnapshot extends OpenStackRequest<Snapshot> {
         public CreateSnapshot(String stackName, String stackID, CreateSnapshotParams params) {
-            super(client, HttpMethod.POST, "/stacks/" + stackName + "/" + stackID + "/snapshots", Entity.json(params), Snapshot.class);
+            super(client, HttpMethod.POST, "/stacks/" + stackName + "/" + stackID + "/snapshots", Entity.json(params),
+                    Snapshot.class);
         }
     }
 
     public class RestoreSnapshot extends OpenStackRequest<Void> {
         public RestoreSnapshot(String stackName, String stackID, String snapshotID) {
-            super(client, HttpMethod.POST, "/stacks/" + stackName + "/" + stackID + "/snapshots/" + snapshotID + "/restore", null, Void.class);
+            super(client, HttpMethod.POST,
+                    "/stacks/" + stackName + "/" + stackID + "/snapshots/" + snapshotID + "/restore", null, Void.class);
         }
     }
 
     public class ShowSnapshot extends OpenStackRequest<Snapshot> {
         public ShowSnapshot(String stackName, String stackID, String snapshotID) {
-            super(client, HttpMethod.GET, "/stacks/" + stackName + "/" + stackID + "/snapshots/" + snapshotID, null, Snapshot.class);
+            super(client, HttpMethod.GET, "/stacks/" + stackName + "/" + stackID + "/snapshots/" + snapshotID, null,
+                    Snapshot.class);
         }
     }
 }
index b9b7bcc..a559b04 100644 (file)
@@ -26,7 +26,6 @@ package org.openecomp.appc.adapter.openstack.heat;
 
 import org.openecomp.appc.adapter.openstack.heat.model.CreateSnapshotParams;
 import org.openecomp.appc.adapter.openstack.heat.model.Snapshot;
-
 import com.woorea.openstack.base.client.Entity;
 import com.woorea.openstack.base.client.HttpMethod;
 import com.woorea.openstack.base.client.OpenStackClient;
index 22c677c..4d8901c 100644 (file)
@@ -32,9 +32,7 @@ import org.apache.commons.lang.builder.ToStringBuilder;
 
 @JsonInclude(JsonInclude.Include.NON_NULL)
 @Generated("org.jsonschema2pojo")
-@JsonPropertyOrder({
-    "name"
-})
+@JsonPropertyOrder({"name"})
 public class CreateSnapshotParams {
 
     @JsonProperty("name")
@@ -42,8 +40,7 @@ public class CreateSnapshotParams {
 
     /**
      * 
-     * @return
-     *     The name
+     * @return The name
      */
     @JsonProperty("name")
     public String getName() {
@@ -52,8 +49,7 @@ public class CreateSnapshotParams {
 
     /**
      * 
-     * @param name
-     *     The name
+     * @param name The name
      */
     @JsonProperty("name")
     public void setName(String name) {
index c7aa5d2..3581818 100644 (file)
@@ -33,17 +33,8 @@ import org.apache.commons.lang.builder.ToStringBuilder;
 
 @JsonInclude(JsonInclude.Include.NON_NULL)
 @Generated("org.jsonschema2pojo")
-@JsonPropertyOrder({
-    "status",
-    "name",
-    "stack_user_project_id",
-    "environment",
-    "template",
-    "action",
-    "project_id",
-    "id",
-    "resources"
-})
+@JsonPropertyOrder({"status", "name", "stack_user_project_id", "environment", "template", "action", "project_id", "id",
+        "resources"})
 public class Data {
 
     @JsonProperty("status")
@@ -70,8 +61,7 @@ public class Data {
 
     /**
      * 
-     * @return
-     *     The status
+     * @return The status
      */
     @JsonProperty("status")
     public String getStatus() {
@@ -80,8 +70,7 @@ public class Data {
 
     /**
      * 
-     * @param status
-     *     The status
+     * @param status The status
      */
     @JsonProperty("status")
     public void setStatus(String status) {
@@ -90,8 +79,7 @@ public class Data {
 
     /**
      * 
-     * @return
-     *     The name
+     * @return The name
      */
     @JsonProperty("name")
     public String getName() {
@@ -100,8 +88,7 @@ public class Data {
 
     /**
      * 
-     * @param name
-     *     The name
+     * @param name The name
      */
     @JsonProperty("name")
     public void setName(String name) {
@@ -110,8 +97,7 @@ public class Data {
 
     /**
      * 
-     * @return
-     *     The stackUserProjectId
+     * @return The stackUserProjectId
      */
     @JsonProperty("stack_user_project_id")
     public String getStackUserProjectId() {
@@ -120,8 +106,7 @@ public class Data {
 
     /**
      * 
-     * @param stackUserProjectId
-     *     The stack_user_project_id
+     * @param stackUserProjectId The stack_user_project_id
      */
     @JsonProperty("stack_user_project_id")
     public void setStackUserProjectId(String stackUserProjectId) {
@@ -130,8 +115,7 @@ public class Data {
 
     /**
      * 
-     * @return
-     *     The environment
+     * @return The environment
      */
     @JsonProperty("environment")
     public Environment getEnvironment() {
@@ -140,8 +124,7 @@ public class Data {
 
     /**
      * 
-     * @param environment
-     *     The environment
+     * @param environment The environment
      */
     @JsonProperty("environment")
     public void setEnvironment(Environment environment) {
@@ -150,8 +133,7 @@ public class Data {
 
     /**
      * 
-     * @return
-     *     The template
+     * @return The template
      */
     @JsonProperty("template")
     public Template getTemplate() {
@@ -160,8 +142,7 @@ public class Data {
 
     /**
      * 
-     * @param template
-     *     The template
+     * @param template The template
      */
     @JsonProperty("template")
     public void setTemplate(Template template) {
@@ -170,8 +151,7 @@ public class Data {
 
     /**
      * 
-     * @return
-     *     The action
+     * @return The action
      */
     @JsonProperty("action")
     public String getAction() {
@@ -180,8 +160,7 @@ public class Data {
 
     /**
      * 
-     * @param action
-     *     The action
+     * @param action The action
      */
     @JsonProperty("action")
     public void setAction(String action) {
@@ -190,8 +169,7 @@ public class Data {
 
     /**
      * 
-     * @return
-     *     The projectId
+     * @return The projectId
      */
     @JsonProperty("project_id")
     public String getProjectId() {
@@ -200,8 +178,7 @@ public class Data {
 
     /**
      * 
-     * @param projectId
-     *     The project_id
+     * @param projectId The project_id
      */
     @JsonProperty("project_id")
     public void setProjectId(String projectId) {
@@ -210,8 +187,7 @@ public class Data {
 
     /**
      * 
-     * @return
-     *     The id
+     * @return The id
      */
     @JsonProperty("id")
     public String getId() {
@@ -220,8 +196,7 @@ public class Data {
 
     /**
      * 
-     * @param id
-     *     The id
+     * @param id The id
      */
     @JsonProperty("id")
     public void setId(String id) {
@@ -230,8 +205,7 @@ public class Data {
 
     /**
      * 
-     * @return
-     *     The resources
+     * @return The resources
      */
     @JsonProperty("resources")
     public Resources__ getResources() {
@@ -240,8 +214,7 @@ public class Data {
 
     /**
      * 
-     * @param resources
-     *     The resources
+     * @param resources The resources
      */
     @JsonProperty("resources")
     public void setResources(Resources__ resources) {
index ea16620..10adaed 100644 (file)
@@ -33,10 +33,7 @@ import org.apache.commons.lang.builder.ToStringBuilder;
 
 @JsonInclude(JsonInclude.Include.NON_NULL)
 @Generated("org.jsonschema2pojo")
-@JsonPropertyOrder({
-    "parameters",
-    "resource_registry"
-})
+@JsonPropertyOrder({"parameters", "resource_registry"})
 public class Environment {
 
     @JsonProperty("parameters")
@@ -48,8 +45,7 @@ public class Environment {
 
     /**
      * 
-     * @return
-     *     The parameters
+     * @return The parameters
      */
     @JsonProperty("parameters")
     public Parameters getParameters() {
@@ -58,8 +54,7 @@ public class Environment {
 
     /**
      * 
-     * @param parameters
-     *     The parameters
+     * @param parameters The parameters
      */
     @JsonProperty("parameters")
     public void setParameters(Parameters parameters) {
@@ -68,8 +63,7 @@ public class Environment {
 
     /**
      * 
-     * @return
-     *     The resourceRegistry
+     * @return The resourceRegistry
      */
     @JsonProperty("resource_registry")
     public ResourceRegistry getResourceRegistry() {
@@ -78,8 +72,7 @@ public class Environment {
 
     /**
      * 
-     * @param resourceRegistry
-     *     The resource_registry
+     * @param resourceRegistry The resource_registry
      */
     @JsonProperty("resource_registry")
     public void setResourceRegistry(ResourceRegistry resourceRegistry) {
index d04d241..3be9461 100644 (file)
@@ -32,9 +32,7 @@ import org.apache.commons.lang.builder.ToStringBuilder;
 
 @JsonInclude(JsonInclude.Include.NON_NULL)
 @Generated("org.jsonschema2pojo")
-@JsonPropertyOrder({
-    "size"
-})
+@JsonPropertyOrder({"size"})
 public class Properties {
 
     @JsonProperty("size")
@@ -42,8 +40,7 @@ public class Properties {
 
     /**
      * 
-     * @return
-     *     The size
+     * @return The size
      */
     @JsonProperty("size")
     public int getSize() {
@@ -52,8 +49,7 @@ public class Properties {
 
     /**
      * 
-     * @param size
-     *     The size
+     * @param size The size
      */
     @JsonProperty("size")
     public void setSize(int size) {
index 8df4d8b..8ac70e3 100644 (file)
@@ -32,9 +32,7 @@ import org.apache.commons.lang.builder.ToStringBuilder;
 
 @JsonInclude(JsonInclude.Include.NON_NULL)
 @Generated("org.jsonschema2pojo")
-@JsonPropertyOrder({
-    "backup_id"
-})
+@JsonPropertyOrder({"backup_id"})
 public class ResourceData {
 
     @JsonProperty("backup_id")
@@ -42,8 +40,7 @@ public class ResourceData {
 
     /**
      * 
-     * @return
-     *     The backupId
+     * @return The backupId
      */
     @JsonProperty("backup_id")
     public String getBackupId() {
@@ -52,8 +49,7 @@ public class ResourceData {
 
     /**
      * 
-     * @param backupId
-     *     The backup_id
+     * @param backupId The backup_id
      */
     @JsonProperty("backup_id")
     public void setBackupId(String backupId) {
index ad421b3..c214c41 100644 (file)
@@ -33,9 +33,7 @@ import org.apache.commons.lang.builder.ToStringBuilder;
 
 @JsonInclude(JsonInclude.Include.NON_NULL)
 @Generated("org.jsonschema2pojo")
-@JsonPropertyOrder({
-    "resources"
-})
+@JsonPropertyOrder({"resources"})
 public class ResourceRegistry {
 
     @JsonProperty("resources")
@@ -44,8 +42,7 @@ public class ResourceRegistry {
 
     /**
      * 
-     * @return
-     *     The resources
+     * @return The resources
      */
     @JsonProperty("resources")
     public Resources getResources() {
@@ -54,8 +51,7 @@ public class ResourceRegistry {
 
     /**
      * 
-     * @param resources
-     *     The resources
+     * @param resources The resources
      */
     @JsonProperty("resources")
     public void setResources(Resources resources) {
index 45f67c7..cbacd77 100644 (file)
@@ -33,9 +33,7 @@ import org.apache.commons.lang.builder.ToStringBuilder;
 
 @JsonInclude(JsonInclude.Include.NON_NULL)
 @Generated("org.jsonschema2pojo")
-@JsonPropertyOrder({
-    "volume"
-})
+@JsonPropertyOrder({"volume"})
 public class Resources_ {
 
     @JsonProperty("volume")
@@ -44,8 +42,7 @@ public class Resources_ {
 
     /**
      * 
-     * @return
-     *     The volume
+     * @return The volume
      */
     @JsonProperty("volume")
     public Volume getVolume() {
@@ -54,8 +51,7 @@ public class Resources_ {
 
     /**
      * 
-     * @param volume
-     *     The volume
+     * @param volume The volume
      */
     @JsonProperty("volume")
     public void setVolume(Volume volume) {
index 4b5cbc7..b389c2d 100644 (file)
@@ -33,9 +33,7 @@ import org.apache.commons.lang.builder.ToStringBuilder;
 
 @JsonInclude(JsonInclude.Include.NON_NULL)
 @Generated("org.jsonschema2pojo")
-@JsonPropertyOrder({
-    "volume"
-})
+@JsonPropertyOrder({"volume"})
 public class Resources__ {
 
     @JsonProperty("volume")
@@ -44,8 +42,7 @@ public class Resources__ {
 
     /**
      * 
-     * @return
-     *     The volume
+     * @return The volume
      */
     @JsonProperty("volume")
     public Volume_ getVolume() {
@@ -54,8 +51,7 @@ public class Resources__ {
 
     /**
      * 
-     * @param volume
-     *     The volume
+     * @param volume The volume
      */
     @JsonProperty("volume")
     public void setVolume(Volume_ volume) {
index 062ce1d..5480356 100644 (file)
@@ -33,14 +33,7 @@ import org.apache.commons.lang.builder.ToStringBuilder;
 
 @JsonInclude(JsonInclude.Include.NON_NULL)
 @Generated("org.jsonschema2pojo")
-@JsonPropertyOrder({
-    "id",
-    "name",
-    "status",
-    "status_reason",
-    "creation_time",
-    "data"
-})
+@JsonPropertyOrder({"id", "name", "status", "status_reason", "creation_time", "data"})
 public class Snapshot {
 
     @JsonProperty("id")
@@ -59,8 +52,7 @@ public class Snapshot {
 
     /**
      * 
-     * @return
-     *     The id
+     * @return The id
      */
     @JsonProperty("id")
     public String getId() {
@@ -69,8 +61,7 @@ public class Snapshot {
 
     /**
      * 
-     * @param id
-     *     The id
+     * @param id The id
      */
     @JsonProperty("id")
     public void setId(String id) {
@@ -79,8 +70,7 @@ public class Snapshot {
 
     /**
      * 
-     * @return
-     *     The name
+     * @return The name
      */
     @JsonProperty("name")
     public String getName() {
@@ -89,8 +79,7 @@ public class Snapshot {
 
     /**
      * 
-     * @param name
-     *     The name
+     * @param name The name
      */
     @JsonProperty("name")
     public void setName(String name) {
@@ -99,8 +88,7 @@ public class Snapshot {
 
     /**
      * 
-     * @return
-     *     The status
+     * @return The status
      */
     @JsonProperty("status")
     public String getStatus() {
@@ -109,8 +97,7 @@ public class Snapshot {
 
     /**
      * 
-     * @param status
-     *     The status
+     * @param status The status
      */
     @JsonProperty("status")
     public void setStatus(String status) {
@@ -119,8 +106,7 @@ public class Snapshot {
 
     /**
      * 
-     * @return
-     *     The statusReason
+     * @return The statusReason
      */
     @JsonProperty("status_reason")
     public String getStatusReason() {
@@ -129,8 +115,7 @@ public class Snapshot {
 
     /**
      * 
-     * @param statusReason
-     *     The status_reason
+     * @param statusReason The status_reason
      */
     @JsonProperty("status_reason")
     public void setStatusReason(String statusReason) {
@@ -139,8 +124,7 @@ public class Snapshot {
 
     /**
      * 
-     * @return
-     *     The creationTime
+     * @return The creationTime
      */
     @JsonProperty("creation_time")
     public String getCreationTime() {
@@ -149,8 +133,7 @@ public class Snapshot {
 
     /**
      * 
-     * @param creationTime
-     *     The creation_time
+     * @param creationTime The creation_time
      */
     @JsonProperty("creation_time")
     public void setCreationTime(String creationTime) {
@@ -159,8 +142,7 @@ public class Snapshot {
 
     /**
      * 
-     * @return
-     *     The data
+     * @return The data
      */
     @JsonProperty("data")
     public Data getData() {
@@ -169,8 +151,7 @@ public class Snapshot {
 
     /**
      * 
-     * @param data
-     *     The data
+     * @param data The data
      */
     @JsonProperty("data")
     public void setData(Data data) {
index 816a8d4..172072d 100644 (file)
@@ -33,9 +33,7 @@ import org.apache.commons.lang.builder.ToStringBuilder;
 
 @JsonInclude(JsonInclude.Include.NON_NULL)
 @Generated("org.jsonschema2pojo")
-@JsonPropertyOrder({
-    "snapshot"
-})
+@JsonPropertyOrder({"snapshot"})
 public class SnapshotDetails {
 
     @JsonProperty("snapshot")
@@ -44,8 +42,7 @@ public class SnapshotDetails {
 
     /**
      * 
-     * @return
-     *     The snapshot
+     * @return The snapshot
      */
     @JsonProperty("snapshot")
     public Snapshot getSnapshot() {
@@ -54,8 +51,7 @@ public class SnapshotDetails {
 
     /**
      * 
-     * @param snapshot
-     *     The snapshot
+     * @param snapshot The snapshot
      */
     @JsonProperty("snapshot")
     public void setSnapshot(Snapshot snapshot) {
index 6dae3bd..5e829ba 100644 (file)
@@ -32,11 +32,7 @@ import org.apache.commons.lang.builder.ToStringBuilder;
 
 @JsonInclude(JsonInclude.Include.NON_NULL)
 @Generated("org.jsonschema2pojo")
-@JsonPropertyOrder({
-    "code",
-    "message",
-    "title"
-})
+@JsonPropertyOrder({"code", "message", "title"})
 public class SnapshotRestoreResponse {
 
     @JsonProperty("code")
@@ -48,8 +44,7 @@ public class SnapshotRestoreResponse {
 
     /**
      * 
-     * @return
-     *     The code
+     * @return The code
      */
     @JsonProperty("code")
     public String getCode() {
@@ -58,8 +53,7 @@ public class SnapshotRestoreResponse {
 
     /**
      * 
-     * @param code
-     *     The code
+     * @param code The code
      */
     @JsonProperty("code")
     public void setCode(String code) {
@@ -68,8 +62,7 @@ public class SnapshotRestoreResponse {
 
     /**
      * 
-     * @return
-     *     The message
+     * @return The message
      */
     @JsonProperty("message")
     public String getMessage() {
@@ -78,8 +71,7 @@ public class SnapshotRestoreResponse {
 
     /**
      * 
-     * @param message
-     *     The message
+     * @param message The message
      */
     @JsonProperty("message")
     public void setMessage(String message) {
@@ -88,8 +80,7 @@ public class SnapshotRestoreResponse {
 
     /**
      * 
-     * @return
-     *     The title
+     * @return The title
      */
     @JsonProperty("title")
     public String getTitle() {
@@ -98,8 +89,7 @@ public class SnapshotRestoreResponse {
 
     /**
      * 
-     * @param title
-     *     The title
+     * @param title The title
      */
     @JsonProperty("title")
     public void setTitle(String title) {
index 08ab747..fd762dc 100644 (file)
@@ -33,10 +33,7 @@ import org.apache.commons.lang.builder.ToStringBuilder;
 
 @JsonInclude(JsonInclude.Include.NON_NULL)
 @Generated("org.jsonschema2pojo")
-@JsonPropertyOrder({
-    "heat_template_version",
-    "resources"
-})
+@JsonPropertyOrder({"heat_template_version", "resources"})
 public class Template {
 
     @JsonProperty("heat_template_version")
@@ -47,8 +44,7 @@ public class Template {
 
     /**
      * 
-     * @return
-     *     The heatTemplateVersion
+     * @return The heatTemplateVersion
      */
     @JsonProperty("heat_template_version")
     public String getHeatTemplateVersion() {
@@ -57,8 +53,7 @@ public class Template {
 
     /**
      * 
-     * @param heatTemplateVersion
-     *     The heat_template_version
+     * @param heatTemplateVersion The heat_template_version
      */
     @JsonProperty("heat_template_version")
     public void setHeatTemplateVersion(String heatTemplateVersion) {
@@ -67,8 +62,7 @@ public class Template {
 
     /**
      * 
-     * @return
-     *     The resources
+     * @return The resources
      */
     @JsonProperty("resources")
     public Resources_ getResources() {
@@ -77,8 +71,7 @@ public class Template {
 
     /**
      * 
-     * @param resources
-     *     The resources
+     * @param resources The resources
      */
     @JsonProperty("resources")
     public void setResources(Resources_ resources) {
index 9f34710..9173fe8 100644 (file)
@@ -33,10 +33,7 @@ import org.apache.commons.lang.builder.ToStringBuilder;
 
 @JsonInclude(JsonInclude.Include.NON_NULL)
 @Generated("org.jsonschema2pojo")
-@JsonPropertyOrder({
-    "type",
-    "properties"
-})
+@JsonPropertyOrder({"type", "properties"})
 public class Volume {
 
     @JsonProperty("type")
@@ -47,8 +44,7 @@ public class Volume {
 
     /**
      * 
-     * @return
-     *     The type
+     * @return The type
      */
     @JsonProperty("type")
     public String getType() {
@@ -57,8 +53,7 @@ public class Volume {
 
     /**
      * 
-     * @param type
-     *     The type
+     * @param type The type
      */
     @JsonProperty("type")
     public void setType(String type) {
@@ -67,8 +62,7 @@ public class Volume {
 
     /**
      * 
-     * @return
-     *     The properties
+     * @return The properties
      */
     @JsonProperty("properties")
     public Properties getProperties() {
@@ -77,8 +71,7 @@ public class Volume {
 
     /**
      * 
-     * @param properties
-     *     The properties
+     * @param properties The properties
      */
     @JsonProperty("properties")
     public void setProperties(Properties properties) {
index 9fd08b6..abad08f 100644 (file)
@@ -33,15 +33,7 @@ import org.apache.commons.lang.builder.ToStringBuilder;
 
 @JsonInclude(JsonInclude.Include.NON_NULL)
 @Generated("org.jsonschema2pojo")
-@JsonPropertyOrder({
-    "status",
-    "name",
-    "resource_data",
-    "resource_id",
-    "action",
-    "type",
-    "metadata"
-})
+@JsonPropertyOrder({"status", "name", "resource_data", "resource_id", "action", "type", "metadata"})
 public class Volume_ {
 
     @JsonProperty("status")
@@ -63,8 +55,7 @@ public class Volume_ {
 
     /**
      * 
-     * @return
-     *     The status
+     * @return The status
      */
     @JsonProperty("status")
     public String getStatus() {
@@ -73,8 +64,7 @@ public class Volume_ {
 
     /**
      * 
-     * @param status
-     *     The status
+     * @param status The status
      */
     @JsonProperty("status")
     public void setStatus(String status) {
@@ -83,8 +73,7 @@ public class Volume_ {
 
     /**
      * 
-     * @return
-     *     The name
+     * @return The name
      */
     @JsonProperty("name")
     public String getName() {
@@ -93,8 +82,7 @@ public class Volume_ {
 
     /**
      * 
-     * @param name
-     *     The name
+     * @param name The name
      */
     @JsonProperty("name")
     public void setName(String name) {
@@ -103,8 +91,7 @@ public class Volume_ {
 
     /**
      * 
-     * @return
-     *     The resourceData
+     * @return The resourceData
      */
     @JsonProperty("resource_data")
     public ResourceData getResourceData() {
@@ -113,8 +100,7 @@ public class Volume_ {
 
     /**
      * 
-     * @param resourceData
-     *     The resource_data
+     * @param resourceData The resource_data
      */
     @JsonProperty("resource_data")
     public void setResourceData(ResourceData resourceData) {
@@ -123,8 +109,7 @@ public class Volume_ {
 
     /**
      * 
-     * @return
-     *     The resourceId
+     * @return The resourceId
      */
     @JsonProperty("resource_id")
     public String getResourceId() {
@@ -133,8 +118,7 @@ public class Volume_ {
 
     /**
      * 
-     * @param resourceId
-     *     The resource_id
+     * @param resourceId The resource_id
      */
     @JsonProperty("resource_id")
     public void setResourceId(String resourceId) {
@@ -143,8 +127,7 @@ public class Volume_ {
 
     /**
      * 
-     * @return
-     *     The action
+     * @return The action
      */
     @JsonProperty("action")
     public String getAction() {
@@ -153,8 +136,7 @@ public class Volume_ {
 
     /**
      * 
-     * @param action
-     *     The action
+     * @param action The action
      */
     @JsonProperty("action")
     public void setAction(String action) {
@@ -163,8 +145,7 @@ public class Volume_ {
 
     /**
      * 
-     * @return
-     *     The type
+     * @return The type
      */
     @JsonProperty("type")
     public String getType() {
@@ -173,8 +154,7 @@ public class Volume_ {
 
     /**
      * 
-     * @param type
-     *     The type
+     * @param type The type
      */
     @JsonProperty("type")
     public void setType(String type) {
@@ -183,8 +163,7 @@ public class Volume_ {
 
     /**
      * 
-     * @return
-     *     The metadata
+     * @return The metadata
      */
     @JsonProperty("metadata")
     public Metadata getMetadata() {
@@ -193,8 +172,7 @@ public class Volume_ {
 
     /**
      * 
-     * @param metadata
-     *     The metadata
+     * @param metadata The metadata
      */
     @JsonProperty("metadata")
     public void setMetadata(Metadata metadata) {
index 1694529..d7dc2a8 100644 (file)
@@ -28,9 +28,7 @@ package org.openecomp.appc.adapter.iaas.impl;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
-
 import java.util.Properties;
-
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.openecomp.appc.adapter.iaas.impl.IdentityURL;
index 1e827b7..cbca170 100644 (file)
@@ -29,7 +29,6 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
-
 import java.io.IOException;
 import java.lang.reflect.Field;
 import java.util.HashMap;
@@ -37,7 +36,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
-
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Ignore;
@@ -61,7 +59,6 @@ import com.att.cdp.zones.model.Image;
 import com.att.cdp.zones.model.Server;
 import com.att.cdp.zones.model.Server.Status;
 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-
 import com.woorea.openstack.keystone.model.Access.Service.Endpoint;
 
 /**
@@ -100,15 +97,12 @@ public class TestProviderAdapterImpl {
     private ProviderAdapterImpl adapter;
 
     /**
-     * Use reflection to locate fields and methods so that they can be manipulated during the test to change the
-     * internal state accordingly.
+     * Use reflection to locate fields and methods so that they can be manipulated during the test
+     * to change the internal state accordingly.
      * 
-     * @throws NoSuchFieldException
-     *             if the field(s) dont exist
-     * @throws SecurityException
-     *             if reflective access is not allowed
-     * @throws NoSuchMethodException
-     *             If the method(s) dont exist
+     * @throws NoSuchFieldException if the field(s) dont exist
+     * @throws SecurityException if reflective access is not allowed
+     * @throws NoSuchMethodException If the method(s) dont exist
      */
     @SuppressWarnings("nls")
     @BeforeClass
@@ -135,16 +129,14 @@ public class TestProviderAdapterImpl {
     /**
      * Setup the test environment.
      * 
-     * @throws IllegalAccessException
-     *             if this Field object is enforcing Java language access control and the underlying field is either
-     *             inaccessible or final.
-     * @throws IllegalArgumentException
-     *             if the specified object is not an instance of the class or interface declaring the underlying field
-     *             (or a subclass or implementor thereof), or if an unwrapping conversion fails.
-     * @throws NullPointerException
-     *             if the specified object is null and the field is an instance field.
-     * @throws ExceptionInInitializerError
-     *             if the initialization provoked by this method fails.
+     * @throws IllegalAccessException if this Field object is enforcing Java language access control
+     *         and the underlying field is either inaccessible or final.
+     * @throws IllegalArgumentException if the specified object is not an instance of the class or
+     *         interface declaring the underlying field (or a subclass or implementor thereof), or
+     *         if an unwrapping conversion fails.
+     * @throws NullPointerException if the specified object is null and the field is an instance
+     *         field.
+     * @throws ExceptionInInitializerError if the initialization provoked by this method fails.
      */
     @Before
     public void setup() throws IllegalArgumentException, IllegalAccessException {
@@ -154,19 +146,16 @@ public class TestProviderAdapterImpl {
     }
 
     /**
-     * This method inspects the provider adapter implementation to make sure that the cache of providers and tenants, as
-     * well as the service catalog, and all pools of contexts have been set up correctly.
+     * This method inspects the provider adapter implementation to make sure that the cache of
+     * providers and tenants, as well as the service catalog, and all pools of contexts have been
+     * set up correctly.
      * 
-     * @throws IllegalAccessException
-     *             if this Field object is enforcing Java language access control and the underlying field is
-     *             inaccessible.
-     * @throws IllegalArgumentException
-     *             if the specified object is not an instance of the class or interface declaring the underlying field
-     *             (or a subclass or implementor thereof).
+     * @throws IllegalAccessException if this Field object is enforcing Java language access control
+     *         and the underlying field is inaccessible.
+     * @throws IllegalArgumentException if the specified object is not an instance of the class or
+     *         interface declaring the underlying field (or a subclass or implementor thereof).
      */
-    @SuppressWarnings({
-        "unchecked"
-    })
+    @SuppressWarnings({"unchecked"})
     @Ignore
     @Test
     public void validateCacheIsCreatedCorrectly() throws IllegalArgumentException, IllegalAccessException {
@@ -199,18 +188,18 @@ public class TestProviderAdapterImpl {
         assertNotNull(serviceTypes);
         assertEquals(12, serviceTypes.size());
 
-        assertEquals(TENANT_NAME, catalog.getTenantName());
-        assertEquals(TENANT_ID, catalog.getTenantId());
+        assertEquals(TENANT_NAME, catalog.getProjectName());
+        assertEquals(TENANT_ID, catalog.getProjectId());
 
         Set<String> regionNames = catalog.getRegions();
         assertNotNull(regionNames);
         assertEquals(1, regionNames.size());
         assertTrue(regionNames.contains(REGION_NAME));
 
-        List<Endpoint> endpoints = catalog.getEndpoints(ServiceCatalog.IDENTITY_SERVICE);
+        List<?> endpoints = catalog.getEndpoints(ServiceCatalog.IDENTITY_SERVICE);
         assertNotNull(endpoints);
         assertEquals(1, endpoints.size());
-        Endpoint endpoint = endpoints.get(0);
+        Endpoint endpoint = (Endpoint) endpoints.get(0);
         assertNotNull(endpoint);
         assertEquals(REGION_NAME, endpoint.getRegion());
         assertEquals(IDENTITY_URL, endpoint.getPublicURL());
@@ -218,28 +207,28 @@ public class TestProviderAdapterImpl {
         endpoints = catalog.getEndpoints(ServiceCatalog.COMPUTE_SERVICE);
         assertNotNull(endpoints);
         assertEquals(1, endpoints.size());
-        endpoint = endpoints.get(0);
+        endpoint = (Endpoint) endpoints.get(0);
         assertNotNull(endpoint);
         assertEquals(REGION_NAME, endpoint.getRegion());
 
         endpoints = catalog.getEndpoints(ServiceCatalog.VOLUME_SERVICE);
         assertNotNull(endpoints);
         assertEquals(1, endpoints.size());
-        endpoint = endpoints.get(0);
+        endpoint = (Endpoint) endpoints.get(0);
         assertNotNull(endpoint);
         assertEquals(REGION_NAME, endpoint.getRegion());
 
         endpoints = catalog.getEndpoints(ServiceCatalog.IMAGE_SERVICE);
         assertNotNull(endpoints);
         assertEquals(1, endpoints.size());
-        endpoint = endpoints.get(0);
+        endpoint = (Endpoint) endpoints.get(0);
         assertNotNull(endpoint);
         assertEquals(REGION_NAME, endpoint.getRegion());
 
         endpoints = catalog.getEndpoints(ServiceCatalog.NETWORK_SERVICE);
         assertNotNull(endpoints);
         assertEquals(1, endpoints.size());
-        endpoint = endpoints.get(0);
+        endpoint = (Endpoint) endpoints.get(0);
         assertNotNull(endpoint);
         assertEquals(REGION_NAME, endpoint.getRegion());
 
@@ -251,23 +240,21 @@ public class TestProviderAdapterImpl {
     }
 
     /**
-     * This test case is used to actually validate that a server has been restarted from an already running state
+     * This test case is used to actually validate that a server has been restarted from an already
+     * running state
      * 
-     * @throws ZoneException
-     *             If the login cannot be performed because the principal and/or credentials are invalid.
-     * @throws IllegalArgumentException
-     *             If the principal and/or credential are null or empty, or if the expected argument(s) are not defined
-     *             or are invalid
-     * @throws IllegalStateException
-     *             If the identity service is not available or cannot be created
-     * @throws IOException
-     *             if an I/O error occurs
-     * @throws APPCException 
+     * @throws ZoneException If the login cannot be performed because the principal and/or
+     *         credentials are invalid.
+     * @throws IllegalArgumentException If the principal and/or credential are null or empty, or if
+     *         the expected argument(s) are not defined or are invalid
+     * @throws IllegalStateException If the identity service is not available or cannot be created
+     * @throws IOException if an I/O error occurs
+     * @throws APPCException
      */
     // @Ignore
     @Test
     public void testRestartRunningServer()
-        throws IllegalStateException, IllegalArgumentException, ZoneException, IOException, APPCException {
+            throws IllegalStateException, IllegalArgumentException, ZoneException, IOException, APPCException {
         Properties properties = new Properties();
         properties.setProperty(ContextFactory.PROPERTY_IDENTITY_URL, IDENTITY_URL);
         properties.setProperty(ContextFactory.PROPERTY_REGION, REGION_NAME);
@@ -297,27 +284,24 @@ public class TestProviderAdapterImpl {
         }
     }
 
-    
+
     /****************************************/
     /**
-     * Tests that the vmStatuschecker method works and returns the correct status of the VM requested
+     * Tests that the vmStatuschecker method works and returns the correct status of the VM
+     * requested
      * 
-     * @throws ZoneException
-     *             If the login cannot be performed because the principal and/or credentials are invalid.
-     * @throws IllegalArgumentException
-     *             If the principal and/or credential are null or empty, or if the expected argument(s) are not defined
-     *             or are invalid
-     * @throws IllegalStateException
-     *             If the identity service is not available or cannot be created
-     * @throws IOException
-     *             if an I/O error occurs
-     * @throws UnknownProviderException
-     *             If the provider cannot be found
+     * @throws ZoneException If the login cannot be performed because the principal and/or
+     *         credentials are invalid.
+     * @throws IllegalArgumentException If the principal and/or credential are null or empty, or if
+     *         the expected argument(s) are not defined or are invalid
+     * @throws IllegalStateException If the identity service is not available or cannot be created
+     * @throws IOException if an I/O error occurs
+     * @throws UnknownProviderException If the provider cannot be found
      */
     // @Ignore
     @Test
     public void testVmStatuschecker() throws IllegalStateException, IllegalArgumentException, ZoneException,
-        UnknownProviderException, IOException {
+            UnknownProviderException, IOException {
         Properties properties = new Properties();
         properties.setProperty(ContextFactory.PROPERTY_IDENTITY_URL, IDENTITY_URL);
         properties.setProperty(ContextFactory.PROPERTY_REGION, REGION_NAME);
@@ -333,33 +317,32 @@ public class TestProviderAdapterImpl {
             Server server = computeService.getServer(vm.getServerId());
             if (!server.getStatus().equals(Status.RUNNING)) {
                 server.start();
-                assertTrue(waitForStateChange(server, Status.RUNNING));}
-            //or instead of the if-block, can ensureRunning(server) be used?
+                assertTrue(waitForStateChange(server, Status.RUNNING));
+            }
+            // or instead of the if-block, can ensureRunning(server) be used?
             ensureRunning(server);
             assertEquals(Server.Status.RUNNING, server.getStatus());
-        }   
+        }
     }
+
     /****************************************/
-    
-    
+
+
     /**
      * Tests that we can restart a server that is already stopped
      * 
-     * @throws ZoneException
-     *             If the login cannot be performed because the principal and/or credentials are invalid.
-     * @throws IllegalArgumentException
-     *             If the principal and/or credential are null or empty, or if the expected argument(s) are not defined
-     *             or are invalid.
-     * @throws IllegalStateException
-     *             If the identity service is not available or cannot be created
-     * @throws IOException
-     *             if an I/O error occurs
-     * @throws APPCException 
+     * @throws ZoneException If the login cannot be performed because the principal and/or
+     *         credentials are invalid.
+     * @throws IllegalArgumentException If the principal and/or credential are null or empty, or if
+     *         the expected argument(s) are not defined or are invalid.
+     * @throws IllegalStateException If the identity service is not available or cannot be created
+     * @throws IOException if an I/O error occurs
+     * @throws APPCException
      */
     // @Ignore
     @Test
     public void testRestartStoppedServer()
-        throws IllegalStateException, IllegalArgumentException, ZoneException, IOException, APPCException {
+            throws IllegalStateException, IllegalArgumentException, ZoneException, IOException, APPCException {
         Properties properties = new Properties();
         properties.setProperty(ContextFactory.PROPERTY_IDENTITY_URL, IDENTITY_URL);
         properties.setProperty(ContextFactory.PROPERTY_REGION, REGION_NAME);
@@ -392,24 +375,19 @@ public class TestProviderAdapterImpl {
     /**
      * Tests that we can rebuild a running server (not created from a bootable volume)
      * 
-     * @throws ZoneException
-     *             If the login cannot be performed because the principal and/or credentials are invalid.
-     * @throws IllegalArgumentException
-     *             If the principal and/or credential are null or empty, or if the expected argument(s) are not defined
-     *             or are invalid.
-     * @throws IllegalStateException
-     *             If the identity service is not available or cannot be created
-     * @throws UnknownProviderException
-     *             If the provider cannot be found
-     * @throws IOException
-     *             if an I/O error occurs
-     * @throws APPCException
-     *             If the server cannot be rebuilt for some reason
+     * @throws ZoneException If the login cannot be performed because the principal and/or
+     *         credentials are invalid.
+     * @throws IllegalArgumentException If the principal and/or credential are null or empty, or if
+     *         the expected argument(s) are not defined or are invalid.
+     * @throws IllegalStateException If the identity service is not available or cannot be created
+     * @throws UnknownProviderException If the provider cannot be found
+     * @throws IOException if an I/O error occurs
+     * @throws APPCException If the server cannot be rebuilt for some reason
      */
     // @Ignore
     @Test
     public void testRebuildRunningServer()
-        throws IOException, IllegalStateException, IllegalArgumentException, ZoneException, APPCException {
+            throws IOException, IllegalStateException, IllegalArgumentException, ZoneException, APPCException {
         Properties properties = new Properties();
         properties.setProperty(ContextFactory.PROPERTY_IDENTITY_URL, IDENTITY_URL);
         properties.setProperty(ContextFactory.PROPERTY_REGION, REGION_NAME);
@@ -438,24 +416,19 @@ public class TestProviderAdapterImpl {
     /**
      * Tests that we can rebuild a paused server (not created from a bootable volume)
      * 
-     * @throws ZoneException
-     *             If the login cannot be performed because the principal and/or credentials are invalid.
-     * @throws IllegalArgumentException
-     *             If the principal and/or credential are null or empty, or if the expected argument(s) are not defined
-     *             or are invalid.
-     * @throws IllegalStateException
-     *             If the identity service is not available or cannot be created
-     * @throws UnknownProviderException
-     *             If the provider cannot be found
-     * @throws IOException
-     *             if an I/O error occurs
-     * @throws APPCException
-     *             If the server cannot be rebuilt for some reason
+     * @throws ZoneException If the login cannot be performed because the principal and/or
+     *         credentials are invalid.
+     * @throws IllegalArgumentException If the principal and/or credential are null or empty, or if
+     *         the expected argument(s) are not defined or are invalid.
+     * @throws IllegalStateException If the identity service is not available or cannot be created
+     * @throws UnknownProviderException If the provider cannot be found
+     * @throws IOException if an I/O error occurs
+     * @throws APPCException If the server cannot be rebuilt for some reason
      */
     // @Ignore
     @Test
     public void testRebuildPausedServer()
-        throws IOException, IllegalStateException, IllegalArgumentException, ZoneException, APPCException {
+            throws IOException, IllegalStateException, IllegalArgumentException, ZoneException, APPCException {
         Properties properties = new Properties();
         properties.setProperty(ContextFactory.PROPERTY_IDENTITY_URL, IDENTITY_URL);
         properties.setProperty(ContextFactory.PROPERTY_REGION, REGION_NAME);
@@ -483,24 +456,19 @@ public class TestProviderAdapterImpl {
     /**
      * Tests that we can rebuild a paused server (not created from a bootable volume)
      * 
-     * @throws ZoneException
-     *             If the login cannot be performed because the principal and/or credentials are invalid.
-     * @throws IllegalArgumentException
-     *             If the principal and/or credential are null or empty, or if the expected argument(s) are not defined
-     *             or are invalid.
-     * @throws IllegalStateException
-     *             If the identity service is not available or cannot be created
-     * @throws UnknownProviderException
-     *             If the provider cannot be found
-     * @throws IOException
-     *             if an I/O error occurs
-     * @throws APPCException
-     *             If the server cannot be rebuilt for some reason
+     * @throws ZoneException If the login cannot be performed because the principal and/or
+     *         credentials are invalid.
+     * @throws IllegalArgumentException If the principal and/or credential are null or empty, or if
+     *         the expected argument(s) are not defined or are invalid.
+     * @throws IllegalStateException If the identity service is not available or cannot be created
+     * @throws UnknownProviderException If the provider cannot be found
+     * @throws IOException if an I/O error occurs
+     * @throws APPCException If the server cannot be rebuilt for some reason
      */
     // @Ignore
     @Test
     public void testRebuildSuspendedServer()
-        throws IOException, IllegalStateException, IllegalArgumentException, ZoneException, APPCException {
+            throws IOException, IllegalStateException, IllegalArgumentException, ZoneException, APPCException {
         Properties properties = new Properties();
         properties.setProperty(ContextFactory.PROPERTY_IDENTITY_URL, IDENTITY_URL);
         properties.setProperty(ContextFactory.PROPERTY_REGION, REGION_NAME);
@@ -528,24 +496,19 @@ public class TestProviderAdapterImpl {
     /**
      * Tests that we can rebuild a paused server (not created from a bootable volume)
      * 
-     * @throws ZoneException
-     *             If the login cannot be performed because the principal and/or credentials are invalid.
-     * @throws IllegalArgumentException
-     *             If the principal and/or credential are null or empty, or if the expected argument(s) are not defined
-     *             or are invalid.
-     * @throws IllegalStateException
-     *             If the identity service is not available or cannot be created
-     * @throws UnknownProviderException
-     *             If the provider cannot be found
-     * @throws IOException
-     *             if an I/O error occurs
-     * @throws APPCException
-     *             If the server cannot be rebuilt for some reason
+     * @throws ZoneException If the login cannot be performed because the principal and/or
+     *         credentials are invalid.
+     * @throws IllegalArgumentException If the principal and/or credential are null or empty, or if
+     *         the expected argument(s) are not defined or are invalid.
+     * @throws IllegalStateException If the identity service is not available or cannot be created
+     * @throws UnknownProviderException If the provider cannot be found
+     * @throws IOException if an I/O error occurs
+     * @throws APPCException If the server cannot be rebuilt for some reason
      */
     // @Ignore
     @Test
     public void testRebuildStoppedServer()
-        throws IOException, IllegalStateException, IllegalArgumentException, ZoneException, APPCException {
+            throws IOException, IllegalStateException, IllegalArgumentException, ZoneException, APPCException {
         Properties properties = new Properties();
         properties.setProperty(ContextFactory.PROPERTY_IDENTITY_URL, IDENTITY_URL);
         properties.setProperty(ContextFactory.PROPERTY_REGION, REGION_NAME);
@@ -571,98 +534,97 @@ public class TestProviderAdapterImpl {
     }
 
     /**
-     * Test subsequent action on second vm in different Tenant resulting in {"itemNotFound": {"message": "Instance could not be found", "code": 404}}
+     * Test subsequent action on second vm in different Tenant resulting in {"itemNotFound":
+     * {"message": "Instance could not be found", "code": 404}}
      * 
-     * @throws ZoneException
-     *             If the login cannot be performed because the principal and/or credentials are invalid.
-     * @throws IllegalArgumentException
-     *             If the principal and/or credential are null or empty, or if the expected argument(s) are not defined
-     *             or are invalid
-     * @throws IllegalStateException
-     *             If the identity service is not available or cannot be created
-     * @throws IOException
-     *             if an I/O error occurs
-     * @throws APPCException 
+     * @throws ZoneException If the login cannot be performed because the principal and/or
+     *         credentials are invalid.
+     * @throws IllegalArgumentException If the principal and/or credential are null or empty, or if
+     *         the expected argument(s) are not defined or are invalid
+     * @throws IllegalStateException If the identity service is not available or cannot be created
+     * @throws IOException if an I/O error occurs
+     * @throws APPCException
      */
 
     @Test
-    public void testTenantVerification() throws IllegalStateException, IllegalArgumentException, ZoneException,
-        IOException, APPCException {
-        
+    public void testTenantVerification()
+            throws IllegalStateException, IllegalArgumentException, ZoneException, IOException, APPCException {
+
         Properties properties = new Properties();
         properties.setProperty(ContextFactory.PROPERTY_IDENTITY_URL, "http://example.com:5000");
         properties.setProperty(ContextFactory.PROPERTY_TENANT, "APP-C");
         properties.setProperty(ContextFactory.PROPERTY_TRUSTED_HOSTS, "*");
 
         String vmUrl =
-            "http://192.168.1.2:8774/v2/abcde12345fghijk6789lmnopq123rst/servers/abc12345-1234-5678-890a-abcdefg12345";
-
-        //try (Context context = ContextFactory.getContext(PROVIDER_TYPE, properties)) {
-        //    context.login("AppC", "AppC");
-            
-            // call lookupServer on vm in defined tenant "APP-C_TLV"
-            VMURL vm = VMURL.parseURL(vmUrl);
-
-            Map<String, String> params = new HashMap<>();
-            params.put(ProviderAdapter.PROPERTY_INSTANCE_URL, vmUrl);
-            params.put(ProviderAdapter.PROPERTY_IDENTITY_URL, "http://example.com:5000/v2.0");
-            params.put(ProviderAdapter.PROPERTY_PROVIDER_NAME, "http://example.com:5000/v2.0");
-            SvcLogicContext svcContext = new SvcLogicContext();
-            
-            long start, end = 0;
-
-            System.out.println("\n--------------------Begin lookupServer on tenant 1--------------------");          
-            start = System.currentTimeMillis();
-            Server server = adapter.lookupServer(params, svcContext);
-            end = System.currentTimeMillis();
-            
-            System.out.println(String.format("lookupServer on tenant 1 took %ds", (end - start) / 1000));
-            System.out.println("----------------------------------------------------------------------\n");
-            assertNotNull(server);
-            
-            //repeat to show that context is reused for second request
-            System.out.println("\n-----------------Begin repeat lookupServer on tenant 1----------------");               
-            start = System.currentTimeMillis();
-            server = adapter.lookupServer(params, svcContext);
-            end = System.currentTimeMillis();
-            
-            System.out.println(String.format("Repeat lookupServer on tenant 1 took %ds", (end - start) / 1000));
-            System.out.println("----------------------------------------------------------------------\n");
-            assertNotNull(server);
-            
-            // call lookupServer on vm in second tenant "Play"
-            // This is where we would fail due to using the previous
-            // tenants context
-            vmUrl = "http://192.168.1.2:8774/v2/abcde12345fghijk6789lmnopq123rst/servers/abc12345-1234-5678-890a-abcdefg12345";
-            vm = VMURL.parseURL(vmUrl);
-            params.put(ProviderAdapter.PROPERTY_INSTANCE_URL, vmUrl);
-            
-            System.out.println("\n--------------------Begin lookupServer on tenant 2--------------------");
-            start = System.currentTimeMillis();
-            server = adapter.lookupServer(params, svcContext);
-            end = System.currentTimeMillis();
-            System.out.println(String.format("\nlookupServer on tenant 2 took %ds", (end - start) / 1000));
-            System.out.println("----------------------------------------------------------------------\n");
-            assertNotNull(server);
-            
-            // call lookupServer on vm in non-existing tenant
-            vmUrl = "http://192.168.1.2:8774/v2/abcde12345fghijk6789lmnopq123rst/servers/abc12345-1234-5678-890a-abcdefg12345";
-            vm = VMURL.parseURL(vmUrl);
-            params.put(ProviderAdapter.PROPERTY_INSTANCE_URL, vmUrl);
-            
-            System.out.println("\n--------------Begin lookupServer on non-existant tenant--------------");
-            start = System.currentTimeMillis();
-            server = adapter.lookupServer(params, svcContext);
-            end = System.currentTimeMillis();            
-            System.out.println(String.format("\nlookupServer on tenant 3 took %ds", (end - start) / 1000));
-            System.out.println("----------------------------------------------------------------------\n");
-            assertNull(server);
-            
-        //}
+                "http://192.168.1.2:8774/v2/abcde12345fghijk6789lmnopq123rst/servers/abc12345-1234-5678-890a-abcdefg12345";
+
+        // try (Context context = ContextFactory.getContext(PROVIDER_TYPE, properties)) {
+        // context.login("AppC", "AppC");
+
+        // call lookupServer on vm in defined tenant "APP-C_TLV"
+        VMURL vm = VMURL.parseURL(vmUrl);
+
+        Map<String, String> params = new HashMap<>();
+        params.put(ProviderAdapter.PROPERTY_INSTANCE_URL, vmUrl);
+        params.put(ProviderAdapter.PROPERTY_IDENTITY_URL, "http://example.com:5000/v2.0");
+        params.put(ProviderAdapter.PROPERTY_PROVIDER_NAME, "http://example.com:5000/v2.0");
+        SvcLogicContext svcContext = new SvcLogicContext();
+
+        long start, end = 0;
+
+        System.out.println("\n--------------------Begin lookupServer on tenant 1--------------------");
+        start = System.currentTimeMillis();
+        Server server = adapter.lookupServer(params, svcContext);
+        end = System.currentTimeMillis();
+
+        System.out.println(String.format("lookupServer on tenant 1 took %ds", (end - start) / 1000));
+        System.out.println("----------------------------------------------------------------------\n");
+        assertNotNull(server);
+
+        // repeat to show that context is reused for second request
+        System.out.println("\n-----------------Begin repeat lookupServer on tenant 1----------------");
+        start = System.currentTimeMillis();
+        server = adapter.lookupServer(params, svcContext);
+        end = System.currentTimeMillis();
+
+        System.out.println(String.format("Repeat lookupServer on tenant 1 took %ds", (end - start) / 1000));
+        System.out.println("----------------------------------------------------------------------\n");
+        assertNotNull(server);
+
+        // call lookupServer on vm in second tenant "Play"
+        // This is where we would fail due to using the previous
+        // tenants context
+        vmUrl = "http://192.168.1.2:8774/v2/abcde12345fghijk6789lmnopq123rst/servers/abc12345-1234-5678-890a-abcdefg12345";
+        vm = VMURL.parseURL(vmUrl);
+        params.put(ProviderAdapter.PROPERTY_INSTANCE_URL, vmUrl);
+
+        System.out.println("\n--------------------Begin lookupServer on tenant 2--------------------");
+        start = System.currentTimeMillis();
+        server = adapter.lookupServer(params, svcContext);
+        end = System.currentTimeMillis();
+        System.out.println(String.format("\nlookupServer on tenant 2 took %ds", (end - start) / 1000));
+        System.out.println("----------------------------------------------------------------------\n");
+        assertNotNull(server);
+
+        // call lookupServer on vm in non-existing tenant
+        vmUrl = "http://192.168.1.2:8774/v2/abcde12345fghijk6789lmnopq123rst/servers/abc12345-1234-5678-890a-abcdefg12345";
+        vm = VMURL.parseURL(vmUrl);
+        params.put(ProviderAdapter.PROPERTY_INSTANCE_URL, vmUrl);
+
+        System.out.println("\n--------------Begin lookupServer on non-existant tenant--------------");
+        start = System.currentTimeMillis();
+        server = adapter.lookupServer(params, svcContext);
+        end = System.currentTimeMillis();
+        System.out.println(String.format("\nlookupServer on tenant 3 took %ds", (end - start) / 1000));
+        System.out.println("----------------------------------------------------------------------\n");
+        assertNull(server);
+
+        // }
     }
+
     /****************************************/
 
-    
+
     @Test
     public void testSnapshotServer() throws Exception {
         Properties properties = new Properties();
@@ -672,7 +634,7 @@ public class TestProviderAdapterImpl {
         properties.setProperty(ContextFactory.PROPERTY_TRUSTED_HOSTS, "*");
 
         String vmUrl =
-            "http://192.168.1.2:8774/v2/abcde12345fghijk6789lmnopq123rst/servers/abc12345-1234-5678-890a-abcdefg12345";
+                "http://192.168.1.2:8774/v2/abcde12345fghijk6789lmnopq123rst/servers/abc12345-1234-5678-890a-abcdefg12345";
 
         try (Context context = ContextFactory.getContext(PROVIDER_TYPE, properties)) {
             context.login("AppC", "AppC");
@@ -704,10 +666,8 @@ public class TestProviderAdapterImpl {
     /**
      * Ensures that the server is in stopped (shutdown) state prior to test
      * 
-     * @param server
-     *            The server to ensure is stopped
-     * @throws ZoneException
-     *             If the server can't be operated upon for some reason
+     * @param server The server to ensure is stopped
+     * @throws ZoneException If the server can't be operated upon for some reason
      */
     @SuppressWarnings("nls")
     private static void ensureStopped(Server server) throws ZoneException {
@@ -717,7 +677,7 @@ public class TestProviderAdapterImpl {
 
             case PENDING:
                 waitForStateChange(server, Server.Status.READY, Server.Status.RUNNING, Server.Status.PAUSED,
-                    Server.Status.SUSPENDED, Server.Status.ERROR);
+                        Server.Status.SUSPENDED, Server.Status.ERROR);
                 ensureSuspended(server);
                 break;
 
@@ -750,10 +710,8 @@ public class TestProviderAdapterImpl {
     /**
      * Ensures that the server is in suspended state prior to test
      * 
-     * @param server
-     *            The server to ensure is suspended
-     * @throws ZoneException
-     *             If the server can't be operated upon for some reason
+     * @param server The server to ensure is suspended
+     * @throws ZoneException If the server can't be operated upon for some reason
      */
     @SuppressWarnings("nls")
     private static void ensureSuspended(Server server) throws ZoneException {
@@ -763,7 +721,7 @@ public class TestProviderAdapterImpl {
 
             case PENDING:
                 waitForStateChange(server, Server.Status.READY, Server.Status.RUNNING, Server.Status.PAUSED,
-                    Server.Status.SUSPENDED, Server.Status.ERROR);
+                        Server.Status.SUSPENDED, Server.Status.ERROR);
                 ensureSuspended(server);
                 break;
 
@@ -796,10 +754,8 @@ public class TestProviderAdapterImpl {
     /**
      * This method makes sure that the indicated server is running before performing a test
      * 
-     * @param server
-     *            The server to ensure is running
-     * @throws ZoneException
-     *             If the server can't be operated upon
+     * @param server The server to ensure is running
+     * @throws ZoneException If the server can't be operated upon
      */
     @SuppressWarnings("nls")
     private static void ensureRunning(Server server) throws ZoneException {
@@ -809,7 +765,7 @@ public class TestProviderAdapterImpl {
 
             case PENDING:
                 waitForStateChange(server, Server.Status.READY, Server.Status.RUNNING, Server.Status.PAUSED,
-                    Server.Status.SUSPENDED, Server.Status.ERROR);
+                        Server.Status.SUSPENDED, Server.Status.ERROR);
                 ensureRunning(server);
                 break;
 
@@ -838,10 +794,8 @@ public class TestProviderAdapterImpl {
     /**
      * This method will make sure that the server we are testing is paused
      * 
-     * @param server
-     *            The server to make sure is paused for the test
-     * @throws ZoneException
-     *             If anything fails
+     * @param server The server to make sure is paused for the test
+     * @throws ZoneException If anything fails
      */
     @SuppressWarnings("nls")
     private static void ensurePaused(Server server) throws ZoneException {
@@ -851,7 +805,7 @@ public class TestProviderAdapterImpl {
 
             case PENDING:
                 waitForStateChange(server, Server.Status.READY, Server.Status.RUNNING, Server.Status.PAUSED,
-                    Server.Status.SUSPENDED, Server.Status.ERROR);
+                        Server.Status.SUSPENDED, Server.Status.ERROR);
                 ensurePaused(server);
                 break;
 
@@ -882,23 +836,24 @@ public class TestProviderAdapterImpl {
     }
 
     /**
-     * Enter a pool-wait loop checking the server state to see if it has entered one of the desired states or not.
+     * Enter a pool-wait loop checking the server state to see if it has entered one of the desired
+     * states or not.
      * <p>
-     * This method checks the state of the server periodically for one of the desired states. When the server enters one
-     * of the desired states, the method returns a successful indication (true). If the server never enters one of the
-     * desired states within the alloted timeout period, then the method returns a failed response (false). No
-     * exceptions are thrown from this method.
+     * This method checks the state of the server periodically for one of the desired states. When
+     * the server enters one of the desired states, the method returns a successful indication
+     * (true). If the server never enters one of the desired states within the alloted timeout
+     * period, then the method returns a failed response (false). No exceptions are thrown from this
+     * method.
      * </p>
      * 
-     * @param server
-     *            The server to wait on
-     * @param desiredStates
-     *            A variable list of desired states, any one of which is allowed.
-     * @return True if the server entered one of the desired states, and false if not and the wait loop timed out.
+     * @param server The server to wait on
+     * @param desiredStates A variable list of desired states, any one of which is allowed.
+     * @return True if the server entered one of the desired states, and false if not and the wait
+     *         loop timed out.
      */
     private static boolean waitForStateChange(Server server, Server.Status... desiredStates) {
-        int timeout =
-            ConfigurationFactory.getConfiguration().getIntegerProperty(Constants.PROPERTY_SERVER_STATE_CHANGE_TIMEOUT);
+        int timeout = ConfigurationFactory.getConfiguration()
+                .getIntegerProperty(Constants.PROPERTY_SERVER_STATE_CHANGE_TIMEOUT);
         long limit = System.currentTimeMillis() + (timeout * 1000);
         Server vm = server;
 
@@ -925,20 +880,22 @@ public class TestProviderAdapterImpl {
     }
 
     /*
-     * @Test public void testTerminateStack() throws IllegalStateException, IllegalArgumentException, ZoneException,
-     * UnknownProviderException, IOException { Properties properties = new Properties();
-     * properties.setProperty(ContextFactory.PROPERTY_IDENTITY_URL, IDENTITY_URL);
-     * properties.setProperty(ContextFactory.PROPERTY_REGION, REGION_NAME);
+     * @Test public void testTerminateStack() throws IllegalStateException,
+     * IllegalArgumentException, ZoneException, UnknownProviderException, IOException { Properties
+     * properties = new Properties(); properties.setProperty(ContextFactory.PROPERTY_IDENTITY_URL,
+     * IDENTITY_URL); properties.setProperty(ContextFactory.PROPERTY_REGION, REGION_NAME);
      * properties.setProperty(ContextFactory.PROPERTY_TENANT, TENANT_NAME);
      * properties.setProperty(ContextFactory.PROPERTY_TRUSTED_HOSTS, "*");
      * properties.setProperty(ContextFactory.PROPERTY_DISABLE_PROXY, "true"); try (Context context =
-     * ContextFactory.getContext(PROVIDER_TYPE, properties)) { context.login(PRINCIPAL, CREDENTIAL); VMURL vm =
-     * VMURL.parseURL(SERVER_URL); ComputeService computeService = context.getComputeService(); Server server =
-     * computeService.getServer(vm.getServerId()); if (!server.getStatus().equals(Status.RUNNING)) { server.start();
-     * assertTrue(waitForStateChange(server, Status.RUNNING)); } Map<String, String> params = new HashMap<>();
-     * params.put(ProviderAdapter.PROPERTY_INSTANCE_URL, SERVER_URL); params.put(ProviderAdapter.PROPERTY_PROVIDER_NAME,
-     * PROVIDER_NAME); SvcLogicContext svcContext = new SvcLogicContext(); Stack stack = adapter.terminateStack(params,
-     * svcContext); assertNotNull(stack); } }
+     * ContextFactory.getContext(PROVIDER_TYPE, properties)) { context.login(PRINCIPAL, CREDENTIAL);
+     * VMURL vm = VMURL.parseURL(SERVER_URL); ComputeService computeService =
+     * context.getComputeService(); Server server = computeService.getServer(vm.getServerId()); if
+     * (!server.getStatus().equals(Status.RUNNING)) { server.start();
+     * assertTrue(waitForStateChange(server, Status.RUNNING)); } Map<String, String> params = new
+     * HashMap<>(); params.put(ProviderAdapter.PROPERTY_INSTANCE_URL, SERVER_URL);
+     * params.put(ProviderAdapter.PROPERTY_PROVIDER_NAME, PROVIDER_NAME); SvcLogicContext svcContext
+     * = new SvcLogicContext(); Stack stack = adapter.terminateStack(params, svcContext);
+     * assertNotNull(stack); } }
      */
 
 }
index a954a70..56c67dd 100644 (file)
@@ -26,7 +26,6 @@ package org.openecomp.appc.adapter.iaas.impl;
 
 import java.lang.reflect.Field;
 import java.util.Map;
-
 import org.openecomp.appc.adapter.iaas.provider.operation.impl.base.ProviderOperation;
 import org.openecomp.appc.exceptions.APPCException;
 import com.att.cdp.zones.model.ModelObject;
@@ -34,21 +33,19 @@ import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.slf4j.MDC;
-
 import org.openecomp.appc.configuration.ConfigurationFactory;
 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-
 import static org.openecomp.appc.adapter.iaas.provider.operation.common.constants.Constants.MDC_SERVICE;
 
 /**
- * This class is used to test methods and functions of the adapter implementation that do not require and do not set up
- * connections to any providers.
+ * This class is used to test methods and functions of the adapter implementation that do not
+ * require and do not set up connections to any providers.
  *
  * @since Jan 20, 2016
  * @version $Id$
  */
 
-public class TestProviderOperation extends ProviderOperation{
+public class TestProviderOperation extends ProviderOperation {
 
     private static Class<?> providerAdapterImplClass;
     private static Class<?> configurationFactoryClass;
@@ -56,15 +53,12 @@ public class TestProviderOperation extends ProviderOperation{
     private static Field configField;
 
     /**
-     * Use reflection to locate fields and methods so that they can be manipulated during the test to change the
-     * internal state accordingly.
+     * Use reflection to locate fields and methods so that they can be manipulated during the test
+     * to change the internal state accordingly.
      *
-     * @throws NoSuchFieldException
-     *             if the field(s) dont exist
-     * @throws SecurityException
-     *             if reflective access is not allowed
-     * @throws NoSuchMethodException
-     *             If the method(s) dont exist
+     * @throws NoSuchFieldException if the field(s) dont exist
+     * @throws SecurityException if reflective access is not allowed
+     * @throws NoSuchMethodException If the method(s) dont exist
      */
     @SuppressWarnings("nls")
     @BeforeClass
@@ -82,8 +76,7 @@ public class TestProviderOperation extends ProviderOperation{
     /**
      * This test expects a failure because the value to be validated is a null URL
      *
-     * @throws RequestFailedException
-     *             Expected
+     * @throws RequestFailedException Expected
      */
     @SuppressWarnings("nls")
     @Test(expected = RequestFailedException.class)
@@ -99,8 +92,7 @@ public class TestProviderOperation extends ProviderOperation{
     /**
      * This test expects a failure because the value to be validated is an empty URL
      *
-     * @throws RequestFailedException
-     *             Expected
+     * @throws RequestFailedException Expected
      */
     @SuppressWarnings("nls")
     @Test(expected = RequestFailedException.class)
@@ -116,8 +108,7 @@ public class TestProviderOperation extends ProviderOperation{
     /**
      * This test expects a failure because the value to be validated is a blank URL
      *
-     * @throws RequestFailedException
-     *             Expected
+     * @throws RequestFailedException Expected
      */
     @SuppressWarnings("nls")
     @Test(expected = RequestFailedException.class)
@@ -133,8 +124,7 @@ public class TestProviderOperation extends ProviderOperation{
     /**
      * This test expects a failure because the value to be validated is a bad URL
      *
-     * @throws RequestFailedException
-     *             Expected
+     * @throws RequestFailedException Expected
      */
     @SuppressWarnings("nls")
     @Test(expected = RequestFailedException.class)
@@ -150,8 +140,7 @@ public class TestProviderOperation extends ProviderOperation{
     /**
      * This test expects to pass
      *
-     * @throws RequestFailedException
-     *             Un-Expected
+     * @throws RequestFailedException Un-Expected
      */
     @SuppressWarnings("nls")
     @Test
@@ -160,13 +149,14 @@ public class TestProviderOperation extends ProviderOperation{
         SvcLogicContext svcContext = new SvcLogicContext();
         RequestContext rc = new RequestContext(svcContext);
         String link =
-            "http://some.host:1234/v2/01d82c08594a4b23a0f9260c94be0c4d/servers/f888f89f-096b-421e-ba36-34f714071551";
+                "http://some.host:1234/v2/01d82c08594a4b23a0f9260c94be0c4d/servers/f888f89f-096b-421e-ba36-34f714071551";
 
         validateVMURL(VMURL.parseURL(link));
     }
 
     @Override
-    protected ModelObject executeProviderOperation(Map<String, String> params, SvcLogicContext context) throws APPCException {
+    protected ModelObject executeProviderOperation(Map<String, String> params, SvcLogicContext context)
+            throws APPCException {
         return null;
     }
 }
index 1c67e2d..efb40df 100644 (file)
@@ -26,7 +26,6 @@
 package org.openecomp.appc.adapter.iaas.impl;
 
 import static org.junit.Assert.*;
-
 import org.junit.Before;
 import org.junit.Test;
 import org.openecomp.appc.Constants;
@@ -37,7 +36,8 @@ import org.openecomp.appc.configuration.ConfigurationFactory;
 /**
  * Test the RequestContext object
  * <p>
- * The request context is used to track retries, recovery attempts, and time to live of the processing of a request.
+ * The request context is used to track retries, recovery attempts, and time to live of the
+ * processing of a request.
  * </p>
  */
 
@@ -47,8 +47,8 @@ public class TestRequestContext {
     private Configuration config = ConfigurationFactory.getConfiguration();
 
     /**
-     * Set up the test environment by forcing the retry delay and limit to small values for the test and setting up the
-     * request context object.
+     * Set up the test environment by forcing the retry delay and limit to small values for the test
+     * and setting up the request context object.
      */
     @Before
     public void setup() {
@@ -95,8 +95,8 @@ public class TestRequestContext {
     }
 
     /**
-     * The RequestContext tracks the number of retry attempts against the limit. This test verifies that tracking logic
-     * works correctly.
+     * The RequestContext tracks the number of retry attempts against the limit. This test verifies
+     * that tracking logic works correctly.
      */
     @Test
     public void testCanRetry() {
@@ -116,10 +116,10 @@ public class TestRequestContext {
     }
 
     /**
-     * The same RequestContext is used throughout the processing, and retries need to be reset once successfully
-     * connected so that any earlier (successful) recoveries are not considered when performing any new future
-     * recoveries. This test ensures that a reset clears the retry counter and that we can attempt retries again up to
-     * the limit.
+     * The same RequestContext is used throughout the processing, and retries need to be reset once
+     * successfully connected so that any earlier (successful) recoveries are not considered when
+     * performing any new future recoveries. This test ensures that a reset clears the retry counter
+     * and that we can attempt retries again up to the limit.
      */
     @Test
     public void testResetAndCanRetry() {
@@ -137,10 +137,10 @@ public class TestRequestContext {
     }
 
     /**
-     * This test is used to test tracking of time to live for the request context. Because time is inexact, the
-     * assertions can only be ranges of values, such as at least some value or greater. The total duration tracking in
-     * the request context is only updated on each call to {@link RequestContext#isAlive()}. Also, durations are NOT
-     * affected by calls to reset.
+     * This test is used to test tracking of time to live for the request context. Because time is
+     * inexact, the assertions can only be ranges of values, such as at least some value or greater.
+     * The total duration tracking in the request context is only updated on each call to
+     * {@link RequestContext#isAlive()}. Also, durations are NOT affected by calls to reset.
      */
     @Test
     public void testTimeToLive() {
index 7dbe374..be769a0 100644 (file)
@@ -30,28 +30,27 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
-
+import java.util.HashSet;
 import java.util.List;
 import java.util.Properties;
-
+import java.util.Set;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Ignore;
 import org.junit.Test;
-import org.openecomp.appc.adapter.iaas.impl.ServiceCatalog;
+import org.mockito.Mockito;
 import org.openecomp.appc.configuration.ConfigurationFactory;
 import com.att.cdp.exceptions.ZoneException;
-
 import com.woorea.openstack.keystone.model.Access.Service;
 
 /**
  * This class tests the service catalog against a known provider.
  */
-@Ignore
 public class TestServiceCatalog {
 
     // Number
-    private static int EXPECTED_REGIONS = 1;
+    private static int EXPECTED_REGIONS = 2;
     private static int EXPECTED_ENDPOINTS = 1;
 
     private static String PRINCIPAL;
@@ -72,12 +71,11 @@ public class TestServiceCatalog {
         PRINCIPAL = props.getProperty("provider1.tenant1.userid", "appc");
         CREDENTIAL = props.getProperty("provider1.tenant1.password", "appc");
         TENANT_NAME = props.getProperty("provider1.tenant1.name", "appc");
-        TENANT_ID =
-            props.getProperty("provider1.tenant1.id",
+        TENANT_ID = props.getProperty("provider1.tenant1.id",
                 props.getProperty("test.tenantid", "abcde12345fghijk6789lmnopq123rst"));
         REGION_NAME = props.getProperty("provider1.tenant1.region", "RegionOne");
 
-        EXPECTED_REGIONS = Integer.valueOf(props.getProperty("test.expected-regions", "0"));
+        EXPECTED_REGIONS = Integer.valueOf(props.getProperty("test.expected-regions", "2"));
         EXPECTED_ENDPOINTS = Integer.valueOf(props.getProperty("test.expected-endpoints", "0"));
     }
 
@@ -89,16 +87,12 @@ public class TestServiceCatalog {
     @Before
     public void setup() throws ZoneException {
         properties = new Properties();
-        catalog = new ServiceCatalog(IDENTITY_URL, TENANT_NAME, PRINCIPAL, CREDENTIAL, properties);
-    }
+        catalog = Mockito.mock(ServiceCatalog.class, Mockito.CALLS_REAL_METHODS);
+        catalog.rwLock = new ReentrantReadWriteLock();
 
-    /**
-     * Test that the tenant name and ID are returned correctly
-     */
-    @Test
-    public void testKnownTenant() {
-        assertEquals(TENANT_NAME, catalog.getTenantName());
-        assertEquals(TENANT_ID, catalog.getTenantId());
+        Set<String> testdata = new HashSet<>();
+        testdata.add("RegionOne");
+        catalog.regions = testdata;
     }
 
     /**
@@ -107,44 +101,5 @@ public class TestServiceCatalog {
     @Test
     public void testKnownRegions() {
         assertEquals(EXPECTED_REGIONS, catalog.getRegions().size());
-        // assertEquals(REGION_NAME, catalog.getRegions().toArray()[0]);
-    }
-
-    /**
-     * Test that we can check for published services correctly
-     */
-    @Test
-    public void testServiceTypesPublished() {
-        assertTrue(catalog.isServicePublished("compute"));
-        assertFalse(catalog.isServicePublished("bogus"));
-    }
-
-    /**
-     * Check that we can get the list of published services
-     */
-    @Test
-    public void testPublishedServicesList() {
-        List<String> services = catalog.getServiceTypes();
-
-        assertTrue(services.contains(ServiceCatalog.COMPUTE_SERVICE));
-        assertTrue(services.contains(ServiceCatalog.IDENTITY_SERVICE));
-        assertTrue(services.contains(ServiceCatalog.IMAGE_SERVICE));
-        assertTrue(services.contains(ServiceCatalog.NETWORK_SERVICE));
-        assertTrue(services.contains(ServiceCatalog.VOLUME_SERVICE));
-    }
-
-    /**
-     * Test that we can get the endpoint(s) for a service
-     */
-    @Test
-    public void testEndpointList() {
-        List<Service.Endpoint> endpoints = catalog.getEndpoints(ServiceCatalog.COMPUTE_SERVICE);
-
-        assertNotNull(endpoints);
-        assertFalse(endpoints.isEmpty());
-        assertEquals(EXPECTED_ENDPOINTS, endpoints.size());
-
-        Service.Endpoint endpoint = endpoints.get(0);
-        // assertEquals(REGION_NAME, endpoint.getRegion());
     }
 }
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestServiceCatalogFactory.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestServiceCatalogFactory.java
new file mode 100644 (file)
index 0000000..e97e64d
--- /dev/null
@@ -0,0 +1,89 @@
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP : APPC\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Copyright (C) 2017 Amdocs\r
+ * =============================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * \r
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package org.openecomp.appc.adapter.iaas.impl;\r
+\r
+import java.util.Properties;\r
+import org.junit.Assert;\r
+import org.junit.Test;\r
+\r
+public class TestServiceCatalogFactory {\r
+\r
+    @Test\r
+    public void testGetServiceCatalogV2() {\r
+        String tenantIdentifier = null;\r
+        String principal = null;\r
+        String credential = null;\r
+        String domain = null;\r
+        Properties properties = null;\r
+\r
+        String url = "http://192.168.1.1:5000/v2.0/";\r
+        ServiceCatalog catalog = ServiceCatalogFactory.getServiceCatalog(url, tenantIdentifier, principal, credential,\r
+                domain, properties);\r
+        Assert.assertNotNull(catalog);\r
+        Assert.assertEquals(catalog.getClass(), ServiceCatalogV2.class);\r
+\r
+        url = "http://192.168.1.1:5000/v2/";\r
+        catalog = ServiceCatalogFactory.getServiceCatalog(url, tenantIdentifier, principal, credential, domain,\r
+                properties);\r
+        Assert.assertNotNull(catalog);\r
+        Assert.assertEquals(catalog.getClass(), ServiceCatalogV2.class);\r
+\r
+        url = "http://192.168.1.1:5000/v2.1/";\r
+        catalog = ServiceCatalogFactory.getServiceCatalog(url, tenantIdentifier, principal, credential, domain,\r
+                properties);\r
+        Assert.assertNotNull(catalog);\r
+        Assert.assertEquals(catalog.getClass(), ServiceCatalogV2.class);\r
+\r
+    }\r
+\r
+    @Test\r
+    public void testGetServiceCatalogV3() {\r
+        String url = "http://192.168.1.1:5000/v3.0/";\r
+        String tenantIdentifier = null;\r
+        String principal = null;\r
+        String credential = null;\r
+        String domain = null;\r
+        Properties properties = null;\r
+        ServiceCatalog catalog = ServiceCatalogFactory.getServiceCatalog(url, tenantIdentifier, principal, credential,\r
+                domain, properties);\r
+\r
+        Assert.assertNotNull(catalog);\r
+        Assert.assertEquals(catalog.getClass(), ServiceCatalogV3.class);\r
+    }\r
+\r
+    @Test\r
+    public void testGetServiceCatalogOther() {\r
+        String url = "http://192.168.1.1:5000/v4.0/";\r
+        String tenantIdentifier = null;\r
+        String principal = null;\r
+        String credential = null;\r
+        String domain = null;\r
+        Properties properties = null;\r
+        ServiceCatalog catalog = ServiceCatalogFactory.getServiceCatalog(url, tenantIdentifier, principal, credential,\r
+                domain, properties);\r
+\r
+        Assert.assertNull(catalog);\r
+    }\r
+}\r
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestServiceCatalogV2.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestServiceCatalogV2.java
new file mode 100644 (file)
index 0000000..c26b3be
--- /dev/null
@@ -0,0 +1,174 @@
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP : APPC\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Copyright (C) 2017 Amdocs\r
+ * =============================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * \r
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package org.openecomp.appc.adapter.iaas.impl;\r
+\r
+import static org.junit.Assert.assertEquals;\r
+import static org.junit.Assert.assertFalse;\r
+import static org.junit.Assert.assertNotNull;\r
+import static org.junit.Assert.assertTrue;\r
+import com.att.cdp.exceptions.ZoneException;\r
+import com.woorea.openstack.keystone.model.Access.Service;\r
+import java.util.List;\r
+import java.util.Properties;\r
+import org.junit.Before;\r
+import org.junit.BeforeClass;\r
+import org.junit.Ignore;\r
+import org.junit.Test;\r
+import org.openecomp.appc.configuration.ConfigurationFactory;\r
+\r
+/**\r
+ * This class tests the service catalog against a known provider.\r
+ */\r
+@Ignore\r
+public class TestServiceCatalogV2 {\r
+\r
+    // Number\r
+    private static int EXPECTED_REGIONS = 1;\r
+    private static int EXPECTED_ENDPOINTS = 1;\r
+\r
+    private static String PRINCIPAL;\r
+    private static String CREDENTIAL;\r
+    private static String TENANT_NAME;\r
+    private static String TENANT_ID;\r
+    private static String IDENTITY_URL;\r
+    private static String REGION_NAME;\r
+\r
+    private ServiceCatalogV2 catalog;\r
+\r
+    private Properties properties;\r
+\r
+    @BeforeClass\r
+    public static void before() {\r
+        Properties props = ConfigurationFactory.getConfiguration().getProperties();\r
+        IDENTITY_URL = props.getProperty("provider1.identity", "appc");\r
+        PRINCIPAL = props.getProperty("provider1.tenant1.userid", "appc");\r
+        CREDENTIAL = props.getProperty("provider1.tenant1.password", "appc");\r
+        TENANT_NAME = props.getProperty("provider1.tenant1.name", "appc");\r
+        TENANT_ID = props.getProperty("provider1.tenant1.id",\r
+                props.getProperty("test.tenantid", "abcde12345fghijk6789lmnopq123rst"));\r
+        REGION_NAME = props.getProperty("provider1.tenant1.region", "RegionOne");\r
+\r
+        EXPECTED_REGIONS = Integer.valueOf(props.getProperty("test.expected-regions", "0"));\r
+        EXPECTED_ENDPOINTS = Integer.valueOf(props.getProperty("test.expected-endpoints", "0"));\r
+    }\r
+\r
+    /**\r
+     * Setup the test environment by loading a new service catalog for each test\r
+     * \r
+     * @throws ZoneException\r
+     */\r
+    @Before\r
+    public void setup() throws ZoneException {\r
+        properties = new Properties();\r
+        catalog = new ServiceCatalogV2(IDENTITY_URL, TENANT_NAME, PRINCIPAL, CREDENTIAL, properties);\r
+        catalog.init();\r
+    }\r
+\r
+    /**\r
+     * Test that the tenant name and ID are returned correctly\r
+     */\r
+    @Test\r
+    public void testKnownTenant() {\r
+        assertEquals(TENANT_NAME, catalog.getProjectName());\r
+        assertEquals(TENANT_ID, catalog.getProjectId());\r
+    }\r
+\r
+    /**\r
+     * Test that we find all of the expected region(s)\r
+     */\r
+    @Test\r
+    public void testKnownRegions() {\r
+        assertEquals(EXPECTED_REGIONS, catalog.getRegions().size());\r
+        // assertEquals(REGION_NAME, catalog.getRegions().toArray()[0]);\r
+    }\r
+\r
+    /**\r
+     * Test that we can check for published services correctly\r
+     */\r
+    @Test\r
+    public void testServiceTypesPublished() {\r
+        assertTrue(catalog.isServicePublished("compute"));\r
+        assertFalse(catalog.isServicePublished("bogus"));\r
+    }\r
+\r
+    /**\r
+     * Check that we can get the list of published services\r
+     */\r
+    @Test\r
+    public void testPublishedServicesList() {\r
+        // List<String> services = catalog.getServiceTypes();\r
+\r
+        // assertTrue(services.contains(ServiceCatalog.COMPUTE_SERVICE));\r
+        // assertTrue(services.contains(ServiceCatalog.IDENTITY_SERVICE));\r
+        // assertTrue(services.contains(ServiceCatalog.IMAGE_SERVICE));\r
+        // assertTrue(services.contains(ServiceCatalog.NETWORK_SERVICE));\r
+        // assertTrue(services.contains(ServiceCatalog.VOLUME_SERVICE));\r
+    }\r
+\r
+    /**\r
+     * Test that we can get the endpoint(s) for a service\r
+     */\r
+    @Test\r
+    public void testEndpointList() {\r
+        List<Service.Endpoint> endpoints = catalog.getEndpoints(ServiceCatalog.COMPUTE_SERVICE);\r
+\r
+        assertNotNull(endpoints);\r
+        assertFalse(endpoints.isEmpty());\r
+        assertEquals(EXPECTED_ENDPOINTS, endpoints.size());\r
+\r
+        Service.Endpoint endpoint = endpoints.get(0);\r
+        // assertEquals(REGION_NAME, endpoint.getRegion());\r
+    }\r
+\r
+    @Test\r
+    public void testToString() {\r
+        String testString = catalog.toString();\r
+        assertNotNull(testString);\r
+    }\r
+\r
+    @Ignore\r
+    @Test\r
+    public void liveConnectionTest() {\r
+        // this test should only be used by developers when testing against a live Openstack\r
+        // instance, otherwise it should be ignored\r
+        properties = new Properties();\r
+        String identity = "http://192.168.0.1:5000/v2.0";\r
+        String tenantName = "Tenant";\r
+        String user = "user";\r
+        String pass = "pass";\r
+\r
+        ServiceCatalogV2 catalog = new ServiceCatalogV2(identity, tenantName, user, pass, properties);\r
+\r
+        try {\r
+            catalog.init();\r
+        } catch (ZoneException e) {\r
+            // TODO Auto-generated catch block\r
+            e.printStackTrace();\r
+        }\r
+\r
+        String out = catalog.toString();\r
+        System.out.println(out);\r
+    }\r
+}\r
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestServiceCatalogV3.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestServiceCatalogV3.java
new file mode 100644 (file)
index 0000000..14f44d1
--- /dev/null
@@ -0,0 +1,167 @@
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP : APPC\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Copyright (C) 2017 Amdocs\r
+ * =============================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * \r
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+\r
+\r
+package org.openecomp.appc.adapter.iaas.impl;\r
+\r
+import static org.junit.Assert.assertEquals;\r
+import static org.junit.Assert.assertFalse;\r
+import static org.junit.Assert.assertNotNull;\r
+import static org.junit.Assert.assertTrue;\r
+import com.att.cdp.exceptions.ZoneException;\r
+import com.woorea.openstack.keystone.v3.model.Token.Service.Endpoint;\r
+import java.util.List;\r
+import java.util.Properties;\r
+import org.junit.Before;\r
+import org.junit.BeforeClass;\r
+import org.junit.Ignore;\r
+import org.junit.Test;\r
+import org.openecomp.appc.configuration.ConfigurationFactory;\r
+\r
+/**\r
+ * This class tests the service catalog against a known provider.\r
+ */\r
+@Ignore\r
+public class TestServiceCatalogV3 {\r
+\r
+    // Number\r
+    private static int EXPECTED_REGIONS = 1;\r
+    private static int EXPECTED_ENDPOINTS = 1;\r
+\r
+    private static String PRINCIPAL;\r
+    private static String CREDENTIAL;\r
+    private static String DOMAIN;\r
+    private static String TENANT_NAME;\r
+    private static String TENANT_ID;\r
+    private static String IDENTITY_URL;\r
+    private static String REGION_NAME;\r
+\r
+    private ServiceCatalogV3 catalog;\r
+\r
+    private Properties properties;\r
+\r
+    @BeforeClass\r
+    public static void before() {\r
+        Properties props = ConfigurationFactory.getConfiguration().getProperties();\r
+        IDENTITY_URL = props.getProperty("provider1.identity");\r
+        PRINCIPAL = props.getProperty("provider1.tenant1.userid", "appc");\r
+        CREDENTIAL = props.getProperty("provider1.tenant1.password", "appc");\r
+        DOMAIN = props.getProperty("provider1.tenant1.domain", "Default");\r
+        TENANT_NAME = props.getProperty("provider1.tenant1.name", "appc");\r
+        TENANT_ID = props.getProperty("provider1.tenant1.id",\r
+                props.getProperty("test.tenantid", "abcde12345fghijk6789lmnopq123rst"));\r
+        REGION_NAME = props.getProperty("provider1.tenant1.region", "RegionOne");\r
+\r
+        EXPECTED_REGIONS = Integer.valueOf(props.getProperty("test.expected-regions", "0"));\r
+        EXPECTED_ENDPOINTS = Integer.valueOf(props.getProperty("test.expected-endpoints", "0"));\r
+    }\r
+\r
+    /**\r
+     * Setup the test environment by loading a new service catalog for each test\r
+     * \r
+     * @throws ZoneException\r
+     */\r
+    @Before\r
+    public void setup() throws ZoneException {\r
+        properties = new Properties();\r
+        catalog = new ServiceCatalogV3(IDENTITY_URL, TENANT_NAME, PRINCIPAL, CREDENTIAL, DOMAIN, properties);\r
+    }\r
+\r
+    /**\r
+     * Test that the tenant name and ID are returned correctly\r
+     */\r
+    @Test\r
+    public void testKnownTenant() {\r
+        assertEquals(TENANT_NAME, catalog.getProjectName());\r
+        assertEquals(TENANT_ID, catalog.getProjectId());\r
+    }\r
+\r
+    /**\r
+     * Test that we find all of the expected region(s)\r
+     */\r
+    @Test\r
+    public void testKnownRegions() {\r
+        assertEquals(EXPECTED_REGIONS, catalog.getRegions().size());\r
+        // assertEquals(REGION_NAME, catalog.getRegions().toArray()[0]);\r
+    }\r
+\r
+    /**\r
+     * Test that we can check for published services correctly\r
+     */\r
+    @Test\r
+    public void testServiceTypesPublished() {\r
+        assertTrue(catalog.isServicePublished("compute"));\r
+        assertFalse(catalog.isServicePublished("bogus"));\r
+    }\r
+\r
+    /**\r
+     * Check that we can get the list of published services\r
+     */\r
+    @Test\r
+    public void testPublishedServicesList() {\r
+        List<String> services = catalog.getServiceTypes();\r
+\r
+        assertTrue(services.contains(ServiceCatalog.COMPUTE_SERVICE));\r
+        assertTrue(services.contains(ServiceCatalog.IDENTITY_SERVICE));\r
+        assertTrue(services.contains(ServiceCatalog.IMAGE_SERVICE));\r
+        assertTrue(services.contains(ServiceCatalog.NETWORK_SERVICE));\r
+        assertTrue(services.contains(ServiceCatalog.VOLUME_SERVICE));\r
+    }\r
+\r
+    /**\r
+     * Test that we can get the endpoint(s) for a service\r
+     */\r
+    @Test\r
+    public void testEndpointList() {\r
+        List<Endpoint> endpoints = catalog.getEndpoints(ServiceCatalog.COMPUTE_SERVICE);\r
+\r
+        assertNotNull(endpoints);\r
+        assertFalse(endpoints.isEmpty());\r
+        assertEquals(EXPECTED_ENDPOINTS, endpoints.size());\r
+\r
+        Endpoint endpoint = endpoints.get(0);\r
+        // assertEquals(REGION_NAME, endpoint.getRegion());\r
+    }\r
+\r
+    @Test\r
+    public void testToString() {\r
+        String testString = catalog.toString();\r
+        assertNotNull(testString);\r
+    }\r
+\r
+    @Ignore\r
+    @Test\r
+    public void liveConnectionTest() {\r
+        // this test should only be used by developers when testing against a live Openstack\r
+        // instance, otherwise it should be ignored\r
+        properties = new Properties();\r
+        String identity = "";\r
+        String tenantName = "";\r
+        String user = "";\r
+        String pass = "";\r
+\r
+        catalog = new ServiceCatalogV3(IDENTITY_URL, TENANT_NAME, PRINCIPAL, CREDENTIAL, DOMAIN, properties);\r
+    }\r
+}\r
index 46dd5ee..5986fdd 100644 (file)
@@ -29,9 +29,7 @@ package org.openecomp.appc.adapter.iaas.impl;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
-
 import java.util.Properties;
-
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.openecomp.appc.adapter.iaas.impl.VMURL;
@@ -94,22 +92,6 @@ public class TestVMURL {
         assertEquals("/api/multicloud/v0/cloudowner_region", url.getPath());
         assertEquals(TENANTID, url.getTenantId());
         assertEquals(VMID, url.getServerId());
-        assertEquals("v2",url.getVersion());
-        assertEquals(url.toString(), URL);
-    }
-
-    @Test
-    public void testValidURL4() {
-        URL = "http://msb.onap.org:80/api/multicloud/v0/cloudowner_region/v2.1/abcde12345fghijk6789lmnopq123rst/servers/abc12345-1234-5678-890a-abcdefg12345";
-        VMURL url = VMURL.parseURL(URL);
-        assertNotNull(url);
-        assertEquals("http", url.getScheme());
-        assertEquals("msb.onap.org", url.getHost());
-        assertEquals("80", url.getPort());
-        assertEquals("/api/multicloud/v0/cloudowner_region", url.getPath());
-        assertEquals(TENANTID, url.getTenantId());
-        assertEquals(VMID, url.getServerId());
-        assertEquals("v2.1",url.getVersion());
         assertEquals(url.toString(), URL);
     }
 
index 9dc3938..a05474a 100644 (file)
@@ -32,9 +32,7 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-
 import org.openecomp.appc.test.InterceptLogger;
-
 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
 import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
 
@@ -55,38 +53,39 @@ public class ExecutorHarness {
     private Map<String, Method> methods;
 
     /**
-     * The field of the class being tested that contains the reference to the logger to be used. This is modified to
-     * point to our interception logger for the test.
+     * The field of the class being tested that contains the reference to the logger to be used.
+     * This is modified to point to our interception logger for the test.
      */
     private Field contextLogger;
 
     /**
-     * The interception logger that buffers all messages logged and allows us to look at them as part of the test case.
+     * The interception logger that buffers all messages logged and allows us to look at them as
+     * part of the test case.
      */
     private InterceptLogger logger;
 
     /**
      * Create the harness and initialize it
      * 
-     * @throws SecurityException
-     *             If a security manager, s, is present and any of the following conditions is met:
-     *             <ul>
-     *             <li>invocation of s.checkMemberAccess(this, Member.DECLARED) denies access to the declared field</li>
-     *             <li>the caller's class loader is not the same as or an ancestor of the class loader for the current
-     *             class and invocation of s.checkPackageAccess() denies access to the package of this class</li>
-     *             </ul>
-     * @throws NoSuchFieldException
-     *             if a field with the specified name is not found.
-     * @throws IllegalAccessException
-     *             if this Field object is enforcing Java language access control and the underlying field is either
-     *             inaccessible or final.
-     * @throws IllegalArgumentException
-     *             if the specified object is not an instance of the class or interface declaring the underlying field
-     *             (or a subclass or implementor thereof), or if an unwrapping conversion fails.
+     * @throws SecurityException If a security manager, s, is present and any of the following
+     *         conditions is met:
+     *         <ul>
+     *         <li>invocation of s.checkMemberAccess(this, Member.DECLARED) denies access to the
+     *         declared field</li>
+     *         <li>the caller's class loader is not the same as or an ancestor of the class loader
+     *         for the current class and invocation of s.checkPackageAccess() denies access to the
+     *         package of this class</li>
+     *         </ul>
+     * @throws NoSuchFieldException if a field with the specified name is not found.
+     * @throws IllegalAccessException if this Field object is enforcing Java language access control
+     *         and the underlying field is either inaccessible or final.
+     * @throws IllegalArgumentException if the specified object is not an instance of the class or
+     *         interface declaring the underlying field (or a subclass or implementor thereof), or
+     *         if an unwrapping conversion fails.
      */
     @SuppressWarnings("nls")
-    public ExecutorHarness() throws NoSuchFieldException, SecurityException, IllegalArgumentException,
-                    IllegalAccessException {
+    public ExecutorHarness()
+            throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
         methods = new HashMap<>();
         new SvcLogicContext();
 
@@ -100,33 +99,31 @@ public class ExecutorHarness {
     /**
      * Convenience constructor
      * 
-     * @param executor
-     *            The executor to be tested by the harness
-     * @throws SecurityException
-     *             If a security manager, s, is present and any of the following conditions is met:
-     *             <ul>
-     *             <li>invocation of s.checkMemberAccess(this, Member.DECLARED) denies access to the declared field</li>
-     *             <li>the caller's class loader is not the same as or an ancestor of the class loader for the current
-     *             class and invocation of s.checkPackageAccess() denies access to the package of this class</li>
-     *             </ul>
-     * @throws NoSuchFieldException
-     *             if a field with the specified name is not found.
-     * @throws IllegalAccessException
-     *             if this Field object is enforcing Java language access control and the underlying field is either
-     *             inaccessible or final.
-     * @throws IllegalArgumentException
-     *             if the specified object is not an instance of the class or interface declaring the underlying field
-     *             (or a subclass or implementor thereof), or if an unwrapping conversion fails.
+     * @param executor The executor to be tested by the harness
+     * @throws SecurityException If a security manager, s, is present and any of the following
+     *         conditions is met:
+     *         <ul>
+     *         <li>invocation of s.checkMemberAccess(this, Member.DECLARED) denies access to the
+     *         declared field</li>
+     *         <li>the caller's class loader is not the same as or an ancestor of the class loader
+     *         for the current class and invocation of s.checkPackageAccess() denies access to the
+     *         package of this class</li>
+     *         </ul>
+     * @throws NoSuchFieldException if a field with the specified name is not found.
+     * @throws IllegalAccessException if this Field object is enforcing Java language access control
+     *         and the underlying field is either inaccessible or final.
+     * @throws IllegalArgumentException if the specified object is not an instance of the class or
+     *         interface declaring the underlying field (or a subclass or implementor thereof), or
+     *         if an unwrapping conversion fails.
      */
-    public ExecutorHarness(SvcLogicJavaPlugin executor) throws NoSuchFieldException, SecurityException,
-                    IllegalArgumentException, IllegalAccessException {
+    public ExecutorHarness(SvcLogicJavaPlugin executor)
+            throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
         this();
         setExecutor(executor);
     }
 
     /**
-     * @param executor
-     *            The java plugin class to be executed
+     * @param executor The java plugin class to be executed
      */
     public void setExecutor(SvcLogicJavaPlugin executor) {
         this.executor = executor;
@@ -150,20 +147,20 @@ public class ExecutorHarness {
     }
 
     /**
-     * Returns an indication if the named method is a valid executor method that could be called from a DG execute node
+     * Returns an indication if the named method is a valid executor method that could be called
+     * from a DG execute node
      * 
-     * @param methodName
-     *            The method name to be validated
-     * @return True if the method name meets the signature requirements, false if the method either does not exist or
-     *         does not meet the requirements.
+     * @param methodName The method name to be validated
+     * @return True if the method name meets the signature requirements, false if the method either
+     *         does not exist or does not meet the requirements.
      */
     public boolean isExecMethod(String methodName) {
         return methods.containsKey(methodName);
     }
 
     /**
-     * This method scans the executor class hierarchy to locate all methods that match the required signature of the
-     * executor and records these methods in a map.
+     * This method scans the executor class hierarchy to locate all methods that match the required
+     * signature of the executor and records these methods in a map.
      */
     private void scanExecutor() {
         methods.clear();
@@ -174,7 +171,7 @@ public class ExecutorHarness {
                 Class<?>[] paramTypes = method.getParameterTypes();
                 if (paramTypes.length == 2) {
                     if (Map.class.isAssignableFrom(paramTypes[0])
-                        && SvcLogicContext.class.isAssignableFrom(paramTypes[1])) {
+                            && SvcLogicContext.class.isAssignableFrom(paramTypes[1])) {
                         methods.put(method.getName(), method);
                     }
                 }
index b0a8e82..efc84a1 100644 (file)
@@ -28,14 +28,13 @@ package org.openecomp.appc.test;
 import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.List;
-
 import org.slf4j.Marker;
-
 import ch.qos.logback.classic.Level;
 
 /**
- * This class is used as an intercept logger that can be used in testing to intercept and record all messages that are
- * logged, thus allowing a junit test case to examine the log output and make assertions.
+ * This class is used as an intercept logger that can be used in testing to intercept and record all
+ * messages that are logged, thus allowing a junit test case to examine the log output and make
+ * assertions.
  */
 public class InterceptLogger implements org.slf4j.Logger {
 
@@ -81,24 +80,21 @@ public class InterceptLogger implements org.slf4j.Logger {
         }
 
         /**
-         * @param level
-         *            the value for level
+         * @param level the value for level
          */
         public void setLevel(Level level) {
             this.level = level;
         }
 
         /**
-         * @param message
-         *            the value for message
+         * @param message the value for message
          */
         public void setMessage(String message) {
             this.message = message;
         }
 
         /**
-         * @param timestamp
-         *            the value for timestamp
+         * @param timestamp the value for timestamp
          */
         public void setTimestamp(long timestamp) {
             this.timestamp = timestamp;
@@ -112,8 +108,7 @@ public class InterceptLogger implements org.slf4j.Logger {
         }
 
         /**
-         * @param t
-         *            the value for t
+         * @param t the value for t
          */
         public void setThrowable(Throwable t) {
             this.t = t;
index 5f0aa32..f4a393f 100644 (file)
@@ -807,7 +807,13 @@ public enum Msg implements EELFResolvableErrorEnum {
     /**
      * {0}
      */
-    OAM_OPERATION_INVALID_INPUT
+    OAM_OPERATION_INVALID_INPUT, 
+
+    /**
+     * Unsupported identity service version, unable to retrieve ServiceCatalog
+     * for identity service {0}
+     */
+    IAAS_UNSUPPORTED_IDENTITY_SERVICE
     ;
     /*
      * Static initializer to ensure the resource bundles for this class are loaded...
index 86d9b55..354adff 100644 (file)
@@ -1011,3 +1011,10 @@ OAM_OPERATION_INVALID_INPUT=APPC0162E|\
   {0}|\
   No recovery required|\
   Fix the input parameter and retry.
+
+IAAS_UNSUPPORTED_IDENTITY_SERVICE=APPC0163E|\
+  Unsupported identity service version, unable to retrieve ServiceCatalog for identity service {0}|\
+  Verify the identity url provided is correct. Currently supported version of the OpenStack identity servicer\
+    are v2 and v3. If a support for a new version in required contact development.|\
+  This message indicates that a request was made to connect to an unsupported version of \
+    identity service.
\ No newline at end of file