2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.bpmn.infrastructure.aai.tasks;
24 import org.onap.so.bpmn.common.BuildingBlockExecution;
25 import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
26 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
27 import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
28 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
29 import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
30 import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
31 import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
32 import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
33 import org.onap.so.client.exception.ExceptionBuilder;
34 import org.onap.so.client.orchestration.AAINetworkResources;
35 import org.onap.so.client.orchestration.AAIServiceInstanceResources;
36 import org.onap.so.client.orchestration.AAIVfModuleResources;
37 import org.onap.so.client.orchestration.AAIVnfResources;
38 import org.onap.so.client.orchestration.AAIVolumeGroupResources;
39 import org.springframework.beans.factory.annotation.Autowired;
40 import org.springframework.stereotype.Component;
43 public class AAIDeleteTasks {
46 private ExceptionBuilder exceptionUtil;
48 private ExtractPojosForBB extractPojosForBB;
50 private AAIServiceInstanceResources aaiSIResources;
52 private AAIVnfResources aaiVnfResources;
54 private AAIVfModuleResources aaiVfModuleResources;
56 private AAINetworkResources aaiNetworkResources;
58 private AAIVolumeGroupResources aaiVolumeGroupResources;
60 public void deleteVfModule(BuildingBlockExecution execution) throws Exception {
61 GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID));
62 VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID, execution.getLookupMap().get(ResourceKey.VF_MODULE_ID));
64 execution.setVariable("aaiVfModuleRollback", false);
66 aaiVfModuleResources.deleteVfModule(vfModule, genericVnf);
67 execution.setVariable("aaiVfModuleRollback", true);
68 } catch (Exception ex) {
69 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
73 public void deleteVnf(BuildingBlockExecution execution) throws Exception {
74 GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID));
76 execution.setVariable("aaiVnfRollback", false);
78 aaiVnfResources.deleteVnf(genericVnf);
79 execution.setVariable("aaiVnfRollback", true);
80 } catch (Exception ex) {
81 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
85 public void deleteServiceInstance(BuildingBlockExecution execution) throws Exception {
87 ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
88 aaiSIResources.deleteServiceInstance(serviceInstance);
91 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
96 public void deleteNetwork(BuildingBlockExecution execution) throws Exception {
98 L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, execution.getLookupMap().get(ResourceKey.NETWORK_ID));
99 aaiNetworkResources.deleteNetwork(l3network);
100 execution.setVariable("isRollbackNeeded", true);
102 catch(Exception ex) {
103 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
107 public void deleteCollection(BuildingBlockExecution execution) throws Exception {
109 ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
110 aaiNetworkResources.deleteCollection(serviceInstance.getCollection());
112 catch(Exception ex) {
113 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
117 public void deleteInstanceGroup(BuildingBlockExecution execution) throws Exception {
119 ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
120 aaiNetworkResources.deleteNetworkInstanceGroup(serviceInstance.getCollection().getInstanceGroup());
122 catch(Exception ex) {
123 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
127 public void deleteVolumeGroup(BuildingBlockExecution execution) {
129 VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID, execution.getLookupMap().get(ResourceKey.VOLUME_GROUP_ID));
130 CloudRegion cloudRegion = execution.getGeneralBuildingBlock().getCloudRegion();
131 aaiVolumeGroupResources.deleteVolumeGroup(volumeGroup, cloudRegion);
132 } catch (Exception ex) {
133 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);