From 1bad00ddeecd2d6e53ae967fd9faad64cacdafc4 Mon Sep 17 00:00:00 2001 From: "Kalkere Ramesh, Sharan" Date: Tue, 8 Dec 2020 16:53:39 -0500 Subject: added in support for delete instance cnf Issue-ID: SO-3404 Change-Id: I1dccebefdeea8f53c4889cc7c61108462de0bf9c Signed-off-by: Kalkere Ramesh, Sharan --- .../servicedecomposition/tasks/BBInputSetup.java | 5 + .../subprocess/BuildingBlock/DeleteVfModuleBB.bpmn | 245 +++++++------ .../BuildingBlock/ExecuteBuildingBlock.bpmn | 389 +++++++++++---------- .../adapter/cnf/tasks/CnfAdapterDeleteTasks.java | 66 ++++ .../so/client/adapter/cnf/CnfAdapterClient.java | 19 + 5 files changed, 428 insertions(+), 296 deletions(-) create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterDeleteTasks.java (limited to 'bpmn') diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java index 2f6713dcd1..4cd1d7dcb0 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java @@ -1478,6 +1478,11 @@ public class BBInputSetup implements JavaDelegate { lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, volumeGroupIdOp.get()); } } + if (vfModule.getModelInfoVfModule() != null + && vfModule.getModelInfoVfModule().getModelName() != null + && vfModule.getModelInfoVfModule().getModelName().contains("helm")) { + gBB.getRequestContext().setIsHelm(true); + } break; } } diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn index fba1139117..36d1708a45 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn @@ -1,18 +1,17 @@ - + - Flow_02lmh6f + Flow_069drgn - Flow_02lmh6f - SequenceFlow_08tvhtf + Flow_1c15ua4 + Flow_0yz0t7z SequenceFlow_01vfwtp SequenceFlow_09l7pcg - SequenceFlow_09l7pcg @@ -28,7 +27,7 @@ - SequenceFlow_08tvhtf + Flow_0yz0t7z Flow_0hlvlw2 @@ -59,6 +58,7 @@ Flow_0plbl7p + Flow_1ktykz6 @@ -77,7 +77,6 @@ - Flow_0yqo5xu @@ -93,155 +92,197 @@ + + Flow_10r76pp + Flow_1ktykz6 + + + + Flow_069drgn + Flow_10r76pp + Flow_1c15ua4 + + + ${execution.getVariable("isHelm")} + + + + - - + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - + + + + - + - - + + + - + - - - - - - - - - - + + + + - + - - + + - - - + + + - + - - - - - - - - - + + + + + + + + + - + - - - - - - + + + + + + + + + + + - + - - - + + - + - + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + - + - + - + - - - - - - - - diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ExecuteBuildingBlock.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ExecuteBuildingBlock.bpmn index 443a571312..fd650b9d50 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ExecuteBuildingBlock.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ExecuteBuildingBlock.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_0rq4c5r @@ -12,6 +12,7 @@ + SequenceFlow_19wuics SequenceFlow_01h9qmz @@ -55,7 +56,7 @@ SequenceFlow_0ndt8ft SequenceFlow_07a1ytc - + ${execution.getVariable("RetryDuration")} @@ -70,12 +71,12 @@ - + ${execution.getVariable("handlingCode")=="Retry"} - + ${execution.getVariable("retryCount")<execution.getVariable("maxRetries")} SequenceFlow_0h8v45y @@ -106,10 +107,10 @@ - + ${execution.getVariable("handlingCode")=="Manual"} - + ${execution.getVariable("handlingCode")=="Skip"} SequenceFlow_0xyd2zl @@ -132,12 +133,12 @@ - + ${execution.getVariable("handlingCode")=="Timeout"} - + ${execution.getVariable("orchestrationStatusValidationResult").name() == "SILENT_SUCCESS"} SequenceFlow_1j0vskt @@ -164,285 +165,285 @@ - - + + + - + - - - - - - - + + + + - + - - - + + + + + - + - - - - - + + + - + - + + + + + + + + + + + + + + + - - + + - - + + + - + - - - + + + + - + - - - + + + - + - - - + + + + + + + + - + - - - - + + + + + + - + - - - - + + + + + + + - + - - - - - - + + + - + - - - + + + - + - - - - - - + + + + + - + - - - - - + + + + + - + - - - - + + + + - + - - - + + + - + - - - - - + + + - + - - - + + + + - + - - - - + + + + - + - - - - - + + + - + - - - - - - + + + - + - - - + + + - + - - - - - - - - - + + + - + - - - + + + - + - - + + + + + - + - - - - - - + + - + - - - + + + - + - - - + + + + + - + - - - - - - - - + + - + - - - - - - + + + - + - - - - + + + + + + - + - + + + + - + - + - + - + - - - - - - - - - - - - - - + + + + + + + + + diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterDeleteTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterDeleteTasks.java new file mode 100644 index 0000000000..87466bbbd4 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterDeleteTasks.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.adapter.cnf.tasks; + +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.adapter.cnf.CnfAdapterClient; +import org.onap.so.client.exception.ExceptionBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class CnfAdapterDeleteTasks { + private static final Logger logger = LoggerFactory.getLogger(CnfAdapterDeleteTasks.class); + + @Autowired + private ExtractPojosForBB extractPojosForBB; + @Autowired + private ExceptionBuilder exceptionUtil; + @Autowired + private CnfAdapterClient cnfAdapterClient; + + /** + * This method is used for deleting the instance with Multicloud K8s Plugin. + * + * @param execution + * @return + */ + public void deleteInstance(BuildingBlockExecution execution) { + try { + logger.debug("Running delete instance - Helm"); + VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID); + String heatStackId = vfModule.getHeatStackId(); + execution.setVariable("heatStackId", heatStackId); + cnfAdapterClient.deleteVfModule(heatStackId); + } catch (Exception ex) { + logger.error("Exception occurred", ex); + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClient.java index 65f8a084eb..da36a6f040 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClient.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClient.java @@ -76,6 +76,25 @@ public class CnfAdapterClient { } } + + @Retryable(value = {HttpServerErrorException.class}, maxAttempts = 3, backoff = @Backoff(delay = 3000)) + public void deleteVfModule(String heatStackId) throws CnfAdapterClientException { + try { + // String uri = env.getRequiredProperty("mso.cnf.adapter.endpoint"); //TODO: This needs to be added as well + // for configuration + String uri = "http://so-cnf-adapter:8090"; + String endpoint = UriBuilder.fromUri(uri).path(INSTANCE_CREATE_PATH + "/" + heatStackId).build().toString(); + HttpEntity entity = new HttpEntity<>(getHttpHeaders()); + restTemplate.exchange(endpoint, HttpMethod.DELETE, entity, String.class); + } catch (HttpClientErrorException e) { + logger.error("Error Calling CNF Adapter, e"); + if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) { + throw new EntityNotFoundException(e.getResponseBodyAsString()); + } + throw e; + } + } + @Retryable(value = {HttpServerErrorException.class}, maxAttempts = 3, backoff = @Backoff(delay = 3000)) public InstanceResponse healthcheck() throws CnfAdapterClientException { try { -- cgit 1.2.3-korg