aboutsummaryrefslogtreecommitdiffstats
path: root/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java')
-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/CamundaVariableNameConstants.java6
-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/Constants.java1
-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/extclients/aai/AaiServiceProvider.java2
-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/extclients/aai/AaiServiceProviderImpl.java7
-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/extclients/vnfm/Sol003AdapterServiceProvider.java3
-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/extclients/vnfm/Sol003AdapterServiceProviderImpl.java32
-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/extclients/vnfm/Sol003AdapterUrlProvider.java10
-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/service/JobExecutorService.java104
-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.java69
-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.java12
-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/InstantiateNsTask.java63
-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/MonitorSol003AdapterNodeTask.java6
-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/MonitorSol003AdapterTerminateJobTask.java106
-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/MonitorSol003AdapterTerminateNodeTask.java55
-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/TerminateNsTask.java145
-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.java187
16 files changed, 728 insertions, 80 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/CamundaVariableNameConstants.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/CamundaVariableNameConstants.java
index e90391d51a..fd51b1a873 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/CamundaVariableNameConstants.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/CamundaVariableNameConstants.java
@@ -31,7 +31,6 @@ public class CamundaVariableNameConstants {
public static final String GLOBAL_CUSTOMER_ID_PARAM_NAME = "globalCustomerId";
public static final String SERVICE_TYPE_PARAM_NAME = "serviceType";
-
public static final String NS_PACKAGE_MODEL_PARAM_NAME = "NSPackageModel";
public static final String CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME =
"CreateNsWorkflowProcessingException";
@@ -47,6 +46,11 @@ public class CamundaVariableNameConstants {
public static final String CREATE_VNF_RESPONSE_PARAM_NAME = "createVnfResponse";
public static final String OPERATION_STATUS_PARAM_NAME = "operationStatus";
+ public static final String TERMINATE_NS_REQUEST_PARAM_NAME = "terminateNsRequest";
+ public static final String NFVO_NF_INST_IDS_PARAM_NAME = "nfvoNfInstIds";
+ public static final String DELETE_VNF_RESPONSE_PARAM_NAME = "deleteVnfResponse";
+ public static final String TERMINATE_VNF_VNFID_PARAM_NAME = "vnfId";
+
private CamundaVariableNameConstants() {}
}
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/Constants.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/Constants.java
index a2128fc2af..14a4f4340b 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/Constants.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/Constants.java
@@ -29,6 +29,7 @@ public class Constants {
public static final String NS_WORKFLOW_ENGINE = "NS-WORKFLOW-ENGINE";
public static final String CREATE_NS_WORKFLOW_NAME = "CreateNs";
public static final String INSTANTIATE_NS_WORKFLOW_NAME = "InstantiateNs";
+ public static final String TERMINATE_NS_WORKFLOW_NAME = "TerminateNs";
public static final String GET_NS_OCCURRENCE_OPERATION_STATUS_NAME = "GetNsOccurrenceOperationStatus";
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/extclients/aai/AaiServiceProvider.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/extclients/aai/AaiServiceProvider.java
index 53062395cf..29ed85cbd8 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/extclients/aai/AaiServiceProvider.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/extclients/aai/AaiServiceProvider.java
@@ -41,4 +41,6 @@ public interface AaiServiceProvider {
Optional<GenericVnf> getGenericVnf(final String vnfId);
+ void deleteGenericVnf(final String vnfId);
+
}
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/extclients/aai/AaiServiceProviderImpl.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/extclients/aai/AaiServiceProviderImpl.java
index c48d10bb69..78cdc797bc 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/extclients/aai/AaiServiceProviderImpl.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/extclients/aai/AaiServiceProviderImpl.java
@@ -84,4 +84,11 @@ public class AaiServiceProviderImpl implements AaiServiceProvider {
return aaiClientProvider.getAaiClient().get(GenericVnf.class,
AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)));
}
+
+ @Override
+ public void deleteGenericVnf(final String vnfId) {
+ logger.info("Deleting GenericVnf with id: {} from AAI.", vnfId);
+ final AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId);
+ aaiClientProvider.getAaiClient().delete(aaiResourceUri);
+ }
}
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/extclients/vnfm/Sol003AdapterServiceProvider.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/extclients/vnfm/Sol003AdapterServiceProvider.java
index c053ba94f1..4f98e2c267 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/extclients/vnfm/Sol003AdapterServiceProvider.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/extclients/vnfm/Sol003AdapterServiceProvider.java
@@ -23,6 +23,7 @@ package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.vnfm;
import java.util.Optional;
import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfRequest;
import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfResponse;
+import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.DeleteVnfResponse;
import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.QueryJobResponse;
public interface Sol003AdapterServiceProvider {
@@ -31,4 +32,6 @@ public interface Sol003AdapterServiceProvider {
Optional<QueryJobResponse> getInstantiateOperationJobStatus(final String jobId);
+ Optional<DeleteVnfResponse> invokeTerminationRequest(final String vnfId);
+
}
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/extclients/vnfm/Sol003AdapterServiceProviderImpl.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/extclients/vnfm/Sol003AdapterServiceProviderImpl.java
index 09fecc64ae..a0798f6e55 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/extclients/vnfm/Sol003AdapterServiceProviderImpl.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/extclients/vnfm/Sol003AdapterServiceProviderImpl.java
@@ -24,6 +24,7 @@ import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.vnfm.Sol003Adap
import java.util.Optional;
import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfRequest;
import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfResponse;
+import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.DeleteVnfResponse;
import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.QueryJobResponse;
import org.onap.so.rest.exceptions.HttpResouceNotFoundException;
import org.onap.so.rest.exceptions.InvalidRestRequestException;
@@ -114,4 +115,35 @@ public class Sol003AdapterServiceProviderImpl implements Sol003AdapterServicePro
throw exception;
}
}
+
+ @Override
+ public Optional<DeleteVnfResponse> invokeTerminationRequest(final String vnfId) {
+ try {
+ final String url = urlProvider.getTerminateVnfUrl(vnfId);
+
+ final ResponseEntity<DeleteVnfResponse> response =
+ httpServiceProvider.deleteHttpRequest(url, DeleteVnfResponse.class);
+ final HttpStatus httpStatus = response.getStatusCode();
+ if (!(httpStatus.equals(HttpStatus.ACCEPTED)) && !(httpStatus.equals(HttpStatus.OK))) {
+ LOGGER.error("Unable to invoke HTTP DELETE using URL: {}, Response Code: {}", url, httpStatus.value());
+ return Optional.empty();
+ }
+ if (!response.hasBody()) {
+ LOGGER.error(RECEIVED_RESPONSE_WITHOUT_BODY, response);
+ return Optional.empty();
+ }
+
+ final DeleteVnfResponse deleteVnfResponse = response.getBody();
+ if (deleteVnfResponse.getJobId() == null || deleteVnfResponse.getJobId().isEmpty()) {
+ LOGGER.error("Received invalid terminate response: {}", response);
+ return Optional.empty();
+ }
+
+ return Optional.of(deleteVnfResponse);
+ } catch (final RestProcessingException | InvalidRestRequestException
+ | HttpResouceNotFoundException httpInvocationException) {
+ LOGGER.error("Unexpected error while processing terminate request", httpInvocationException);
+ return Optional.empty();
+ }
+ }
}
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/extclients/vnfm/Sol003AdapterUrlProvider.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/extclients/vnfm/Sol003AdapterUrlProvider.java
index 351d4bf88c..e3abc059f5 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/extclients/vnfm/Sol003AdapterUrlProvider.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/extclients/vnfm/Sol003AdapterUrlProvider.java
@@ -61,4 +61,14 @@ public class Sol003AdapterUrlProvider {
return UriComponentsBuilder.fromUri(baseUri).pathSegment("jobs").pathSegment(jobId).build().toString();
}
+ /**
+ * Get VNFM terminate vnf URL
+ *
+ * @param vnfId
+ * @return
+ */
+ public String getTerminateVnfUrl(final String vnfId) {
+ return UriComponentsBuilder.fromUri(baseUri).pathSegment("vnfs").pathSegment(vnfId).build().toString();
+ }
+
}
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/service/JobExecutorService.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/service/JobExecutorService.java
index 13cdc60b1b..f240fa33ef 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/service/JobExecutorService.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/service/JobExecutorService.java
@@ -26,9 +26,12 @@ import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstan
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.OCC_ID_PARAM_NAME;
import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.SERVICE_TYPE_PARAM_NAME;
+import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.TERMINATE_NS_REQUEST_PARAM_NAME;
import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.Constants.CREATE_NS_WORKFLOW_NAME;
import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.Constants.INSTANTIATE_NS_WORKFLOW_NAME;
+import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.Constants.TERMINATE_NS_WORKFLOW_NAME;
import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobAction.INSTANTIATE;
+import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobAction.TERMINATE;
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.FINISHED_WITH_ERROR;
@@ -47,14 +50,17 @@ import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.exceptions.NsRequestProcessingExc
import org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobAction;
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.NfvoNsInst;
import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NsLcmOpOcc;
import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NsLcmOpType;
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;
import org.onap.so.etsi.nfvo.ns.lcm.model.CreateNsRequest;
import org.onap.so.etsi.nfvo.ns.lcm.model.InlineResponse400;
import org.onap.so.etsi.nfvo.ns.lcm.model.InstantiateNsRequest;
import org.onap.so.etsi.nfvo.ns.lcm.model.NsInstancesNsInstance;
+import org.onap.so.etsi.nfvo.ns.lcm.model.TerminateNsRequest;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -156,8 +162,8 @@ public class JobExecutorService {
final LocalDateTime currentDateTime = LocalDateTime.now();
final NsLcmOpOcc newNsLcmOpOcc = new NsLcmOpOcc().id(nsInstanceId).operation(NsLcmOpType.INSTANTIATE)
.operationState(OperationStateEnum.PROCESSING).stateEnteredTime(currentDateTime)
- .startTime(currentDateTime).isAutoInnovation(false).isCancelPending(false)
- .operationParams(gson.toJson(instantiateNsRequest));
+ .startTime(currentDateTime).nfvoNsInst(getNfvoNsInst(nsInstanceId)).isAutoInnovation(false)
+ .isCancelPending(false).operationParams(gson.toJson(instantiateNsRequest));
databaseServiceProvider.addNSLcmOpOcc(newNsLcmOpOcc);
logger.info("New NSLcmOpOcc created in database :\n{}", newNsLcmOpOcc);
@@ -190,6 +196,89 @@ public class JobExecutorService {
throw new NsRequestProcessingException(message);
}
+ public String runTerminateNsJob(final String nsInstanceId, final TerminateNsRequest terminateNsRequest) {
+ doInitialTerminateChecks(nsInstanceId, terminateNsRequest);
+
+ final NfvoJob nfvoJob = new NfvoJob().startTime(LocalDateTime.now()).jobType("NS").jobAction(TERMINATE)
+ .resourceId(nsInstanceId).status(STARTING).progress(0);
+ databaseServiceProvider.addJob(nfvoJob);
+ logger.info("New job created in database :\n{}", nfvoJob);
+
+ final LocalDateTime currentDateTime = LocalDateTime.now();
+ final NsLcmOpOcc nsLcmOpOcc = new NsLcmOpOcc().id(nsInstanceId).operation(NsLcmOpType.TERMINATE)
+ .operationState(OperationStateEnum.PROCESSING).stateEnteredTime(currentDateTime)
+ .startTime(currentDateTime).nfvoNsInst(getNfvoNsInst(nsInstanceId)).isAutoInnovation(false)
+ .isCancelPending(false).operationParams(gson.toJson(terminateNsRequest));
+ databaseServiceProvider.addNSLcmOpOcc(nsLcmOpOcc);
+ logger.info("New NSLcmOpOcc created in database :\n{}", nsLcmOpOcc);
+
+ workflowExecutorService.executeWorkflow(nfvoJob.getJobId(), TERMINATE_NS_WORKFLOW_NAME,
+ getVariables(nsInstanceId, nfvoJob.getJobId(), nsLcmOpOcc.getId(), terminateNsRequest));
+
+ final ImmutableSet<JobStatusEnum> jobFinishedStates =
+ ImmutableSet.of(FINISHED, ERROR, FINISHED_WITH_ERROR, IN_PROGRESS);
+ final ImmutablePair<String, JobStatusEnum> immutablePair =
+ waitForJobToFinish(nfvoJob.getJobId(), jobFinishedStates);
+
+ if (immutablePair.getRight() == null) {
+ final String message =
+ "Failed to Terminate NS with id: " + nsInstanceId + " for request: \n" + terminateNsRequest;
+ logger.error(message);
+ throw new NsRequestProcessingException(message);
+ }
+
+ final JobStatusEnum finalJobStatus = immutablePair.getRight();
+
+ if (IN_PROGRESS.equals(finalJobStatus) || FINISHED.equals(finalJobStatus)) {
+ logger.info("Termination Job status: {}", finalJobStatus);
+ return nsLcmOpOcc.getId();
+ }
+
+ final String message = "Received unexpected Job Status: " + finalJobStatus + " Failed to Terminate NS with id: "
+ + nsInstanceId + " for request: \n" + terminateNsRequest;
+ logger.error(message);
+ throw new NsRequestProcessingException(message);
+ }
+
+ private void doInitialTerminateChecks(final String nsInstanceId, final TerminateNsRequest terminateNsRequest) {
+ if (isNotImmediateTerminateRequest(terminateNsRequest)) {
+ final String message = "TerminateNsRequest received with terminateTime: "
+ + terminateNsRequest.getTerminationTime()
+ + "\nOnly immediate Terminate requests are currently supported \n(i.e., terminateTime field must not be set).";
+ logger.error(message);
+ throw new NsRequestProcessingException(message);
+ }
+
+ final NfvoNsInst nfvoNsInst = getNfvoNsInst(nsInstanceId);
+ if (isNotInstantiated(nfvoNsInst)) {
+ final String message = "TerminateNsRequest received: " + terminateNsRequest + " for nsInstanceId: "
+ + nsInstanceId + "\nUnable to terminate. NS Instance is already in NOT_INSTANTIATED state."
+ + "\nThis method can only be used with an NS instance in the INSTANTIATED state.";
+ logger.error(message);
+ throw new NsRequestProcessingException(message);
+ }
+ }
+
+ private boolean isNotImmediateTerminateRequest(final TerminateNsRequest terminateNsRequest) {
+ return terminateNsRequest.getTerminationTime() != null;
+ }
+
+ private boolean isNotInstantiated(final NfvoNsInst nfvoNsInst) {
+ return State.NOT_INSTANTIATED.equals(nfvoNsInst.getStatus());
+ }
+
+ private NfvoNsInst getNfvoNsInst(final String nsInstId) {
+ logger.info("Getting NfvoNsInst with nsInstId: {}", nsInstId);
+ final Optional<NfvoNsInst> optionalNfvoNsInst = databaseServiceProvider.getNfvoNsInst(nsInstId);
+
+ if (optionalNfvoNsInst.isEmpty()) {
+ final String message = "No matching NS Instance for id: " + nsInstId + " found in database.";
+ throw new NsRequestProcessingException(message);
+ }
+
+ return optionalNfvoNsInst.get();
+ }
+
private ImmutablePair<String, JobStatusEnum> waitForJobToFinish(final String jobId,
final ImmutableSet<JobStatusEnum> jobFinishedStates) {
try {
@@ -209,7 +298,7 @@ public class JobExecutorService {
final NfvoJob nfvoJob = optional.get();
currentJobStatus = nfvoJob.getStatus();
- logger.info("Received job status response: \n ", nfvoJob);
+ logger.debug("Received job status response: \n {}", nfvoJob);
if (jobFinishedStates.contains(nfvoJob.getStatus())) {
logger.info("Job finished \n {}", currentJobStatus);
return ImmutablePair.of(nfvoJob.getProcessInstanceId(), currentJobStatus);
@@ -249,4 +338,13 @@ public class JobExecutorService {
return variables;
}
+ private Map<String, Object> getVariables(final String nsInstanceId, final String jobId, final String occId,
+ final TerminateNsRequest terminateNsRequest) {
+ final Map<String, Object> variables = new HashMap<>();
+ variables.put(NS_INSTANCE_ID_PARAM_NAME, nsInstanceId);
+ variables.put(JOB_ID_PARAM_NAME, jobId);
+ variables.put(OCC_ID_PARAM_NAME, occId);
+ variables.put(TERMINATE_NS_REQUEST_PARAM_NAME, terminateNsRequest);
+ return variables;
+ }
}
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 99116dacad..e6905b86fc 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
@@ -21,6 +21,8 @@ package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.tasks;
import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.CREATE_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.OCC_ID_PARAM_NAME;
import java.time.LocalDateTime;
import java.util.Optional;
import org.camunda.bpm.engine.delegate.BpmnError;
@@ -28,6 +30,9 @@ import org.camunda.bpm.engine.delegate.DelegateExecution;
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.service.DatabaseServiceProvider;
import org.onap.so.etsi.nfvo.ns.lcm.model.InlineResponse400;
import org.slf4j.Logger;
@@ -35,6 +40,7 @@ import org.slf4j.LoggerFactory;
/**
* @author Waqas Ikram (waqas.ikram@est.tech)
+ * @author Andrew Lamb (andrew.a.lamb@est.tech)
*
*/
public abstract class AbstractNetworkServiceTask {
@@ -90,6 +96,49 @@ 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);
+
+ logger.info("Finished executing updateNsLcmOpOccStatusToCompleted ...");
+
+ }
+
+ 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);
+ }
+
+ logger.info("Finished executing updateNsLcmOpOccStatusToFailed ...");
+
+ }
+
protected void abortOperation(final DelegateExecution execution, final String message) {
abortOperation(execution, message, new InlineResponse400().detail(message));
}
@@ -104,7 +153,7 @@ public abstract class AbstractNetworkServiceTask {
private NfvoJob getNfvoJob(final DelegateExecution execution) {
final String jobId = (String) execution.getVariable(JOB_ID_PARAM_NAME);
final Optional<NfvoJob> optional = databaseServiceProvider.getJob(jobId);
- if (!optional.isPresent()) {
+ if (optional.isEmpty()) {
final String message = "Unable to find job using job id: " + jobId;
logger.error(message);
execution.setVariable(CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME,
@@ -114,4 +163,22 @@ public abstract class AbstractNetworkServiceTask {
}
return optional.get();
}
+
+ protected NfvoNsInst getNfvoNsInst(final DelegateExecution execution) {
+ final String nsInstId = (String) execution.getVariable(NS_INSTANCE_ID_PARAM_NAME);
+ return getNfvoNsInst(execution, nsInstId);
+ }
+
+ protected NfvoNsInst getNfvoNsInst(final DelegateExecution execution, final String nsInstId) {
+ logger.info("Getting NfvoNsInst to update with nsInstId: {}", nsInstId);
+ final Optional<NfvoNsInst> optionalNfvoNsInst = databaseServiceProvider.getNfvoNsInst(nsInstId);
+
+ if (optionalNfvoNsInst.isEmpty()) {
+ final String message = "Unable to find NS Instance in database using id: " + nsInstId;
+ abortOperation(execution, message);
+ }
+
+ return optionalNfvoNsInst.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/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 c33c67e540..251e694219 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
@@ -219,16 +219,4 @@ public class CreateInstantiateVnfTask extends AbstractNetworkServiceTask {
databaseServiceProvider.saveNfvoNfInst(nfvoNfInst);
}
- private NfvoNsInst getNfvoNsInst(final DelegateExecution execution, final String nsInstId) {
- logger.info("Getting NfvoNsInst to update with nsInstId: {}", nsInstId);
- final Optional<NfvoNsInst> optionalNfvoNsInst = databaseServiceProvider.getNfvoNsInst(nsInstId);
-
- if (!optionalNfvoNsInst.isPresent()) {
- final String message = "Unable to find NS Instance in datababse using id: " + nsInstId;
- abortOperation(execution, message);
- }
-
- return optionalNfvoNsInst.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/InstantiateNsTask.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/InstantiateNsTask.java
index 8d212045ad..6774fad543 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/InstantiateNsTask.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/InstantiateNsTask.java
@@ -55,6 +55,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
* @author Andrew Lamb (andrew.a.lamb@est.tech)
*
*/
@@ -272,50 +273,6 @@ public class InstantiateNsTask extends AbstractNetworkServiceTask {
setJobStatusToError(execution, "Instantiate NS workflow process failed");
}
-
- 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.isPresent()) {
- 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);
-
- logger.info("Finished executing updateNsLcmOpOccStatusToCompleted ...");
-
- }
-
- 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);
- }
-
- logger.info("Finished executing updateNsLcmOpOccStatusToFailed ...");
-
- }
-
private NsdInfo getNsdInfo(final DelegateExecution execution, final String nsPackageId) {
try {
final Optional<NsdInfo> optional =
@@ -395,22 +352,4 @@ public class InstantiateNsTask extends AbstractNetworkServiceTask {
}
- private NfvoNsInst getNfvoNsInst(final DelegateExecution execution) {
- final String nsInstId = (String) execution.getVariable(NS_INSTANCE_ID_PARAM_NAME);
- return getNfvoNsInst(execution, nsInstId);
- }
-
- private NfvoNsInst getNfvoNsInst(final DelegateExecution execution, final String nsInstId) {
- logger.info("Getting NfvoNsInst to update with nsInstId: {}", nsInstId);
- final Optional<NfvoNsInst> optionalNfvoNsInst = databaseServiceProvider.getNfvoNsInst(nsInstId);
-
- if (!optionalNfvoNsInst.isPresent()) {
- final String message = "Unable to find NS Instance in database using id: " + nsInstId;
- abortOperation(execution, message);
- }
-
- return optionalNfvoNsInst.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/MonitorSol003AdapterNodeTask.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/MonitorSol003AdapterNodeTask.java
index e27e0c1579..e4dc3d5e07 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/MonitorSol003AdapterNodeTask.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/MonitorSol003AdapterNodeTask.java
@@ -57,7 +57,7 @@ public abstract class MonitorSol003AdapterNodeTask extends AbstractNetworkServic
final Optional<GenericVnf> aaiGenericVnfOptional = aaiServiceProvider.getGenericVnf(vnfId);
if (!aaiGenericVnfOptional.isPresent()) {
- abortOperation(execution, "Unable to invoke Sol003 adapter for create and instantiate vnfId" + vnfId);
+ abortOperation(execution, "Unable to find generic vnf in A&AI using vnfId" + vnfId);
}
final GenericVnf genericVnf = aaiGenericVnfOptional.get();
final String orchestrationStatus = genericVnf.getOrchestrationStatus();
@@ -89,4 +89,8 @@ public abstract class MonitorSol003AdapterNodeTask extends AbstractNetworkServic
LOGGER.error(message);
abortOperation(execution, message);
}
+
+ AaiServiceProvider getAaiServiceProvider() {
+ return aaiServiceProvider;
+ }
}
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/MonitorSol003AdapterTerminateJobTask.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/MonitorSol003AdapterTerminateJobTask.java
new file mode 100644
index 0000000000..d85444497d
--- /dev/null
+++ 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/MonitorSol003AdapterTerminateJobTask.java
@@ -0,0 +1,106 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.tasks;
+
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.DeleteVnfResponse;
+import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.OperationStateEnum;
+import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.vnfm.Sol003AdapterServiceProvider;
+import org.onap.so.etsi.nfvo.ns.lcm.database.service.DatabaseServiceProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.OPERATION_STATUS_PARAM_NAME;
+import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.DELETE_VNF_RESPONSE_PARAM_NAME;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ * @author Andrew Lamb (andrew.a.lamb@est.tech)
+ *
+ */
+@Component
+public class MonitorSol003AdapterTerminateJobTask extends MonitorSol003AdapterJobTask {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(MonitorSol003AdapterTerminateJobTask.class);
+
+ @Autowired
+ public MonitorSol003AdapterTerminateJobTask(final Sol003AdapterServiceProvider sol003AdapterServiceProvider,
+ final DatabaseServiceProvider databaseServiceProvider) {
+ super(sol003AdapterServiceProvider, databaseServiceProvider);
+ }
+
+ public void getCurrentOperationStatus(final DelegateExecution execution) {
+ try {
+ LOGGER.debug("Executing getCurrentOperationStatus ...");
+ final DeleteVnfResponse deleteVnfResponse =
+ (DeleteVnfResponse) execution.getVariable(DELETE_VNF_RESPONSE_PARAM_NAME);
+ execution.setVariable(OPERATION_STATUS_PARAM_NAME,
+ getOperationStatus(execution, deleteVnfResponse.getJobId()));
+ LOGGER.debug("Finished executing getCurrentOperationStatus ...");
+ } catch (final Exception exception) {
+ final String message = "Unable to invoke get current Operation status";
+ LOGGER.error(message, exception);
+ abortOperation(execution, message);
+
+ }
+ }
+
+ /**
+ * Log and throw exception on timeout for job status
+ *
+ * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
+ */
+ public void timeOutLogFailure(final DelegateExecution execution) {
+ final String message = "Termination operation time out";
+ LOGGER.error(message);
+ abortOperation(execution, message);
+ }
+
+ /**
+ * Check the final status of termination throw exception if not completed successfully
+ *
+ * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
+ */
+ public void checkIfOperationWasSuccessful(final DelegateExecution execution) {
+ LOGGER.debug("Executing checkIfOperationWasSuccessful ...");
+ final OperationStateEnum operationStatus =
+ (OperationStateEnum) execution.getVariable(OPERATION_STATUS_PARAM_NAME);
+ final DeleteVnfResponse deleteVnfResponse =
+ (DeleteVnfResponse) execution.getVariable(DELETE_VNF_RESPONSE_PARAM_NAME);
+
+ if (operationStatus == null) {
+ final String message =
+ "Unable to terminate, jobId: " + (deleteVnfResponse != null ? deleteVnfResponse.getJobId() : "null")
+ + "Unable to retrieve OperationStatus";
+ LOGGER.error(message);
+ abortOperation(execution, message);
+ }
+ if (operationStatus != OperationStateEnum.COMPLETED) {
+ final String message =
+ "Unable to terminate, jobId: " + (deleteVnfResponse != null ? deleteVnfResponse.getJobId() : "null")
+ + " OperationStatus: " + operationStatus;
+ LOGGER.error(message);
+ abortOperation(execution, message);
+ }
+
+ LOGGER.debug("Successfully completed termination of job {}", deleteVnfResponse);
+ }
+}
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/MonitorSol003AdapterTerminateNodeTask.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/MonitorSol003AdapterTerminateNodeTask.java
new file mode 100644
index 0000000000..f38bdba71b
--- /dev/null
+++ 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/MonitorSol003AdapterTerminateNodeTask.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.tasks;
+
+import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.aai.AaiServiceProvider;
+import org.onap.so.etsi.nfvo.ns.lcm.database.service.DatabaseServiceProvider;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ * @author Andrew Lamb (andrew.a.lamb@est.tech)
+ *
+ */
+@Component
+public class MonitorSol003AdapterTerminateNodeTask extends MonitorSol003AdapterNodeTask {
+
+ public static final String DELETE_VNF_NODE_STATUS = "deleteVnfNodeStatus";
+ public static final String VNF_ASSIGNED = "Assigned";
+
+ @Autowired
+ public MonitorSol003AdapterTerminateNodeTask(final DatabaseServiceProvider databaseServiceProvider,
+ final AaiServiceProvider aaiServiceProvider) {
+ super(databaseServiceProvider, aaiServiceProvider);
+ }
+
+ @Override
+ public String getNodeStatusVariableName() {
+ return DELETE_VNF_NODE_STATUS;
+ }
+
+ @Override
+ public boolean isOrchestrationStatusValid(final String orchestrationStatus) {
+ return VNF_ASSIGNED.equalsIgnoreCase(orchestrationStatus);
+ }
+
+}
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/TerminateNsTask.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/TerminateNsTask.java
new file mode 100644
index 0000000000..972e4d6de8
--- /dev/null
+++ 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/TerminateNsTask.java
@@ -0,0 +1,145 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.tasks;
+
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants;
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNfInst;
+import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNsInst;
+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;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import java.util.ArrayList;
+import java.util.List;
+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.database.beans.JobStatusEnum.FINISHED;
+import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum.IN_PROGRESS;
+import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum.STARTED;
+
+/**
+ * @author Andrew Lamb (andrew.a.lamb@est.tech)
+ *
+ */
+@Component
+public class TerminateNsTask extends AbstractNetworkServiceTask {
+
+ private static final String IS_NS_TERMINATION_SUCCESSFUL_PARAM_NAME = "isNsTerminationSuccessful";
+ private static final Logger logger = LoggerFactory.getLogger(TerminateNsTask.class);
+
+ @Autowired
+ public TerminateNsTask(final DatabaseServiceProvider databaseServiceProvider) {
+ super(databaseServiceProvider);
+ }
+
+ public void setJobStatusToStarted(final DelegateExecution execution) {
+ setJobStatus(execution, STARTED, "Terminate NS workflow process started");
+ }
+
+ public void setJobStatusToFinished(final DelegateExecution execution) {
+ setJobStatus(execution, FINISHED, "Terminate NS workflow process finished");
+ }
+
+ public void setJobStatusToError(final DelegateExecution execution) {
+ updateNsInstanceStatus(execution, State.FAILED);
+ setJobStatusToError(execution, "Terminate NS workflow process failed");
+ }
+
+ public void updateNsInstanceStatusToTerminating(final DelegateExecution execution) {
+ logger.info("Executing updateNsInstanceStatusToTerminating");
+ setJobStatus(execution, IN_PROGRESS, "Updating NfvoNsInst Status to " + State.TERMINATING);
+ updateNsInstanceStatus(execution, State.TERMINATING);
+ logger.info("Finished executing updateNsInstanceStatusToTerminating ...");
+ }
+
+ public void updateNsInstanceStatusToNotInstantiated(final DelegateExecution execution) {
+ logger.info("Executing updateNsInstanceStatusToNotInstantiated");
+ setJobStatus(execution, IN_PROGRESS, "Updating NfvoNsInst Status to " + State.NOT_INSTANTIATED);
+ updateNsInstanceStatus(execution, State.NOT_INSTANTIATED);
+ logger.info("Finished executing updateNsInstanceStatusToNotInstantiated ...");
+ }
+
+ public void getVnfIdsInNs(final DelegateExecution execution) {
+ logger.info("Executing getVnfIdsInNs ...");
+ setJobStatus(execution, IN_PROGRESS, "Getting Each VnfId In Ns");
+ final List<String> nfvoNfInstIds = getNfvoNfInstIds(execution);
+ execution.setVariable(CamundaVariableNameConstants.NFVO_NF_INST_IDS_PARAM_NAME, nfvoNfInstIds);
+ logger.info("Finished executing getVnfIdsInNs ...");
+ }
+
+ public void checkIfVnfTerminationWasSuccessful(final DelegateExecution execution) {
+ logger.info("Executing checkIfVnfTerminationWasSuccessful");
+
+ final String nsInstId = (String) execution.getVariable(NS_INSTANCE_ID_PARAM_NAME);
+ final List<NfvoNfInst> nfInstances = databaseServiceProvider.getNfvoNfInstByNsInstId(nsInstId);
+
+ if ((nfInstances != null) && !(nfInstances.isEmpty())) {
+ final String message = "Found NF Instances";
+ nfInstances.stream().forEach(instance -> {
+ logger.error("VNF : {} {} termination failed", instance.getNfInstId(), instance.getName());
+ execution.setVariable(IS_NS_TERMINATION_SUCCESSFUL_PARAM_NAME, false);
+ });
+ abortOperation(execution, message);
+ }
+
+ execution.setVariable(IS_NS_TERMINATION_SUCCESSFUL_PARAM_NAME, true);
+ logger.info("Finished executing checkIfVnfTerminationWasSuccessful");
+ }
+
+ public void logTimeOut(final DelegateExecution execution) {
+ logger.error("Vnf termination timedOut ...");
+ final String nsInstId = (String) execution.getVariable(NS_INSTANCE_ID_PARAM_NAME);
+ final List<NfvoNfInst> nfInstances = databaseServiceProvider.getNfvoNfInstByNsInstId(nsInstId);
+ if (nfInstances != null) {
+ nfInstances.stream().forEach(instance -> {
+ logger.info("Current status {} of vnf: {}", instance.getStatus(), instance.getName());
+ });
+ }
+ }
+
+ private void updateNsInstanceStatus(final DelegateExecution execution, final State nsStatus) {
+ final NfvoNsInst nfvoNsInst = getNfvoNsInst(execution);
+ logger.info("Updating NfvoNsInst Status to {} and saving to DB", nsStatus);
+ nfvoNsInst.setStatus(nsStatus);
+ databaseServiceProvider.saveNfvoNsInst(nfvoNsInst);
+ }
+
+ private List<String> getNfvoNfInstIds(final DelegateExecution execution) {
+ final String nsInstId = (String) execution.getVariable(NS_INSTANCE_ID_PARAM_NAME);
+ logger.info("Getting NfvoNfInstList using nsInstId: {}", nsInstId);
+ final List<NfvoNfInst> nfvoNfInstList = databaseServiceProvider.getNfvoNfInstByNsInstId(nsInstId);
+
+ if (nfvoNfInstList.size() == 0) {
+ final String message = "Unable to find NF Instances in database using id: " + nsInstId;
+ abortOperation(execution, message);
+ }
+
+ final List<String> vnfIdsList = new ArrayList<>();
+
+ nfvoNfInstList.stream().forEach(nfvoNfInst -> {
+ vnfIdsList.add(nfvoNfInst.getNfInstId());
+ });
+
+ return vnfIdsList;
+ }
+
+}
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
new file mode 100644
index 0000000000..15eee22dd2
--- /dev/null
+++ 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
@@ -0,0 +1,187 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.tasks;
+
+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;
+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;
+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)
+ */
+@Component
+public class TerminateVnfTask extends AbstractNetworkServiceTask {
+ private static final Logger logger = LoggerFactory.getLogger(TerminateVnfTask.class);
+ private final AaiServiceProvider aaiServiceProvider;
+ private final Sol003AdapterServiceProvider sol003AdapterServiceProvider;
+
+ @Autowired
+ public TerminateVnfTask(final DatabaseServiceProvider databaseServiceProvider,
+ final AaiServiceProvider aaiServiceProvider,
+ final Sol003AdapterServiceProvider sol003AdapterServiceProvider) {
+ super(databaseServiceProvider);
+ this.aaiServiceProvider = aaiServiceProvider;
+ this.sol003AdapterServiceProvider = sol003AdapterServiceProvider;
+ }
+
+ public void checkIfNfInstanceExistsInDb(final DelegateExecution execution) {
+ logger.info("Executing checkIfNfInstanceInDb");
+ final String vnfId = (String) execution.getVariable(TERMINATE_VNF_VNFID_PARAM_NAME);
+ logger.info("vnfId: {}", vnfId);
+ execution.setVariable(NF_INST_ID_PARAM_NAME, vnfId);
+
+ setJobStatus(execution, JobStatusEnum.IN_PROGRESS,
+ "Checking if VNF Instance with id: " + vnfId + " exists in database.");
+ if (!databaseServiceProvider.isNfInstExists(vnfId)) {
+ abortOperation(execution,
+ "VNF instance with id: " + vnfId + " does not exist in database, so will not be terminated.");
+ }
+ logger.info("Finished executing checkIfNfInstanceInDb ...");
+
+ }
+
+ public void invokeTerminateRequest(final DelegateExecution execution) {
+ logger.info("Executing invokeTerminateRequest");
+ 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);
+
+ final Optional<DeleteVnfResponse> optional = sol003AdapterServiceProvider.invokeTerminationRequest(vnfId);
+
+ if (optional.isEmpty()) {
+ final String errorMessage = "Unexpected error while processing terminate request for vnfId: " + vnfId;
+ logger.error(errorMessage);
+ abortOperation(execution, errorMessage);
+ }
+
+ final DeleteVnfResponse vnfResponse = optional.get();
+
+ 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: "
+ + vnfId + " DeleteVnfResponse Job Id: " + vnfResponse.getJobId());
+ logger.debug("Finished executing invokeTerminateRequest ...");
+ } catch (final Exception exception) {
+ final String message = "Unable to invoke terminate request for vnfId: " + vnfId;
+ logger.error(message, exception);
+ abortOperation(execution, message);
+ }
+
+ }
+
+ public void deleteGenericVnfFromAai(final DelegateExecution execution) {
+ logger.info("Executing deleteGenericVnfFromAai");
+ final String vnfId = (String) execution.getVariable(TERMINATE_VNF_VNFID_PARAM_NAME);
+
+ try {
+ setJobStatus(execution, IN_PROGRESS, "Deleting GenericVnf record from AAI for vnfId: " + vnfId);
+ aaiServiceProvider.deleteGenericVnf(vnfId);
+
+ } catch (final Exception exception) {
+ final String message = "Unable to Delete GenericVnf from AAI for vnfId: " + vnfId;
+ logger.error(message, exception);
+ abortOperation(execution, message);
+ }
+
+ logger.info("Finished executing deleteGenericVnfFromAai ...");
+ }
+
+ public void deleteNfInstanceFromDb(final DelegateExecution execution) {
+ 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);
+ databaseServiceProvider.deleteNfvoNfInst(vnfId);
+
+ setJobStatus(execution, FINISHED, "Successfully finished terminating VNF with vnfId: " + vnfId);
+ logger.info("Finished executing deleteNfInstanceFromDb ...");
+ }
+
+ public void updateNfInstanceStatusToTerminating(final DelegateExecution execution) {
+ logger.info("Executing updateNfInstanceStatusToTerminating");
+
+ updateNfInstanceStatus(execution, State.TERMINATING);
+ final String vnfId = (String) execution.getVariable(TERMINATE_VNF_VNFID_PARAM_NAME);
+ setJobStatus(execution, IN_PROGRESS,
+ "Terminating VNF with vnfId: " + vnfId + " will set status to " + State.TERMINATING);
+
+ logger.info("Finished executing updateNfInstanceStatusToTerminating ...");
+
+ }
+
+ public void updateNfInstanceStatusToNotInstantiated(final DelegateExecution execution) {
+ logger.info("Executing updateNfInstanceStatusToNotInstantiated");
+
+ updateNfInstanceStatus(execution, State.NOT_INSTANTIATED);
+ final String vnfId = (String) execution.getVariable(TERMINATE_VNF_VNFID_PARAM_NAME);
+ setJobStatus(execution, IN_PROGRESS,
+ "Successfully terminated VNF with vnfId: " + vnfId + " will set status to " + State.NOT_INSTANTIATED);
+
+ logger.info("Finished executing updateNfInstanceStatusToInstantiated ...");
+
+ }
+
+ public void updateNfInstanceStatusToFailed(final DelegateExecution execution) {
+ logger.info("Executing updateNfInstanceStatusToFailed");
+
+ updateNfInstanceStatus(execution, State.FAILED);
+ final String vnfId = (String) execution.getVariable(TERMINATE_VNF_VNFID_PARAM_NAME);
+ setJobStatus(execution, ERROR,
+ "Failed to terminate VNF with vnfId: " + vnfId + " will set status to " + State.FAILED);
+
+ logger.info("Finished executing updateNfInstanceStatusToFailed ...");
+
+ }
+
+ 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;
+ logger.error(message);
+
+ abortOperation(execution, message);
+
+ }
+
+ final NfvoNfInst nfvoNfInst = optional.get();
+ nfvoNfInst.setStatus(vnfStatus);
+ databaseServiceProvider.saveNfvoNfInst(nfvoNfInst);
+ }
+
+}