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";
+ public static final String NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME = "NsWorkflowProcessingException";
public static final String CREATE_NS_RESPONSE_PARAM_NAME = "createNsResponse";
public static final String INSTANTIATE_NS_REQUEST_PARAM_NAME = "instantiateNsRequest";
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 DELETE_NS_WORKFLOW_NAME = "DeleteNs";
public static final String GET_NS_OCCURRENCE_OPERATION_STATUS_NAME = "GetNsOccurrenceOperationStatus";
void deleteGenericVnf(final String vnfId);
+ void deleteServiceInstance(final String globalCustomerId, final String serviceType, final String serviceInstanceId);
}
import java.util.Optional;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.ServiceInstance;
-import org.onap.aaiclient.client.aai.AAIObjectType;
import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder;
AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId));
aaiClientProvider.getAaiClient().delete(aaiResourceUri);
}
+
+ @Override
+ public void deleteServiceInstance(final String globalCustomerId, final String serviceType,
+ final String serviceInstanceId) {
+ logger.info(
+ "Deleting Service Instance with \nGlobal Customer Id: {}, \nService Type: {}, and \nService Instance Id: {} \nfrom AAI.",
+ globalCustomerId, serviceType, serviceInstanceId);
+ final AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business()
+ .customer(globalCustomerId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId));
+ aaiClientProvider.getAaiClient().delete(serviceInstanceUri);
+ }
}
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.DELETE_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.DELETE;
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;
throw new NsRequestProcessingException(message);
}
+ public void runDeleteNsJob(final String nsInstanceId) {
+ final NfvoJob nfvoJob = new NfvoJob().startTime(LocalDateTime.now()).jobType("NS").jobAction(DELETE)
+ .resourceId(nsInstanceId).status(STARTING).progress(0);
+ databaseServiceProvider.addJob(nfvoJob);
+ logger.info("New job created in database :\n{}", nfvoJob);
+
+ workflowExecutorService.executeWorkflow(nfvoJob.getJobId(), DELETE_NS_WORKFLOW_NAME,
+ getVariables(nsInstanceId, nfvoJob.getJobId()));
+
+ final ImmutablePair<String, JobStatusEnum> immutablePair =
+ waitForJobToFinish(nfvoJob.getJobId(), JOB_FINISHED_STATES);
+
+ if (immutablePair.getRight() == null) {
+ final String message = "Failed to Delete NS with id: " + nsInstanceId;
+ logger.error(message);
+ throw new NsRequestProcessingException(message);
+ }
+
+ final JobStatusEnum finalJobStatus = immutablePair.getRight();
+ final String processInstanceId = immutablePair.getLeft();
+
+ if (FINISHED.equals(finalJobStatus)) {
+ logger.info("Delete Job status: {}", finalJobStatus);
+ return;
+ }
+
+ final Optional<InlineResponse400> optional = workflowQueryService.getProblemDetails(processInstanceId);
+ if (optional.isPresent()) {
+ final InlineResponse400 problemDetails = optional.get();
+ final String message = "Failed to Delete NS with id: " + nsInstanceId + " due to:\n" + problemDetails;
+ logger.error(message);
+ throw new NsRequestProcessingException(message, problemDetails);
+ }
+
+ final String message =
+ "Received unexpected Job Status: " + finalJobStatus + " Failed to Delete NS with id: " + nsInstanceId;
+ 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: "
variables.put(TERMINATE_NS_REQUEST_PARAM_NAME, terminateNsRequest);
return variables;
}
+
+ private Map<String, Object> getVariables(final String nsInstanceId, final String jobId) {
+ final Map<String, Object> variables = new HashMap<>();
+ variables.put(NS_INSTANCE_ID_PARAM_NAME, nsInstanceId);
+ variables.put(JOB_ID_PARAM_NAME, jobId);
+ return variables;
+ }
}
package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.service;
import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.CREATE_NS_RESPONSE_PARAM_NAME;
-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.NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME;
import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.Constants.TENANT_ID;
import static org.slf4j.LoggerFactory.getLogger;
import java.util.Optional;
public Optional<InlineResponse400> getProblemDetails(final String processInstanceId) {
try {
final HistoricVariableInstance historicVariableInstance =
- getVariable(processInstanceId, CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME);
+ getVariable(processInstanceId, NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME);
logger.info("Found HistoricVariableInstance : {}", historicVariableInstance);
final Object variableValue = historicVariableInstance.getValue();
historicVariableInstance.getValue() != null ? variableValue.getClass() : null, variableValue);
} catch (final ProcessEngineException processEngineException) {
logger.error("Unable to find {} variable using processInstanceId: {}",
- CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME, processInstanceId, processEngineException);
+ NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME, processInstanceId, processEngineException);
}
return Optional.empty();
}
*/
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.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 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;
import org.onap.so.etsi.nfvo.ns.lcm.model.InlineResponse400;
import org.slf4j.Logger;
final Optional<NfvoJob> optional = databaseServiceProvider.getJob(jobId);
if (optional.isPresent()) {
final InlineResponse400 problemDetails =
- (InlineResponse400) execution.getVariable(CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME);
+ (InlineResponse400) execution.getVariable(NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME);
final NfvoJob nfvoJob = optional.get();
nfvoJob.status(JobStatusEnum.ERROR).endTime(LocalDateTime.now());
protected void abortOperation(final DelegateExecution execution, final String message,
final InlineResponse400 problemDetails) {
logger.error(message);
- execution.setVariable(CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME, problemDetails);
+ execution.setVariable(NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME, problemDetails);
throw new BpmnError("WORKFLOW_FAILED");
}
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,
- new InlineResponse400().detail(message));
+ execution.setVariable(NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME, new InlineResponse400().detail(message));
throw new BpmnError("WORKFLOW_FAILED");
}
return optional.get();
}
+ protected 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);
+ }
+
protected NfvoNsInst getNfvoNsInst(final DelegateExecution execution) {
final String nsInstId = (String) execution.getVariable(NS_INSTANCE_ID_PARAM_NAME);
return getNfvoNsInst(execution, nsInstId);
import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.CREATE_NS_REQUEST_PARAM_NAME;
import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.CREATE_NS_RESPONSE_PARAM_NAME;
-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.NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME;
import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.GLOBAL_CUSTOMER_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_PACKAGE_MODEL_PARAM_NAME;
final String message = "Unable to find NS package using NsdId: " + createNsRequest.getNsdId();
logger.error(message);
execution.setVariable(DOES_NS_PACKAGE_EXISTS_PARAM_NAME, false);
- execution.setVariable(CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME,
+ execution.setVariable(NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME,
new InlineResponse400().detail(message));
}
execution.setVariable(DOES_NS_PACKAGE_EXISTS_PARAM_NAME, false);
- execution.setVariable(CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME,
+ execution.setVariable(NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME,
new InlineResponse400().title(message).detail(message));
}
final Optional<NfvoNsInst> optional =
databaseServiceProvider.getNfvoNsInstByName(createNsRequest.getNsName());
final NfvoNsInst nfvoNsInst = optional.get();
- execution.setVariable(CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME, new InlineResponse400()
+ execution.setVariable(NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME, new InlineResponse400()
.detail("Ns Instance already exists in database : " + nfvoNsInst.toString()));
}
--- /dev/null
+/*-
+ * ============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.extclients.aai.AaiServiceProvider;
+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.onap.so.etsi.nfvo.ns.lcm.model.InlineResponse400;
+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.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.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;
+import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.State.NOT_INSTANTIATED;
+
+/**
+ * @author Andrew Lamb (andrew.a.lamb@est.tech)
+ *
+ */
+@Component
+public class DeleteNsTask extends AbstractNetworkServiceTask {
+
+ private static final String NS_INSTANCE_EXISTS_PARAM_NAME = "nsInstanceExists";
+ private static final String NS_INSTANCE_IS_IN_NOT_INSTANTIATED_STATE_PARAM_NAME = "isInNotInstantiatedState";
+ private static final Logger logger = LoggerFactory.getLogger(DeleteNsTask.class);
+ private final AaiServiceProvider aaiServiceProvider;
+
+ @Autowired
+ public DeleteNsTask(final DatabaseServiceProvider databaseServiceProvider,
+ final AaiServiceProvider aaiServiceProvider) {
+ super(databaseServiceProvider);
+ this.aaiServiceProvider = aaiServiceProvider;
+ }
+
+ public void setJobStatusToStarted(final DelegateExecution execution) {
+ setJobStatus(execution, STARTED, "Delete NS workflow process started");
+ }
+
+ public void setJobStatusToFinished(final DelegateExecution execution) {
+ setJobStatus(execution, FINISHED, "Delete NS workflow process finished");
+ }
+
+ public void setJobStatusInProgress(final DelegateExecution execution, final String message) {
+ setJobStatus(execution, IN_PROGRESS, message);
+ }
+
+ public void setJobStatusToError(final DelegateExecution execution) {
+ setJobStatusToError(execution, "Delete NS workflow process failed");
+ }
+
+ public void checkIfNsInstanceExistsInDb(final DelegateExecution execution) {
+ logger.info("Executing checkIfNsInstanceExistsInDb ...");
+ setJobStatusInProgress(execution, "Checking that NS Instance Exists in DB");
+
+ final String nsInstId = (String) execution.getVariable(NS_INSTANCE_ID_PARAM_NAME);
+ final Optional<NfvoNsInst> optionalNfvoNsInst = databaseServiceProvider.getNfvoNsInst(nsInstId);
+ final boolean nsInstanceExists = optionalNfvoNsInst.isPresent();
+ logger.info("NS Instance entry with id: {} {} exist in database", nsInstId,
+ nsInstanceExists ? "does" : "doesn't");
+ execution.setVariable(NS_INSTANCE_EXISTS_PARAM_NAME, nsInstanceExists);
+
+ if (!nsInstanceExists) {
+ final String message =
+ "NS Instance with id: " + nsInstId + " does not exist in database, so will not be deleted.";
+ logger.info(message);
+ execution.setVariable(NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME, new InlineResponse400().detail(message));
+ }
+
+ logger.info("Finished executing checkIfNsInstanceExistsInDb ...");
+ }
+
+ public void checkthatNsInstanceInDbIsInNotInstantiatedState(final DelegateExecution execution) {
+ logger.info("Executing checkthatNsInstanceInDbIsInNotInstantiatedState ...");
+ setJobStatusInProgress(execution, "Checking that NS Instance is in NOT_INSTANTIATED state in Db");
+
+ final String nsInstId = (String) execution.getVariable(NS_INSTANCE_ID_PARAM_NAME);
+ final NfvoNsInst nfvoNsInst = getNfvoNsInst(execution, nsInstId);
+ final State nfvoNsInstState = nfvoNsInst.getStatus();
+ final boolean nsInstanceIsNotInstantiated = NOT_INSTANTIATED.equals(nfvoNsInstState);
+ logger.info("Ns Instance entry with nsInstId: {} is in state: {}", nsInstId, nfvoNsInstState);
+ execution.setVariable(NS_INSTANCE_IS_IN_NOT_INSTANTIATED_STATE_PARAM_NAME, nsInstanceIsNotInstantiated);
+
+ if (!nsInstanceIsNotInstantiated) {
+ final String message =
+ "Cannot Delete NS Instance with id: " + nsInstId + " in the state: " + nfvoNsInstState;
+ logger.info(message);
+ execution.setVariable(NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME, new InlineResponse400().detail(message));
+ }
+
+ logger.info("Finished executing checkthatNsInstanceInDbIsInNotInstantiatedState ...");
+ }
+
+ public void deleteNsInstanceFromAai(final DelegateExecution execution) {
+ logger.info("Executing deleteNsInstanceFromAAI ...");
+ setJobStatusInProgress(execution, "Deleting NS Instance from AAI");
+
+ final String nsInstId = (String) execution.getVariable(NS_INSTANCE_ID_PARAM_NAME);
+ final NfvoNsInst nfvoNsInst = getNfvoNsInst(execution, nsInstId);
+ final String globalCustomerId = nfvoNsInst.getGlobalCustomerId();
+ final String serviceType = nfvoNsInst.getServiceType();
+
+ aaiServiceProvider.deleteServiceInstance(globalCustomerId, serviceType, nsInstId);
+
+ logger.info("Finished executing deleteNsInstanceFromAAI ...");
+ }
+
+ public void deleteNsInstanceFromDb(final DelegateExecution execution) {
+ logger.info("Executing deleteNsInstanceFromDb ...");
+ setJobStatusInProgress(execution, "Deleting NS Instance from Db");
+
+ final String nsInstId = (String) execution.getVariable(NS_INSTANCE_ID_PARAM_NAME);
+ databaseServiceProvider.deleteNfvoNsInst(nsInstId);
+
+ logger.info("Finished executing deleteNsInstanceFromDb ...");
+ }
+}
}
- 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 Optional<Tenant> getTenant(final Map<String, String> additionalParams) {
final String vimId = (String) additionalParams.get("vim_id");
if (vimId != null) {
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;
}
}
- 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);
<?xml version="1.0" encoding="UTF-8"?>
-<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1l4zor5" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.0.0">
+<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1l4zor5" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.2.0">
<bpmn:process id="CreateNs" name=" CreateNs" isExecutable="true">
<bpmn:startEvent id="StartEvent_1" name="Start Process">
<bpmn:outgoing>Flow_1tqn5q5</bpmn:outgoing>
<bpmn:sequenceFlow id="Flow_1rtsvpm" sourceRef="Activity_03ht66t" targetRef="Activity_1r4l8w8" />
</bpmn:process>
<bpmn:error id="Error_0s855yd" name="java.lang.Exception" errorCode="java.lang.Exception" />
- <bpmn:error id="Error_0rqvnym" name="CreateNsProcessingException" errorCode="CREATE_NS_PROCESSING_EXCEPTION" />
+ <bpmn:error id="Error_0rqvnym" name="NsWorkflowProcessingException" errorCode="CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION" />
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="CreateNs">
<bpmndi:BPMNEdge id="Flow_1rtsvpm_di" bpmnElement="Flow_1rtsvpm">
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1l4zor5" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.2.0">
+ <bpmn:process id="DeleteNs" name="DeleteNs" isExecutable="true">
+ <bpmn:startEvent id="StartEvent_1" name="Start Process">
+ <bpmn:outgoing>Flow_1tqn5q5</bpmn:outgoing>
+ </bpmn:startEvent>
+ <bpmn:endEvent id="EndEvent_1" name="End Process">
+ <bpmn:incoming>Flow_0t87ov3</bpmn:incoming>
+ </bpmn:endEvent>
+ <bpmn:sequenceFlow id="Flow_1tqn5q5" sourceRef="StartEvent_1" targetRef="Activity_15ksfz6" />
+ <bpmn:serviceTask id="Activity_15ksfz6" name="Set Job Status to STARTED" camunda:asyncBefore="true" camunda:expression="${DeleteNsTask.setJobStatusToStarted(execution)}">
+ <bpmn:incoming>Flow_1tqn5q5</bpmn:incoming>
+ <bpmn:outgoing>Flow_0fhodlp</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:serviceTask id="Activity_1r4l8w8" name="Set Job Status to FINISHED" camunda:expression="${DeleteNsTask.setJobStatusToFinished(execution)}">
+ <bpmn:incoming>Flow_1rtsvpm</bpmn:incoming>
+ <bpmn:outgoing>Flow_0t87ov3</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:sequenceFlow id="Flow_0t87ov3" sourceRef="Activity_1r4l8w8" targetRef="EndEvent_1" />
+ <bpmn:subProcess id="Activity_06ko4e2" name="Error Handling" triggeredByEvent="true">
+ <bpmn:startEvent id="Event_1ibvrn2" name="error">
+ <bpmn:outgoing>Flow_0554tjv</bpmn:outgoing>
+ <bpmn:errorEventDefinition id="ErrorEventDefinition_0lc46mh" />
+ </bpmn:startEvent>
+ <bpmn:endEvent id="Event_02f7sr1" name="end">
+ <bpmn:incoming>Flow_04xvpee</bpmn:incoming>
+ </bpmn:endEvent>
+ <bpmn:sequenceFlow id="Flow_0554tjv" sourceRef="Event_1ibvrn2" targetRef="Activity_1sj0nvr" />
+ <bpmn:serviceTask id="Activity_1sj0nvr" name="Set Job Status to ERROR" camunda:asyncBefore="true" camunda:expression="${DeleteNsTask.setJobStatusToError(execution)}">
+ <bpmn:incoming>Flow_0554tjv</bpmn:incoming>
+ <bpmn:outgoing>Flow_04xvpee</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:sequenceFlow id="Flow_04xvpee" sourceRef="Activity_1sj0nvr" targetRef="Event_02f7sr1" />
+ </bpmn:subProcess>
+ <bpmn:subProcess id="Activity_1dx9fz6" name="Java Exception Handling" triggeredByEvent="true">
+ <bpmn:startEvent id="Event_0zne7ch" name="error">
+ <bpmn:outgoing>Flow_0j1otrx</bpmn:outgoing>
+ <bpmn:errorEventDefinition id="ErrorEventDefinition_1p3h4ta" errorRef="Error_0rqvnym" camunda:errorCodeVariable="BPMN_javaExpCode" camunda:errorMessageVariable="BPMN_javaExpMsg" />
+ </bpmn:startEvent>
+ <bpmn:endEvent id="Event_0bcyh7u">
+ <bpmn:incoming>Flow_0oqv7vl</bpmn:incoming>
+ </bpmn:endEvent>
+ <bpmn:sequenceFlow id="Flow_0j1otrx" sourceRef="Event_0zne7ch" targetRef="Activity_15uwy90" />
+ <bpmn:serviceTask id="Activity_15uwy90" name="Set Job Status to ERROR" camunda:asyncBefore="true" camunda:expression="${DeleteNsTask.setJobStatusToError(execution)}">
+ <bpmn:incoming>Flow_0j1otrx</bpmn:incoming>
+ <bpmn:outgoing>Flow_0oqv7vl</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:sequenceFlow id="Flow_0oqv7vl" sourceRef="Activity_15uwy90" targetRef="Event_0bcyh7u" />
+ </bpmn:subProcess>
+ <bpmn:serviceTask id="Activity_0vlb2nk" name="Check NS Instance exists In DB " camunda:expression="${DeleteNsTask.checkIfNsInstanceExistsInDb(execution)}">
+ <bpmn:incoming>Flow_0fhodlp</bpmn:incoming>
+ <bpmn:outgoing>Flow_1duwqzf</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:serviceTask id="Activity_09tqz8x" name="Check that NS Instance in DB is in NOT_INSTANTIATED state" camunda:expression="${DeleteNsTask.checkthatNsInstanceInDbIsInNotInstantiatedState(execution)}">
+ <bpmn:incoming>Flow_02g3nbb</bpmn:incoming>
+ <bpmn:outgoing>Flow_1ihvsfs</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:serviceTask id="Activity_03ht66t" name="Delete NS Instance from DB" camunda:expression="${DeleteNsTask.deleteNsInstanceFromDb(execution)}">
+ <bpmn:incoming>Flow_04wub0a</bpmn:incoming>
+ <bpmn:outgoing>Flow_1rtsvpm</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:sequenceFlow id="Flow_1rtsvpm" sourceRef="Activity_03ht66t" targetRef="Activity_1r4l8w8" />
+ <bpmn:sequenceFlow id="Flow_0fhodlp" sourceRef="Activity_15ksfz6" targetRef="Activity_0vlb2nk" />
+ <bpmn:sequenceFlow id="Flow_1duwqzf" sourceRef="Activity_0vlb2nk" targetRef="Gateway_1tjajb0" />
+ <bpmn:sequenceFlow id="Flow_1ihvsfs" sourceRef="Activity_09tqz8x" targetRef="Gateway_1voek52" />
+ <bpmn:serviceTask id="Activity_1rrzri0" name="Delete NS Instance from AAI" camunda:expression="${DeleteNsTask.deleteNsInstanceFromAai(execution)}">
+ <bpmn:incoming>Flow_1buncqe</bpmn:incoming>
+ <bpmn:outgoing>Flow_04wub0a</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:sequenceFlow id="Flow_04wub0a" sourceRef="Activity_1rrzri0" targetRef="Activity_03ht66t" />
+ <bpmn:exclusiveGateway id="Gateway_1tjajb0" name="Does NS Instance Exist?">
+ <bpmn:incoming>Flow_1duwqzf</bpmn:incoming>
+ <bpmn:outgoing>Flow_02g3nbb</bpmn:outgoing>
+ <bpmn:outgoing>Flow_1swnlzf</bpmn:outgoing>
+ </bpmn:exclusiveGateway>
+ <bpmn:sequenceFlow id="Flow_02g3nbb" name="Yes" sourceRef="Gateway_1tjajb0" targetRef="Activity_09tqz8x">
+ <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{nsInstanceExists}</bpmn:conditionExpression>
+ </bpmn:sequenceFlow>
+ <bpmn:exclusiveGateway id="Gateway_1voek52" name="Is NS Instance in NOT INSTANTIATED State?">
+ <bpmn:incoming>Flow_1ihvsfs</bpmn:incoming>
+ <bpmn:outgoing>Flow_1buncqe</bpmn:outgoing>
+ <bpmn:outgoing>Flow_1eozcur</bpmn:outgoing>
+ </bpmn:exclusiveGateway>
+ <bpmn:sequenceFlow id="Flow_1buncqe" name="Yes" sourceRef="Gateway_1voek52" targetRef="Activity_1rrzri0">
+ <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{isInNotInstantiatedState}</bpmn:conditionExpression>
+ </bpmn:sequenceFlow>
+ <bpmn:endEvent id="Event_0dqc93c">
+ <bpmn:incoming>Flow_1swnlzf</bpmn:incoming>
+ <bpmn:incoming>Flow_1eozcur</bpmn:incoming>
+ <bpmn:errorEventDefinition id="ErrorEventDefinition_0pfrgad" errorRef="Error_0rqvnym" />
+ </bpmn:endEvent>
+ <bpmn:sequenceFlow id="Flow_1swnlzf" name="No" sourceRef="Gateway_1tjajb0" targetRef="Event_0dqc93c">
+ <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{not nsInstanceExists}</bpmn:conditionExpression>
+ </bpmn:sequenceFlow>
+ <bpmn:sequenceFlow id="Flow_1eozcur" name="No" sourceRef="Gateway_1voek52" targetRef="Event_0dqc93c">
+ <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{not isInNotInstantiatedState}</bpmn:conditionExpression>
+ </bpmn:sequenceFlow>
+ </bpmn:process>
+ <bpmn:error id="Error_0s855yd" name="java.lang.Exception" errorCode="java.lang.Exception" />
+ <bpmn:error id="Error_0rqvnym" name="NsWorkflowProcessingException" errorCode="DELETE_NS_WORKFLOW_PROCESSING_EXCEPTION" />
+ <bpmndi:BPMNDiagram id="BPMNDiagram_1">
+ <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DeleteNs">
+ <bpmndi:BPMNEdge id="Flow_1eozcur_di" bpmnElement="Flow_1eozcur">
+ <di:waypoint x="830" y="192" />
+ <di:waypoint x="830" y="270" />
+ <di:waypoint x="708" y="270" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="843" y="228" width="14" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_1swnlzf_di" bpmnElement="Flow_1swnlzf">
+ <di:waypoint x="550" y="192" />
+ <di:waypoint x="550" y="270" />
+ <di:waypoint x="672" y="270" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="558" y="228" width="14" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_1buncqe_di" bpmnElement="Flow_1buncqe">
+ <di:waypoint x="855" y="167" />
+ <di:waypoint x="960" y="167" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="890" y="149" width="19" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_02g3nbb_di" bpmnElement="Flow_02g3nbb">
+ <di:waypoint x="575" y="167" />
+ <di:waypoint x="640" y="167" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="598" y="149" width="19" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_04wub0a_di" bpmnElement="Flow_04wub0a">
+ <di:waypoint x="1060" y="167" />
+ <di:waypoint x="1100" y="167" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_1ihvsfs_di" bpmnElement="Flow_1ihvsfs">
+ <di:waypoint x="740" y="167" />
+ <di:waypoint x="805" y="167" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_1duwqzf_di" bpmnElement="Flow_1duwqzf">
+ <di:waypoint x="490" y="167" />
+ <di:waypoint x="525" y="167" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_0fhodlp_di" bpmnElement="Flow_0fhodlp">
+ <di:waypoint x="350" y="167" />
+ <di:waypoint x="390" y="167" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_1rtsvpm_di" bpmnElement="Flow_1rtsvpm">
+ <di:waypoint x="1200" y="167" />
+ <di:waypoint x="1240" y="167" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_0t87ov3_di" bpmnElement="Flow_0t87ov3">
+ <di:waypoint x="1340" y="167" />
+ <di:waypoint x="1382" y="167" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_1tqn5q5_di" bpmnElement="Flow_1tqn5q5">
+ <di:waypoint x="208" y="167" />
+ <di:waypoint x="250" y="167" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
+ <dc:Bounds x="172" y="149" width="36" height="36" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="158" y="192" width="67" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Event_0db1w1a_di" bpmnElement="EndEvent_1">
+ <dc:Bounds x="1382" y="149" width="36" height="36" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="1369" y="192" width="63" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_15ksfz6_di" bpmnElement="Activity_15ksfz6">
+ <dc:Bounds x="250" y="127" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_1r4l8w8_di" bpmnElement="Activity_1r4l8w8">
+ <dc:Bounds x="1240" y="127" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_06ko4e2_di" bpmnElement="Activity_06ko4e2" isExpanded="true">
+ <dc:Bounds x="431" y="360" width="438" height="130" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="Flow_04xvpee_di" bpmnElement="Flow_04xvpee">
+ <di:waypoint x="681" y="423" />
+ <di:waypoint x="813" y="423" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_0554tjv_di" bpmnElement="Flow_0554tjv">
+ <di:waypoint x="489" y="423" />
+ <di:waypoint x="581" y="423" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="Event_1ibvrn2_di" bpmnElement="Event_1ibvrn2">
+ <dc:Bounds x="453" y="405" width="36" height="36" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="459" y="448" width="24" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Event_02f7sr1_di" bpmnElement="Event_02f7sr1">
+ <dc:Bounds x="813" y="405" width="36" height="36" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="823" y="447" width="19" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_1sj0nvr_di" bpmnElement="Activity_1sj0nvr">
+ <dc:Bounds x="581" y="383" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_1dx9fz6_di" bpmnElement="Activity_1dx9fz6" isExpanded="true">
+ <dc:Bounds x="431" y="520" width="438" height="130" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="Flow_0oqv7vl_di" bpmnElement="Flow_0oqv7vl">
+ <di:waypoint x="680" y="583" />
+ <di:waypoint x="772" y="583" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_0j1otrx_di" bpmnElement="Flow_0j1otrx">
+ <di:waypoint x="522" y="583" />
+ <di:waypoint x="580" y="583" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="Event_0zne7ch_di" bpmnElement="Event_0zne7ch">
+ <dc:Bounds x="486" y="565" width="36" height="36" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="493" y="608" width="24" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Event_0bcyh7u_di" bpmnElement="Event_0bcyh7u">
+ <dc:Bounds x="772" y="565" width="36" height="36" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_15uwy90_di" bpmnElement="Activity_15uwy90">
+ <dc:Bounds x="580" y="543" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_0vlb2nk_di" bpmnElement="Activity_0vlb2nk">
+ <dc:Bounds x="390" y="127" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_09tqz8x_di" bpmnElement="Activity_09tqz8x">
+ <dc:Bounds x="640" y="127" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_03ht66t_di" bpmnElement="Activity_03ht66t">
+ <dc:Bounds x="1100" y="127" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_1rrzri0_di" bpmnElement="Activity_1rrzri0">
+ <dc:Bounds x="960" y="127" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Gateway_1tjajb0_di" bpmnElement="Gateway_1tjajb0" isMarkerVisible="true">
+ <dc:Bounds x="525" y="142" width="50" height="50" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="505" y="106" width="89" height="27" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Gateway_1voek52_di" bpmnElement="Gateway_1voek52" isMarkerVisible="true">
+ <dc:Bounds x="805" y="142" width="50" height="50" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="791" y="83" width="79" height="53" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Event_029a1ih_di" bpmnElement="Event_0dqc93c">
+ <dc:Bounds x="672" y="252" width="36" height="36" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="646" y="245" width="88" height="27" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ </bpmndi:BPMNPlane>
+ </bpmndi:BPMNDiagram>
+</bpmn:definitions>
</bpmn:serviceTask>
<bpmn:sequenceFlow id="Flow_1i36dw4" sourceRef="Activity_0gkpdft" targetRef="Activity_1w09i1k" />
</bpmn:process>
- <bpmn:error id="Error_0jsct8p" name="InstantiateNsProcessingException" errorCode="INSTANTIATE_NS_PROCESSING_EXCEPTION" />
+ <bpmn:error id="Error_0jsct8p" name="NsWorkflowProcessingException" errorCode="INSTANTIATE_NS_WORKFLOW_PROCESSING_EXCEPTION" />
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="InstantiateNs">
<bpmndi:BPMNEdge id="Flow_1p21p1m_di" bpmnElement="Flow_1p21p1m">
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
-</bpmn:definitions>
+</bpmn:definitions>
\ No newline at end of file
</bpmn:serviceTask>
<bpmn:sequenceFlow id="Flow_1i36dw4" sourceRef="Activity_0gkpdft" targetRef="Activity_1w09i1k" />
</bpmn:process>
- <bpmn:error id="Error_0jsct8p" name="TerminateNsProcessingException" errorCode="TERMINATE_NS_PROCESSING_EXCEPTION" />
+ <bpmn:error id="Error_0jsct8p" name="NsWorkflowProcessingException" errorCode="TERMINATE_NS_WORKFLOW_PROCESSING_EXCEPTION" />
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="TerminateNs">
<bpmndi:BPMNEdge id="Flow_1i36dw4_di" bpmnElement="Flow_1i36dw4">
return runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult() == null;
}
+ protected String getAaiServiceInstanceEndPoint() {
+ return "/aai/v[0-9]+/business/customers/customer/" + GLOBAL_CUSTOMER_ID
+ + "/service-subscriptions/service-subscription/" + SERVICE_TYPE
+ + "/service-instances/service-instance/.*";
+ }
}
assertNull(nsResponseVariable);
final HistoricVariableInstance workflowExceptionVariable = getVariable(processInstance.getProcessInstanceId(),
- CamundaVariableNameConstants.CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME);
+ CamundaVariableNameConstants.NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME);
final InlineResponse400 problemDetails = (InlineResponse400) workflowExceptionVariable.getValue();
assertNotNull(problemDetails);
mockEtsiCatalogEndpoints(nsdId);
- final String modelEndpoint = getAiaServiceInstancelEndPoint(createNsRequest);
+ final String modelEndpoint = getAaiServiceInstanceEndPoint();
wireMockServer.stubFor(put(urlMatching(modelEndpoint)).willReturn(WireMock.serverError()));
wireMockServer.stubFor(get(urlMatching(modelEndpoint)).willReturn(WireMock.serverError()));
}
private void mockAAIEndpoints(final CreateNsRequest createNsRequest) {
- final String modelEndpoint = getAiaServiceInstancelEndPoint(createNsRequest);
+ final String modelEndpoint = getAaiServiceInstanceEndPoint();
wireMockServer.stubFor(put(urlMatching(modelEndpoint)).willReturn(ok()));
wireMockServer.stubFor(get(urlMatching(modelEndpoint)).willReturn(notFound()));
}
- private String getAiaServiceInstancelEndPoint(final CreateNsRequest createNsRequest) {
- return "/aai/v[0-9]+/business/customers/customer/" + GLOBAL_CUSTOMER_ID
- + "/service-subscriptions/service-subscription/" + SERVICE_TYPE
- + "/service-instances/service-instance/.*";
- }
-
private void mockEtsiCatalogEndpoints(final String nsdId) {
mockRestServiceServer.expect(requestTo(ETSI_CATALOG_URL + "/nsd/v1/ns_descriptors/" + nsdId))
.andExpect(method(HttpMethod.GET))
--- /dev/null
+/*-
+ * ============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.workflow.engine.tasks;
+
+import com.google.gson.Gson;
+import org.camunda.bpm.engine.history.HistoricProcessInstance;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.BaseTest;
+import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.GsonProvider;
+import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.exceptions.NsRequestProcessingException;
+import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.service.JobExecutorService;
+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.State;
+import org.springframework.beans.factory.annotation.Autowired;
+import java.time.LocalDateTime;
+import java.util.Optional;
+import java.util.UUID;
+import static com.github.tomakehurst.wiremock.client.WireMock.delete;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.ok;
+import static com.github.tomakehurst.wiremock.client.WireMock.okJson;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * @author Andrew Lamb (andrew.a.lamb@est.tech)
+ *
+ */
+public class DeleteNsTaskTest extends BaseTest {
+
+ @Autowired
+ private JobExecutorService objUnderTest;
+
+ @Autowired
+ private GsonProvider gsonProvider;
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ private Gson gson;
+
+ @Before
+ public void before() {
+ wireMockServer.resetAll();
+ gson = gsonProvider.getGson();
+ }
+
+ @After
+ public void after() {
+ wireMockServer.resetAll();
+ }
+
+ @Test
+ public void testRunDeleteNsJob_nsInstanceIdNotInDatabase_throwsException() {
+ final String nsInstanceId = UUID.randomUUID().toString();
+ assertTrue(databaseServiceProvider.getNfvoNsInst(nsInstanceId).isEmpty());
+
+ expectedException.expect(NsRequestProcessingException.class);
+ objUnderTest.runDeleteNsJob(nsInstanceId);
+ }
+
+ @Test
+ public void testRunDeleteNsJob_nsInstanceStateInstantiated_throwsException() {
+ final String nsInstanceId = UUID.randomUUID().toString();
+ addDummyNsToDatabase(nsInstanceId, State.INSTANTIATED);
+
+ final Optional<NfvoNsInst> optionalNfvoNsInst = databaseServiceProvider.getNfvoNsInst(nsInstanceId);
+ assertTrue(optionalNfvoNsInst.isPresent());
+ assertEquals(State.INSTANTIATED, optionalNfvoNsInst.get().getStatus());
+
+ expectedException.expect(NsRequestProcessingException.class);
+ objUnderTest.runDeleteNsJob(nsInstanceId);
+ }
+
+ @Test
+ public void testRunDeleteNsJob_nsInstanceStateInstantiating_throwsException() {
+ final String nsInstanceId = UUID.randomUUID().toString();
+ addDummyNsToDatabase(nsInstanceId, State.INSTANTIATING);
+
+ final Optional<NfvoNsInst> optionalNfvoNsInst = databaseServiceProvider.getNfvoNsInst(nsInstanceId);
+ assertTrue(optionalNfvoNsInst.isPresent());
+ assertEquals(State.INSTANTIATING, optionalNfvoNsInst.get().getStatus());
+
+ expectedException.expect(NsRequestProcessingException.class);
+ objUnderTest.runDeleteNsJob(nsInstanceId);
+ }
+
+ @Test
+ public void testRunDeleteNsJob_nsInstanceStateTerminating_throwsException() {
+ final String nsInstanceId = UUID.randomUUID().toString();
+ addDummyNsToDatabase(nsInstanceId, State.TERMINATING);
+
+ final Optional<NfvoNsInst> optionalNfvoNsInst = databaseServiceProvider.getNfvoNsInst(nsInstanceId);
+ assertTrue(optionalNfvoNsInst.isPresent());
+ assertEquals(State.TERMINATING, optionalNfvoNsInst.get().getStatus());
+
+ expectedException.expect(NsRequestProcessingException.class);
+ objUnderTest.runDeleteNsJob(nsInstanceId);
+ }
+
+ @Test
+ public void testRunDeleteNsJob_nsInstanceStateFailed_throwsException() {
+ final String nsInstanceId = UUID.randomUUID().toString();
+ addDummyNsToDatabase(nsInstanceId, State.FAILED);
+
+ final Optional<NfvoNsInst> optionalNfvoNsInst = databaseServiceProvider.getNfvoNsInst(nsInstanceId);
+ assertTrue(optionalNfvoNsInst.isPresent());
+ assertEquals(State.FAILED, optionalNfvoNsInst.get().getStatus());
+
+ expectedException.expect(NsRequestProcessingException.class);
+ objUnderTest.runDeleteNsJob(nsInstanceId);
+ }
+
+ @Test
+ public void testRunDeleteNsJob_SuccessfulCase() throws InterruptedException {
+ final String nsInstanceId = UUID.randomUUID().toString();
+ addDummyNsToDatabase(nsInstanceId, State.NOT_INSTANTIATED);
+ mockAaiEndpoints();
+
+ final Optional<NfvoNsInst> optionalNfvoNsInst = databaseServiceProvider.getNfvoNsInst(nsInstanceId);
+ assertTrue(optionalNfvoNsInst.isPresent());
+ assertEquals(State.NOT_INSTANTIATED, optionalNfvoNsInst.get().getStatus());
+
+ objUnderTest.runDeleteNsJob(nsInstanceId);
+
+ final Optional<NfvoJob> optional = getJobByResourceId(nsInstanceId);
+ assertTrue(optional.isPresent());
+ final NfvoJob nfvoJob = optional.get();
+
+ // Confirm Process finishes in STATE_COMPLETED
+ assertTrue(waitForProcessInstanceToFinish(nfvoJob.getProcessInstanceId()));
+ final HistoricProcessInstance historicProcessInstance =
+ getHistoricProcessInstance(nfvoJob.getProcessInstanceId());
+ assertNotNull(historicProcessInstance);
+ assertEquals(HistoricProcessInstance.STATE_COMPLETED, historicProcessInstance.getState());
+
+ // Confirm NS Instance no longer in database
+ final Optional<NfvoNsInst> optionalNfvoNsInstance = databaseServiceProvider.getNfvoNsInst(nsInstanceId);
+ assertTrue(optionalNfvoNsInstance.isEmpty());
+ }
+
+ private void addDummyNsToDatabase(final String nsInstanceId, final State state) {
+ final String nsPackageId = UUID.randomUUID().toString();
+ final NfvoNsInst nfvoNsInst = new NfvoNsInst().nsInstId(nsInstanceId).name("nsName").nsPackageId(nsPackageId)
+ .nsdId("nsdId").nsdInvariantId("nsdId").status(state).statusUpdatedTime(LocalDateTime.now())
+ .globalCustomerId(GLOBAL_CUSTOMER_ID).serviceType(SERVICE_TYPE);
+ databaseServiceProvider.saveNfvoNsInst(nfvoNsInst);
+ }
+
+ private void mockAaiEndpoints() {
+ final String modelEndpoint = getAaiServiceInstanceEndPoint();
+ final String resourceVersion = "12345";
+
+ final String body =
+ "{\"resource-version\": \"" + resourceVersion + "\",\n\"orchestration-status\": \"Assigned\"}";
+ wireMockServer.stubFor(get(urlMatching(modelEndpoint)).willReturn(ok()).willReturn(okJson(body)));
+
+ wireMockServer.stubFor(
+ delete(urlMatching(modelEndpoint + "\\?resource-version=" + resourceVersion)).willReturn(ok()));
+ }
+}
assertNull(nsResponseVariable);
final HistoricVariableInstance workflowExceptionVariable = getVariable(processInstance.getProcessInstanceId(),
- CamundaVariableNameConstants.CREATE_NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME);
+ CamundaVariableNameConstants.NS_WORKFLOW_PROCESSING_EXCEPTION_PARAM_NAME);
final InlineResponse400 problemDetails = (InlineResponse400) workflowExceptionVariable.getValue();
assertNotNull(problemDetails);
*/
public class TerminateNsTaskTest extends BaseTest {
- @Autowired
- @Qualifier(ETSI_CATALOG_REST_TEMPLATE_BEAN)
- private RestTemplate etsiCatalogRestTemplate;
-
@Autowired
@Qualifier(SOL003_ADAPTER_REST_TEMPLATE_BEAN)
private RestTemplate sol003AdapterRestTemplate;
- private MockRestServiceServer mockEtsiCatalogRestServiceServer;
-
private MockRestServiceServer mockSol003AdapterRestServiceServer;
@Autowired
public void before() {
wireMockServer.resetAll();
gson = gsonProvider.getGson();
-
- mockEtsiCatalogRestServiceServer =
- MockRestServiceServer.bindTo(etsiCatalogRestTemplate).ignoreExpectOrder(true).build();
mockSol003AdapterRestServiceServer =
MockRestServiceServer.bindTo(sol003AdapterRestTemplate).ignoreExpectOrder(true).build();
-
- etsiCatalogRestTemplate.getMessageConverters().add(new GsonHttpMessageConverter(gson));
sol003AdapterRestTemplate.getMessageConverters().add(new GsonHttpMessageConverter(gson));
-
}
@After
public void after() {
wireMockServer.resetAll();
- mockEtsiCatalogRestServiceServer.reset();
}
@Test
return nsLcmOpOccRepository.findById(id);
}
-
+ public void deleteNfvoNsInst(final String nsInstId) {
+ logger.info("Deleting NfvoNsInst with nsInstId: {}", nsInstId);
+ nfvoNsInstRepository.deleteById(nsInstId);
+ }
}
return etsiSoNsLcmManagerUrlProvider.getNsLcmOpOccUri(nsLcmOpOccId);
}
+
+ public void deleteNs(final String nsInstanceId) {
+ logger.info("Will execute Delete Ns for nsInstanceId: {}", nsInstanceId);
+ jobExecutorService.runDeleteNsJob(nsInstanceId);
+ }
}
import org.onap.so.etsi.nfvo.ns.lcm.model.TerminateNsRequest;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.DeleteMapping;
produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public ResponseEntity<?> deleteNs(@PathVariable("nsInstanceId") final String nsInstanceId) {
logger.debug("Received delete NS request for nsInstanceId: {}", nsInstanceId);
- return ResponseEntity.status(HttpStatus.NOT_IMPLEMENTED).body("Operation is not supported yet");
+ nsLifeCycleManager.deleteNs(nsInstanceId);
+ logger.info("Successfully deleted NS for nsInstanceId: {}", nsInstanceId);
+ return ResponseEntity.noContent().build();
}
/**
*/
package org.onap.so.etsi.nfvo.ns.lcm.rest;
-/**
- * @author Waqas Ikram (waqas.ikram@est.tech)
- *
- */
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.when;
import java.net.URISyntaxException;
-import java.time.LocalDateTime;
import java.util.List;
import java.util.UUID;
import org.junit.Before;
}
@Test
- public void testCreateNs_ValidDeleteNsRequest() {
- final String baseUrl = getNsLcmBaseUrl() + "/ns_instances/" + UUID.randomUUID().toString();
+ public void testDeleteNs_SuccessfulCase() {
+ final String nsInstId = UUID.randomUUID().toString();
+ doNothing().when(mockedJobExecutorService).runDeleteNsJob(eq(nsInstId));
+
+ final String baseUrl = getNsLcmBaseUrl() + "/ns_instances/" + nsInstId;
final ResponseEntity<Void> responseEntity =
testRestTemplate.exchange(baseUrl, HttpMethod.DELETE, null, Void.class);
- assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode());
+ assertEquals(HttpStatus.NO_CONTENT, responseEntity.getStatusCode());
+ }
+
+ @Test
+ public void testDeleteNs_nsRequestProcessingExceptionThrown_returnInlineResponse400() {
+ final String nsInstId = UUID.randomUUID().toString();
+ final String message = "Unable to process request";
+ doThrow(new NsRequestProcessingException(message, new InlineResponse400().detail(message)))
+ .when(mockedJobExecutorService).runDeleteNsJob(eq(nsInstId));
+
+ final String baseUrl = getNsLcmBaseUrl() + "/ns_instances/" + nsInstId;
+ final ResponseEntity<InlineResponse400> responseEntity =
+ testRestTemplate.exchange(baseUrl, HttpMethod.DELETE, null, InlineResponse400.class);
+
+ assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, responseEntity.getStatusCode());
+ assertTrue(responseEntity.hasBody());
+ assertNotNull(responseEntity.getBody());
}
@Test