summaryrefslogtreecommitdiffstats
path: root/adapters/mso-adapter-utils
diff options
context:
space:
mode:
Diffstat (limited to 'adapters/mso-adapter-utils')
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentInfo.java220
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentInfoBuilder.java118
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java60
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java3
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudParam.java110
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java266
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateHeatResponse.java77
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateLinkResponse.java76
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateResponse.java90
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateStackResponse.java60
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudQueryResponse.java90
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudRequest.java120
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/beans/DeploymentInfoBuilderTest.java168
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/beans/DeploymentInfoTest.java76
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/utils/MsoCloudifyUtilsTest2.java60
15 files changed, 1129 insertions, 465 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentInfo.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentInfo.java
index c6e29d05d7..d2b3334c8c 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentInfo.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentInfo.java
@@ -4,12 +4,14 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Copyright (C) 2018 Nokia.
+ * ================================================================================
* 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.
@@ -20,166 +22,78 @@
package org.onap.so.cloudify.beans;
-import java.util.HashMap;
import java.util.Map;
-import org.onap.so.cloudify.v3.model.Deployment;
-import org.onap.so.cloudify.v3.model.DeploymentOutputs;
-import org.onap.so.cloudify.v3.model.Execution;
-
/*
* This Java bean class relays Heat stack status information to ActiveVOS processes.
- *
+ *
* This bean is returned by all Heat-specific adapter operations (create, query, delete)
*/
-public class DeploymentInfo {
- // Set defaults for everything
- private String id = "";
- private DeploymentStatus status = DeploymentStatus.NOTFOUND;
- private Map<String,Object> outputs = new HashMap<String,Object>();
- private Map<String,Object> inputs = new HashMap<String,Object>();
- private String lastAction;
- private String actionStatus;
- private String errorMessage;
-
- public DeploymentInfo () {
- }
-
- public DeploymentInfo (String id, Map<String,Object> outputs) {
- this.id = id;
- if (outputs != null) this.outputs = outputs;
- }
-
- public DeploymentInfo (String id) {
- this.id = id;
- }
-
- public DeploymentInfo (String id, DeploymentStatus status) {
- this.id = id;
- this.status = status;
- }
-
- public DeploymentInfo (Deployment deployment) {
- this(deployment, null, null);
- }
-
- /**
- * Construct a DeploymentInfo object from a deployment and the latest Execution action
- * @param deployment
- * @param execution
- */
- public DeploymentInfo (Deployment deployment, DeploymentOutputs outputs, Execution execution)
- {
- if (deployment == null) {
- this.id = null;
- return;
- }
-
- this.id = deployment.getId();
-
- if (outputs != null)
- this.outputs = outputs.getOutputs();
-
- if (deployment.getInputs() != null)
- this.inputs = deployment.getInputs();
-
- if (execution != null) {
- this.lastAction = execution.getWorkflowId();
- this.actionStatus = execution.getStatus();
- this.errorMessage = execution.getError();
-
- // Compute the status based on the last workflow
- if (lastAction.equals("install")) {
- if (actionStatus.equals("terminated"))
- this.status = DeploymentStatus.INSTALLED;
- else if (actionStatus.equals("failed"))
- this.status = DeploymentStatus.FAILED;
- else if (actionStatus.equals("started") || actionStatus.equals("pending"))
- this.status = DeploymentStatus.INSTALLING;
- else
- this.status = DeploymentStatus.UNKNOWN;
- }
- else if (lastAction.equals("uninstall")) {
- if (actionStatus.equals("terminated"))
- this.status = DeploymentStatus.CREATED;
- else if (actionStatus.equals("failed"))
- this.status = DeploymentStatus.FAILED;
- else if (actionStatus.equals("started") || actionStatus.equals("pending"))
- this.status = DeploymentStatus.UNINSTALLING;
- else
- this.status = DeploymentStatus.UNKNOWN;
- }
- else {
- // Could have more cases in the future for different actions.
- this.status = DeploymentStatus.UNKNOWN;
- }
- }
- else {
- this.status = DeploymentStatus.CREATED;
- }
- }
-
- public String getId() {
- return id;
- }
-
- public void setId (String id) {
- this.id = id;
- }
-
- public DeploymentStatus getStatus() {
- return status;
- }
-
- public void setStatus (DeploymentStatus status) {
- this.status = status;
- }
-
- public Map<String,Object> getOutputs () {
- return outputs;
- }
-
- public void setOutputs (Map<String,Object> outputs) {
- this.outputs = outputs;
- }
-
- public Map<String,Object> getInputs () {
- return inputs;
- }
-
- public void setInputs (Map<String,Object> inputs) {
- this.inputs = inputs;
- }
-
- public String getLastAction() {
- return lastAction;
- }
-
- public String getActionStatus() {
- return actionStatus;
- }
-
- public String getErrorMessage() {
- return errorMessage;
- }
-
- public void saveExecutionStatus (Execution execution) {
- this.lastAction = execution.getWorkflowId();
- this.actionStatus = execution.getStatus();
- this.errorMessage = execution.getError();
- }
-
- @Override
+public final class DeploymentInfo {
+
+ private final String id;
+ private final DeploymentStatus status;
+ private final Map<String, Object> outputs;
+ private final Map<String, Object> inputs;
+ private final String lastAction;
+ private final String actionStatus;
+ private final String errorMessage;
+
+ DeploymentInfo(String id, DeploymentStatus deploymentStatus,
+ Map<String, Object> deploymentOutputs,
+ Map<String, Object> deploymentInputs,
+ String lastAction,
+ String actionStatus,
+ String errorMessage) {
+
+ this.id = id;
+ this.status = deploymentStatus;
+ this.outputs = deploymentOutputs;
+ this.inputs = deploymentInputs;
+ this.lastAction = lastAction;
+ this.actionStatus = actionStatus;
+ this.errorMessage = errorMessage;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public DeploymentStatus getStatus() {
+ return status;
+ }
+
+ public Map<String, Object> getOutputs() {
+ return outputs;
+ }
+
+ public Map<String, Object> getInputs() {
+ return inputs;
+ }
+
+ public String getLastAction() {
+ return lastAction;
+ }
+
+ public String getActionStatus() {
+ return actionStatus;
+ }
+
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+ @Override
public String toString() {
return "DeploymentInfo {" +
- "id='" + id + '\'' +
- ", inputs='" + inputs + '\'' +
- ", outputs='" + outputs + '\'' +
- ", lastAction='" + lastAction + '\'' +
- ", status='" + status + '\'' +
- ", errorMessage='" + errorMessage + '\'' +
- '}';
+ "id='" + id + '\'' +
+ ", inputs='" + inputs + '\'' +
+ ", outputs='" + outputs + '\'' +
+ ", lastAction='" + lastAction + '\'' +
+ ", status='" + status + '\'' +
+ ", errorMessage='" + errorMessage + '\'' +
+ '}';
}
}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentInfoBuilder.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentInfoBuilder.java
new file mode 100644
index 0000000000..2e12869c95
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentInfoBuilder.java
@@ -0,0 +1,118 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : SO
+ * ================================================================================
+ * Copyright (C) 2018 Nokia.
+ * =============================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.cloudify.beans;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.onap.so.cloudify.v3.model.Execution;
+
+public final class DeploymentInfoBuilder {
+
+ private String id = "";
+ private DeploymentStatus deploymentStatus = DeploymentStatus.NOTFOUND;
+ private Map<String, Object> deploymentOutputs = new HashMap<>();
+ private Map<String, Object> deploymentInputs = new HashMap<>();
+ private String lastAction;
+ private String actionStatus;
+ private String errorMessage;
+
+ public DeploymentInfoBuilder withId(String id) {
+ this.id = id;
+ return this;
+ }
+
+ public DeploymentInfoBuilder withStatus(DeploymentStatus deploymentStatus) {
+ this.deploymentStatus = deploymentStatus;
+ return this;
+ }
+
+ public DeploymentInfoBuilder withDeploymentOutputs(Map<String, Object> deploymentOutputs) {
+ this.deploymentOutputs = deploymentOutputs;
+ return this;
+ }
+
+ public DeploymentInfoBuilder withDeploymentInputs(Map<String, Object> deploymentInputs) {
+ this.deploymentInputs = deploymentInputs;
+ return this;
+ }
+
+ public DeploymentInfoBuilder withLastAction(String lastAction) {
+ this.lastAction = lastAction;
+ return this;
+ }
+
+ public DeploymentInfoBuilder withActionStatus(String actionStatus) {
+ this.actionStatus = actionStatus;
+ return this;
+ }
+
+ public DeploymentInfoBuilder withErrorMessage(String errorMessage) {
+ this.errorMessage = errorMessage;
+ return this;
+ }
+
+ public DeploymentInfoBuilder fromExecution(Execution execution) {
+ if (execution != null) {
+ this.lastAction = execution.getWorkflowId();
+ this.actionStatus = execution.getStatus();
+ this.errorMessage = execution.getError();
+
+ // Compute the status based on the last workflow
+ if (lastAction.equals("install")) {
+ if (actionStatus.equals("terminated")) {
+ this.deploymentStatus = DeploymentStatus.INSTALLED;
+ } else if (actionStatus.equals("failed")) {
+ this.deploymentStatus = DeploymentStatus.FAILED;
+ } else if (actionStatus.equals("started") || actionStatus.equals("pending")) {
+ this.deploymentStatus = DeploymentStatus.INSTALLING;
+ } else {
+ this.deploymentStatus = DeploymentStatus.UNKNOWN;
+ }
+ } else if (lastAction.equals("uninstall")) {
+ if (actionStatus.equals("terminated")) {
+ this.deploymentStatus = DeploymentStatus.CREATED;
+ } else if (actionStatus.equals("failed")) {
+ this.deploymentStatus = DeploymentStatus.FAILED;
+ } else if (actionStatus.equals("started") || actionStatus.equals("pending")) {
+ this.deploymentStatus = DeploymentStatus.UNINSTALLING;
+ } else {
+ this.deploymentStatus = DeploymentStatus.UNKNOWN;
+ }
+ } else {
+ // Could have more cases in the future for different actions.
+ this.deploymentStatus = DeploymentStatus.UNKNOWN;
+ }
+ } else {
+ this.deploymentStatus = DeploymentStatus.CREATED;
+ }
+
+ return this;
+ }
+
+ public DeploymentInfo build() {
+ return new DeploymentInfo(id,
+ deploymentStatus,
+ deploymentOutputs,
+ deploymentInputs,
+ lastAction,
+ actionStatus,
+ errorMessage);
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java
index 677f6395ff..85abf9403c 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Copyright (C) 2018 Nokia.
+ * ================================================================================
* 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
@@ -20,6 +22,9 @@
package org.onap.so.cloudify.utils;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -30,7 +35,6 @@ import java.util.Map;
import java.util.Optional;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
-
import org.onap.so.adapters.vdu.CloudInfo;
import org.onap.so.adapters.vdu.PluginAction;
import org.onap.so.adapters.vdu.VduArtifact;
@@ -42,14 +46,13 @@ import org.onap.so.adapters.vdu.VduPlugin;
import org.onap.so.adapters.vdu.VduStateType;
import org.onap.so.adapters.vdu.VduStatus;
import org.onap.so.cloud.CloudConfig;
-import org.onap.so.db.catalog.beans.CloudSite;
-import org.onap.so.db.catalog.beans.CloudifyManager;
import org.onap.so.cloudify.base.client.CloudifyBaseException;
import org.onap.so.cloudify.base.client.CloudifyClientTokenProvider;
import org.onap.so.cloudify.base.client.CloudifyConnectException;
import org.onap.so.cloudify.base.client.CloudifyRequest;
import org.onap.so.cloudify.base.client.CloudifyResponseException;
import org.onap.so.cloudify.beans.DeploymentInfo;
+import org.onap.so.cloudify.beans.DeploymentInfoBuilder;
import org.onap.so.cloudify.beans.DeploymentStatus;
import org.onap.so.cloudify.exceptions.MsoCloudifyException;
import org.onap.so.cloudify.exceptions.MsoCloudifyManagerNotFound;
@@ -77,6 +80,8 @@ import org.onap.so.cloudify.v3.model.Executions;
import org.onap.so.cloudify.v3.model.OpenstackConfig;
import org.onap.so.cloudify.v3.model.StartExecutionParams;
import org.onap.so.config.beans.PoConfig;
+import org.onap.so.db.catalog.beans.CloudSite;
+import org.onap.so.db.catalog.beans.CloudifyManager;
import org.onap.so.db.catalog.beans.HeatTemplateParam;
import org.onap.so.logger.MessageEnum;
import org.onap.so.logger.MsoAlarmLogger;
@@ -93,10 +98,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
@Component
public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{
@@ -155,7 +156,6 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{
* @param inputs A map of key/value inputs
* @param pollForCompletion Indicator that polling should be handled in Java vs. in the client
* @param timeoutMinutes Timeout after which the "install" will be cancelled
- * @param environment An optional yaml-format string to specify environmental parameters
* @param backout Flag to delete deployment on install Failure - defaulted to True
* @return A DeploymentInfo object
* @throws MsoCloudifyException Thrown if the Cloudify API call returns an exception.
@@ -256,7 +256,12 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{
// Success!
// Create and return a DeploymentInfo structure. Include the Runtime outputs
DeploymentOutputs outputs = getDeploymentOutputs (cloudify, deploymentId);
- return new DeploymentInfo (deployment, outputs, installWorkflow);
+ return new DeploymentInfoBuilder()
+ .withId(deployment.getId())
+ .withDeploymentInputs(deployment.getInputs())
+ .withDeploymentOutputs(outputs.getOutputs())
+ .fromExecution(installWorkflow)
+ .build();
}
else {
// The workflow completed with errors. Must try to back it out.
@@ -538,7 +543,6 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{
*
* @param tenantId The Openstack ID of the tenant in which to query
* @param cloudSiteId The cloud identifier (may be a region) in which to query
- * @param stackName The name of the stack to query (may be simple or canonical)
* @return A StackInfo object
* @throws MsoOpenstackException Thrown if the Openstack API call returns an exception.
*/
@@ -556,7 +560,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{
Cloudify cloudify = getCloudifyClient (cloudSite.get());
// Build and send the Cloudify request
- Deployment deployment = null;
+ Deployment deployment = new Deployment();
DeploymentOutputs outputs = null;
try {
GetDeployment queryDeployment = cloudify.deployments().byId(deploymentId);
@@ -573,10 +577,18 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{
// If no executions, does this give NOT_FOUND or empty set?
if (executions.getItems().isEmpty()) {
- return new DeploymentInfo (deployment);
+ return new DeploymentInfoBuilder()
+ .withId(deployment.getId())
+ .withDeploymentInputs(deployment.getInputs())
+ .build();
}
else {
- return new DeploymentInfo (deployment, outputs, executions.getItems().get(0));
+ return new DeploymentInfoBuilder()
+ .withId(deployment.getId())
+ .withDeploymentInputs(deployment.getInputs())
+ .withDeploymentOutputs(outputs.getOutputs())
+ .fromExecution(executions.getItems().get(0))
+ .build();
}
}
catch (CloudifyConnectException ce) {
@@ -589,10 +601,14 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{
// Got a NOT FOUND error. React differently based on deployment vs. execution
if (deployment != null) {
// Got NOT_FOUND on the executions. Assume this is a valid "empty" set
- return new DeploymentInfo (deployment, outputs, null);
+ return new DeploymentInfoBuilder()
+ .withId(deployment.getId())
+ .withDeploymentInputs(deployment.getInputs())
+ .withDeploymentOutputs(outputs.getOutputs())
+ .build();
} else {
// Deployment not found. Default status of a DeploymentInfo object is NOTFOUND
- return new DeploymentInfo (deploymentId);
+ return new DeploymentInfoBuilder().withId(deploymentId).build();
}
}
throw new MsoCloudifyException (re.getStatus(), re.getMessage(), re.getLocalizedMessage(), re);
@@ -615,8 +631,6 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{
*
* @param tenantId The Openstack ID of the tenant in which to perform the delete
* @param cloudSiteId The cloud identifier (may be a region) from which to delete the stack.
- * @param stackName The name/id of the stack to delete. May be simple or canonical
- * @param pollForCompletion Indicator that polling should be handled in Java vs. in the client
* @return A StackInfo object
* @throws MsoOpenstackException Thrown if the Openstack API call returns an exception.
* @throws MsoCloudSiteNotFound
@@ -651,7 +665,10 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{
// Deployment doesn't exist. Return a "NOTFOUND" DeploymentInfo object
// TODO: Should return NULL?
LOGGER.debug("Deployment requested for deletion does not exist: " + deploymentId);
- return new DeploymentInfo (deploymentId, DeploymentStatus.NOTFOUND);
+ return new DeploymentInfoBuilder()
+ .withId(deploymentId)
+ .withStatus(DeploymentStatus.NOTFOUND)
+ .build();
} else {
// Convert the CloudifyResponseException to an MsoOpenstackException
LOGGER.debug("ERROR STATUS = " + e.getStatus() + ",\n" + e.getMessage() + "\n" + e.getLocalizedMessage());
@@ -741,7 +758,12 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{
}
// Return the deleted deployment info (with runtime outputs) along with the completed uninstall workflow status
- return new DeploymentInfo (deployment, outputs, uninstallWorkflow);
+ return new DeploymentInfoBuilder()
+ .withId(deployment.getId())
+ .withDeploymentInputs(deployment.getInputs())
+ .withDeploymentOutputs(outputs.getOutputs())
+ .fromExecution(uninstallWorkflow)
+ .build();
}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
index 15f84890b7..476bff3692 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
@@ -277,8 +277,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
boolean backout) throws MsoException {
// Take out the multicloud inputs, if present.
- String[] directives = { "oof_directives", "sdnc_directives", "generic_vnf_id", "vf_module_id" };
- for (String key : directives) {
+ for (String key : MsoMulticloudUtils.MULTICLOUD_INPUTS) {
if (stackInputs.containsKey(key)) {
stackInputs.remove(key);
if (stackInputs.isEmpty()) {
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudParam.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudParam.java
deleted file mode 100644
index 9b2475a1c4..0000000000
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudParam.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2018 Intel Corp. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.so.openstack.utils;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-public class MsoMulticloudParam {
-
- @JsonProperty("generic-vnf-id")
- private String genericVnfId;
-
- @JsonProperty("vf-module-id")
- private String vfModuleId;
-
- @JsonProperty("oof_directives")
- private String oofDirectives;
-
- @JsonProperty("sdnc_directives")
- private String sdncDirectives;
-
- @JsonProperty("template_type")
- private String templateType;
-
- @JsonProperty("template_data")
- private String templateData;
-
- public void setGenericVnfId(String genericVnfId){
- this.genericVnfId = genericVnfId;
- }
-
- public String getGenericVnfId(){
- return this.genericVnfId;
- }
-
- public void setVfModuleId(String vfModuleId){
- this.vfModuleId = vfModuleId;
- }
-
- public String getVfModuleId(){
- return this.vfModuleId;
- }
-
- public void setOofDirectives(String oofDirectives){
- this.oofDirectives = oofDirectives;
- }
-
- public String getOofDirectives(){
- return this.oofDirectives;
- }
-
- public void setSdncDirectives(String sdncDirectives){
- this.sdncDirectives = sdncDirectives;
- }
-
- public String getSdncDirectives(){
- return this.sdncDirectives;
- }
-
- public void setTemplateType(String templateType){
- this.templateType = templateType;
- }
-
- public String TemplateType(){
- return this.templateType;
- }
-
- public void setTemplateData(String templateData){
- this.templateData = templateData;
- }
-
- public String getTemplateData(){
- return this.templateData;
- }
-
- @Override
- public String toString() {
- return String.format("MulticloudParam{"
- + "genericVnfId='%s',"
- + " vfModuleId='%s',"
- + " oofDirectives='%s',"
- + " sdncDirectives='%s',"
- + " templateType='%s',"
- + " templateData='%s'"
- + "}",
- genericVnfId,
- vfModuleId,
- oofDirectives,
- sdncDirectives,
- templateType,
- templateData);
- }
-}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java
index 4ed35a4d28..306de05eea 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java
@@ -21,13 +21,21 @@
package org.onap.so.openstack.utils;
import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
+import java.util.Scanner;
import javax.ws.rs.core.UriBuilder;
import javax.ws.rs.core.UriBuilderException;
+import javax.ws.rs.core.Response.StatusType;
import javax.ws.rs.core.Response;
+import org.apache.http.HttpStatus;
+import org.onap.so.db.catalog.beans.CloudIdentity;
+import org.onap.so.utils.CryptoUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.onap.so.adapters.vdu.CloudInfo;
@@ -48,24 +56,27 @@ import org.onap.so.openstack.exceptions.MsoOpenstackException;
import org.onap.so.openstack.mappers.StackInfoMapper;
import org.onap.so.client.HttpClient;
import org.onap.so.client.RestClient;
-import org.onap.so.cloud.CloudConfig;
import org.onap.so.db.catalog.beans.CloudSite;
import org.onap.so.utils.TargetEntity;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.env.Environment;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.woorea.openstack.heat.model.CreateStackParam;
import com.woorea.openstack.heat.model.Stack;
@Component
public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
- @Autowired
- protected CloudConfig cloudConfig;
-
- @Autowired
- private Environment env;
+ public static final String OOF_DIRECTIVES = "oof_directives";
+ public static final String SDNC_DIRECTIVES = "sdnc_directives";
+ public static final String GENERIC_VNF_ID = "generic_vnf_id";
+ public static final String VF_MODULE_ID = "vf_module_id";
+ public static final String TEMPLATE_TYPE = "template_type";
+ public static final List<String> MULTICLOUD_INPUTS =
+ Arrays.asList(OOF_DIRECTIVES, SDNC_DIRECTIVES, GENERIC_VNF_ID, VF_MODULE_ID, TEMPLATE_TYPE);
private static final String ONAP_IP = "ONAP_IP";
@@ -75,6 +86,8 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
private static final Logger logger = LoggerFactory.getLogger(MsoMulticloudUtils.class);
+ private static final ObjectMapper JSON_MAPPER = new ObjectMapper();
+
/******************************************************************************
*
* Methods (and associated utilities) to implement the VduPlugin interface
@@ -135,59 +148,90 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
Map <String, Object> heatFiles,
boolean backout) throws MsoException {
- // Get the directives, if present.
- String oofDirectives = null;
- String sdncDirectives = null;
- String genericVnfId = null;
- String vfModuleId = null;
+ logger.trace("Started MsoMulticloudUtils.createStack");
- String key = "oof_directives";
- if (!stackInputs.isEmpty() && stackInputs.containsKey(key)) {
- oofDirectives = (String) stackInputs.get(key);
- stackInputs.remove(key);
- }
- key = "sdnc_directives";
- if (!stackInputs.isEmpty() && stackInputs.containsKey(key)) {
- sdncDirectives = (String) stackInputs.get(key);
- stackInputs.remove(key);
- }
- key = "generic_vnf_id";
- if (!stackInputs.isEmpty() && stackInputs.containsKey(key)) {
- genericVnfId = (String) stackInputs.get(key);
- stackInputs.remove(key);
- }
- key = "vf_module_id";
- if (!stackInputs.isEmpty() && stackInputs.containsKey(key)) {
- vfModuleId = (String) stackInputs.get(key);
- stackInputs.remove(key);
+ // Get the directives, if present.
+ String oofDirectives = "";
+ String sdncDirectives = "";
+ String genericVnfId = "";
+ String vfModuleId = "";
+ String templateType = "";
+
+ for (String key: MULTICLOUD_INPUTS) {
+ if (!stackInputs.isEmpty() && stackInputs.containsKey(key)) {
+ if ( key == OOF_DIRECTIVES) {oofDirectives = (String) stackInputs.get(key);}
+ if ( key == SDNC_DIRECTIVES) {sdncDirectives = (String) stackInputs.get(key);}
+ if ( key == GENERIC_VNF_ID) {genericVnfId = (String) stackInputs.get(key);}
+ if ( key == VF_MODULE_ID) {vfModuleId = (String) stackInputs.get(key);}
+ if ( key == TEMPLATE_TYPE) {templateType = (String) stackInputs.get(key);}
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format("Found %s: %s", key, stackInputs.get(key)));
+ }
+ stackInputs.remove(key);
+ }
}
// create the multicloud payload
CreateStackParam stack = createStackParam(stackName, heatTemplate, stackInputs, timeoutMinutes, environment, files, heatFiles);
- MsoMulticloudParam multicloudParam = new MsoMulticloudParam();
- multicloudParam.setGenericVnfId(genericVnfId);
- multicloudParam.setVfModuleId(vfModuleId);
- multicloudParam.setOofDirectives(oofDirectives);
- multicloudParam.setSdncDirectives(sdncDirectives);
- multicloudParam.setTemplateType("heat");
- multicloudParam.setTemplateData(stack.toString());
+ MulticloudRequest multicloudRequest= new MulticloudRequest();
+ HttpEntity<MulticloudRequest> request = null;
+ try {
+ multicloudRequest.setGenericVnfId(genericVnfId);
+ multicloudRequest.setVfModuleId(vfModuleId);
+ multicloudRequest.setOofDirectives(oofDirectives);
+ multicloudRequest.setSdncDirectives(sdncDirectives);
+ multicloudRequest.setTemplateType(templateType);
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format("Stack Template Data is: %s", stack.toString().substring(16)));
+ }
+ multicloudRequest.setTemplateData(JSON_MAPPER.writeValueAsString(stack));
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format("Multicloud Request is: %s", multicloudRequest.toString()));
+ }
+ CloudSite cloudSite = cloudConfig.getCloudSite(cloudSiteId).orElseThrow(() ->
+ new MsoCloudSiteNotFound(cloudSiteId));
+ CloudIdentity cloudIdentity = cloudSite.getIdentityService();
+ HttpHeaders headers = new HttpHeaders();
+ headers.set ("X-Auth-User", cloudIdentity.getMsoId ());
+ headers.set ("X-Auth-Key", CryptoUtils.decryptCloudConfigPassword(cloudIdentity.getMsoPass ()));
+ headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON.toString());
+ headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON.toString());
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format("Multicloud Request Headers: %s", headers.toString()));
+ }
+ request = new HttpEntity<>(multicloudRequest, headers);
+ } catch (Exception e) {
+ logger.debug("ERROR making multicloud JSON body ", e);
+ }
String multicloudEndpoint = getMulticloudEndpoint(cloudSiteId, null);
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format("Multicloud Endpoint is: %s", multicloudEndpoint));
+ }
RestClient multicloudClient = getMulticloudClient(multicloudEndpoint);
- if (multicloudClient != null) {
- Response res = multicloudClient.post(multicloudParam);
- logger.debug("Multicloud Post response is: " + res);
- }
+ Response response = multicloudClient.post(request);
- Stack responseStack = new Stack();
- responseStack.setStackStatus(HeatStatus.CREATED.toString());
+ StackInfo responseStackInfo = new StackInfo();
+ responseStackInfo.setName(stackName);
+ responseStackInfo.setStatus(mapResponseToHeatStatus(response));
- return new StackInfoMapper(responseStack).map();
+ MulticloudCreateResponse multicloudResponseBody = null;
+ if (response.getStatus() == Response.Status.CREATED.getStatusCode() && response.hasEntity()) {
+ multicloudResponseBody = getCreateBody((java.io.InputStream)response.getEntity());
+ responseStackInfo.setCanonicalName(multicloudResponseBody.getWorkloadId());
+ if (logger.isDebugEnabled()) {
+ logger.debug("Multicloud Create Response Body: " + multicloudResponseBody);
+ }
+ }
+
+ return responseStackInfo;
}
+ @Override
public Map<String, Object> queryStackForOutputs(String cloudSiteId,
String tenantId, String stackName) throws MsoException {
logger.debug("MsoHeatUtils.queryStackForOutputs)");
@@ -211,64 +255,129 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
*/
@Override
public StackInfo queryStack (String cloudSiteId, String tenantId, String stackName) throws MsoException {
- logger.debug ("Query multicloud HEAT stack: " + stackName + " in tenant " + tenantId);
+ if (logger.isDebugEnabled()) {
+ logger.debug (String.format("Query multicloud HEAT stack: %s in tenant %s", stackName, tenantId));
+ }
- String multicloudEndpoint = getMulticloudEndpoint(cloudSiteId, stackName);
+ StackInfo returnInfo = new StackInfo();
+ returnInfo.setName(stackName);
+ String multicloudEndpoint = getMulticloudEndpoint(cloudSiteId, stackName);
RestClient multicloudClient = getMulticloudClient(multicloudEndpoint);
if (multicloudClient != null) {
Response response = multicloudClient.get();
- logger.debug("Multicloud Get response is: " + response);
+ if (logger.isDebugEnabled()) {
+ logger.debug (String.format("Mulicloud GET Response: %s", response.toString()));
+ }
+
+ returnInfo.setStatus(mapResponseToHeatStatus(response));
- return new StackInfo (stackName, HeatStatus.CREATED);
+ MulticloudQueryResponse multicloudQueryBody = null;
+ if (response.getStatus() == Response.Status.OK.getStatusCode() && response.hasEntity()) {
+ multicloudQueryBody = getQueryBody((java.io.InputStream)response.getEntity());
+ returnInfo.setCanonicalName(multicloudQueryBody.getWorkloadId());
+ if (logger.isDebugEnabled()) {
+ logger.debug("Multicloud Create Response Body: " + multicloudQueryBody.toString());
+ }
+ }
}
- return new StackInfo (stackName, HeatStatus.NOTFOUND);
+ return returnInfo;
+
}
public StackInfo deleteStack (String cloudSiteId, String tenantId, String stackName) throws MsoException {
- logger.debug ("Delete multicloud HEAT stack: " + stackName + " in tenant " + tenantId);
+ if (logger.isDebugEnabled()) {
+ logger.debug (String.format("Delete multicloud HEAT stack: %s in tenant %s", stackName, tenantId));
+ }
+ StackInfo returnInfo = new StackInfo();
+ returnInfo.setName(stackName);
+ Response response = null;
String multicloudEndpoint = getMulticloudEndpoint(cloudSiteId, stackName);
-
RestClient multicloudClient = getMulticloudClient(multicloudEndpoint);
if (multicloudClient != null) {
- Response response = multicloudClient.delete();
- logger.debug("Multicloud Get response is: " + response);
-
- return new StackInfo (stackName, HeatStatus.DELETING);
+ response = multicloudClient.delete();
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format("Multicloud Delete response is: %s", response.getEntity().toString()));
+ }
}
-
- return new StackInfo (stackName, HeatStatus.FAILED);
+ returnInfo.setStatus(mapResponseToHeatStatus(response));
+ return returnInfo;
}
// ---------------------------------------------------------------
// PRIVATE FUNCTIONS FOR USE WITHIN THIS CLASS
+ private HeatStatus mapResponseToHeatStatus(Response response) {
+ if (response.getStatusInfo().getStatusCode() == Response.Status.OK.getStatusCode()) {
+ return HeatStatus.CREATED;
+ } else if (response.getStatusInfo().getStatusCode() == Response.Status.CREATED.getStatusCode()) {
+ return HeatStatus.CREATED;
+ } else if (response.getStatusInfo().getStatusCode() == Response.Status.NO_CONTENT.getStatusCode()) {
+ return HeatStatus.CREATED;
+ } else if (response.getStatusInfo().getStatusCode() == Response.Status.BAD_REQUEST.getStatusCode()) {
+ return HeatStatus.FAILED;
+ } else if (response.getStatusInfo().getStatusCode() == Response.Status.UNAUTHORIZED.getStatusCode()) {
+ return HeatStatus.FAILED;
+ } else if (response.getStatusInfo().getStatusCode() == Response.Status.NOT_FOUND.getStatusCode()) {
+ return HeatStatus.NOTFOUND;
+ } else if (response.getStatusInfo().getStatusCode() == Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()) {
+ return HeatStatus.FAILED;
+ } else {
+ return HeatStatus.UNKNOWN;
+ }
+ }
+ private MulticloudCreateResponse getCreateBody(java.io.InputStream in) {
+ Scanner scanner = new Scanner(in);
+ scanner.useDelimiter("\\Z");
+ String body = "";
+ if (scanner.hasNext()) {
+ body = scanner.next();
+ }
+ scanner.close();
- private String getMsbHost() {
- // MSB_IP will be set as ONAP_IP environment parameter in install flow.
- String msbIp = System.getenv().get(ONAP_IP);
+ try {
+ return new ObjectMapper().readerFor(MulticloudCreateResponse.class).readValue(body);
+ } catch (Exception e) {
+ logger.debug("Exception retrieving multicloud vfModule POST response body " + e);
+ }
+ return null;
+ }
- // if ONAP IP is not set. get it from config file.
- if (null == msbIp || msbIp.isEmpty()) {
- msbIp = env.getProperty("mso.msb-ip", DEFAULT_MSB_IP);
+ private MulticloudQueryResponse getQueryBody(java.io.InputStream in) {
+ Scanner scanner = new Scanner(in);
+ scanner.useDelimiter("\\Z");
+ String body = "";
+ if (scanner.hasNext()) {
+ body = scanner.next();
}
- Integer msbPort = env.getProperty("mso.msb-port", Integer.class, DEFAULT_MSB_PORT);
+ scanner.close();
- return UriBuilder.fromPath("").host(msbIp).port(msbPort).scheme("http").build().toString();
+ try {
+ return new ObjectMapper().readerFor(MulticloudQueryResponse.class).readValue(body);
+ } catch (Exception e) {
+ logger.debug("Exception retrieving multicloud workload query response body " + e);
+ }
+ return null;
}
private String getMulticloudEndpoint(String cloudSiteId, String workloadId) throws MsoCloudSiteNotFound {
CloudSite cloudSite = cloudConfig.getCloudSite(cloudSiteId).orElseThrow(() -> new MsoCloudSiteNotFound(cloudSiteId));
- String endpoint = getMsbHost() + cloudSite.getIdentityService().getIdentityUrl();
+ String endpoint = cloudSite.getIdentityService().getIdentityUrl();
if (workloadId != null) {
- return endpoint + workloadId;
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format("Multicloud Endpoint is: %s/%s", endpoint, workloadId));
+ }
+ return String.format("%s/%s", endpoint, workloadId);
} else {
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format("Multicloud Endpoint is: %s", endpoint));
+ }
return endpoint;
}
}
@@ -277,13 +386,13 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
RestClient client = null;
try {
client= new HttpClient(UriBuilder.fromUri(endpoint).build().toURL(),
- "application/json", TargetEntity.OPENSTACK_ADAPTER);
+ MediaType.APPLICATION_JSON.toString(), TargetEntity.MULTICLOUD);
} catch (MalformedURLException e) {
- logger.debug("Encountered malformed URL error getting multicloud rest client " + e.getMessage());
+ logger.debug(String.format("Encountered malformed URL error getting multicloud rest client %s", e.getMessage()));
} catch (IllegalArgumentException e) {
- logger.debug("Encountered illegal argument getting multicloud rest client " + e.getMessage());
+ logger.debug(String.format("Encountered illegal argument getting multicloud rest client %s",e.getMessage()));
} catch (UriBuilderException e) {
- logger.debug("Encountered URI builder error getting multicloud rest client " + e.getMessage());
+ logger.debug(String.format("Encountered URI builder error getting multicloud rest client %s", e.getMessage()));
}
return client;
}
@@ -382,7 +491,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
try {
// Delete the Multicloud stack
- StackInfo stackInfo = deleteStack (tenantId, cloudSiteId, instanceId, true);
+ StackInfo stackInfo = deleteStack (tenantId, cloudSiteId, instanceId);
// Populate a VduInstance based on the deleted Cloudify Deployment object
VduInstance vduInstance = stackInfoToVduInstance(stackInfo);
@@ -425,6 +534,9 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
{
VduInstance vduInstance = new VduInstance();
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format("StackInfo to convert: %s", stackInfo.getParameters().toString()));
+ }
// The full canonical name as the instance UUID
vduInstance.setVduInstanceId(stackInfo.getCanonicalName());
vduInstance.setVduInstanceName(stackInfo.getName());
@@ -447,6 +559,12 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
// There are lots of HeatStatus values, so this is a bit long...
HeatStatus heatStatus = stackInfo.getStatus();
String statusMessage = stackInfo.getStatusMessage();
+ logger.debug("HeatStatus = " + heatStatus + " msg = " + statusMessage);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format("Stack Status: %s", heatStatus.toString()));
+ logger.debug(String.format("Stack Status Message: %s", statusMessage));
+ }
if (heatStatus == HeatStatus.INIT || heatStatus == HeatStatus.BUILDING) {
vduStatus.setState(VduStateType.INSTANTIATING);
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateHeatResponse.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateHeatResponse.java
new file mode 100644
index 0000000000..543ad07d52
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateHeatResponse.java
@@ -0,0 +1,77 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 Intel Corp. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.openstack.utils;
+
+import java.io.Serializable;
+import java.util.List;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "id",
+ "links"
+})
+public class MulticloudCreateHeatResponse implements Serializable {
+ private final static long serialVersionUID = -5215028275577848311L;
+
+ @JsonProperty("id")
+ private String id;
+ @JsonProperty("links")
+ private List<MulticloudCreateLinkResponse> links;
+
+ @JsonCreator
+ public MulticloudCreateHeatResponse(
+ @JsonProperty("id") String id,
+ @JsonProperty("links") List<MulticloudCreateLinkResponse> links) {
+ this.id = id;
+ this.links = links;
+ }
+
+ @JsonProperty("id")
+ public String getId() {
+ return id;
+ }
+
+ @JsonProperty("id")
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ @JsonProperty("links")
+ public List<MulticloudCreateLinkResponse> getLinks() {
+ return links;
+ }
+
+ @JsonProperty("links")
+ public void setLinks(List<MulticloudCreateLinkResponse> links) {
+ this.links = links;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this).append("id", id).append("links", links).toString();
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateLinkResponse.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateLinkResponse.java
new file mode 100644
index 0000000000..b609ac96c4
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateLinkResponse.java
@@ -0,0 +1,76 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 Intel Corp. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.openstack.utils;
+
+import java.io.Serializable;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "href",
+ "rel"
+})
+public class MulticloudCreateLinkResponse implements Serializable {
+ private final static long serialVersionUID = -5215028275577848311L;
+
+ @JsonProperty("href")
+ private String href;
+ @JsonProperty("rel")
+ private String rel;
+
+ @JsonCreator
+ public MulticloudCreateLinkResponse(
+ @JsonProperty("href") String href,
+ @JsonProperty("rel") String rel) {
+ this.href = href;
+ this.rel = rel;
+ }
+
+ @JsonProperty("href")
+ public String getHref() {
+ return href;
+ }
+
+ @JsonProperty("href")
+ public void setHref(String href) {
+ this.href = href;
+ }
+
+ @JsonProperty("rel")
+ public String getRel() {
+ return rel;
+ }
+
+ @JsonProperty("rel")
+ public void setRel(String rel) {
+ this.rel = rel;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this).append("href", href).append("rel", rel).toString();
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateResponse.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateResponse.java
new file mode 100644
index 0000000000..fafd4a074d
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateResponse.java
@@ -0,0 +1,90 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 Intel Corp. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.openstack.utils;
+
+import java.io.Serializable;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "template_type",
+ "workload_id",
+ "template_response"
+})
+public class MulticloudCreateResponse implements Serializable {
+ private final static long serialVersionUID = -5215028275577848311L;
+
+ @JsonProperty("template_type")
+ private String templateType;
+ @JsonProperty("workload_id")
+ private String workloadId;
+ @JsonProperty("template_response")
+ private MulticloudCreateStackResponse templateResponse;
+
+ @JsonCreator
+ public MulticloudCreateResponse(
+ @JsonProperty("template_type") String templateType,
+ @JsonProperty("workload_id") String workloadId,
+ @JsonProperty("template_response") MulticloudCreateStackResponse templateResponse) {
+ this.templateType = templateType;
+ this.workloadId = workloadId;
+ this.templateResponse = templateResponse;
+ }
+
+ @JsonProperty("template_type")
+ public String getTemplateType() {
+ return templateType;
+ }
+
+ @JsonProperty("template_type")
+ public void setTemplateType(String templateType) {
+ this.templateType = templateType;
+ }
+
+ @JsonProperty("workload_id")
+ public String getWorkloadId() {
+ return workloadId;
+ }
+
+ @JsonProperty("workload_id")
+ public void setWorkloadId(String workloadId) {
+ this.workloadId = workloadId;
+ }
+
+ @JsonProperty("template_response")
+ public void setTemplateResponse(MulticloudCreateStackResponse templateResponse) {
+ this.templateResponse = templateResponse;
+ }
+
+ @JsonProperty("template_response")
+ public MulticloudCreateStackResponse getTemplateResponse() {
+ return templateResponse;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this).append("templateType", templateType).append("workloadId", workloadId).append("templateResponse", templateResponse).toString();
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateStackResponse.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateStackResponse.java
new file mode 100644
index 0000000000..f1d44a8814
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateStackResponse.java
@@ -0,0 +1,60 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 Intel Corp. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.openstack.utils;
+
+import java.io.Serializable;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "stack"
+})
+public class MulticloudCreateStackResponse implements Serializable {
+ private final static long serialVersionUID = -5215028275577848311L;
+
+ @JsonProperty("stack")
+ private MulticloudCreateHeatResponse stack;
+
+ @JsonCreator
+ public MulticloudCreateStackResponse(
+ @JsonProperty("stack") MulticloudCreateHeatResponse stack) {
+ this.stack = stack;
+ }
+
+ @JsonProperty("stack")
+ public MulticloudCreateHeatResponse getStack() {
+ return stack;
+ }
+
+ @JsonProperty("stack")
+ public void setStack(MulticloudCreateHeatResponse stack) {
+ this.stack = stack;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this).append("stack", stack).toString();
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudQueryResponse.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudQueryResponse.java
new file mode 100644
index 0000000000..b22e9dc03e
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudQueryResponse.java
@@ -0,0 +1,90 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 Intel Corp. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.openstack.utils;
+
+import java.io.Serializable;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "template_type",
+ "workload_id",
+ "workload_status"
+})
+public class MulticloudQueryResponse implements Serializable {
+ private final static long serialVersionUID = -5215028275577848311L;
+
+ @JsonProperty("template_type")
+ private String templateType;
+ @JsonProperty("workload_id")
+ private String workloadId;
+ @JsonProperty("workload_status")
+ private String workloadStatus;
+
+ @JsonCreator
+ public MulticloudQueryResponse(
+ @JsonProperty("template_type") String templateType,
+ @JsonProperty("workload_id") String workloadId,
+ @JsonProperty("workload_status") String workloadStatus) {
+ this.templateType = templateType;
+ this.workloadId = workloadId;
+ this.workloadStatus = workloadStatus;
+ }
+
+ @JsonProperty("template_type")
+ public String getTemplateType() {
+ return templateType;
+ }
+
+ @JsonProperty("template_type")
+ public void setTemplateType(String templateType) {
+ this.templateType = templateType;
+ }
+
+ @JsonProperty("workload_id")
+ public String getWorkloadId() {
+ return workloadId;
+ }
+
+ @JsonProperty("workload_id")
+ public void setWorkloadId(String workloadId) {
+ this.workloadId = workloadId;
+ }
+
+ @JsonProperty("workload_status")
+ public String getWorkloadStatus() {
+ return workloadStatus;
+ }
+
+ @JsonProperty("workload_status")
+ public void setWorkloadStatus(String workloadStatus) {
+ this.workloadStatus = workloadStatus;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this).append("templateType", templateType).append("workloadId", workloadId).append("workloadStatus", workloadStatus).toString();
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudRequest.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudRequest.java
new file mode 100644
index 0000000000..fefc0951f6
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudRequest.java
@@ -0,0 +1,120 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 Intel Corp. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.openstack.utils;
+
+import java.io.Serializable;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "generic-vnf-id",
+ "vf-module-id",
+ "oof_directives",
+ "sdnc_directives",
+ "template_type",
+ "template_data"
+})
+public class MulticloudRequest implements Serializable {
+ private final static long serialVersionUID = -5215028275577848311L;
+
+ @JsonProperty("generic-vnf-id")
+ private String genericVnfId;
+ @JsonProperty("vf-module-id")
+ private String vfModuleId;
+ @JsonProperty("oof_directives")
+ private String oofDirectives;
+ @JsonProperty("sdnc_directives")
+ private String sdncDirectives;
+ @JsonProperty("template_type")
+ private String templateType;
+ @JsonProperty("template_data")
+ private String templateData;
+
+
+ @JsonProperty("generic-vnf-id")
+ public String getGenericVnfId() {
+ return genericVnfId;
+ }
+
+ @JsonProperty("generic-vnf-id")
+ public void setGenericVnfId(String genericVnfId) {
+ this.genericVnfId = genericVnfId;
+ }
+
+ @JsonProperty("vf-module-id")
+ public String getVfModuleId() {
+ return vfModuleId;
+ }
+
+ @JsonProperty("vf-module-id")
+ public void setVfModuleId(String vfModuleId) {
+ this.vfModuleId = vfModuleId;
+ }
+
+ @JsonProperty("oof_directives")
+ public String getOofDirectives() {
+ return oofDirectives;
+ }
+
+ @JsonProperty("oof_directives")
+ public void setOofDirectives(String oofDirectives) {
+ this.oofDirectives = oofDirectives;
+ }
+
+ @JsonProperty("sdnc_directives")
+ public String getSdncDirectives() {
+ return sdncDirectives;
+ }
+
+ @JsonProperty("sdnc_directives")
+ public void setSdncDirectives(String sdncDirectives) {
+ this.sdncDirectives = sdncDirectives;
+ }
+
+ @JsonProperty("template_type")
+ public String getTemplateType() {
+ return templateType;
+ }
+
+ @JsonProperty("template_type")
+ public void setTemplateType(String templateType) {
+ this.templateType = templateType;
+ }
+
+ @JsonProperty("template_data")
+ public String getTemplateData() {
+ return templateData;
+ }
+
+ @JsonProperty("template_data")
+ public void setTemplateData(String templateData) {
+ this.templateData = templateData;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this).append("genericVnfId", genericVnfId).append("vfModuleId", vfModuleId).append("oofDirectives", oofDirectives).append("sdncDirectives", sdncDirectives).append("templateType", templateType).append("templateData", templateData).toString();
+ }
+
+}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/beans/DeploymentInfoBuilderTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/beans/DeploymentInfoBuilderTest.java
new file mode 100644
index 0000000000..8f172b79ca
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/beans/DeploymentInfoBuilderTest.java
@@ -0,0 +1,168 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : SO
+ * ================================================================================
+ * Copyright (C) 2018 Nokia.
+ * =============================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.cloudify.beans;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import com.google.common.collect.ImmutableMap;
+import org.junit.Test;
+import org.onap.so.cloudify.v3.model.Execution;
+
+public class DeploymentInfoBuilderTest {
+
+ private static final String ERROR_MESSAGE = "something went wrong";
+ private static final String INSTALL_WORKFLOW_ID = "install";
+ private static final String UNINSTALL_WORKFLOW_ID = "uninstall";
+
+ @Test
+ public void shouldConstructDeploymentInfo_withBasicValues() {
+ DeploymentInfo deploymentInfo = new DeploymentInfoBuilder()
+ .withId("id")
+ .withStatus(DeploymentStatus.CREATED)
+ .withDeploymentOutputs(ImmutableMap.of())
+ .withDeploymentInputs(ImmutableMap.of())
+ .withActionStatus("started")
+ .withLastAction(INSTALL_WORKFLOW_ID)
+ .withErrorMessage(ERROR_MESSAGE)
+ .build();
+
+ assertThat(deploymentInfo.getId()).isEqualTo("id");
+ assertThat(deploymentInfo.getStatus()).isEqualTo(DeploymentStatus.CREATED);
+ assertThat(deploymentInfo.getOutputs()).isEqualTo(ImmutableMap.of());
+ assertThat(deploymentInfo.getInputs()).isEqualTo(ImmutableMap.of());
+ assertThat(deploymentInfo.getActionStatus()).isEqualTo("started");
+ assertThat(deploymentInfo.getLastAction()).isEqualTo(INSTALL_WORKFLOW_ID);
+ assertThat(deploymentInfo.getErrorMessage()).isEqualTo(ERROR_MESSAGE);
+ }
+
+ @Test
+ public void shouldConstructDeploymentInfo_withCreateDeploymentStatus_fromNullExecution() {
+ DeploymentInfo deploymentInfo = new DeploymentInfoBuilder()
+ .fromExecution(null)
+ .build();
+
+ assertThat(deploymentInfo.getStatus()).isEqualTo(DeploymentStatus.CREATED);
+ }
+
+ @Test
+ public void shouldConstructDeploymentInfo_withInstalledDeploymentStatus_fromTerminatedExecution() {
+ String workflowIdLastAction = INSTALL_WORKFLOW_ID;
+ String status = "terminated";
+ DeploymentStatus expectedDeploymentStatus = DeploymentStatus.INSTALLED;
+ verifyDeploymentInfoConstruction(workflowIdLastAction, status, expectedDeploymentStatus);
+ }
+
+ @Test
+ public void shouldConstructDeploymentInfo_withFailedDeploymentStatus_fromFailedInstallExecution() {
+ String workflowIdLastAction = INSTALL_WORKFLOW_ID;
+ String status = "failed";
+ DeploymentStatus expectedDeploymentStatus = DeploymentStatus.FAILED;
+ verifyDeploymentInfoConstruction(workflowIdLastAction, status, expectedDeploymentStatus);
+ }
+
+ @Test
+ public void shouldConstructDeploymentInfo_withInstallingDeploymentStatus_fromStartedExecution() {
+ String workflowIdLastAction = INSTALL_WORKFLOW_ID;
+ String status = "started";
+ DeploymentStatus expectedDeploymentStatus = DeploymentStatus.INSTALLING;
+ verifyDeploymentInfoConstruction(workflowIdLastAction, status, expectedDeploymentStatus);
+ }
+
+ @Test
+ public void shouldConstructDeploymentInfo_withInstallingDeploymentStatus_fromPendingExecution() {
+ String workflowIdLastAction = INSTALL_WORKFLOW_ID;
+ String status = "pending";
+ DeploymentStatus expectedDeploymentStatus = DeploymentStatus.INSTALLING;
+ verifyDeploymentInfoConstruction(workflowIdLastAction, status, expectedDeploymentStatus);
+ }
+
+ @Test
+ public void shouldConstructDeploymentInfo_withUnknownDeploymentStatus_fromUnmappableExecution() {
+ String workflowIdLastAction = INSTALL_WORKFLOW_ID;
+ String status = "strangeStatus";
+ DeploymentStatus expectedDeploymentStatus = DeploymentStatus.UNKNOWN;
+ verifyDeploymentInfoConstruction(workflowIdLastAction, status, expectedDeploymentStatus);
+ }
+
+ @Test
+ public void shouldConstructDeploymentInfo_withCreatedDeploymentStatus_fromTerminatedExecution() {
+ String workflowIdLastAction = UNINSTALL_WORKFLOW_ID;
+ String status = "terminated";
+ DeploymentStatus expectedDeploymentStatus = DeploymentStatus.CREATED;
+ verifyDeploymentInfoConstruction(workflowIdLastAction, status, expectedDeploymentStatus);
+ }
+
+ @Test
+ public void shouldConstructDeploymentInfo_withFailedDeploymentStatus_fromFailedUninstallExecution() {
+ String workflowIdLastAction = UNINSTALL_WORKFLOW_ID;
+ String status = "failed";
+ DeploymentStatus expectedDeploymentStatus = DeploymentStatus.FAILED;
+ verifyDeploymentInfoConstruction(workflowIdLastAction, status, expectedDeploymentStatus);
+ }
+
+ @Test
+ public void shouldConstructDeploymentInfo_withUninstallingDeploymentStatus_fromStartedUninstallExecution() {
+ String workflowIdLastAction = UNINSTALL_WORKFLOW_ID;
+ String status = "started";
+ DeploymentStatus expectedDeploymentStatus = DeploymentStatus.UNINSTALLING;
+ verifyDeploymentInfoConstruction(workflowIdLastAction, status, expectedDeploymentStatus);
+ }
+
+ @Test
+ public void shouldConstructDeploymentInfo_withUninstallingDeploymentStatus_fromPendingUninstallExecution() {
+ String workflowIdLastAction = UNINSTALL_WORKFLOW_ID;
+ String status = "pending";
+ DeploymentStatus expectedDeploymentStatus = DeploymentStatus.UNINSTALLING;
+ verifyDeploymentInfoConstruction(workflowIdLastAction, status, expectedDeploymentStatus);
+ }
+
+ @Test
+ public void shouldConstructDeploymentInfo_withUnknownDeploymentStatus_fromUnmappableUninstallExecution() {
+ String workflowIdLastAction = UNINSTALL_WORKFLOW_ID;
+ String status = "strangeStatus";
+ DeploymentStatus expectedDeploymentStatus = DeploymentStatus.UNKNOWN;
+ verifyDeploymentInfoConstruction(workflowIdLastAction, status, expectedDeploymentStatus);
+ }
+
+ @Test
+ public void shouldConstructDeploymentInfo_withUnknownDeploymentStatus_forUnknownExecutionWorkflowId() {
+ String workflowIdLastAction = "strangeWorkflowIdLastAction";
+ String status = "strangeStatus";
+ DeploymentStatus expectedDeploymentStatus = DeploymentStatus.UNKNOWN;
+ verifyDeploymentInfoConstruction(workflowIdLastAction, status, expectedDeploymentStatus);
+ }
+
+ private void verifyDeploymentInfoConstruction(String workflowIdLastAction, String actionStatus,
+ DeploymentStatus expectedDeploymentStatus) {
+
+ Execution execution = new Execution();
+ execution.setWorkflowId(workflowIdLastAction);
+ execution.setStatus(actionStatus);
+ execution.setError(ERROR_MESSAGE);
+ DeploymentInfo deploymentInfo = new DeploymentInfoBuilder()
+ .fromExecution(execution)
+ .build();
+
+ assertThat(deploymentInfo.getLastAction()).isEqualTo(workflowIdLastAction);
+ assertThat(deploymentInfo.getActionStatus()).isEqualTo(actionStatus);
+ assertThat(deploymentInfo.getErrorMessage()).isEqualTo(ERROR_MESSAGE);
+ assertThat(deploymentInfo.getStatus()).isEqualTo(expectedDeploymentStatus);
+ }
+} \ No newline at end of file
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/beans/DeploymentInfoTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/beans/DeploymentInfoTest.java
deleted file mode 100644
index e200f9aa96..0000000000
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/beans/DeploymentInfoTest.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
-* ============LICENSE_START=======================================================
- * ONAP : SO
- * ================================================================================
- * Copyright (C) 2018 TechMahindra
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
-*/
-
-package org.onap.so.cloudify.beans;
-
-import static org.mockito.Mockito.mock;
-import java.util.HashMap;
-import java.util.Map;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.onap.so.cloudify.v3.model.Deployment;
-import org.onap.so.cloudify.v3.model.DeploymentOutputs;
-import org.onap.so.cloudify.v3.model.Execution;
-import org.powermock.api.mockito.PowerMockito;
-
-public class DeploymentInfoTest {
-
- @Mock
- DeploymentStatus status;
-
- @Mock
- DeploymentOutputs out;
-
- @Mock
- Execution execution;
-
- @Mock
- Deployment deployment;
-
- @Test
- public void test() {
- Deployment deployment=mock(Deployment.class);
- Map<String,Object> dep=new HashMap();
- Map<String,Object> outputs = new HashMap<String,Object>();
- Map<String,Object> inputs = new HashMap<String,Object>();
- inputs.put("id",dep);
- status=DeploymentStatus.CREATED;
- outputs.put("id", out);
- dep.put("id", outputs);
- DeploymentInfo dinfo=new DeploymentInfo(deployment);
- DeploymentInfo dinfi=new DeploymentInfo("id");
- DeploymentInfo din=new DeploymentInfo("id",outputs);
- DeploymentInfo dfo=new DeploymentInfo("id", status);
- DeploymentInfo dfoi=new DeploymentInfo(deployment, out, execution);
- dinfo=PowerMockito.spy(new DeploymentInfo());
- dinfo.setId("id");
- dinfi.setInputs(inputs);
- din.setStatus(status);
- din.setOutputs(outputs);
- assert(din.toString()!=null);
- assert(din.getOutputs().equals(outputs));
- assert(din.getId().equals("id"));
- assert(din.getStatus().equals(status));
- din.getLastAction();
- din.getErrorMessage();
- din.getActionStatus();
- }
-
-}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/utils/MsoCloudifyUtilsTest2.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/utils/MsoCloudifyUtilsTest2.java
index 96202c5122..c7aecd90be 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/utils/MsoCloudifyUtilsTest2.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/utils/MsoCloudifyUtilsTest2.java
@@ -2,14 +2,16 @@
* ============LICENSE_START=======================================================
* ONAP - SO
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2018 Nokia.
* ================================================================================
* 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.
@@ -17,7 +19,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.onap.so.cloudify.utils;
import static com.shazam.shazamcrest.MatcherAssert.assertThat;
@@ -42,6 +43,7 @@ import org.onap.so.adapters.vdu.VduModelInfo;
import org.onap.so.adapters.vdu.VduStateType;
import org.onap.so.adapters.vdu.VduStatus;
import org.onap.so.cloud.CloudConfig;
+import org.onap.so.cloudify.beans.DeploymentInfoBuilder;
import org.onap.so.db.catalog.beans.CloudIdentity;
import org.onap.so.db.catalog.beans.CloudSite;
import org.onap.so.cloudify.beans.DeploymentInfo;
@@ -82,9 +84,10 @@ public class MsoCloudifyUtilsTest2 {
List<VduArtifact> artifacts = new ArrayList<>();
artifacts.add(artifact);
vduModel.setArtifacts(artifacts);
- DeploymentInfo deployment = new DeploymentInfo();
- deployment.setId("id");
- deployment.setStatus(DeploymentStatus.INSTALLED);
+ DeploymentInfo deployment = new DeploymentInfoBuilder()
+ .withId("id")
+ .withStatus(DeploymentStatus.INSTALLED)
+ .build();
Map<String, byte[]> blueprintFiles = new HashMap<>();
blueprintFiles.put(artifact.getName(), artifact.getContent());
String instanceName = "instanceName";
@@ -118,9 +121,10 @@ public class MsoCloudifyUtilsTest2 {
CloudInfo cloudInfo = new CloudInfo();
cloudInfo.setCloudSiteId("cloudSiteId");
cloudInfo.setTenantId("tenantId");
- DeploymentInfo deployment = new DeploymentInfo();
- deployment.setId("id");
- deployment.setStatus(DeploymentStatus.INSTALLED);
+ DeploymentInfo deployment = new DeploymentInfoBuilder()
+ .withId("id")
+ .withStatus(DeploymentStatus.INSTALLED)
+ .build();
String instanceId = "instanceId";
MsoCloudifyUtils cloudify = Mockito.spy(MsoCloudifyUtils.class);
@@ -148,14 +152,12 @@ public class MsoCloudifyUtilsTest2 {
cloudInfo.setTenantId("tenantId");
String instanceId = "instanceId";
int timeoutMinutes = 1;
- DeploymentInfo deployment = Mockito.mock(DeploymentInfo.class);
- deployment.setId("id");
- deployment.setStatus(DeploymentStatus.CREATED);
- when(deployment.getId()).thenReturn("id");
- when(deployment.getStatus()).thenReturn(DeploymentStatus.CREATED);
- when(deployment.getLastAction()).thenReturn("deleting");
+ DeploymentInfo deploymentInfo = new DeploymentInfoBuilder()
+ .withId("id")
+ .withStatus(DeploymentStatus.CREATED)
+ .withLastAction("deleting").build();
MsoCloudifyUtils cloudify = Mockito.spy(MsoCloudifyUtils.class);
- doReturn(deployment).when(cloudify).uninstallAndDeleteDeployment(cloudInfo.getCloudSiteId(),
+ doReturn(deploymentInfo).when(cloudify).uninstallAndDeleteDeployment(cloudInfo.getCloudSiteId(),
cloudInfo.getTenantId(), instanceId, timeoutMinutes);
VduInstance actual = cloudify.deleteVdu(cloudInfo, instanceId, timeoutMinutes);
@@ -173,16 +175,14 @@ public class MsoCloudifyUtilsTest2 {
status.setLastAction(new PluginAction("deleting", null, null));
expected.setStatus(status);
- DeploymentInfo deployment = Mockito.mock(DeploymentInfo.class);
- deployment.setId("id");
- deployment.setStatus(DeploymentStatus.CREATED);
- when(deployment.getId()).thenReturn("id");
- when(deployment.getStatus()).thenReturn(DeploymentStatus.CREATED);
- when(deployment.getLastAction()).thenReturn("deleting");
+ DeploymentInfo deploymentInfo = new DeploymentInfoBuilder()
+ .withId("id")
+ .withStatus(DeploymentStatus.CREATED)
+ .withLastAction("deleting").build();
MsoCloudifyUtils cloudify = new MsoCloudifyUtils();
- VduInstance actual = cloudify.deploymentInfoToVduInstance(deployment);
+ VduInstance actual = cloudify.deploymentInfoToVduInstance(deploymentInfo);
assertThat(actual, sameBeanAs(expected));
}
@@ -193,16 +193,14 @@ public class MsoCloudifyUtilsTest2 {
expected.setState(VduStateType.DELETING);
expected.setLastAction(new PluginAction("deleting", null, null));
- DeploymentInfo deployment = Mockito.mock(DeploymentInfo.class);
- deployment.setId("id");
- deployment.setStatus(DeploymentStatus.CREATED);
- when(deployment.getId()).thenReturn("id");
- when(deployment.getStatus()).thenReturn(DeploymentStatus.CREATED);
- when(deployment.getLastAction()).thenReturn("deleting");
+ DeploymentInfo deploymentInfo = new DeploymentInfoBuilder()
+ .withId("id")
+ .withStatus(DeploymentStatus.CREATED)
+ .withLastAction("deleting").build();
MsoCloudifyUtils cloudify = new MsoCloudifyUtils();
- VduStatus actual = cloudify.deploymentStatusToVduStatus(deployment);
+ VduStatus actual = cloudify.deploymentStatusToVduStatus(deploymentInfo);
assertThat(actual, sameBeanAs(expected));
}