aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-requests-db-adapter/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'adapters/mso-requests-db-adapter/src/main')
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsScheduler.java33
-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.java41
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/OrchestrationTaskRepositoryCustomController.java62
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbException.java2
-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/main/resources/db/migration/V7.2.1__Add_PNF_Column_Infra_Requests_archive_tables.sql4
-rw-r--r--adapters/mso-requests-db-adapter/src/main/resources/db/migration/V7.2__Add_PNF_Column_Infra_Requests_archive_tables.sql2
-rw-r--r--adapters/mso-requests-db-adapter/src/main/resources/db/migration/V7.3.1__AddResourceStatusMessageColumn.sql4
-rw-r--r--adapters/mso-requests-db-adapter/src/main/resources/db/migration/V7.3__Add_Columns_Tenant_Name_Product_Family_Name.sql7
-rw-r--r--adapters/mso-requests-db-adapter/src/main/resources/db/migration/V8.1__Add_Orchestration_Task_Table.sql12
11 files changed, 172 insertions, 22 deletions
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 3deabb3ce1..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.
@@ -27,19 +27,15 @@ import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
-import org.onap.logging.filter.base.ONAPComponents;
-import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.db.request.beans.ArchivedInfraRequests;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.data.repository.ArchivedInfraRequestsRepository;
import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository;
-import org.onap.so.logger.ErrorCode;
-import org.onap.so.logger.LoggingAnchor;
-import org.onap.so.logger.MessageEnum;
-import org.onap.so.logger.ScheduledTasksMDCSetup;
+import org.onap.logging.filter.base.ErrorCode;
+import org.onap.logging.filter.base.ScheduledLogging;
+import org.onap.logging.filter.base.ScheduledTaskException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.PageRequest;
@@ -56,8 +52,6 @@ public class ArchiveInfraRequestsScheduler {
private InfraActiveRequestsRepository infraActiveRepo;
@Autowired
private ArchivedInfraRequestsRepository archivedInfraRepo;
- @Autowired
- private ScheduledTasksMDCSetup scheduledMDCSetup;
@Value("${mso.infra-requests.archived.period}")
@@ -65,11 +59,13 @@ public class ArchiveInfraRequestsScheduler {
/**
* Runs the scheduler nightly [Seconds] [Minutes] [Hours] [Day of month] [Month] [Day of week] [Year]
+ *
+ * @throws ScheduledTaskException
*/
+ @ScheduledLogging
@Scheduled(cron = "0 0 1 * * ?")
@SchedulerLock(name = "archiveInfraRequestsScheduler")
- public void infraRequestsScheduledTask() {
- scheduledMDCSetup.mdcSetup(ONAPComponents.REQUEST_DB, "infraRequestsScheduledTask");
+ public void infraRequestsScheduledTask() throws ScheduledTaskException {
logger.debug("Start of archiveInfraRequestsScheduler");
Date currentDate = new Date();
@@ -97,10 +93,9 @@ public class ArchiveInfraRequestsScheduler {
} while (!requestsByStartTime.isEmpty());
logger.debug("End of archiveInfraRequestsScheduler");
- scheduledMDCSetup.exitAndClearMDC();
}
- protected void archiveInfraRequests(List<InfraActiveRequests> requests) {
+ protected void archiveInfraRequests(List<InfraActiveRequests> requests) throws ScheduledTaskException {
List<ArchivedInfraRequests> newArchivedReqs = new ArrayList<>();
List<InfraActiveRequests> oldInfraReqs = new ArrayList<>();
@@ -145,14 +140,14 @@ public class ArchiveInfraRequestsScheduler {
archivedInfra.setVnfType(iar.getVnfType());
archivedInfra.setVolumeGroupId(iar.getVolumeGroupId());
archivedInfra.setVolumeGroupName(iar.getVolumeGroupName());
+ archivedInfra.setProductFamilyName(iar.getProductFamilyName());
+ archivedInfra.setTenantName(iar.getTenantName());
+ archivedInfra.setResourceStatusMessage(iar.getResourceStatusMessage());
newArchivedReqs.add(archivedInfra);
oldInfraReqs.add(iar);
} catch (Exception e) {
- scheduledMDCSetup.errorMDCSetup(ErrorCode.UnknownError, e.getMessage());
- MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.ERROR.toString());
- logger.error(LoggingAnchor.TWO, MessageEnum.RA_GENERAL_EXCEPTION.toString(),
- ErrorCode.UnknownError.getValue(), e);
+ throw new ScheduledTaskException(ErrorCode.UnknownError, e.getMessage(), e);
}
}
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..b262cb21cb 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,13 +31,15 @@ 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.logger.ErrorCode;
+import org.onap.so.db.request.data.repository.InstanceNfvoMappingRepository;
+import org.onap.logging.filter.base.ErrorCode;
import org.onap.so.requestsdb.RequestsDbConstant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -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/java/org/onap/so/adapters/requestsdb/OrchestrationTaskRepositoryCustomController.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/OrchestrationTaskRepositoryCustomController.java
new file mode 100644
index 0000000000..e32d90b137
--- /dev/null
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/OrchestrationTaskRepositoryCustomController.java
@@ -0,0 +1,62 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.requestsdb;
+
+import org.onap.so.adapters.requestsdb.exceptions.MsoRequestsDbException;
+import org.onap.so.db.request.beans.OrchestrationTask;
+import org.onap.so.db.request.data.repository.OrchestrationTaskRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import java.util.List;
+
+@RestController
+public class OrchestrationTaskRepositoryCustomController {
+
+ @Autowired
+ private OrchestrationTaskRepository orchestrationTaskRepository;
+
+ @RequestMapping(method = RequestMethod.GET, value = "/orchestrationTask")
+ public List<OrchestrationTask> getAllOrchestrationTask() {
+ return orchestrationTaskRepository.findAll();
+ }
+
+ @RequestMapping(method = RequestMethod.GET, value = "/orchestrationTask/{taskId}")
+ public OrchestrationTask getOrchestrationTask(@PathVariable("taskId") String taskId) throws MsoRequestsDbException {
+ return orchestrationTaskRepository.findById(taskId)
+ .orElseThrow(() -> new MsoRequestsDbException("orchestration task not found: " + taskId));
+ }
+
+ @RequestMapping(method = RequestMethod.POST, value = "/orchestrationTask/")
+ public OrchestrationTask createOrchestrationTask(@RequestBody OrchestrationTask orchestrationTask) {
+ return orchestrationTaskRepository.save(orchestrationTask);
+ }
+
+ @RequestMapping(method = RequestMethod.PUT, value = "/orchestrationTask/{taskId}")
+ public OrchestrationTask updateOrchestrationTask(@PathVariable("taskId") String taskId,
+ @RequestBody OrchestrationTask orchestrationTask) throws MsoRequestsDbException {
+ return orchestrationTaskRepository.save(orchestrationTask);
+ }
+
+ @RequestMapping(method = RequestMethod.DELETE, value = "/orchestrationTask/{taskId}")
+ public void deleteOrchestrationTask(@PathVariable("taskId") String taskId) {
+ orchestrationTaskRepository.deleteById(taskId);
+ }
+}
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbException.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbException.java
index 27580977b8..e1e629008d 100644
--- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbException.java
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbException.java
@@ -24,7 +24,7 @@ package org.onap.so.adapters.requestsdb.exceptions;
import javax.xml.ws.WebFault;
import org.onap.so.exceptions.MSOException;
-import org.onap.so.logger.ErrorCode;
+import org.onap.logging.filter.base.ErrorCode;
/**
* This class simply extends Exception (without addition additional functionality) to provide an identifier for
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/main/resources/db/migration/V7.2.1__Add_PNF_Column_Infra_Requests_archive_tables.sql b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V7.2.1__Add_PNF_Column_Infra_Requests_archive_tables.sql
new file mode 100644
index 0000000000..8c042dcbaf
--- /dev/null
+++ b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V7.2.1__Add_PNF_Column_Infra_Requests_archive_tables.sql
@@ -0,0 +1,4 @@
+use requestdb;
+
+ALTER TABLE infra_active_requests ADD COLUMN IF NOT EXISTS PNF_NAME varchar(45);
+ALTER TABLE archived_infra_requests ADD COLUMN IF NOT EXISTS PNF_NAME varchar(45);
diff --git a/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V7.2__Add_PNF_Column_Infra_Requests_archive_tables.sql b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V7.2__Add_PNF_Column_Infra_Requests_archive_tables.sql
index dbdc925dae..d82e666855 100644
--- a/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V7.2__Add_PNF_Column_Infra_Requests_archive_tables.sql
+++ b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V7.2__Add_PNF_Column_Infra_Requests_archive_tables.sql
@@ -1,4 +1,4 @@
use requestdb;
ALTER TABLE infra_active_requests ADD COLUMN IF NOT EXISTS PNF_ID varchar(45);
-ALTER TABLE archived_infra_requests ADD COLUMN IF NOT EXISTS PNF_ID varchar(45); \ No newline at end of file
+ALTER TABLE archived_infra_requests ADD COLUMN IF NOT EXISTS PNF_ID varchar(45);
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
diff --git a/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V7.3__Add_Columns_Tenant_Name_Product_Family_Name.sql b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V7.3__Add_Columns_Tenant_Name_Product_Family_Name.sql
new file mode 100644
index 0000000000..a79b1a86c1
--- /dev/null
+++ b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V7.3__Add_Columns_Tenant_Name_Product_Family_Name.sql
@@ -0,0 +1,7 @@
+use requestdb;
+
+ALTER TABLE infra_active_requests ADD COLUMN IF NOT EXISTS TENANT_NAME varchar(200);
+ALTER TABLE archived_infra_requests ADD COLUMN IF NOT EXISTS TENANT_NAME varchar(200);
+
+ALTER TABLE infra_active_requests ADD COLUMN IF NOT EXISTS PRODUCT_FAMILY_NAME varchar(200);
+ALTER TABLE archived_infra_requests ADD COLUMN IF NOT EXISTS PRODUCT_FAMILY_NAME varchar(200); \ No newline at end of file
diff --git a/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V8.1__Add_Orchestration_Task_Table.sql b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V8.1__Add_Orchestration_Task_Table.sql
new file mode 100644
index 0000000000..0d7cb7a62b
--- /dev/null
+++ b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V8.1__Add_Orchestration_Task_Table.sql
@@ -0,0 +1,12 @@
+USE `requestdb`;
+
+CREATE TABLE `orchestration_task` (
+ `TASK_ID` varchar(200) NOT NULL,
+ `REQUEST_ID` varchar(200) NOT NULL,
+ `NAME` varchar(200) NOT NULL,
+ `CREATED_TIME` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ `STATUS` varchar(200) NOT NULL,
+ `IS_MANUAL` varchar(20) NOT NULL,
+ `PARAMS` varchar(20000) DEFAULT NULL,
+ PRIMARY KEY (`TASK_ID`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;