summaryrefslogtreecommitdiffstats
path: root/adapters/mso-requests-db-adapter/src
diff options
context:
space:
mode:
authorSambasiva K <sambasiva.kokkirala@verizon.com>2020-02-27 16:42:36 +0530
committersambasiva k <sambasiva.kokkirala@verizon.com>2020-02-27 16:42:36 +0530
commit2363c37d07e37317252e843c28f410519f83588d (patch)
treed195a14bfea9104732861042aa31e7b39c1ca59b /adapters/mso-requests-db-adapter/src
parent8151f09eb4db8bf30b96722d710c952bb5a43445 (diff)
Modification of VFC adapter code to make it SOL005 compliant
Change-Id: Ife06298197bed8c1e3766083c7bec39132610f84 Issue-ID: SO-1579 Signed-Off-by: Sambasiva K<sambasiva.kokkirala@verizon.com>
Diffstat (limited to 'adapters/mso-requests-db-adapter/src')
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapter.java15
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java39
-rw-r--r--adapters/mso-requests-db-adapter/src/main/resources/db/migration/V6.1.1__Add_Instance_NFVO_Mapping_Table.sql12
-rw-r--r--adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/MSORequestDBImplTest.java28
4 files changed, 94 insertions, 0 deletions
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapter.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapter.java
index 110fc6c03e..84ff054a7c 100644
--- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapter.java
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapter.java
@@ -26,6 +26,7 @@ import javax.jws.WebService;
import javax.xml.bind.annotation.XmlElement;
import org.onap.so.adapters.requestsdb.exceptions.MsoRequestsDbException;
import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.beans.InstanceNfvoMapping;
import org.onap.so.db.request.beans.ResourceOperationStatus;
/**
@@ -55,6 +56,20 @@ public interface MsoRequestsDbAdapter {
throws MsoRequestsDbException;
@WebMethod
+ public void setInstanceNfvoMappingRepository(
+ @WebParam(name = "instanceId") @XmlElement(required = true) String instanceId,
+ @WebParam(name = "nfvoName") @XmlElement(required = true) String nfvoName,
+ @WebParam(name = "endpoint") @XmlElement(required = true) String endpoint,
+ @WebParam(name = "username") @XmlElement(required = true) String username,
+ @WebParam(name = "password") @XmlElement(required = true) String password,
+ @WebParam(name = "apiRoot") @XmlElement(required = false) String apiRoot) throws MsoRequestsDbException;
+
+ @WebMethod
+ public InstanceNfvoMapping getInstanceNfvoMapping(
+ @WebParam(name = "instanceId") @XmlElement(required = true) String instanceId)
+ throws MsoRequestsDbException;
+
+ @WebMethod
public InfraActiveRequests getInfraRequest(
@WebParam(name = "requestId") @XmlElement(required = true) String requestId) throws MsoRequestsDbException;
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java
index 085a255948..052a53bb1f 100644
--- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java
@@ -31,12 +31,14 @@ import org.onap.so.adapters.requestsdb.exceptions.MsoRequestsDbException;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.beans.OperationStatus;
import org.onap.so.db.request.beans.ResourceOperationStatus;
+import org.onap.so.db.request.beans.InstanceNfvoMapping;
import org.onap.so.db.request.beans.ResourceOperationStatusId;
import org.onap.so.db.request.beans.SiteStatus;
import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository;
import org.onap.so.db.request.data.repository.OperationStatusRepository;
import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository;
import org.onap.so.db.request.data.repository.SiteStatusRepository;
+import org.onap.so.db.request.data.repository.InstanceNfvoMappingRepository;
import org.onap.so.logger.ErrorCode;
import org.onap.so.requestsdb.RequestsDbConstant;
import org.slf4j.Logger;
@@ -59,6 +61,9 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter {
private InfraActiveRequestsRepository infraActive;
@Autowired
+ private InstanceNfvoMappingRepository instanceNfvoMappingRepository;
+
+ @Autowired
private SiteStatusRepository siteRepo;
@Autowired
@@ -69,6 +74,40 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter {
@Transactional
@Override
+ public void setInstanceNfvoMappingRepository(String instanceId, String nfvoName, String endpoint, String username,
+ String password, String apiRoot) {
+ InstanceNfvoMapping instanceNfvoMapping = new InstanceNfvoMapping();
+ if (apiRoot != null) {
+ instanceNfvoMapping.setApiRoot(apiRoot);
+ }
+ if (endpoint != null) {
+ instanceNfvoMapping.setEndpoint(endpoint);
+ }
+ if (instanceId != null) {
+ instanceNfvoMapping.setInstanceId(instanceId);
+ }
+ if (nfvoName != null) {
+ instanceNfvoMapping.setNfvoName(nfvoName);
+ }
+ if (username != null) {
+ instanceNfvoMapping.setUsername(username);
+ }
+ if (password != null) {
+ instanceNfvoMapping.setPassword(password);
+ }
+
+ instanceNfvoMappingRepository.save(instanceNfvoMapping);
+ }
+
+ @Transactional
+ @Override
+ public InstanceNfvoMapping getInstanceNfvoMapping(String instanceId) {
+ InstanceNfvoMapping instanceNfvoMapping = instanceNfvoMappingRepository.findOneByInstanceId(instanceId);
+ return instanceNfvoMapping;
+ }
+
+ @Transactional
+ @Override
public void updateInfraRequest(String requestId, String lastModifiedBy, String statusMessage, String responseBody,
RequestStatusType requestStatus, String progress, String vnfOutputs, String serviceInstanceId,
String networkId, String vnfId, String vfModuleId, String volumeGroupId, String serviceInstanceName,
diff --git a/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V6.1.1__Add_Instance_NFVO_Mapping_Table.sql b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V6.1.1__Add_Instance_NFVO_Mapping_Table.sql
new file mode 100644
index 0000000000..165a9b33f8
--- /dev/null
+++ b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V6.1.1__Add_Instance_NFVO_Mapping_Table.sql
@@ -0,0 +1,12 @@
+use requestdb;
+
+CREATE TABLE `instance_nfvo_mapping` (
+ `INSTANCE_ID` varchar(256) NOT NULL,
+ `NFVO_NAME` varchar(256) DEFAULT NULL,
+ `ENDPOINT` varchar(256) DEFAULT NULL,
+ `USERNAME` varchar(256) DEFAULT NULL,
+ `PASSWORD` varchar(256) DEFAULT NULL,
+ `API_ROOT` varchar(256) DEFAULT NULL,
+ `JOB_ID` varchar(256) DEFAULT NULL,
+ PRIMARY KEY (`INSTANCE_ID`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1; \ No newline at end of file
diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/MSORequestDBImplTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/MSORequestDBImplTest.java
index fef9dbc22c..9ded5b4b79 100644
--- a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/MSORequestDBImplTest.java
+++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/MSORequestDBImplTest.java
@@ -39,8 +39,10 @@ import org.onap.so.adapters.requestsdb.exceptions.MsoRequestsDbException;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.beans.OperationStatus;
import org.onap.so.db.request.beans.ResourceOperationStatus;
+import org.onap.so.db.request.beans.InstanceNfvoMapping;
import org.onap.so.db.request.data.repository.OperationStatusRepository;
import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository;
+import org.onap.so.db.request.data.repository.InstanceNfvoMappingRepository;
import org.onap.so.requestsdb.RequestsDbConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.server.LocalServerPort;
@@ -58,6 +60,9 @@ public class MSORequestDBImplTest extends RequestsAdapterBase {
@Autowired
private ResourceOperationStatusRepository resourceOperationStatusRepo;
+ @Autowired
+ private InstanceNfvoMappingRepository instanceNfvoMappingRepository;
+
@Rule
public ExpectedException thrown = ExpectedException.none();
@@ -257,6 +262,29 @@ public class MSORequestDBImplTest extends RequestsAdapterBase {
}
@Test
+ public void setInstanceNfvoMappingRepository() throws MsoRequestsDbException {
+ InstanceNfvoMapping instanceNfvoMapping = new InstanceNfvoMapping();
+ String instanceId = "9b9f02c0-298b-458a-bc9c-be3692e4f354";
+ String nfvoName = "testNFVO";
+ String endpoint = "http://127.0.0.1:80/";
+ String username = "admin";
+ String password = "admin";
+ String apiRoot = "v1";
+
+ instanceNfvoMapping.setApiRoot(apiRoot);
+ instanceNfvoMapping.setEndpoint(endpoint);
+ instanceNfvoMapping.setInstanceId(instanceId);
+ instanceNfvoMapping.setNfvoName(nfvoName);
+ instanceNfvoMapping.setUsername(username);
+ instanceNfvoMapping.setPassword(password);
+
+ dbAdapter.setInstanceNfvoMappingRepository(instanceId, nfvoName, endpoint, username, password, apiRoot);
+ InstanceNfvoMapping dbInstNfvoMap = dbAdapter.getInstanceNfvoMapping(instanceId);
+ assertThat(dbInstNfvoMap, sameBeanAs(instanceNfvoMapping));
+ }
+
+
+ @Test
public void updateServiceOperation() throws MsoRequestsDbException {
String serviceId = "serviceid";
String operationId = "operationid";