diff options
Diffstat (limited to 'so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main')
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); } } |