summaryrefslogtreecommitdiffstats
path: root/adapters/mso-adapter-utils/src
diff options
context:
space:
mode:
Diffstat (limited to 'adapters/mso-adapter-utils/src')
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentInfoBuilder.java4
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java36
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/beans/DeploymentInfoBuilderTest.java6
3 files changed, 25 insertions, 21 deletions
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
index 2e12869c95..3b945ae484 100644
--- 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
@@ -44,7 +44,9 @@ public final class DeploymentInfoBuilder {
}
public DeploymentInfoBuilder withDeploymentOutputs(Map<String, Object> deploymentOutputs) {
- this.deploymentOutputs = deploymentOutputs;
+ if (deploymentOutputs != null) {
+ this.deploymentOutputs = deploymentOutputs;
+ }
return this;
}
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 bee2d09711..6b16194471 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
@@ -104,7 +104,6 @@ import org.springframework.stereotype.Component;
@Component
public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{
- private static final String CLOUDIFY_ERROR = "CloudifyError";
private static final String CLOUDIFY = "Cloudify";
private static final String CREATE_DEPLOYMENT = "CreateDeployment";
private static final String DELETE_DEPLOYMENT = "DeleteDeployment";
@@ -258,11 +257,10 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{
if (installWorkflow.getStatus().equals(TERMINATED)) {
// Success!
// Create and return a DeploymentInfo structure. Include the Runtime outputs
- DeploymentOutputs outputs = getDeploymentOutputs (cloudify, deploymentId);
return new DeploymentInfoBuilder()
.withId(deployment.getId())
.withDeploymentInputs(deployment.getInputs())
- .withDeploymentOutputs(outputs.getOutputs())
+ .withDeploymentOutputs(getDeploymentOutputs(cloudify, deploymentId).get())
.fromExecution(installWorkflow)
.build();
}
@@ -352,16 +350,21 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{
* Get the runtime Outputs of a deployment.
* Return the Map of tag/value outputs.
*/
- private DeploymentOutputs getDeploymentOutputs (Cloudify cloudify, String deploymentId)
+ private Optional<Map<String, Object>> getDeploymentOutputs (Cloudify cloudify, String deploymentId)
throws MsoException
{
// Build and send the Cloudify request
- DeploymentOutputs deploymentOutputs = null;
+ DeploymentOutputs deploymentOutputs;
try {
GetDeploymentOutputs queryDeploymentOutputs = cloudify.deployments().outputsById(deploymentId);
logger.debug(queryDeploymentOutputs.toString());
deploymentOutputs = executeAndRecordCloudifyRequest(queryDeploymentOutputs);
+ if (deploymentOutputs != null) {
+ return Optional.ofNullable(deploymentOutputs.getOutputs());
+ } else {
+ return Optional.empty();
+ }
}
catch (CloudifyConnectException ce) {
// Couldn't connect to Cloudify
@@ -372,7 +375,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{
catch (CloudifyResponseException re) {
if (re.getStatus () == 404) {
// No Outputs
- return null;
+ return Optional.empty();
}
throw new MsoCloudifyException (re.getStatus(), re.getMessage(), re.getLocalizedMessage(), re);
}
@@ -380,8 +383,6 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{
// Catch-all
throw new MsoAdapterException (e.getMessage(), e);
}
-
- return deploymentOutputs;
}
/*
@@ -579,16 +580,11 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{
// Build and send the Cloudify request
Deployment deployment = new Deployment();
- DeploymentOutputs outputs = null;
try {
GetDeployment queryDeployment = cloudify.deployments().byId(deploymentId);
logger.debug(queryDeployment.toString());
-
-// deployment = queryDeployment.execute();
deployment = executeAndRecordCloudifyRequest(queryDeployment);
- outputs = getDeploymentOutputs (cloudify, deploymentId);
-
// Next look for the latest execution
ListExecutions listExecutions = cloudify.executions().listFiltered ("deployment_id=" + deploymentId, "-created_at");
Executions executions = listExecutions.execute();
@@ -604,7 +600,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{
return new DeploymentInfoBuilder()
.withId(deployment.getId())
.withDeploymentInputs(deployment.getInputs())
- .withDeploymentOutputs(outputs.getOutputs())
+ .withDeploymentOutputs(getDeploymentOutputs(cloudify, deploymentId).get())
.fromExecution(executions.getItems().get(0))
.build();
}
@@ -623,7 +619,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{
return new DeploymentInfoBuilder()
.withId(deployment.getId())
.withDeploymentInputs(deployment.getInputs())
- .withDeploymentOutputs(outputs.getOutputs())
+ .withDeploymentOutputs(getDeploymentOutputs(cloudify, deploymentId).get())
.build();
} else {
// Deployment not found. Default status of a DeploymentInfo object is NOTFOUND
@@ -670,12 +666,11 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{
logger.debug ("Ready to Uninstall/Delete Deployment ({})", deploymentId);
// Query first to save the trouble if deployment not found
- Deployment deployment = null;
- try {
+ try {
GetDeployment queryDeploymentRequest = cloudify.deployments().byId(deploymentId);
logger.debug(queryDeploymentRequest.toString());
- deployment = executeAndRecordCloudifyRequest (queryDeploymentRequest);
+ // deployment = executeAndRecordCloudifyRequest (queryDeploymentRequest);
}
catch (CloudifyResponseException e) {
// Since this came on the 'Create Deployment' command, nothing was changed
@@ -707,7 +702,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{
/*
* Query the outputs before deleting so they can be returned as well
*/
- DeploymentOutputs outputs = getDeploymentOutputs (cloudify, deploymentId);
+ //DeploymentOutputs outputs = getDeploymentOutputs (cloudify, deploymentId);
/*
* Next execute the "uninstall" workflow.
@@ -745,6 +740,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{
// At this point, the deployment has been successfully uninstalled.
// Next step is to delete the deployment itself
+ Deployment deployment;
try {
DeleteDeployment deleteRequest = cloudify.deployments().deleteByName(deploymentId);
logger.debug(deleteRequest.toString());
@@ -781,7 +777,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{
return new DeploymentInfoBuilder()
.withId(deployment.getId())
.withDeploymentInputs(deployment.getInputs())
- .withDeploymentOutputs(outputs.getOutputs())
+ .withDeploymentOutputs(getDeploymentOutputs(cloudify, deploymentId).get())
.fromExecution(uninstallWorkflow)
.build();
}
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
index 8f172b79ca..ce13d98dd1 100644
--- 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
@@ -149,6 +149,12 @@ public class DeploymentInfoBuilderTest {
verifyDeploymentInfoConstruction(workflowIdLastAction, status, expectedDeploymentStatus);
}
+ @Test
+ public void shouldSetEmptyOutputsMapWhenInputIsNull() {
+ DeploymentInfo deploymentInfo = new DeploymentInfoBuilder().withDeploymentOutputs(null).build();
+ assertThat(deploymentInfo.getOutputs()).isEmpty();
+ }
+
private void verifyDeploymentInfoConstruction(String workflowIdLastAction, String actionStatus,
DeploymentStatus expectedDeploymentStatus) {