2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Modifications Copyright (c) 2019 Samsung
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
23 package org.onap.so.bpmn.infrastructure.adapter.vnf.tasks;
25 import org.onap.so.adapters.vnfrest.DeleteVfModuleRequest;
26 import org.onap.so.adapters.vnfrest.DeleteVolumeGroupRequest;
27 import org.onap.so.bpmn.common.BuildingBlockExecution;
28 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
29 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
30 import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
31 import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
32 import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
33 import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
34 import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
35 import org.onap.so.client.exception.ExceptionBuilder;
36 import org.onap.so.client.orchestration.VnfAdapterVfModuleResources;
37 import org.onap.so.client.orchestration.VnfAdapterVolumeGroupResources;
38 import org.springframework.beans.factory.annotation.Autowired;
39 import org.springframework.stereotype.Component;
42 public class VnfAdapterDeleteTasks {
44 private static final String VNFREST_REQUEST = "VNFREST_Request";
47 private ExtractPojosForBB extractPojosForBB;
49 private VnfAdapterVolumeGroupResources vnfAdapterVolumeGroupResources;
51 private VnfAdapterVfModuleResources vnfAdapterVfModuleResources;
53 private ExceptionBuilder exceptionUtil;
55 public void deleteVolumeGroup(BuildingBlockExecution execution) {
57 GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
59 ServiceInstance serviceInstance =
60 extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
61 VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
63 DeleteVolumeGroupRequest deleteVolumeGroupRequest = vnfAdapterVolumeGroupResources.deleteVolumeGroupRequest(
64 gBBInput.getRequestContext(), gBBInput.getCloudRegion(), serviceInstance, volumeGroup);
65 execution.setVariable(VNFREST_REQUEST, deleteVolumeGroupRequest.toXmlString());
66 execution.setVariable("deleteVolumeGroupRequest", "true");
67 } catch (Exception ex) {
68 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
72 public void deleteVfModule(BuildingBlockExecution execution) {
74 GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
76 ServiceInstance serviceInstance =
77 extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
78 VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
79 GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
81 DeleteVfModuleRequest deleteVfModuleRequest = vnfAdapterVfModuleResources.deleteVfModuleRequest(
82 gBBInput.getRequestContext(), gBBInput.getCloudRegion(), serviceInstance, genericVnf, vfModule);
83 execution.setVariable(VNFREST_REQUEST, deleteVfModuleRequest.toXmlString());
84 execution.setVariable("deleteVfModuleRequest", "true");
85 } catch (Exception ex) {
86 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);