summaryrefslogtreecommitdiffstats
path: root/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows
diff options
context:
space:
mode:
authorwaqas.ikram <waqas.ikram@est.tech>2020-10-20 18:39:21 +0100
committerwaqas.ikram <waqas.ikram@est.tech>2020-10-21 15:59:57 +0100
commiteb00f2d1bbc80fb858f15a565a54fa8336c6650d (patch)
treef6fa694420cd726f887a66c0c6bc1206bec5a730 /so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows
parent623dbe5cf31cec13c3c6eec7b74791682eb3b731 (diff)
Fixing Update status query for NfvoNfInst
Change-Id: Iaa9119532c3005001c5af73f904a9395048ffd11 Issue-ID: SO-2868 Signed-off-by: waqas.ikram <waqas.ikram@est.tech>
Diffstat (limited to 'so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows')
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/AbstractNetworkServiceTask.java51
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/CreateInstantiateVnfTask.java15
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/TerminateVnfTask.java11
3 files changed, 28 insertions, 49 deletions
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/AbstractNetworkServiceTask.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/AbstractNetworkServiceTask.java
index e94b3de81e..a785a5199b 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/AbstractNetworkServiceTask.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/AbstractNetworkServiceTask.java
@@ -19,9 +19,9 @@
*/
package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.tasks;
-import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME;
import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.JOB_ID_PARAM_NAME;
import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.NS_INSTANCE_ID_PARAM_NAME;
+import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME;
import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.OCC_ID_PARAM_NAME;
import java.time.LocalDateTime;
import java.util.Optional;
@@ -31,7 +31,6 @@ import org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum;
import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoJob;
import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoJobStatus;
import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNsInst;
-import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NsLcmOpOcc;
import org.onap.so.etsi.nfvo.ns.lcm.database.beans.OperationStateEnum;
import org.onap.so.etsi.nfvo.ns.lcm.database.beans.State;
import org.onap.so.etsi.nfvo.ns.lcm.database.service.DatabaseServiceProvider;
@@ -109,21 +108,8 @@ public abstract class AbstractNetworkServiceTask {
public void updateNsLcmOpOccStatusToCompleted(final DelegateExecution execution) {
logger.info("Executing updateNsLcmOpOccStatusToCompleted ...");
- final String occId = (String) execution.getVariable(OCC_ID_PARAM_NAME);
- final Optional<NsLcmOpOcc> optional = databaseServiceProvider.getNsLcmOpOcc(occId);
-
- if (optional.isEmpty()) {
- final String message = "Unable to find record for NSLcmOpOcc in database using id: " + occId;
- logger.error(message);
- abortOperation(execution, message);
- }
-
- final NsLcmOpOcc nsLcmOpOcc = optional.get();
- final OperationStateEnum operationStateCompleted = OperationStateEnum.COMPLETED;
- logger.info("Setting operation state to {} for id: {}", operationStateCompleted, occId);
- nsLcmOpOcc.setOperationState(operationStateCompleted);
- databaseServiceProvider.addNSLcmOpOcc(nsLcmOpOcc);
+ updateNsLcmOpOccOperationState(execution, OperationStateEnum.COMPLETED);
logger.info("Finished executing updateNsLcmOpOccStatusToCompleted ...");
@@ -131,20 +117,8 @@ public abstract class AbstractNetworkServiceTask {
public void updateNsLcmOpOccStatusToFailed(final DelegateExecution execution) {
logger.info("Executing updateNsLcmOpOccStatusToFailed ...");
- final String occId = (String) execution.getVariable(OCC_ID_PARAM_NAME);
-
- final Optional<NsLcmOpOcc> optional = databaseServiceProvider.getNsLcmOpOcc(occId);
- if (optional.isPresent()) {
- final NsLcmOpOcc nsLcmOpOcc = optional.get();
- final OperationStateEnum operationStateFailed = OperationStateEnum.FAILED;
- logger.info("Setting operation state to {} for id: {}", operationStateFailed, occId);
- nsLcmOpOcc.setOperationState(operationStateFailed);
-
- databaseServiceProvider.addNSLcmOpOcc(nsLcmOpOcc);
- } else {
- logger.error("Unable to find record for NSLcmOpOcc in database using id: {}", occId);
- }
+ updateNsLcmOpOccOperationState(execution, OperationStateEnum.FAILED);
logger.info("Finished executing updateNsLcmOpOccStatusToFailed ...");
@@ -154,6 +128,19 @@ public abstract class AbstractNetworkServiceTask {
abortOperation(execution, message, new InlineResponse400().detail(message));
}
+ private void updateNsLcmOpOccOperationState(final DelegateExecution execution,
+ final OperationStateEnum operationState) {
+ final String occId = (String) execution.getVariable(OCC_ID_PARAM_NAME);
+
+ final boolean isSuccessful = databaseServiceProvider.updateNsLcmOpOccOperationState(occId, operationState);
+ if (!isSuccessful) {
+ final String message =
+ "Unable to update NsLcmOpOcc " + occId + " operationState to" + operationState + " in database";
+ logger.error(message);
+ abortOperation(execution, message);
+ }
+ }
+
protected void abortOperation(final DelegateExecution execution, final String message,
final InlineResponse400 problemDetails) {
logger.error(message);
@@ -175,10 +162,10 @@ public abstract class AbstractNetworkServiceTask {
}
protected void updateNsInstanceStatus(final DelegateExecution execution, final State nsStatus) {
- final NfvoNsInst nfvoNsInst = getNfvoNsInst(execution);
+ final String nsInstId = (String) execution.getVariable(NS_INSTANCE_ID_PARAM_NAME);
+
logger.info("Updating NfvoNsInst Status to {} and saving to DB", nsStatus);
- nfvoNsInst.setStatus(nsStatus);
- databaseServiceProvider.saveNfvoNsInst(nfvoNsInst);
+ databaseServiceProvider.updateNsInstState(nsInstId, nsStatus);
}
protected NfvoNsInst getNfvoNsInst(final DelegateExecution execution) {
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/CreateInstantiateVnfTask.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/CreateInstantiateVnfTask.java
index 600792acc0..0d4cbbe24f 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/CreateInstantiateVnfTask.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/CreateInstantiateVnfTask.java
@@ -195,7 +195,7 @@ public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask {
}
public void updateNfInstanceStatusToFailed(final DelegateExecution execution) {
- logger.info("Executing updateNfInstanceStatusToActive");
+ logger.info("Executing updateNfInstanceStatusToFailed");
updateNfInstanceStatus(execution, State.FAILED);
final CreateInstantiateRequest request =
@@ -203,22 +203,19 @@ public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask {
addJobStatus(execution, ERROR, "Failed to create and instantiate VNF: " + request.getVnfName()
+ " will set status to " + State.FAILED);
- logger.info("Finished executing updateNfInstanceStatusToInstantiated ...");
+ logger.info("Finished executing updateNfInstanceStatusToFailed ...");
}
private void updateNfInstanceStatus(final DelegateExecution execution, final State vnfStatus) {
final String nfInstId = (String) execution.getVariable(NF_INST_ID_PARAM_NAME);
- final Optional<NfvoNfInst> optional = databaseServiceProvider.getNfvoNfInst(nfInstId);
- if (optional.isEmpty()) {
- final String message = "Unable to find NfvoNfInst record in database using nfInstId: " + nfInstId;
+ final boolean isSuccessful = databaseServiceProvider.updateNfInstState(nfInstId, vnfStatus);
+ if (!isSuccessful) {
+ final String message =
+ "Unable to update NfvoNfInst " + nfInstId + " status to" + vnfStatus + " in database";
logger.error(message);
abortOperation(execution, message);
}
-
- final NfvoNfInst nfvoNfInst = optional.get();
- nfvoNfInst.setStatus(vnfStatus);
- databaseServiceProvider.saveNfvoNfInst(nfvoNfInst);
}
}
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/TerminateVnfTask.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/TerminateVnfTask.java
index 049a6f38b0..f3e7eea212 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/TerminateVnfTask.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/tasks/TerminateVnfTask.java
@@ -31,7 +31,6 @@ import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.DeleteVnfResponse;
import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.aai.AaiServiceProvider;
import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.vnfm.Sol003AdapterServiceProvider;
import org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum;
-import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNfInst;
import org.onap.so.etsi.nfvo.ns.lcm.database.beans.State;
import org.onap.so.etsi.nfvo.ns.lcm.database.service.DatabaseServiceProvider;
import org.slf4j.Logger;
@@ -170,16 +169,12 @@ public class TerminateVnfTask extends AbstractNetworkServiceTask {
private void updateNfInstanceStatus(final DelegateExecution execution, final State vnfStatus) {
final String vnfId = (String) execution.getVariable(TERMINATE_VNF_VNFID_PARAM_NAME);
- final Optional<NfvoNfInst> optional = databaseServiceProvider.getNfvoNfInst(vnfId);
- if (optional.isEmpty()) {
- final String message = "Unable to find NfvoNfInst record in database using vnfId: " + vnfId;
+ final boolean isSuccessful = databaseServiceProvider.updateNfInstState(vnfId, vnfStatus);
+ if (!isSuccessful) {
+ final String message = "Unable to update NfvoNfInst " + vnfId + " status to" + vnfStatus + " in database";
logger.error(message);
abortOperation(execution, message);
}
-
- final NfvoNfInst nfvoNfInst = optional.get();
- nfvoNfInst.setStatus(vnfStatus);
- databaseServiceProvider.saveNfvoNfInst(nfvoNfInst);
}
}