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;
* 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
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);
}
* 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
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;
* 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
*/
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";
/**
* </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;
* </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;
* </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;
* </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;
* </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;
* </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;
* 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);
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;
*/
@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
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;
/**
* 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) {
}
/**
- * @param props
- * not used
+ * @param props not used
*/
public ProviderAdapterImpl(@SuppressWarnings("unused") Properties props) {
initialize();
op.setProviderCache(this.providerCache);
op.setDefaultPass(DEFAULT_PASS);
op.setDefaultUser(DEFAULT_USER);
+ op.setDefaultDomain(DEFAULT_DOMAIN);
return (Server) op.doOperation(params, context);
}
op.setProviderCache(this.providerCache);
op.setDefaultPass(DEFAULT_PASS);
op.setDefaultUser(DEFAULT_USER);
+ op.setDefaultDomain(DEFAULT_DOMAIN);
return (Server) op.doOperation(params, context);
}
op.setProviderCache(this.providerCache);
op.setDefaultPass(DEFAULT_PASS);
op.setDefaultUser(DEFAULT_USER);
+ op.setDefaultDomain(DEFAULT_DOMAIN);
return (Server) op.doOperation(params, context);
}
op.setProviderCache(this.providerCache);
op.setDefaultPass(DEFAULT_PASS);
op.setDefaultUser(DEFAULT_USER);
+ op.setDefaultDomain(DEFAULT_DOMAIN);
return (Server) op.doOperation(params, context);
}
op.setProviderCache(this.providerCache);
op.setDefaultPass(DEFAULT_PASS);
op.setDefaultUser(DEFAULT_USER);
+ op.setDefaultDomain(DEFAULT_DOMAIN);
return (Server) op.doOperation(params, context);
}
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);
op.setProviderCache(this.providerCache);
op.setDefaultPass(DEFAULT_PASS);
op.setDefaultUser(DEFAULT_USER);
+ op.setDefaultDomain(DEFAULT_DOMAIN);
return (Server) op.doOperation(params, context);
}
op.setProviderCache(this.providerCache);
op.setDefaultPass(DEFAULT_PASS);
op.setDefaultUser(DEFAULT_USER);
+ op.setDefaultDomain(DEFAULT_DOMAIN);
return (Server) op.doOperation(params, context);
}
op.setProviderCache(this.providerCache);
op.setDefaultPass(DEFAULT_PASS);
op.setDefaultUser(DEFAULT_USER);
+ op.setDefaultDomain(DEFAULT_DOMAIN);
return (Stack) op.doOperation(params, context);
}
op.setProviderCache(this.providerCache);
op.setDefaultPass(DEFAULT_PASS);
op.setDefaultUser(DEFAULT_USER);
+ op.setDefaultDomain(DEFAULT_DOMAIN);
return (Stack) op.doOperation(params, context);
}
op.setProviderCache(this.providerCache);
op.setDefaultPass(DEFAULT_PASS);
op.setDefaultUser(DEFAULT_USER);
+ op.setDefaultDomain(DEFAULT_DOMAIN);
return (Stack) op.doOperation(params, context);
}
op.setProviderCache(this.providerCache);
op.setDefaultPass(DEFAULT_PASS);
op.setDefaultUser(DEFAULT_USER);
+ op.setDefaultDomain(DEFAULT_DOMAIN);
return (Server) op.doOperation(params, context);
}
op.setProviderCache(this.providerCache);
op.setDefaultPass(DEFAULT_PASS);
op.setDefaultUser(DEFAULT_USER);
+ op.setDefaultDomain(DEFAULT_DOMAIN);
return (Image) op.doOperation(params, context);
}
* 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();
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:
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);
}
}
* 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;
}
/**
- * @param identityURL
- * the value for identityURL
+ * @param identityURL the value for identityURL
*/
public void setIdentityURL(String identityURL) {
this.identityURL = identityURL;
}
/**
- * @param providerName
- * the value for providerName
+ * @param providerName the value for providerName
*/
public void setProviderName(String providerName) {
this.providerName = providerName;
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;
/**
* 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);
/**
* 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);
/**
* 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;
}
/**
- * @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;
}
/**
- * @param message
- * The error message
+ * @param message The error message
*/
public RequestFailedException(String message) {
super(message);
* 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) {
* 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) {
* 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) {
}
/**
- * @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);
}
/**
- * @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;
}
/**
- * @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;
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;
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;
* 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
*/
*/
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
*/
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
/**
* @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
* @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.
* 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();
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;
}
}
--- /dev/null
+/*-\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
--- /dev/null
+/*-\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
--- /dev/null
+/*-\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
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;
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;
/**
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
*/
/**
* Construct the cache of tenants for the specified provider
*
- * @param provider
- * The provider
+ * @param provider The provider
*/
public TenantCache(ProviderCache provider) {
configuration = ConfigurationFactory.getConfiguration();
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 {
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);
} 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 {
// ignore
}
}
- } catch ( ZoneException e) {
+ } catch (ZoneException e) {
logger.error(e.getMessage());
break;
}
* 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
*/
}
/**
- * @param provider
- * the value for provider
+ * @param provider the value for provider
*/
public void setProvider(ProviderCache provider) {
this.provider = provider;
}
/**
- * @param password
- * the value for password
+ * @param password the value for password
*/
public void setPassword(String password) {
this.password = password;
}
/**
- * @param tenantId
- * the value for tenantId
+ * @param tenantId the value for tenantId
*/
public void setTenantId(String tenantId) {
this.tenantId = tenantId;
}
/**
- * @param tenantName
- * the value for tenantName
+ * @param tenantName the value for tenantName
*/
public void setTenantName(String tenantName) {
this.tenantName = tenantName;
}
/**
- * @param userid
- * the value for userid
+ * @param userid the value for userid
*/
public void setUserid(String userid) {
this.userid = userid;
* 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
* 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) {
}
/**
- * @return The version of the service
+ * @return The version of the service
*/
public String getVersion() {
return version;
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;
/**
/**
* 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);
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 {
default:
throw new APPCException("Unsupported provider operation.");
}
- operations.put(op,opObject);
+ operations.put(op, opObject);
}
return opObject;
}
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";
*/
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";
}
}
*/
public enum Outcome {
FAILURE {
- public String toString(){
+ public String toString() {
return "failure";
}
},
SUCCESS {
- public String toString(){
+ public String toString() {
return "success";
}
}
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;
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()));
}
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;
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();
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);
setTimeForMetricsLogger();
metricsLogger.info("Executing Provider Operation: Create Snapshot");
-
+
return createSnapshot(params, context);
}
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;
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 {
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() ...");
}
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(),
}
} 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);
/**
- * @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;
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();
// 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);
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();
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) {
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);
/*
* 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 {
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()));
// 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;
}
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 {
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);
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);
}
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;
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;
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);
}
}
/**
- * @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;
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();
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;
* 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")
String msg;
Context context = server.getContext();
Provider provider = context.getProvider();
- ComputeService service = context.getComputeService();
-
+ ComputeService service = context.getComputeService();
+
/*
* Set Time for Metrics Logger
*/
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);
* 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")
}
/*
- * 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();
}
// 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);
}
}
/*
- * 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;
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();
}
/**
- * @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 {
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();
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);
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;
* 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.
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)) {
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);
}
* 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)
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();
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) {
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);
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 {
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");
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);
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");
}
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);
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 {
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");
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()));
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);
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;
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 {
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();
*/
/*
- * 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)) {
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
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
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) {
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);
}
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;
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 {
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();
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)) {
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
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
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);
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) {
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());
}
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;
/**
* 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
*/
* 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")
* 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)
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();
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");
}
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);
}
}
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 {
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) {
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);
}
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;
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();
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);
}
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);
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);
/**
* 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);
/**
* 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()) {
/**
* 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();
* 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);
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 {
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)
// 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(
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()) {
* 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")
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;
}
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()));
}
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);
}
}
- //reserve the context
+ // reserve the context
String tenantName = tenantCache.getTenantName();
String tenantId = tenantCache.getTenantId();
String region = tenantCache.determineRegion(vm);
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();
-
-
-
-
- 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);
}
}
/**
* @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)
/**
* 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
*/
* 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")
* 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)
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));
/**
* 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
*/
/**
* 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
*/
/**
* 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
*/
/**
* 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);
+ *
+ *
+ * }
+ */
+
}
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);
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());
}
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;
}
}
}
}
-/* 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;
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");
}
}
- 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;
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;
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);
}
}
}
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;
@JsonInclude(JsonInclude.Include.NON_NULL)
@Generated("org.jsonschema2pojo")
-@JsonPropertyOrder({
- "name"
-})
+@JsonPropertyOrder({"name"})
public class CreateSnapshotParams {
@JsonProperty("name")
/**
*
- * @return
- * The name
+ * @return The name
*/
@JsonProperty("name")
public String getName() {
/**
*
- * @param name
- * The name
+ * @param name The name
*/
@JsonProperty("name")
public void setName(String name) {
@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")
/**
*
- * @return
- * The status
+ * @return The status
*/
@JsonProperty("status")
public String getStatus() {
/**
*
- * @param status
- * The status
+ * @param status The status
*/
@JsonProperty("status")
public void setStatus(String status) {
/**
*
- * @return
- * The name
+ * @return The name
*/
@JsonProperty("name")
public String getName() {
/**
*
- * @param name
- * The name
+ * @param name The name
*/
@JsonProperty("name")
public void setName(String name) {
/**
*
- * @return
- * The stackUserProjectId
+ * @return The stackUserProjectId
*/
@JsonProperty("stack_user_project_id")
public String getStackUserProjectId() {
/**
*
- * @param stackUserProjectId
- * The stack_user_project_id
+ * @param stackUserProjectId The stack_user_project_id
*/
@JsonProperty("stack_user_project_id")
public void setStackUserProjectId(String stackUserProjectId) {
/**
*
- * @return
- * The environment
+ * @return The environment
*/
@JsonProperty("environment")
public Environment getEnvironment() {
/**
*
- * @param environment
- * The environment
+ * @param environment The environment
*/
@JsonProperty("environment")
public void setEnvironment(Environment environment) {
/**
*
- * @return
- * The template
+ * @return The template
*/
@JsonProperty("template")
public Template getTemplate() {
/**
*
- * @param template
- * The template
+ * @param template The template
*/
@JsonProperty("template")
public void setTemplate(Template template) {
/**
*
- * @return
- * The action
+ * @return The action
*/
@JsonProperty("action")
public String getAction() {
/**
*
- * @param action
- * The action
+ * @param action The action
*/
@JsonProperty("action")
public void setAction(String action) {
/**
*
- * @return
- * The projectId
+ * @return The projectId
*/
@JsonProperty("project_id")
public String getProjectId() {
/**
*
- * @param projectId
- * The project_id
+ * @param projectId The project_id
*/
@JsonProperty("project_id")
public void setProjectId(String projectId) {
/**
*
- * @return
- * The id
+ * @return The id
*/
@JsonProperty("id")
public String getId() {
/**
*
- * @param id
- * The id
+ * @param id The id
*/
@JsonProperty("id")
public void setId(String id) {
/**
*
- * @return
- * The resources
+ * @return The resources
*/
@JsonProperty("resources")
public Resources__ getResources() {
/**
*
- * @param resources
- * The resources
+ * @param resources The resources
*/
@JsonProperty("resources")
public void setResources(Resources__ resources) {
@JsonInclude(JsonInclude.Include.NON_NULL)
@Generated("org.jsonschema2pojo")
-@JsonPropertyOrder({
- "parameters",
- "resource_registry"
-})
+@JsonPropertyOrder({"parameters", "resource_registry"})
public class Environment {
@JsonProperty("parameters")
/**
*
- * @return
- * The parameters
+ * @return The parameters
*/
@JsonProperty("parameters")
public Parameters getParameters() {
/**
*
- * @param parameters
- * The parameters
+ * @param parameters The parameters
*/
@JsonProperty("parameters")
public void setParameters(Parameters parameters) {
/**
*
- * @return
- * The resourceRegistry
+ * @return The resourceRegistry
*/
@JsonProperty("resource_registry")
public ResourceRegistry getResourceRegistry() {
/**
*
- * @param resourceRegistry
- * The resource_registry
+ * @param resourceRegistry The resource_registry
*/
@JsonProperty("resource_registry")
public void setResourceRegistry(ResourceRegistry resourceRegistry) {
@JsonInclude(JsonInclude.Include.NON_NULL)
@Generated("org.jsonschema2pojo")
-@JsonPropertyOrder({
- "size"
-})
+@JsonPropertyOrder({"size"})
public class Properties {
@JsonProperty("size")
/**
*
- * @return
- * The size
+ * @return The size
*/
@JsonProperty("size")
public int getSize() {
/**
*
- * @param size
- * The size
+ * @param size The size
*/
@JsonProperty("size")
public void setSize(int size) {
@JsonInclude(JsonInclude.Include.NON_NULL)
@Generated("org.jsonschema2pojo")
-@JsonPropertyOrder({
- "backup_id"
-})
+@JsonPropertyOrder({"backup_id"})
public class ResourceData {
@JsonProperty("backup_id")
/**
*
- * @return
- * The backupId
+ * @return The backupId
*/
@JsonProperty("backup_id")
public String getBackupId() {
/**
*
- * @param backupId
- * The backup_id
+ * @param backupId The backup_id
*/
@JsonProperty("backup_id")
public void setBackupId(String backupId) {
@JsonInclude(JsonInclude.Include.NON_NULL)
@Generated("org.jsonschema2pojo")
-@JsonPropertyOrder({
- "resources"
-})
+@JsonPropertyOrder({"resources"})
public class ResourceRegistry {
@JsonProperty("resources")
/**
*
- * @return
- * The resources
+ * @return The resources
*/
@JsonProperty("resources")
public Resources getResources() {
/**
*
- * @param resources
- * The resources
+ * @param resources The resources
*/
@JsonProperty("resources")
public void setResources(Resources resources) {
@JsonInclude(JsonInclude.Include.NON_NULL)
@Generated("org.jsonschema2pojo")
-@JsonPropertyOrder({
- "volume"
-})
+@JsonPropertyOrder({"volume"})
public class Resources_ {
@JsonProperty("volume")
/**
*
- * @return
- * The volume
+ * @return The volume
*/
@JsonProperty("volume")
public Volume getVolume() {
/**
*
- * @param volume
- * The volume
+ * @param volume The volume
*/
@JsonProperty("volume")
public void setVolume(Volume volume) {
@JsonInclude(JsonInclude.Include.NON_NULL)
@Generated("org.jsonschema2pojo")
-@JsonPropertyOrder({
- "volume"
-})
+@JsonPropertyOrder({"volume"})
public class Resources__ {
@JsonProperty("volume")
/**
*
- * @return
- * The volume
+ * @return The volume
*/
@JsonProperty("volume")
public Volume_ getVolume() {
/**
*
- * @param volume
- * The volume
+ * @param volume The volume
*/
@JsonProperty("volume")
public void setVolume(Volume_ volume) {
@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")
/**
*
- * @return
- * The id
+ * @return The id
*/
@JsonProperty("id")
public String getId() {
/**
*
- * @param id
- * The id
+ * @param id The id
*/
@JsonProperty("id")
public void setId(String id) {
/**
*
- * @return
- * The name
+ * @return The name
*/
@JsonProperty("name")
public String getName() {
/**
*
- * @param name
- * The name
+ * @param name The name
*/
@JsonProperty("name")
public void setName(String name) {
/**
*
- * @return
- * The status
+ * @return The status
*/
@JsonProperty("status")
public String getStatus() {
/**
*
- * @param status
- * The status
+ * @param status The status
*/
@JsonProperty("status")
public void setStatus(String status) {
/**
*
- * @return
- * The statusReason
+ * @return The statusReason
*/
@JsonProperty("status_reason")
public String getStatusReason() {
/**
*
- * @param statusReason
- * The status_reason
+ * @param statusReason The status_reason
*/
@JsonProperty("status_reason")
public void setStatusReason(String statusReason) {
/**
*
- * @return
- * The creationTime
+ * @return The creationTime
*/
@JsonProperty("creation_time")
public String getCreationTime() {
/**
*
- * @param creationTime
- * The creation_time
+ * @param creationTime The creation_time
*/
@JsonProperty("creation_time")
public void setCreationTime(String creationTime) {
/**
*
- * @return
- * The data
+ * @return The data
*/
@JsonProperty("data")
public Data getData() {
/**
*
- * @param data
- * The data
+ * @param data The data
*/
@JsonProperty("data")
public void setData(Data data) {
@JsonInclude(JsonInclude.Include.NON_NULL)
@Generated("org.jsonschema2pojo")
-@JsonPropertyOrder({
- "snapshot"
-})
+@JsonPropertyOrder({"snapshot"})
public class SnapshotDetails {
@JsonProperty("snapshot")
/**
*
- * @return
- * The snapshot
+ * @return The snapshot
*/
@JsonProperty("snapshot")
public Snapshot getSnapshot() {
/**
*
- * @param snapshot
- * The snapshot
+ * @param snapshot The snapshot
*/
@JsonProperty("snapshot")
public void setSnapshot(Snapshot snapshot) {
@JsonInclude(JsonInclude.Include.NON_NULL)
@Generated("org.jsonschema2pojo")
-@JsonPropertyOrder({
- "code",
- "message",
- "title"
-})
+@JsonPropertyOrder({"code", "message", "title"})
public class SnapshotRestoreResponse {
@JsonProperty("code")
/**
*
- * @return
- * The code
+ * @return The code
*/
@JsonProperty("code")
public String getCode() {
/**
*
- * @param code
- * The code
+ * @param code The code
*/
@JsonProperty("code")
public void setCode(String code) {
/**
*
- * @return
- * The message
+ * @return The message
*/
@JsonProperty("message")
public String getMessage() {
/**
*
- * @param message
- * The message
+ * @param message The message
*/
@JsonProperty("message")
public void setMessage(String message) {
/**
*
- * @return
- * The title
+ * @return The title
*/
@JsonProperty("title")
public String getTitle() {
/**
*
- * @param title
- * The title
+ * @param title The title
*/
@JsonProperty("title")
public void setTitle(String title) {
@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")
/**
*
- * @return
- * The heatTemplateVersion
+ * @return The heatTemplateVersion
*/
@JsonProperty("heat_template_version")
public String getHeatTemplateVersion() {
/**
*
- * @param heatTemplateVersion
- * The heat_template_version
+ * @param heatTemplateVersion The heat_template_version
*/
@JsonProperty("heat_template_version")
public void setHeatTemplateVersion(String heatTemplateVersion) {
/**
*
- * @return
- * The resources
+ * @return The resources
*/
@JsonProperty("resources")
public Resources_ getResources() {
/**
*
- * @param resources
- * The resources
+ * @param resources The resources
*/
@JsonProperty("resources")
public void setResources(Resources_ resources) {
@JsonInclude(JsonInclude.Include.NON_NULL)
@Generated("org.jsonschema2pojo")
-@JsonPropertyOrder({
- "type",
- "properties"
-})
+@JsonPropertyOrder({"type", "properties"})
public class Volume {
@JsonProperty("type")
/**
*
- * @return
- * The type
+ * @return The type
*/
@JsonProperty("type")
public String getType() {
/**
*
- * @param type
- * The type
+ * @param type The type
*/
@JsonProperty("type")
public void setType(String type) {
/**
*
- * @return
- * The properties
+ * @return The properties
*/
@JsonProperty("properties")
public Properties getProperties() {
/**
*
- * @param properties
- * The properties
+ * @param properties The properties
*/
@JsonProperty("properties")
public void setProperties(Properties properties) {
@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")
/**
*
- * @return
- * The status
+ * @return The status
*/
@JsonProperty("status")
public String getStatus() {
/**
*
- * @param status
- * The status
+ * @param status The status
*/
@JsonProperty("status")
public void setStatus(String status) {
/**
*
- * @return
- * The name
+ * @return The name
*/
@JsonProperty("name")
public String getName() {
/**
*
- * @param name
- * The name
+ * @param name The name
*/
@JsonProperty("name")
public void setName(String name) {
/**
*
- * @return
- * The resourceData
+ * @return The resourceData
*/
@JsonProperty("resource_data")
public ResourceData getResourceData() {
/**
*
- * @param resourceData
- * The resource_data
+ * @param resourceData The resource_data
*/
@JsonProperty("resource_data")
public void setResourceData(ResourceData resourceData) {
/**
*
- * @return
- * The resourceId
+ * @return The resourceId
*/
@JsonProperty("resource_id")
public String getResourceId() {
/**
*
- * @param resourceId
- * The resource_id
+ * @param resourceId The resource_id
*/
@JsonProperty("resource_id")
public void setResourceId(String resourceId) {
/**
*
- * @return
- * The action
+ * @return The action
*/
@JsonProperty("action")
public String getAction() {
/**
*
- * @param action
- * The action
+ * @param action The action
*/
@JsonProperty("action")
public void setAction(String action) {
/**
*
- * @return
- * The type
+ * @return The type
*/
@JsonProperty("type")
public String getType() {
/**
*
- * @param type
- * The type
+ * @param type The type
*/
@JsonProperty("type")
public void setType(String type) {
/**
*
- * @return
- * The metadata
+ * @return The metadata
*/
@JsonProperty("metadata")
public Metadata getMetadata() {
/**
*
- * @param metadata
- * The metadata
+ * @param metadata The metadata
*/
@JsonProperty("metadata")
public void setMetadata(Metadata metadata) {
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;
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;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
-
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
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;
/**
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
/**
* 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 {
}
/**
- * 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 {
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());
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());
}
/**
- * 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);
}
}
-
+
/****************************************/
/**
- * 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);
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);
/**
* 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);
/**
* 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);
/**
* 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);
/**
* 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);
}
/**
- * 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();
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");
/**
* 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 {
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;
/**
* 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 {
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;
/**
* 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 {
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;
/**
* 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 {
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;
}
/**
- * 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;
}
/*
- * @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); } }
*/
}
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;
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;
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
/**
* 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)
/**
* 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)
/**
* 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)
/**
* 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)
/**
* This test expects to pass
*
- * @throws RequestFailedException
- * Un-Expected
+ * @throws RequestFailedException Un-Expected
*/
@SuppressWarnings("nls")
@Test
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;
}
}
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;
/**
* 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>
*/
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() {
}
/**
- * 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() {
}
/**
- * 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() {
}
/**
- * 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() {
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;
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"));
}
@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;
}
/**
@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());
}
}
--- /dev/null
+/*-\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
--- /dev/null
+/*-\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
--- /dev/null
+/*-\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
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;
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);
}
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;
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();
/**
* 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;
}
/**
- * 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();
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);
}
}
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 {
}
/**
- * @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;
}
/**
- * @param t
- * the value for t
+ * @param t the value for t
*/
public void setThrowable(Throwable t) {
this.t = t;
/**
* {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...
{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