diff options
Diffstat (limited to 'so-etsi-nfvo')
3 files changed, 33 insertions, 28 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 f87a35f3ab..e94b3de81e 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 @@ -52,6 +52,16 @@ public abstract class AbstractNetworkServiceTask { this.databaseServiceProvider = jobServiceProvider; } + public void addJobStatus(final DelegateExecution execution, final JobStatusEnum jobStatus, + final String description) { + final NfvoJobStatus nfvoJobStatus = + new NfvoJobStatus().status(jobStatus).description(description).updatedTime(LocalDateTime.now()); + logger.info("Adding NfvoJobStatus {}", nfvoJobStatus); + final NfvoJob nfvoJob = getNfvoJob(execution); + nfvoJob.nfvoJobStatus(nfvoJobStatus); + databaseServiceProvider.addJob(nfvoJob); + } + public void setJobStatus(final DelegateExecution execution, final JobStatusEnum jobStatus, final String description) { logger.info("Setting Job Status to {}", jobStatus); 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 fcebea59f2..600792acc0 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 @@ -69,7 +69,7 @@ public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask { (CreateInstantiateRequest) execution.getVariable(CREATE_INSTANTIATE_REQUEST_PARAM_NAME); logger.info("request: {}", request); - setJobStatus(execution, JobStatusEnum.IN_PROGRESS, "Checking if NF Instance record exists in database for " + addJobStatus(execution, JobStatusEnum.IN_PROGRESS, "Checking if NF Instance record exists in database for " + request.getNsInstId() + " and " + request.getVnfName()); if (!databaseServiceProvider.isNsInstExists(request.getNsInstId(), request.getVnfName())) { abortOperation(execution, @@ -85,7 +85,7 @@ public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask { (CreateInstantiateRequest) execution.getVariable(CREATE_INSTANTIATE_REQUEST_PARAM_NAME); logger.info("request: {}", request); - setJobStatus(execution, IN_PROGRESS, "Creating NF Instance record in database for " + request.getVnfName()); + addJobStatus(execution, IN_PROGRESS, "Creating NF Instance record in database for " + request.getVnfName()); final Optional<NfvoNsInst> optional = databaseServiceProvider.getNfvoNsInst(request.getNsInstId()); @@ -110,7 +110,7 @@ public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask { final CreateInstantiateRequest request = (CreateInstantiateRequest) execution.getVariable(CREATE_INSTANTIATE_REQUEST_PARAM_NAME); - setJobStatus(execution, IN_PROGRESS, "Creating GenericVnf record in AAI for " + request.getVnfName()); + addJobStatus(execution, IN_PROGRESS, "Creating GenericVnf record in AAI for " + request.getVnfName()); final String nfInstId = (String) execution.getVariable(NF_INST_ID_PARAM_NAME); final String nsInstId = (String) execution.getVariable(NS_INSTANCE_ID_PARAM_NAME); @@ -148,7 +148,7 @@ public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask { (CreateInstantiateRequest) execution.getVariable(CREATE_INSTANTIATE_REQUEST_PARAM_NAME); logger.info("request: {}", request); - setJobStatus(execution, IN_PROGRESS, + addJobStatus(execution, IN_PROGRESS, "Invoking SOL003 adapter for creating and instantiating VNF: " + request.getVnfName()); final CreateVnfRequest vnfRequest = new CreateVnfRequest(); @@ -170,7 +170,7 @@ public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask { logger.info("Vnf instantiation response: {}", vnfResponse); execution.setVariable(CREATE_VNF_RESPONSE_PARAM_NAME, vnfResponse); - setJobStatus(execution, IN_PROGRESS, "Successfully invoked SOL003 adapater creating and instantiating VNF: " + addJobStatus(execution, IN_PROGRESS, "Successfully invoked SOL003 adapater creating and instantiating VNF: " + request.getVnfName() + " CreaetVnfResponse Job Id: " + vnfResponse.getJobId()); logger.debug("Finished executing invokeCreateInstantiationRequest ..."); } catch (final Exception exception) { @@ -187,7 +187,7 @@ public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask { updateNfInstanceStatus(execution, State.INSTANTIATED); final CreateInstantiateRequest request = (CreateInstantiateRequest) execution.getVariable(CREATE_INSTANTIATE_REQUEST_PARAM_NAME); - setJobStatus(execution, FINISHED, "Successfully created and Instantiated VNF: " + request.getVnfName() + addJobStatus(execution, FINISHED, "Successfully created and Instantiated VNF: " + request.getVnfName() + " will set status to " + State.INSTANTIATED); logger.info("Finished executing updateNfInstanceStatusToInstantiated ..."); @@ -200,7 +200,7 @@ public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask { updateNfInstanceStatus(execution, State.FAILED); final CreateInstantiateRequest request = (CreateInstantiateRequest) execution.getVariable(CREATE_INSTANTIATE_REQUEST_PARAM_NAME); - setJobStatus(execution, ERROR, "Failed to create and instantiate VNF: " + request.getVnfName() + addJobStatus(execution, ERROR, "Failed to create and instantiate VNF: " + request.getVnfName() + " will set status to " + State.FAILED); logger.info("Finished executing updateNfInstanceStatusToInstantiated ..."); @@ -209,14 +209,11 @@ public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask { 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; logger.error(message); - abortOperation(execution, message); - } final NfvoNfInst nfvoNfInst = optional.get(); 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 15eee22dd2..049a6f38b0 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 @@ -19,6 +19,13 @@ */ package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.tasks; +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.DELETE_VNF_RESPONSE_PARAM_NAME; +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.NF_INST_ID_PARAM_NAME; +import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.TERMINATE_VNF_VNFID_PARAM_NAME; +import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum.ERROR; +import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum.FINISHED; +import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum.IN_PROGRESS; +import java.util.Optional; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.DeleteVnfResponse; import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.aai.AaiServiceProvider; @@ -31,13 +38,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import java.util.Optional; -import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.NF_INST_ID_PARAM_NAME; -import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.DELETE_VNF_RESPONSE_PARAM_NAME; -import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.TERMINATE_VNF_VNFID_PARAM_NAME; -import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum.ERROR; -import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum.FINISHED; -import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum.IN_PROGRESS; /** * @author Andrew Lamb (andrew.a.lamb@est.tech) @@ -63,7 +63,7 @@ public class TerminateVnfTask extends AbstractNetworkServiceTask { logger.info("vnfId: {}", vnfId); execution.setVariable(NF_INST_ID_PARAM_NAME, vnfId); - setJobStatus(execution, JobStatusEnum.IN_PROGRESS, + addJobStatus(execution, JobStatusEnum.IN_PROGRESS, "Checking if VNF Instance with id: " + vnfId + " exists in database."); if (!databaseServiceProvider.isNfInstExists(vnfId)) { abortOperation(execution, @@ -78,7 +78,7 @@ public class TerminateVnfTask extends AbstractNetworkServiceTask { final String vnfId = (String) execution.getVariable(TERMINATE_VNF_VNFID_PARAM_NAME); try { - setJobStatus(execution, IN_PROGRESS, "Invoking SOL003 adapter for terminating VNF with vnfId: " + vnfId); + addJobStatus(execution, IN_PROGRESS, "Invoking SOL003 adapter for terminating VNF with vnfId: " + vnfId); final Optional<DeleteVnfResponse> optional = sol003AdapterServiceProvider.invokeTerminationRequest(vnfId); @@ -92,7 +92,7 @@ public class TerminateVnfTask extends AbstractNetworkServiceTask { logger.info("Vnf delete response: {}", vnfResponse); execution.setVariable(DELETE_VNF_RESPONSE_PARAM_NAME, vnfResponse); - setJobStatus(execution, IN_PROGRESS, "Successfully invoked SOL003 adapter terminate VNF with vnfId: " + addJobStatus(execution, IN_PROGRESS, "Successfully invoked SOL003 adapter terminate VNF with vnfId: " + vnfId + " DeleteVnfResponse Job Id: " + vnfResponse.getJobId()); logger.debug("Finished executing invokeTerminateRequest ..."); } catch (final Exception exception) { @@ -108,7 +108,7 @@ public class TerminateVnfTask extends AbstractNetworkServiceTask { final String vnfId = (String) execution.getVariable(TERMINATE_VNF_VNFID_PARAM_NAME); try { - setJobStatus(execution, IN_PROGRESS, "Deleting GenericVnf record from AAI for vnfId: " + vnfId); + addJobStatus(execution, IN_PROGRESS, "Deleting GenericVnf record from AAI for vnfId: " + vnfId); aaiServiceProvider.deleteGenericVnf(vnfId); } catch (final Exception exception) { @@ -124,10 +124,10 @@ public class TerminateVnfTask extends AbstractNetworkServiceTask { logger.info("Executing deleteNfInstanceFromDb"); final String vnfId = (String) execution.getVariable(TERMINATE_VNF_VNFID_PARAM_NAME); - setJobStatus(execution, IN_PROGRESS, "Deleting NF Instance record from Database for vnfId: " + vnfId); + addJobStatus(execution, IN_PROGRESS, "Deleting NF Instance record from Database for vnfId: " + vnfId); databaseServiceProvider.deleteNfvoNfInst(vnfId); - setJobStatus(execution, FINISHED, "Successfully finished terminating VNF with vnfId: " + vnfId); + addJobStatus(execution, FINISHED, "Successfully finished terminating VNF with vnfId: " + vnfId); logger.info("Finished executing deleteNfInstanceFromDb ..."); } @@ -136,7 +136,7 @@ public class TerminateVnfTask extends AbstractNetworkServiceTask { updateNfInstanceStatus(execution, State.TERMINATING); final String vnfId = (String) execution.getVariable(TERMINATE_VNF_VNFID_PARAM_NAME); - setJobStatus(execution, IN_PROGRESS, + addJobStatus(execution, IN_PROGRESS, "Terminating VNF with vnfId: " + vnfId + " will set status to " + State.TERMINATING); logger.info("Finished executing updateNfInstanceStatusToTerminating ..."); @@ -148,7 +148,7 @@ public class TerminateVnfTask extends AbstractNetworkServiceTask { updateNfInstanceStatus(execution, State.NOT_INSTANTIATED); final String vnfId = (String) execution.getVariable(TERMINATE_VNF_VNFID_PARAM_NAME); - setJobStatus(execution, IN_PROGRESS, + addJobStatus(execution, IN_PROGRESS, "Successfully terminated VNF with vnfId: " + vnfId + " will set status to " + State.NOT_INSTANTIATED); logger.info("Finished executing updateNfInstanceStatusToInstantiated ..."); @@ -160,7 +160,7 @@ public class TerminateVnfTask extends AbstractNetworkServiceTask { updateNfInstanceStatus(execution, State.FAILED); final String vnfId = (String) execution.getVariable(TERMINATE_VNF_VNFID_PARAM_NAME); - setJobStatus(execution, ERROR, + addJobStatus(execution, ERROR, "Failed to terminate VNF with vnfId: " + vnfId + " will set status to " + State.FAILED); logger.info("Finished executing updateNfInstanceStatusToFailed ..."); @@ -174,9 +174,7 @@ public class TerminateVnfTask extends AbstractNetworkServiceTask { if (optional.isEmpty()) { final String message = "Unable to find NfvoNfInst record in database using vnfId: " + vnfId; logger.error(message); - abortOperation(execution, message); - } final NfvoNfInst nfvoNfInst = optional.get(); |