aboutsummaryrefslogtreecommitdiffstats
path: root/adapters
diff options
context:
space:
mode:
Diffstat (limited to 'adapters')
-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/main/java/org/onap/so/openstack/utils/StackStatusHandler.java4
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java40
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/StackStatusHandlerTest.java6
-rw-r--r--adapters/mso-requests-db-adapter/src/main/resources/db/migration/V5.9__Add_Column_Ext_System_Error_Source.sql4
5 files changed, 29 insertions, 31 deletions
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 b634b0c3a5..c323bb699d 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
@@ -253,7 +253,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
protected Stack createStack(CreateStackParam stack, String cloudSiteId, String tenantId) throws MsoException {
try {
OpenStackRequest<Stack> request = getHeatClient(cloudSiteId, tenantId).getStacks().create(stack);
- saveStackRequest(request, MDC.get(ONAPLogConstants.MDCs.REQUEST_ID), stack.getStackName());
+ saveStackRequest(stack, MDC.get(ONAPLogConstants.MDCs.REQUEST_ID), stack.getStackName());
return executeAndRecordOpenstackRequest(request);
} catch (OpenStackResponseException e) {
if (e.getStatus() == 409) {
@@ -341,11 +341,11 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
}
}
- protected void saveStackRequest(OpenStackRequest<Stack> request, String requestId, String stackName) {
+ protected void saveStackRequest(CreateStackParam request, String requestId, String stackName) {
try {
ObjectMapper mapper = new ObjectMapper();
InfraActiveRequests foundRequest = requestDBClient.getInfraActiveRequestbyRequestId(requestId);
- String stackRequest = mapper.writeValueAsString(request.entity());
+ String stackRequest = mapper.writeValueAsString(request.getParameters());
CloudApiRequests cloudReq = new CloudApiRequests();
cloudReq.setCloudIdentifier(stackName);
cloudReq.setRequestBody(stackRequest);
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/StackStatusHandler.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/StackStatusHandler.java
index df173c002d..625b584257 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/StackStatusHandler.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/StackStatusHandler.java
@@ -28,8 +28,8 @@ public class StackStatusHandler {
String requestId = MDC.get(ONAPLogConstants.MDCs.REQUEST_ID);
String stackStatus = mapper.writeValueAsString(stack);
RequestProcessingData requestProcessingData =
- requestDBClient.getRequestProcessingDataBySoRequestIdAndNameAndGrouping(requestId, stack.getId(),
- stack.getStackName());
+ requestDBClient.getRequestProcessingDataBySoRequestIdAndNameAndGrouping(requestId,
+ stack.getStackName(), stack.getId());
if (requestProcessingData == null) {
requestProcessingData = new RequestProcessingData();
requestProcessingData.setGroupingId(stack.getId());
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 28ad069f8b..6673e69a09 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
@@ -34,7 +34,9 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -52,7 +54,6 @@ 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.woorea.openstack.base.client.Entity;
import com.woorea.openstack.base.client.OpenStackResponseException;
import com.woorea.openstack.heat.Heat;
import com.woorea.openstack.heat.StackResource;
@@ -122,7 +123,6 @@ public class MsoHeatUtilsTest extends MsoHeatUtils {
latestStack.setStackName("stackName");
latestStack.setStackStatus("CREATE_COMPLETE");
latestStack.setStackStatusReason("Stack Finished");
- doNothing().when(stackStatusHandler).updateStackStatus(stack);
doReturn(latestStack).when(heatUtils).queryHeatStack(isA(Heat.class), eq("stackName/id"));
doReturn(heatClient).when(heatUtils).getHeatClient(cloudSiteId, tenantId);
Stack actual = heatUtils.pollStackForStatus(1, stack, "CREATE_IN_PROGRESS", cloudSiteId, tenantId);
@@ -397,26 +397,23 @@ public class MsoHeatUtilsTest extends MsoHeatUtils {
heatUtils.createStack(createStackParam, cloudSiteId, tenantId);
Mockito.verify(stackResource, times(1)).create(createStackParam);
- Mockito.verify(heatUtils, times(1)).saveStackRequest(eq(mockCreateStack), isNull(), eq("stackName"));
+ Mockito.verify(heatUtils, times(1)).saveStackRequest(eq(createStackParam), isNull(), eq("stackName"));
Mockito.verify(heatClient, times(1)).getStacks();
Mockito.verify(stackResource, times(1)).create(createStackParam);
}
@Test
public final void saveStack_Test() throws MsoException, IOException, NovaClientException {
- Stack stack = new Stack();
- stack.setId("id");
- stack.setStackName("stackName");
- stack.setStackStatus("CREATE_FAILED");
- stack.setStackStatusReason(
- "Resource CREATE failed: Conflict: resources.my_keypair: Key pair 'hst3bbfnm0011vm001' already exists. (HTTP 409) (Request-ID: req-941b0af6-63ae-4d6a-afbc-90b728bacf82");
- Entity<Stack> entity = new Entity(stack, "application/json");
- doReturn(entity).when(mockCreateStack).entity();
+ CreateStackParam createStackParam = new CreateStackParam();
+ createStackParam.setStackName("stackName");
+ Map<String, Object> parameters = new HashMap<String, Object>();
+ parameters.put("test", "value");
+ createStackParam.setParameters(parameters);
InfraActiveRequests request = new InfraActiveRequests();
request.setRequestId("requestId");
doReturn(request).when(requestDbClient).getInfraActiveRequestbyRequestId("requestId");
doNothing().when(requestDbClient).updateInfraActiveRequests(request);
- heatUtils.saveStackRequest(mockCreateStack, "requestId", "stackName");
+ heatUtils.saveStackRequest(createStackParam, "requestId", "stackName");
Mockito.verify(requestDbClient, times(1)).updateInfraActiveRequests(request);
assertNotNull(request.getCloudApiRequests().get(0));
assertEquals(request.getCloudApiRequests().get(0).getRequestId(), "requestId");
@@ -424,14 +421,11 @@ public class MsoHeatUtilsTest extends MsoHeatUtils {
@Test
public final void saveStack__Exists_Test() throws MsoException, IOException, NovaClientException {
- Stack stack = new Stack();
- stack.setId("id");
- stack.setStackName("stackName");
- stack.setStackStatus("CREATE_FAILED");
- stack.setStackStatusReason(
- "Resource CREATE failed: Conflict: resources.my_keypair: Key pair 'hst3bbfnm0011vm001' already exists. (HTTP 409) (Request-ID: req-941b0af6-63ae-4d6a-afbc-90b728bacf82");
- Entity<Stack> entity = new Entity(stack, "application/json");
- doReturn(entity).when(mockCreateStack).entity();
+ CreateStackParam createStackParam = new CreateStackParam();
+ createStackParam.setStackName("stackName");
+ Map<String, Object> parameters = new HashMap<String, Object>();
+ parameters.put("test", "value");
+ createStackParam.setParameters(parameters);
InfraActiveRequests request = new InfraActiveRequests();
request.setRequestId("requestId");
CloudApiRequests cloudRequest = new CloudApiRequests();
@@ -441,7 +435,7 @@ public class MsoHeatUtilsTest extends MsoHeatUtils {
request.getCloudApiRequests().add(cloudRequest);
doReturn(request).when(requestDbClient).getInfraActiveRequestbyRequestId("requestId");
doNothing().when(requestDbClient).updateInfraActiveRequests(request);
- heatUtils.saveStackRequest(mockCreateStack, "requestId", "stackName");
+ heatUtils.saveStackRequest(createStackParam, "requestId", "stackName");
Mockito.verify(requestDbClient, times(1)).updateInfraActiveRequests(request);
assertNotNull(request.getCloudApiRequests().get(0));
assertEquals("requestId", request.getCloudApiRequests().get(0).getRequestId());
@@ -463,7 +457,7 @@ public class MsoHeatUtilsTest extends MsoHeatUtils {
exceptionRule.expectMessage("Unknown Error");
heatUtils.createStack(createStackParam, cloudSiteId, tenantId);
Mockito.verify(stackResource, times(1)).create(createStackParam);
- Mockito.verify(heatUtils, times(1)).saveStackRequest(eq(mockCreateStack), isNull(), eq("stackName"));
+ Mockito.verify(heatUtils, times(1)).saveStackRequest(eq(createStackParam), isNull(), eq("stackName"));
Mockito.verify(heatClient, times(1)).getStacks();
Mockito.verify(stackResource, times(1)).create(createStackParam);
}
@@ -483,7 +477,7 @@ public class MsoHeatUtilsTest extends MsoHeatUtils {
exceptionRule.expectMessage("Stack stackName already exists in Tenant tenantId in Cloud cloudSiteId");
heatUtils.createStack(createStackParam, cloudSiteId, tenantId);
Mockito.verify(stackResource, times(1)).create(createStackParam);
- Mockito.verify(heatUtils, times(1)).saveStackRequest(eq(mockCreateStack), isNull(), eq("stackName"));
+ Mockito.verify(heatUtils, times(1)).saveStackRequest(eq(createStackParam), isNull(), eq("stackName"));
Mockito.verify(heatClient, times(1)).getStacks();
Mockito.verify(stackResource, times(1)).create(createStackParam);
}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/StackStatusHandlerTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/StackStatusHandlerTest.java
index 54e2bbf06d..0d5cd6a118 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/StackStatusHandlerTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/StackStatusHandlerTest.java
@@ -33,7 +33,7 @@ public class StackStatusHandlerTest {
requestProcessingData.setValue("testMe");
doReturn(requestProcessingData).when(requestDBClient)
- .getRequestProcessingDataBySoRequestIdAndNameAndGrouping(null, "id", "stackName");
+ .getRequestProcessingDataBySoRequestIdAndNameAndGrouping(null, "stackName", "id");
Stack latestStack = new Stack();
latestStack.setId("id");
latestStack.setStackName("stackName");
@@ -48,8 +48,8 @@ public class StackStatusHandlerTest {
@Test
public final void record_Not_Exists_Test() throws MsoException, IOException {
ArgumentCaptor<RequestProcessingData> requestCaptor = ArgumentCaptor.forClass(RequestProcessingData.class);
- doReturn(null).when(requestDBClient).getRequestProcessingDataBySoRequestIdAndNameAndGrouping(null, "id",
- "stackName");
+ doReturn(null).when(requestDBClient).getRequestProcessingDataBySoRequestIdAndNameAndGrouping(null, "stackName",
+ "id");
Stack latestStack = new Stack();
latestStack.setId("id");
latestStack.setStackName("stackName");
diff --git a/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V5.9__Add_Column_Ext_System_Error_Source.sql b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V5.9__Add_Column_Ext_System_Error_Source.sql
new file mode 100644
index 0000000000..e76dbbe883
--- /dev/null
+++ b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V5.9__Add_Column_Ext_System_Error_Source.sql
@@ -0,0 +1,4 @@
+use requestdb;
+
+ALTER TABLE infra_active_requests ADD COLUMN IF NOT EXISTS EXT_SYSTEM_ERROR_SOURCE varchar(80);
+ALTER TABLE archived_infra_requests ADD COLUMN IF NOT EXISTS EXT_SYSTEM_ERROR_SOURCE varchar(80); \ No newline at end of file