summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/ProviderAdapter.java30
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/impl/ProviderAdapterImpl.java63
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/api/ProviderOperationFactory.java13
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/common/enums/Operation.java14
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/AttachVolumeServer.java120
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/DettachVolumeServer.java120
6 files changed, 278 insertions, 82 deletions
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/ProviderAdapter.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/ProviderAdapter.java
index c14c936e0..f5b1a7187 100644
--- a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/ProviderAdapter.java
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/ProviderAdapter.java
@@ -43,54 +43,44 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
* </p>
*/
public interface ProviderAdapter extends SvcLogicJavaPlugin {
-
/**
* The type of provider to be accessed to locate and operate on a virtual machine instance. This is used to load the
* correct provider support through the CDP IaaS abstraction layer and can be OpenStackProvider, BareMetalProvider,
* or any other supported provider type.
*/
static final String PROPERTY_PROVIDER_TYPE = "org.onap.appc.provider.type";
-
/**
* The adapter maintains a cache of providers organized by the name of the provider, not its type. This is
* equivalent to the system or installation name. All regions within the same installation are assumed to be the
* same type.
*/
static final String PROPERTY_PROVIDER_NAME = "org.onap.appc.provider.name";
-
/**
* The fully-qualified URL of the instance to be manipulated as it is known to the provider.
*/
static final String PROPERTY_INSTANCE_URL = "org.onap.appc.instance.url";
-
/**
* The fully-qualified URL of the instance to be manipulated as it is known to the provider.
*/
static final String PROPERTY_IDENTITY_URL = "org.onap.appc.identity.url";
-
/**
* The Rebuild VM flag is an optional payload parameter for the Evacuate API.
*/
static final String PROPERTY_REBUILD_VM = "org.onap.appc.rebuildvm";
-
/**
* The target host id is an optional payload parameter for the Evacuate API.
*/
static final String PROPERTY_TARGETHOST_ID = "org.onap.appc.targethost.id";
-
/**
* heat stack id to perform operation on stack
*/
static final String PROPERTY_STACK_ID = "org.onap.appc.stack.id";
-
static final String PROPERTY_SNAPSHOT_ID = "snapshot.id";
-
static final String PROPERTY_INPUT_SNAPSHOT_ID = "org.onap.appc.snapshot.id";
-
static final String DG_OUTPUT_PARAM_NAMESPACE = "output.";
-
static final String SKIP_HYPERVISOR_CHECK = "org.onap.appc.skiphypervisorcheck";
-
+ static final String VOLUME_ID = "org.onap.appc.volumeid";
+ static final String DEVICE = "org.onap.appc.device";
/**
* This method is used to restart an existing virtual machine given the fully qualified URL of the machine.
* <p>
@@ -117,7 +107,6 @@ public interface ProviderAdapter extends SvcLogicJavaPlugin {
* @throws APPCException If the server cannot be restarted for some reason
*/
Server restartServer(Map<String, String> properties, SvcLogicContext context) throws APPCException;
-
/**
* This method is used to stop the indicated server
* <p>
@@ -144,7 +133,6 @@ public interface ProviderAdapter extends SvcLogicJavaPlugin {
* @throws APPCException If the server cannot be stopped for some reason
*/
Server stopServer(Map<String, String> properties, SvcLogicContext context) throws APPCException;
-
/**
* This method is used to start the indicated server
* <p>
@@ -171,7 +159,6 @@ public interface ProviderAdapter extends SvcLogicJavaPlugin {
* @throws APPCException If the server cannot be started for some reason
*/
Server startServer(Map<String, String> properties, SvcLogicContext context) throws APPCException;
-
/**
* This method is used to rebuild the indicated server
* <p>
@@ -198,7 +185,6 @@ public interface ProviderAdapter extends SvcLogicJavaPlugin {
* @throws APPCException If the server cannot be rebuilt for some reason
*/
Server rebuildServer(Map<String, String> properties, SvcLogicContext context) throws APPCException;
-
/**
* This method is used to terminate the indicated server
* <p>
@@ -225,26 +211,20 @@ public interface ProviderAdapter extends SvcLogicJavaPlugin {
* @throws APPCException If the server cannot be terminate for some reason
*/
Server terminateServer(Map<String, String> properties, SvcLogicContext context) throws APPCException;
-
/**
* Returns the symbolic name of the adapter
*
* @return The adapter name
*/
String getAdapterName();
-
Server evacuateServer(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
-
Server migrateServer(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
-
Server vmStatuschecker(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
-
Stack terminateStack(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
-
Stack snapshotStack(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
-
Stack restoreStack(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
-
+ Server attachVolume(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+ Server dettachVolume(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
/**
* This method is used to do the lookup of the indicated server
* <p>
@@ -271,7 +251,6 @@ public interface ProviderAdapter extends SvcLogicJavaPlugin {
* @throws APPCException If the server cannot be found for some reason
*/
Server lookupServer(Map<String, String> properties, SvcLogicContext context) throws APPCException;
-
/**
* The
*
@@ -284,5 +263,4 @@ public interface ProviderAdapter extends SvcLogicJavaPlugin {
* @throws APPCException If the server cannot be restarted for some reason
*/
Image createSnapshot(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
-
}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/impl/ProviderAdapterImpl.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/impl/ProviderAdapterImpl.java
index ba6c8c678..3bb044895 100644
--- a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/impl/ProviderAdapterImpl.java
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/impl/ProviderAdapterImpl.java
@@ -21,8 +21,6 @@
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
* ============LICENSE_END=========================================================
*/
-
-
package org.onap.appc.adapter.iaas.impl;
import org.onap.appc.Constants;
@@ -47,7 +45,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
-
/**
* This class implements the {@link ProviderAdapter} interface. This interface defines the behaviors that our service
* provides.
@@ -61,7 +58,6 @@ public class ProviderAdapterImpl implements ProviderAdapter {
* The default domain name for authentication
*/
public static final String DEFAULT_DOMAIN_NAME = "Default";
-
/**
* The logger to be used
*/
@@ -70,25 +66,20 @@ public class ProviderAdapterImpl implements ProviderAdapter {
* A reference to the adapter configuration object.
*/
private Configuration configuration;
-
/**
* reference to operation factory
*/
ProviderOperationFactory factory = ProviderOperationFactory.getInstance();
-
/**
* A cache of providers that are predefined.
*/
private Map<String /* provider name */, ProviderCache> providerCache;
-
/**
* 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 default constructor is used as a work around because the activator wasnt getting called
*/
@@ -97,7 +88,6 @@ public class ProviderAdapterImpl implements ProviderAdapter {
initialize();
}
-
/**
* This constructor is used primarily in the test cases to bypass initialization of the adapter for isolated,
* disconnected testing
@@ -111,7 +101,6 @@ public class ProviderAdapterImpl implements ProviderAdapter {
initialize();
}
}
-
/**
* @param props not used
*/
@@ -119,10 +108,8 @@ public class ProviderAdapterImpl implements ProviderAdapter {
initialize();
}
-
@Override
public Server restartServer(Map<String, String> params, SvcLogicContext context) throws APPCException {
-
IProviderOperation op = factory.getOperationObject(Operation.RESTART_SERVICE);
op.setProviderCache(this.providerCache);
op.setDefaultPass(DEFAULT_PASS);
@@ -130,10 +117,8 @@ public class ProviderAdapterImpl implements ProviderAdapter {
op.setDefaultDomain(DEFAULT_DOMAIN);
return (Server) op.doOperation(params, context);
}
-
@Override
public Server stopServer(Map<String, String> params, SvcLogicContext context) throws APPCException {
-
IProviderOperation op = factory.getOperationObject(Operation.STOP_SERVICE);
op.setProviderCache(this.providerCache);
op.setDefaultPass(DEFAULT_PASS);
@@ -141,10 +126,8 @@ public class ProviderAdapterImpl implements ProviderAdapter {
op.setDefaultDomain(DEFAULT_DOMAIN);
return (Server) op.doOperation(params, context);
}
-
@Override
public Server startServer(Map<String, String> params, SvcLogicContext context) throws APPCException {
-
IProviderOperation op = factory.getOperationObject(Operation.START_SERVICE);
op.setProviderCache(this.providerCache);
op.setDefaultPass(DEFAULT_PASS);
@@ -152,10 +135,8 @@ public class ProviderAdapterImpl implements ProviderAdapter {
op.setDefaultDomain(DEFAULT_DOMAIN);
return (Server) op.doOperation(params, context);
}
-
@Override
public Server rebuildServer(Map<String, String> params, SvcLogicContext context) throws APPCException {
-
IProviderOperation op = factory.getOperationObject(Operation.REBUILD_SERVICE);
op.setProviderCache(this.providerCache);
op.setDefaultPass(DEFAULT_PASS);
@@ -163,10 +144,8 @@ public class ProviderAdapterImpl implements ProviderAdapter {
op.setDefaultDomain(DEFAULT_DOMAIN);
return (Server) op.doOperation(params, context);
}
-
@Override
public Server terminateServer(Map<String, String> params, SvcLogicContext context) throws APPCException {
-
IProviderOperation op = factory.getOperationObject(Operation.TERMINATE_SERVICE);
op.setProviderCache(this.providerCache);
op.setDefaultPass(DEFAULT_PASS);
@@ -174,10 +153,8 @@ public class ProviderAdapterImpl implements ProviderAdapter {
op.setDefaultDomain(DEFAULT_DOMAIN);
return (Server) op.doOperation(params, context);
}
-
@Override
public Server evacuateServer(Map<String, String> params, SvcLogicContext context) throws APPCException {
-
IProviderOperation op = factory.getOperationObject(Operation.EVACUATE_SERVICE);
op.setProviderCache(this.providerCache);
op.setDefaultPass(DEFAULT_PASS);
@@ -187,10 +164,8 @@ public class ProviderAdapterImpl implements ProviderAdapter {
((EvacuateServer) op).setProvideAdapterRef(this);
return (Server) op.doOperation(params, context);
}
-
@Override
public Server migrateServer(Map<String, String> params, SvcLogicContext context) throws APPCException {
-
IProviderOperation op = factory.getOperationObject(Operation.MIGRATE_SERVICE);
op.setProviderCache(this.providerCache);
op.setDefaultPass(DEFAULT_PASS);
@@ -198,10 +173,8 @@ public class ProviderAdapterImpl implements ProviderAdapter {
op.setDefaultDomain(DEFAULT_DOMAIN);
return (Server) op.doOperation(params, context);
}
-
@Override
public Server vmStatuschecker(Map<String, String> params, SvcLogicContext context) throws APPCException {
-
IProviderOperation op = factory.getOperationObject(Operation.VMSTATUSCHECK_SERVICE);
op.setProviderCache(this.providerCache);
op.setDefaultPass(DEFAULT_PASS);
@@ -209,10 +182,8 @@ public class ProviderAdapterImpl implements ProviderAdapter {
op.setDefaultDomain(DEFAULT_DOMAIN);
return (Server) op.doOperation(params, context);
}
-
@Override
public Stack terminateStack(Map<String, String> params, SvcLogicContext context) throws APPCException {
-
IProviderOperation op = factory.getOperationObject(Operation.TERMINATE_STACK);
op.setProviderCache(this.providerCache);
op.setDefaultPass(DEFAULT_PASS);
@@ -220,10 +191,8 @@ public class ProviderAdapterImpl implements ProviderAdapter {
op.setDefaultDomain(DEFAULT_DOMAIN);
return (Stack) op.doOperation(params, context);
}
-
@Override
public Stack snapshotStack(Map<String, String> params, SvcLogicContext context) throws APPCException {
-
IProviderOperation op = factory.getOperationObject(Operation.SNAPSHOT_STACK);
op.setProviderCache(this.providerCache);
op.setDefaultPass(DEFAULT_PASS);
@@ -231,10 +200,8 @@ public class ProviderAdapterImpl implements ProviderAdapter {
op.setDefaultDomain(DEFAULT_DOMAIN);
return (Stack) op.doOperation(params, context);
}
-
@Override
public Stack restoreStack(Map<String, String> params, SvcLogicContext context) throws APPCException {
-
IProviderOperation op = factory.getOperationObject(Operation.RESTORE_STACK);
op.setProviderCache(this.providerCache);
op.setDefaultPass(DEFAULT_PASS);
@@ -242,10 +209,8 @@ public class ProviderAdapterImpl implements ProviderAdapter {
op.setDefaultDomain(DEFAULT_DOMAIN);
return (Stack) op.doOperation(params, context);
}
-
@Override
public Server lookupServer(Map<String, String> params, SvcLogicContext context) throws APPCException {
-
IProviderOperation op = factory.getOperationObject(Operation.LOOKUP_SERVICE);
op.setProviderCache(this.providerCache);
op.setDefaultPass(DEFAULT_PASS);
@@ -253,10 +218,8 @@ public class ProviderAdapterImpl implements ProviderAdapter {
op.setDefaultDomain(DEFAULT_DOMAIN);
return (Server) op.doOperation(params, context);
}
-
@Override
public Image createSnapshot(Map<String, String> params, SvcLogicContext context) throws APPCException {
-
IProviderOperation op = factory.getOperationObject(Operation.SNAPSHOT_SERVICE);
op.setProviderCache(this.providerCache);
op.setDefaultPass(DEFAULT_PASS);
@@ -264,7 +227,6 @@ public class ProviderAdapterImpl implements ProviderAdapter {
op.setDefaultDomain(DEFAULT_DOMAIN);
return (Image) op.doOperation(params, context);
}
-
/**
* Returns the symbolic name of the adapter
*
@@ -275,14 +237,11 @@ public class ProviderAdapterImpl implements ProviderAdapter {
public String getAdapterName() {
return configuration.getProperty(Constants.PROPERTY_ADAPTER_NAME);
}
-
-
/**
* initialize the provider adapter by building the context cache
*/
private void initialize() {
configuration = ConfigurationFactory.getConfiguration();
-
/*
* Initialize the provider cache for all defined providers. The definition of the providers uses a structured
* property set, where the names form a hierarchical name space (dotted notation, such as one.two.three). Each
@@ -301,7 +260,6 @@ public class ProviderAdapterImpl implements ProviderAdapter {
providerCache = new HashMap<>();
Properties properties = configuration.getProperties();
List<Node> providers = StructuredPropertyHelper.getStructuredProperties(properties, Property.PROVIDER);
-
for (Node provider : providers) {
ProviderCache cache = new ProviderCache();
List<Node> providerNodes = provider.getChildren();
@@ -336,11 +294,9 @@ public class ProviderAdapterImpl implements ProviderAdapter {
break;
}
}
-
cache.addTenant(null, tenantName, userId, password, domain);
}
}
-
/*
* Add the provider to the set of providers cached
*/
@@ -348,12 +304,27 @@ public class ProviderAdapterImpl implements ProviderAdapter {
providerCache.put(null, cache);
providerCache.put(cache.getIdentityURL(), cache);
}
-
/*
* Now, initialize the cache for the loaded provider
*/
cache.initialize();
}
}
-
+ @Override
+ public Server attachVolume(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+ // TODO Auto-generated method stub
+ IProviderOperation op = factory.getOperationObject(Operation.ATTACHVOLUME_SERVICE);
+ op.setProviderCache(this.providerCache);
+ op.setDefaultPass(DEFAULT_PASS);
+ op.setDefaultUser(DEFAULT_USER);
+ return (Server) op.doOperation(params, ctx);
+ }
+ @Override
+ public Server dettachVolume(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+ IProviderOperation op = factory.getOperationObject(Operation.DETACHVOLUME_SERVICE);
+ op.setProviderCache(this.providerCache);
+ op.setDefaultPass(DEFAULT_PASS);
+ op.setDefaultUser(DEFAULT_USER);
+ return (Server) op.doOperation(params, ctx);
+ }
}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/api/ProviderOperationFactory.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/api/ProviderOperationFactory.java
index 1eed4ef90..a4e0fd650 100644
--- a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/api/ProviderOperationFactory.java
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/api/ProviderOperationFactory.java
@@ -29,31 +29,26 @@ import org.onap.appc.adapter.iaas.provider.operation.common.enums.Operation;
import org.onap.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 {
-
/**
* holds instance of the class
*/
private static ProviderOperationFactory instance;
-
/**
* holds concrete operations objects
*/
private Map<Operation, IProviderOperation> operations;
-
/**
* private constructor
*/
private ProviderOperationFactory() {
this.operations = new HashMap<>();
}
-
/**
* @return instance of the factory
*/
@@ -63,13 +58,11 @@ public class ProviderOperationFactory {
}
return instance;
}
-
/**
* @param op
* @return concrete operation impl
*/
public IProviderOperation getOperationObject(Operation op) throws APPCException {
-
IProviderOperation opObject = operations.get(op);
if (opObject == null) {
switch (op) {
@@ -112,6 +105,12 @@ public class ProviderOperationFactory {
case LOOKUP_SERVICE:
opObject = new LookupServer();
break;
+ case ATTACHVOLUME_SERVICE:
+ opObject = new AttachVolumeServer();
+ break;
+ case DETACHVOLUME_SERVICE:
+ opObject = new DettachVolumeServer();
+ break;
default:
throw new APPCException("Unsupported provider operation.");
}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/common/enums/Operation.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/common/enums/Operation.java
index 2f81fab9c..34f763144 100644
--- a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/common/enums/Operation.java
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/common/enums/Operation.java
@@ -21,9 +21,7 @@
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
* ============LICENSE_END=========================================================
*/
-
package org.onap.appc.adapter.iaas.provider.operation.common.enums;
-
/**
* @since September 26, 2016
*/
@@ -92,5 +90,15 @@ public enum Operation {
public String toString() {
return "restoreStack";
}
- }
+ },
+ ATTACHVOLUME_SERVICE {
+ public String toString(){
+ return "attachVolume";
+ }
+ },
+ DETACHVOLUME_SERVICE {
+ public String toString(){
+ return "dettachVolume";
+ }
+ },
}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/AttachVolumeServer.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/AttachVolumeServer.java
new file mode 100644
index 000000000..2acd49918
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/AttachVolumeServer.java
@@ -0,0 +1,120 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.appc.adapter.iaas.provider.operation.impl;
+import static org.onap.appc.adapter.utils.Constants.ADAPTER_NAME;
+import java.util.Map;
+import org.glassfish.grizzly.http.util.HttpStatus;
+import org.onap.appc.Constants;
+import org.onap.appc.adapter.iaas.ProviderAdapter;
+import org.onap.appc.adapter.iaas.impl.IdentityURL;
+import org.onap.appc.adapter.iaas.impl.RequestContext;
+import org.onap.appc.adapter.iaas.impl.RequestFailedException;
+import org.onap.appc.adapter.iaas.impl.VMURL;
+import org.onap.appc.adapter.iaas.provider.operation.common.enums.Operation;
+import org.onap.appc.adapter.iaas.provider.operation.impl.base.ProviderServerOperation;
+import org.onap.appc.exceptions.APPCException;
+import org.onap.appc.i18n.Msg;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import com.att.cdp.exceptions.ZoneException;
+import com.att.cdp.zones.Context;
+import com.att.cdp.zones.VolumeService;
+import com.att.cdp.zones.model.ModelObject;
+import com.att.cdp.zones.model.Server;
+import com.att.cdp.zones.model.Volume;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.att.eelf.i18n.EELFResourceManager;
+import static org.onap.appc.adapter.iaas.provider.operation.common.enums.Operation.ATTACHVOLUME_SERVICE;;
+
+public class AttachVolumeServer extends ProviderServerOperation {
+ private final EELFLogger logger = EELFManager.getInstance().getLogger(AttachVolumeServer.class);
+ private Server attachVolume(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+ Server server = null;
+ RequestContext rc = new RequestContext(ctx);
+ rc.isAlive();
+ String appName = configuration.getProperty(Constants.PROPERTY_APPLICATION_NAME);
+ String vm_url = params.get(ProviderAdapter.PROPERTY_INSTANCE_URL);
+ String volumeid = params.get(ProviderAdapter.VOLUME_ID);
+ String device = params.get(ProviderAdapter.DEVICE);
+ VMURL vm = VMURL.parseURL(vm_url);
+ Context context = null;
+ try {
+ 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();
+ String vol_id = (volumeid == null) ? null : volumeid.toString();
+ String msg;
+ context = getContext(rc, vm_url, identStr);
+ if (context != null) {
+ rc.reset();
+ server = lookupServer(rc, context, vm.getServerId());
+ logger.debug(Msg.SERVER_FOUND, vm_url, context.getTenantName(), server.getStatus().toString());
+ VolumeService vs = context.getVolumeService();
+ vs.getVolumes(server);;
+ Volume vol = new Volume();
+ vol.setId(vol_id);
+ logger.info("Server status: "+server.getStatus());
+ Map volms = server.getVolumes();
+ logger.info("list of attachments");
+ logger.info(volms.size()+"initial volumes");
+ logger.info(vol.getId());
+ if(server.getVolumes().containsValue(vol_id))
+ {
+ logger.info("Alreday volumes exists:");
+ logger.info( volms.size()+"volumes size if exists");
+ }
+ else
+ {
+ server.attachVolume(vol, device);
+ logger.info( volms.size()+"volumes size after attaching volume");
+ }
+ context.close();
+ doSuccess(rc);
+ ctx.setAttribute("VOLUME_STATUS", "SUCCESS");
+ } else {
+ ctx.setAttribute("VOLUME_STATUS", "CONTEXT_NOT_FOUND");
+ }
+ } catch (ZoneException e) {
+ String msg = EELFResourceManager.format(Msg.SERVER_NOT_FOUND, e, vm_url);
+ logger.error(msg);
+ doFailure(rc, HttpStatus.NOT_FOUND_404, msg);
+ } catch (RequestFailedException e) {
+ doFailure(rc, e.getStatus(), e.getMessage());
+ } catch (Exception ex) {
+ String msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, ex, ex.getClass().getSimpleName(),
+ ATTACHVOLUME_SERVICE.toString(), vm_url, context == null ? "Unknown" : context.getTenantName());
+ logger.error(msg, ex);
+ doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg);
+ }
+ return server;
+ }
+ @Override
+ protected ModelObject executeProviderOperation(Map<String, String> params, SvcLogicContext context)
+ throws APPCException {
+ setMDC(Operation.ATTACHVOLUME_SERVICE.toString(), "App-C IaaS Adapter:attachVolume", ADAPTER_NAME);
+ logOperation(Msg.ATTACHINGVOLUME_SERVER, params, context);
+ return attachVolume(params, context);
+ }
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/DettachVolumeServer.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/DettachVolumeServer.java
new file mode 100644
index 000000000..8c408c4d5
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/DettachVolumeServer.java
@@ -0,0 +1,120 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.appc.adapter.iaas.provider.operation.impl;
+
+import static org.onap.appc.adapter.iaas.provider.operation.common.enums.Operation.ATTACHVOLUME_SERVICE;
+import static org.onap.appc.adapter.utils.Constants.ADAPTER_NAME;
+import java.util.Map;
+import org.glassfish.grizzly.http.util.HttpStatus;
+import org.onap.appc.Constants;
+import org.onap.appc.adapter.iaas.ProviderAdapter;
+import org.onap.appc.adapter.iaas.impl.IdentityURL;
+import org.onap.appc.adapter.iaas.impl.RequestContext;
+import org.onap.appc.adapter.iaas.impl.RequestFailedException;
+import org.onap.appc.adapter.iaas.impl.VMURL;
+import org.onap.appc.adapter.iaas.provider.operation.common.enums.Operation;
+import org.onap.appc.adapter.iaas.provider.operation.impl.base.ProviderServerOperation;
+import org.onap.appc.exceptions.APPCException;
+import org.onap.appc.i18n.Msg;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import com.att.cdp.exceptions.ZoneException;
+import com.att.cdp.zones.ComputeService;
+import com.att.cdp.zones.Context;
+import com.att.cdp.zones.VolumeService;
+import com.att.cdp.zones.model.ModelObject;
+import com.att.cdp.zones.model.Server;
+import com.att.cdp.zones.model.Volume;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.att.eelf.i18n.EELFResourceManager;
+
+public class DettachVolumeServer extends ProviderServerOperation{
+ private final EELFLogger logger = EELFManager.getInstance().getLogger(DettachVolumeServer.class);
+ @Override
+ protected ModelObject executeProviderOperation(Map<String, String> params, SvcLogicContext context)
+ throws APPCException {
+ setMDC(Operation.DETACHVOLUME_SERVICE.toString(), "App-C IaaS Adapter:dettachVolume", ADAPTER_NAME);
+ logOperation(Msg.DETTACHINGVOLUME_SERVER, params, context);
+ return dettachVolume(params, context);
+ }
+ private Server dettachVolume(Map<String, String> params, SvcLogicContext ctx) {
+ Server server = null;
+ RequestContext rc = new RequestContext(ctx);
+ rc.isAlive();
+ String appName = configuration.getProperty(Constants.PROPERTY_APPLICATION_NAME);
+ String vm_url = params.get(ProviderAdapter.PROPERTY_INSTANCE_URL);
+ String volumeid = params.get(ProviderAdapter.VOLUME_ID);
+ String device = params.get(ProviderAdapter.DEVICE);
+ VMURL vm = VMURL.parseURL(vm_url);
+ Context context = null;
+ try {
+ 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();
+ String vol_id = (volumeid == null) ? null : volumeid.toString();
+ String msg;
+ context = getContext(rc, vm_url, identStr);
+ if (context != null) {
+ rc.reset();
+ server = lookupServer(rc, context, vm.getServerId());
+ logger.debug(Msg.SERVER_FOUND, vm_url, context.getTenantName(), server.getStatus().toString());
+ Volume vol = new Volume();
+ vol.setId(vol_id);
+ Map volms = server.getVolumes();
+ ComputeService cs = context.getComputeService();
+ if(server.getVolumes().containsValue(vol_id))
+ {
+ logger.info("Alreday volumes exists:");
+ logger.info( volms.size()+"volumes size if exists");
+ cs.detachVolume(server, vol);
+ server.detachVolume(device);
+ }
+ else
+ {
+ logger.info("volume is not available to detach");
+ logger.info("Server status: RUNNING");
+ }
+ context.close();
+ doSuccess(rc);
+ ctx.setAttribute("VOLUME_STATUS", "SUCCESS");
+ } else {
+ ctx.setAttribute("VOLUME_STATUS", "CONTEXT_NOT_FOUND");
+ }
+ } catch (ZoneException e) {
+ String msg = EELFResourceManager.format(Msg.SERVER_NOT_FOUND, e, vm_url);
+ logger.error(msg);
+ doFailure(rc, HttpStatus.NOT_FOUND_404, msg);
+ } catch (RequestFailedException e) {
+ doFailure(rc, e.getStatus(), e.getMessage());
+ } catch (Exception ex) {
+ String msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, ex, ex.getClass().getSimpleName(),
+ ATTACHVOLUME_SERVICE.toString(), vm_url, context == null ? "Unknown" : context.getTenantName());
+ logger.error(msg, ex);
+ doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg);
+ }
+ return server;
+ }
+
+}