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.java30
-rw-r--r--adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/beans/StackInfo.java17
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java27
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java14
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MSONetworkAdapterImplTest.java23
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImplTest.java7
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java14
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java19
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestTest.java11
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2Test.java11
-rw-r--r--adapters/mso-openstack-adapters/src/test/resources/application-test.yaml3
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsScheduler.java5
-rw-r--r--adapters/mso-requests-db-adapter/src/main/resources/db/migration/V7.3.1__AddResourceStatusMessageColumn.sql4
13 files changed, 156 insertions, 29 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 62b9c04e3f..8207c7c589 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
@@ -101,8 +101,6 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
private static final String CREATE_IN_PROGRESS = "CREATE_IN_PROGRESS";
- private static final String DELETE_STACK = "DeleteStack";
-
protected static final String HEAT_ERROR = "HeatError";
protected static final String CREATE_STACK = "CreateStack";
@@ -115,14 +113,14 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
private Environment environment;
@Autowired
- RequestsDbClient requestDBClient;
-
- @Autowired
StackStatusHandler statusHandler;
@Autowired
NovaClientImpl novaClient;
+ @Autowired
+ RequestsDbClient requestDBClient;
+
private static final Logger logger = LoggerFactory.getLogger(MsoHeatUtils.class);
// Properties names and variables (with default values)
@@ -182,6 +180,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
CreateStackParam createStack = createStackParam(stackName, heatTemplate, stackInputs, timeoutMinutes,
environment, nestedTemplates, heatFiles);
Stack currentStack = queryHeatStack(stackName, cloudSiteId, tenantId);
+ boolean operationPerformed = false;
if (currentStack != null) {
logger.debug("Existing Stack found with Status: {} ", currentStack.getStackStatus());
if (CREATE_COMPLETE.equals(currentStack.getStackStatus())) {
@@ -220,8 +219,11 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
currentStack =
queryHeatStack(currentStack.getStackName() + "/" + currentStack.getId(), cloudSiteId, tenantId);
}
+ operationPerformed = true;
}
- return new StackInfoMapper(currentStack).map();
+ StackInfo stackInfo = new StackInfoMapper(currentStack).map();
+ stackInfo.setOperationPerformed(operationPerformed);
+ return stackInfo;
}
/**
@@ -497,14 +499,17 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
public StackInfo deleteStack(String tenantId, String cloudOwner, String cloudSiteId, String stackName,
boolean pollForCompletion, int timeoutMinutes) throws MsoException {
Stack currentStack = queryHeatStack(stackName, cloudSiteId, tenantId);
+ StackInfo stackInfo = null;
if (currentStack == null || DELETE_COMPLETE.equals(currentStack.getStackStatus())) {
- return new StackInfo(stackName, HeatStatus.NOTFOUND);
+ stackInfo = new StackInfo(stackName, HeatStatus.NOTFOUND);
+ stackInfo.setOperationPerformed(false);
} else {
currentStack = deleteStack(currentStack, timeoutMinutes, cloudSiteId, tenantId);
- StackInfo stackInfo = new StackInfoMapper(currentStack).map();
+ stackInfo = new StackInfoMapper(currentStack).map();
stackInfo.setName(stackName);
- return stackInfo;
+ stackInfo.setOperationPerformed(true);
}
+ return stackInfo;
}
/**
@@ -1182,4 +1187,11 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
}
}
+ public void updateResourceStatus(String requestId, String resourceStatusMessage) {
+ InfraActiveRequests request = new InfraActiveRequests();
+ request.setRequestId(requestId);
+ request.setResourceStatusMessage(resourceStatusMessage);
+ requestDBClient.patchInfraActiveRequests(request);
+ }
+
}
diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/beans/StackInfo.java b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/beans/StackInfo.java
index 76d3667632..7e2071525d 100644
--- a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/beans/StackInfo.java
+++ b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/beans/StackInfo.java
@@ -7,9 +7,9 @@
* 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.
@@ -26,7 +26,7 @@ import java.util.Map;
/*
* 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)
*/
@@ -36,6 +36,7 @@ public class StackInfo {
private String canonicalName = "";
private HeatStatus status = HeatStatus.UNKNOWN;
private String statusMessage = "";
+ private boolean operationPerformed;
private Map<String, Object> outputs = new HashMap<>();
private Map<String, Object> parameters = new HashMap<>();
@@ -106,5 +107,15 @@ public class StackInfo {
this.parameters = parameters;
}
+ public boolean isOperationPerformed() {
+ return operationPerformed;
+ }
+
+ public void setOperationPerformed(boolean operationPerformed) {
+ this.operationPerformed = operationPerformed;
+ }
+
+
+
}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java
index 5530fad298..257374fdb2 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java
@@ -92,6 +92,13 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
private static final String NEUTRON_MODE = "NEUTRON";
private static final String CLOUD_OWNER = "CloudOwner";
private static final String LOG_DEBUG_MSG = "Got Network definition from Catalog: {}";
+ private static final String NETWORK_EXIST_STATUS_MESSAGE =
+ "The network was found to already exist, thus no new network was created in the cloud via this request";
+ private static final String NETWORK_CREATED_STATUS_MESSAGE =
+ "The new network was successfully created in the cloud";
+ private static final String NETWORK_NOT_EXIST_STATUS_MESSAGE =
+ "The network as not found, thus no network was deleted in the cloud via this request";
+ private static final String NETWORK_DELETED_STATUS_MESSAGE = "The network was successfully deleted in the cloud";
private static final Logger logger = LoggerFactory.getLogger(MsoNetworkAdapterImpl.class);
@@ -225,7 +232,6 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
// See if the Network already exists (by name)
NetworkInfo netInfo = null;
- long queryNetworkStarttime = System.currentTimeMillis();
try {
netInfo = neutron.queryNetwork(networkName, tenantId, cloudSiteId);
} catch (MsoException me) {
@@ -254,10 +260,10 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
logger.warn("{} {} Found Existing network, status={} for Neutron mode ",
MessageEnum.RA_NETWORK_ALREADY_EXIST, ErrorCode.DataError.getValue(), netInfo.getStatus());
}
+ heat.updateResourceStatus(msoRequest.getRequestId(), NETWORK_EXIST_STATUS_MESSAGE);
return;
}
- long createNetworkStarttime = System.currentTimeMillis();
try {
netInfo = neutron.createNetwork(cloudSiteId, tenantId, neutronNetworkType, networkName,
physicalNetworkName, vlans);
@@ -360,6 +366,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
MessageEnum.RA_NETWORK_ALREADY_EXIST, ErrorCode.DataError.getValue(), heatStack.getStatus(),
networkName, cloudSiteId, tenantId);
}
+ heat.updateResourceStatus(msoRequest.getRequestId(), NETWORK_EXIST_STATUS_MESSAGE);
return;
}
@@ -473,6 +480,12 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
networkRollback.setNetworkCreated(true);
networkRollback.setNetworkType(networkType);
+ try {
+ heat.updateResourceStatus(msoRequest.getRequestId(), NETWORK_CREATED_STATUS_MESSAGE);
+ } catch (Exception e) {
+ logger.warn("Exception while updating infra active request", e);
+ }
+
logger.debug("Network {} successfully created via HEAT", networkName);
}
@@ -1055,8 +1068,8 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
}
} else {
try {
- heat.deleteStack(tenantId, CLOUD_OWNER, cloudSiteId, networkId, true, timeoutMinutes);
- networkDeleted.value = true;
+ StackInfo stack = heat.deleteStack(tenantId, CLOUD_OWNER, cloudSiteId, networkId, true, timeoutMinutes);
+ networkDeleted.value = stack.isOperationPerformed();
} catch (MsoException me) {
me.addContext("DeleteNetwork");
logger.error("{} {} Delete Network (heat): {} in {}/{} ", MessageEnum.RA_DELETE_NETWORK_EXC,
@@ -1064,6 +1077,12 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
throw new NetworkException(me);
}
}
+ try {
+ heat.updateResourceStatus(msoRequest.getRequestId(),
+ networkDeleted.value ? NETWORK_DELETED_STATUS_MESSAGE : NETWORK_NOT_EXIST_STATUS_MESSAGE);
+ } catch (Exception e) {
+ logger.warn("Exception while updating infra active request", e);
+ }
}
/**
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java
index 0dc0d1c290..32e88d8cad 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java
@@ -109,6 +109,12 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
private static final String USER_ERROR = "USER ERROR";
private static final String VERSION_MIN = "VersionMin";
private static final String VERSION_MAX = "VersionMax";
+ private static final String VF_EXIST_STATUS_MESSAGE =
+ "The vf module was found to already exist, thus no new vf module was created in the cloud via this request";
+ private static final String VF_CREATED_STATUS_MESSAGE = "The new vf module was successfully created in the cloud";
+ private static final String VF_NOT_EXIST_STATUS_MESSAGE =
+ "The vf module was not, thus no vf module was deleted in the cloud via this request";
+ private static final String VF_DELETED_STATUS_MESSAGE = "The vf module was successfully deleted in the cloud";
@Autowired
private VFModuleCustomizationRepository vfModuleCustomRepo;
@@ -1046,6 +1052,9 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
heatStack = msoHeatUtils.createStack(cloudSiteId, cloudOwner, tenantId, vfModuleName, null,
template, goldenInputs, true, heatTemplate.getTimeoutMinutes(), newEnvironmentString,
nestedTemplatesChecked, heatFilesObjects, backout.booleanValue(), failIfExists);
+
+ msoHeatUtils.updateResourceStatus(msoRequest.getRequestId(),
+ heatStack.isOperationPerformed() ? VF_EXIST_STATUS_MESSAGE : VF_CREATED_STATUS_MESSAGE);
} else {
throw new MsoHeatNotFoundException();
}
@@ -1125,7 +1134,10 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
}
try {
- msoHeatUtils.deleteStack(tenantId, cloudOwner, cloudSiteId, vnfName, true, timeoutMinutes);
+ StackInfo stackInfo =
+ msoHeatUtils.deleteStack(tenantId, cloudOwner, cloudSiteId, vnfName, true, timeoutMinutes);
+ msoHeatUtils.updateResourceStatus(msoRequest.getRequestId(),
+ stackInfo.isOperationPerformed() ? VF_DELETED_STATUS_MESSAGE : VF_NOT_EXIST_STATUS_MESSAGE);
} catch (MsoException me) {
me.addContext(DELETE_VNF);
// Failed to query the Stack due to an openstack exception.
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MSONetworkAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MSONetworkAdapterImplTest.java
index add1918748..284067a766 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MSONetworkAdapterImplTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MSONetworkAdapterImplTest.java
@@ -7,9 +7,9 @@
* 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,6 +20,9 @@
package org.onap.so.adapters.network;
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.patch;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static org.junit.Assert.assertEquals;
import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackDeleteNeutronNetwork;
import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackDeleteStack_200;
@@ -52,6 +55,7 @@ import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.web.util.UriComponentsBuilder;
+import com.github.tomakehurst.wiremock.WireMockServer;
public class MSONetworkAdapterImplTest extends BaseRestTestUtils {
@@ -112,6 +116,8 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils {
@Test
public void createNetworkByModelNameAlreadyExistNeutronMode() throws IOException {
+ mockUpdateRequestDb(wireMockServer, "9733c8d1-2668-4e5f-8b51-2cacc9b662c0");
+
mockOpenStackResponseAccess(wireMockServer, wireMockPort);
mockOpenStackGetAllNeutronNetworks_200(wireMockServer, "OpenstackGetNeutronNetworks.json");
@@ -140,6 +146,8 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils {
@Test
public void createNetworkByModelNameHeatMode() throws IOException {
+ mockUpdateRequestDb(wireMockServer, "9733c8d1-2668-4e5f-8b51-2cacc9b662c0");
+
mockOpenStackResponseAccess(wireMockServer, wireMockPort);
mockOpenStackGetStack_404(wireMockServer, "DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/stackId");
@@ -158,6 +166,8 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils {
@Test
public void createNetworkByModelNameAlreadyExistHeatMode() throws IOException {
+ mockUpdateRequestDb(wireMockServer, "9733c8d1-2668-4e5f-8b51-2cacc9b662c0");
+
mockOpenStackResponseAccess(wireMockServer, wireMockPort);
mockOpenStackPostStack_200(wireMockServer, "OpenstackResponse_Stack.json");
@@ -236,6 +246,8 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils {
@Test
public void deleteNetworkHeatModeSuccess() throws IOException {
+ mockUpdateRequestDb(wireMockServer, "5a29d907-b8c7-47bf-85f3-3940c0cce0f7");
+
mockOpenStackResponseAccess(wireMockServer, wireMockPort);
mockOpenStackGetStackDeleteOrUpdateComplete_200(wireMockServer, "OpenstackResponse_Stack_DeleteComplete.json");
@@ -292,6 +304,8 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils {
@Test
public void deleteNetworkNeureonMode() throws IOException {
+ mockUpdateRequestDb(wireMockServer, "5a29d907-b8c7-47bf-85f3-3940c0cce0f7");
+
mockOpenStackResponseAccess(wireMockServer, wireMockPort);
mockOpenStackGetNeutronNetwork(wireMockServer, "GetNeutronNetwork.json", NETWORK_ID, HttpStatus.SC_OK);
@@ -506,4 +520,9 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils {
String input = new String(Files.readAllBytes(Paths.get(JsonInput)));
return input;
}
+
+ public static void mockUpdateRequestDb(WireMockServer wireMockServer, String requestId) throws IOException {
+ wireMockServer.stubFor(patch(urlPathEqualTo("/infraActiveRequests/" + requestId))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK)));
+ }
}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImplTest.java
index 727f18902a..00961a16b9 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImplTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImplTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -22,6 +22,7 @@ package org.onap.so.adapters.network;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.containing;
+import static com.github.tomakehurst.wiremock.client.WireMock.patch;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static org.onap.so.bpmn.mock.StubOpenStack.getBodyFromFile;
@@ -41,6 +42,7 @@ import org.onap.so.entity.MsoRequest;
import org.onap.so.openstack.beans.NetworkRollback;
import org.onap.so.openstack.beans.Subnet;
import org.springframework.beans.factory.annotation.Autowired;
+import com.github.tomakehurst.wiremock.WireMockServer;
public class MsoNetworkAdapterAsyncImplTest extends BaseRestTestUtils {
@Autowired
@@ -263,4 +265,5 @@ public class MsoNetworkAdapterAsyncImplTest extends BaseRestTestUtils {
false, new ArrayList<>(), new HashMap<String, String>(), "messageId", new MsoRequest(),
"http://localhost:" + wireMockPort + "/notificationUrl");
}
+
}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java
index a058378425..9fc2aba948 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java
@@ -23,6 +23,7 @@ package org.onap.so.adapters.vnf;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.patch;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static org.mockito.Mockito.when;
import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_200;
@@ -30,6 +31,7 @@ import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_
import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPutStack;
import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackResponseAccess;
import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenstackGetWithResponse;
+import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -53,6 +55,7 @@ import org.onap.so.openstack.beans.VnfRollback;
import org.onap.so.openstack.exceptions.MsoException;
import org.onap.so.openstack.utils.MsoHeatUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import com.github.tomakehurst.wiremock.WireMockServer;
import com.github.tomakehurst.wiremock.stubbing.Scenario;
@@ -73,6 +76,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
public void createVnfTest() throws Exception {
mockOpenStackResponseAccess(wireMockServer, wireMockPort);
mockOpenStackGetStackVfModule_200(wireMockServer);
+ mockUpdateRequestDb(wireMockServer, "12345");
MsoRequest msoRequest = getMsoRequest();
@@ -88,6 +92,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
public void createVnfTest_NullFailIfExists() throws Exception {
mockOpenStackResponseAccess(wireMockServer, wireMockPort);
mockOpenStackGetStackVfModule_200(wireMockServer);
+ mockUpdateRequestDb(wireMockServer, "12345");
MsoRequest msoRequest = getMsoRequest();
@@ -117,6 +122,8 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
.inScenario("HeatStatusFailure").whenScenarioStateIs("HeatStackFailed")
.willSetStateTo("HeatStackSuccess"));
+ mockUpdateRequestDb(wireMockServer, "12345");
+
MsoRequest msoRequest = getMsoRequest();
Map<String, Object> map = new HashMap<>();
@@ -133,6 +140,8 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
public void createVnfTest_HeatStatusCreated() throws Exception {
mockOpenStackResponseAccess(wireMockServer, wireMockPort);
mockOpenStackGetStackVfModule_200(wireMockServer);
+ mockUpdateRequestDb(wireMockServer, "12345");
+
MsoRequest msoRequest = getMsoRequest();
Map<String, Object> map = new HashMap<>();
map.put("key1", "value1");
@@ -516,5 +525,10 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
return vfModuleCustomization;
}
+ public static void mockUpdateRequestDb(WireMockServer wireMockServer, String requestId) throws IOException {
+ wireMockServer.stubFor(patch(urlPathEqualTo("/infraActiveRequests/" + requestId))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK)));
+ }
+
}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java
index 5a8524fd73..9655e90e46 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -22,6 +22,8 @@ package org.onap.so.adapters.vnf;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
+import com.github.tomakehurst.wiremock.WireMockServer;
+import org.apache.http.HttpStatus;
import org.json.JSONException;
import org.junit.Ignore;
import org.junit.Test;
@@ -49,6 +51,9 @@ import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.patch;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
@@ -112,6 +117,8 @@ public class VnfAdapterRestTest extends BaseRestTestUtils {
mockOpenStackGetStackVfModule_200(wireMockServer);
+ mockUpdateRequestDb(wireMockServer, "62265093-277d-4388-9ba6-449838ade586");
+
headers.add("Accept", MediaType.APPLICATION_JSON);
HttpEntity<CreateVfModuleRequest> entity = new HttpEntity<CreateVfModuleRequest>(request, headers);
@@ -208,6 +215,8 @@ public class VnfAdapterRestTest extends BaseRestTestUtils {
mockOpenStackGetStackVfModule_200(wireMockServer);
+ mockUpdateRequestDb(wireMockServer, "62265093-277d-4388-9ba6-449838ade586");
+
headers.add("Accept", MediaType.APPLICATION_JSON);
HttpEntity<CreateVfModuleRequest> entity = new HttpEntity<CreateVfModuleRequest>(request, headers);
@@ -342,6 +351,7 @@ public class VnfAdapterRestTest extends BaseRestTestUtils {
mockOpenStackDeletePublicUrlStackByNameAndID_204(wireMockServer);
+ mockUpdateRequestDb(wireMockServer, "62265093-277d-4388-9ba6-449838ade586");
headers.add("Accept", MediaType.APPLICATION_JSON);
HttpEntity<DeleteVfModuleRequest> entity = new HttpEntity<DeleteVfModuleRequest>(request, headers);
@@ -539,4 +549,9 @@ public class VnfAdapterRestTest extends BaseRestTestUtils {
return request;
}
+
+ public static void mockUpdateRequestDb(WireMockServer wireMockServer, String requestId) throws IOException {
+ wireMockServer.stubFor(patch(urlPathEqualTo("/infraActiveRequests/" + requestId))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK)));
+ }
}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestTest.java
index 523a6903cc..c2e2b567f1 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestTest.java
@@ -7,9 +7,9 @@
* 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,6 +20,7 @@
package org.onap.so.adapters.vnf;
+import org.apache.http.HttpStatus;
import org.junit.Test;
import org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest;
import org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse;
@@ -37,6 +38,9 @@ import org.springframework.http.ResponseEntity;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriBuilder;
import java.io.IOException;
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.patch;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static org.junit.Assert.assertEquals;
import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_200;
import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackWithBody_200;
@@ -50,6 +54,9 @@ public class VolumeAdapterRestTest extends VolumeGroupAdapterCommon {
@Test
public void testCreateVNFVolumes() throws IOException {
+ wireMockServer.stubFor(patch(urlPathEqualTo("/infraActiveRequests/62265093-277d-4388-9ba6-449838ade586"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK)));
+
mockOpenStackResponseAccess(wireMockServer, wireMockPort);
mockOpenStackPostStacks_200(wireMockServer);
mockOpenStackGetStackVfModule_200(wireMockServer);
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2Test.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2Test.java
index fb4bec69ed..6fd9f02cfe 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2Test.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2Test.java
@@ -7,9 +7,9 @@
* 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,6 +20,7 @@
package org.onap.so.adapters.vnf;
+import org.apache.http.HttpStatus;
import org.junit.Test;
import org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest;
import org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse;
@@ -37,6 +38,9 @@ import org.springframework.http.ResponseEntity;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriBuilder;
import java.io.IOException;
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.patch;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static org.junit.Assert.assertEquals;
import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_200;
import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackWithBody_200;
@@ -52,6 +56,9 @@ public class VolumeAdapterRestV2Test extends VolumeGroupAdapterCommon {
mockOpenStackResponseAccess(wireMockServer, wireMockPort);
mockOpenStackPostStacks_200(wireMockServer);
mockOpenStackGetStackVfModule_200(wireMockServer);
+ wireMockServer.stubFor(patch(urlPathEqualTo("/infraActiveRequests/62265093-277d-4388-9ba6-449838ade586"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK)));
+
CreateVolumeGroupRequest request = buildCreateVfModuleRequest();
HttpEntity<CreateVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
diff --git a/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml b/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml
index 6171e7a624..42955c35c9 100644
--- a/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml
+++ b/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml
@@ -61,6 +61,9 @@ ssl-enable: false
tomcat:
max-threads: 50
mso:
+ adapters:
+ requestDb:
+ endpoint: http://localhost:${wiremock.server.port}
audit:
lock-time: 240000
logPath: logs
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsScheduler.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsScheduler.java
index a092099bfb..9f48144eb8 100644
--- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsScheduler.java
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsScheduler.java
@@ -10,9 +10,9 @@
* 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.
@@ -142,6 +142,7 @@ public class ArchiveInfraRequestsScheduler {
archivedInfra.setVolumeGroupName(iar.getVolumeGroupName());
archivedInfra.setProductFamilyName(iar.getProductFamilyName());
archivedInfra.setTenantName(iar.getTenantName());
+ archivedInfra.setResourceStatusMessage(iar.getResourceStatusMessage());
newArchivedReqs.add(archivedInfra);
oldInfraReqs.add(iar);
diff --git a/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V7.3.1__AddResourceStatusMessageColumn.sql b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V7.3.1__AddResourceStatusMessageColumn.sql
new file mode 100644
index 0000000000..f388a185f5
--- /dev/null
+++ b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V7.3.1__AddResourceStatusMessageColumn.sql
@@ -0,0 +1,4 @@
+use requestdb;
+
+ALTER TABLE infra_active_requests ADD COLUMN IF NOT EXISTS RESOURCE_STATUS_MESSAGE longtext;
+ALTER TABLE archived_infra_requests ADD COLUMN IF NOT EXISTS RESOURCE_STATUS_MESSAGE longtext; \ No newline at end of file