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.slf4j.Logger;
39 import org.slf4j.LoggerFactory;
40 import org.springframework.beans.factory.annotation.Autowired;
41 import org.springframework.stereotype.Component;
44 public class VnfAdapterDeleteTasks {
45 private static final Logger logger = LoggerFactory.getLogger(VnfAdapterDeleteTasks.class);
46 private static final String VNFREST_REQUEST = "VNFREST_Request";
49 private ExtractPojosForBB extractPojosForBB;
51 private VnfAdapterVolumeGroupResources vnfAdapterVolumeGroupResources;
53 private VnfAdapterVfModuleResources vnfAdapterVfModuleResources;
55 private ExceptionBuilder exceptionUtil;
57 public void deleteVolumeGroup(BuildingBlockExecution execution) {
59 GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
61 ServiceInstance serviceInstance =
62 extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
63 VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
65 DeleteVolumeGroupRequest deleteVolumeGroupRequest = vnfAdapterVolumeGroupResources.deleteVolumeGroupRequest(
66 gBBInput.getRequestContext(), gBBInput.getCloudRegion(), serviceInstance, volumeGroup);
67 execution.setVariable(VNFREST_REQUEST, deleteVolumeGroupRequest.toXmlString());
68 execution.setVariable("deleteVolumeGroupRequest", "true");
69 } catch (Exception ex) {
70 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
74 public void deleteVfModule(BuildingBlockExecution execution) {
76 GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
78 ServiceInstance serviceInstance =
79 extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
80 VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
81 GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
83 DeleteVfModuleRequest deleteVfModuleRequest = vnfAdapterVfModuleResources.deleteVfModuleRequest(
84 gBBInput.getRequestContext(), gBBInput.getCloudRegion(), serviceInstance, genericVnf, vfModule);
85 execution.setVariable(VNFREST_REQUEST, deleteVfModuleRequest.toXmlString());
86 execution.setVariable("deleteVfModuleRequest", "true");
87 } catch (Exception ex) {
88 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);