aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGamboa, Gilbert <gilbert.g.gamboa@att.com>2019-07-25 11:10:05 -0400
committerBenjamin, Max (mb388a) <mb388a@att.com>2019-07-25 11:10:06 -0400
commitd7cd3bcf7a9631dc7e4bb51b2b4099b786d665ca (patch)
treebebdbeb1e2758ecb535f73a45bed59ba608b363a
parent5128f152409017604d97b1e2f711a77a4c3acdf3 (diff)
store heat env file sent to heat
Initial commit, include heat environment info in cloud-api_requests. Updated MSOHeatUtilsTest.saveStackTest unit test to assert cloudApiRequests requestBody Issue-ID: SO-2158 Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com> Change-Id: I333cae7746459917ba5e64feb07db4f710b8d99b
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/beans/CreateStackRequest.java36
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java6
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java16
3 files changed, 56 insertions, 2 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/beans/CreateStackRequest.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/beans/CreateStackRequest.java
new file mode 100644
index 0000000000..86be9ec3d8
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/beans/CreateStackRequest.java
@@ -0,0 +1,36 @@
+package org.onap.so.openstack.beans;
+
+import java.util.Map;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class CreateStackRequest {
+
+ @JsonProperty("parameters")
+ private Map<String, Object> parameters;
+
+ @JsonProperty("environment")
+ private String environment;
+
+ public Map<String, Object> getParameters() {
+ return parameters;
+ }
+
+ public void setParameters(Map<String, Object> parameters) {
+ this.parameters = parameters;
+ }
+
+ public String getEnvironment() {
+ return environment;
+ }
+
+ public void setEnvironment(String environment) {
+ this.environment = environment;
+ }
+
+ @Override
+ public String toString() {
+ return "CreateStackRequest [parameters=" + parameters + ", environment=" + environment + "]";
+ }
+
+
+}
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 28d4f3f9b4..1d75892138 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
@@ -55,6 +55,7 @@ import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.client.RequestsDbClient;
import org.onap.so.logger.ErrorCode;
import org.onap.so.logger.MessageEnum;
+import org.onap.so.openstack.beans.CreateStackRequest;
import org.onap.so.openstack.beans.HeatStatus;
import org.onap.so.openstack.beans.StackInfo;
import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound;
@@ -354,7 +355,10 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
try {
ObjectMapper mapper = new ObjectMapper();
InfraActiveRequests foundRequest = requestDBClient.getInfraActiveRequestbyRequestId(requestId);
- String stackRequest = mapper.writeValueAsString(request.getParameters());
+ CreateStackRequest createStackRequest = new CreateStackRequest();
+ createStackRequest.setEnvironment(request.getEnvironment());
+ createStackRequest.setParameters(request.getParameters());
+ String stackRequest = mapper.writeValueAsString(createStackRequest);
CloudApiRequests cloudReq = new CloudApiRequests();
cloudReq.setCloudIdentifier(stackName);
cloudReq.setRequestBody(stackRequest);
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java
index 687b7d8d2f..e840d5affd 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java
@@ -48,10 +48,12 @@ import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.db.request.beans.CloudApiRequests;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.client.RequestsDbClient;
+import org.onap.so.openstack.beans.CreateStackRequest;
import org.onap.so.openstack.exceptions.MsoException;
import org.onap.so.openstack.exceptions.MsoOpenstackException;
import org.onap.so.openstack.exceptions.MsoStackAlreadyExists;
import org.springframework.core.env.Environment;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.woorea.openstack.base.client.OpenStackResponseException;
import com.woorea.openstack.heat.Heat;
import com.woorea.openstack.heat.StackResource;
@@ -415,11 +417,22 @@ public class MsoHeatUtilsTest extends MsoHeatUtils {
@Test
public final void saveStack_Test() throws MsoException, IOException, NovaClientException {
+
CreateStackParam createStackParam = new CreateStackParam();
createStackParam.setStackName("stackName");
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("test", "value");
+ String environment =
+ "parameters:\n mmn_volume_name_1: \"data-mn-v-vdb\"\n mmn_volume_name_2: \"arch-mn-v-vdc\"\n";
createStackParam.setParameters(parameters);
+ createStackParam.setEnvironment(environment);
+
+ CreateStackRequest createStackRequest = new CreateStackRequest();
+ createStackRequest.setEnvironment(environment);
+ createStackRequest.setParameters(parameters);
+ ObjectMapper mapper = new ObjectMapper();
+ String stackRequest = mapper.writeValueAsString(createStackRequest);
+
InfraActiveRequests request = new InfraActiveRequests();
request.setRequestId("requestId");
doReturn(request).when(requestDbClient).getInfraActiveRequestbyRequestId("requestId");
@@ -427,7 +440,8 @@ public class MsoHeatUtilsTest extends MsoHeatUtils {
heatUtils.saveStackRequest(createStackParam, "requestId", "stackName");
Mockito.verify(requestDbClient, times(1)).updateInfraActiveRequests(request);
assertNotNull(request.getCloudApiRequests().get(0));
- assertEquals(request.getCloudApiRequests().get(0).getRequestId(), "requestId");
+ assertEquals("requestId", request.getCloudApiRequests().get(0).getRequestId());
+ assertEquals(stackRequest, request.getCloudApiRequests().get(0).getRequestBody());
}
@Test