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.Configuration;
27 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
28 import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
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.ResourceKey;
33 import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
34 import org.onap.so.client.exception.ExceptionBuilder;
35 import org.onap.so.client.orchestration.AAIConfigurationResources;
36 import org.onap.so.client.orchestration.AAINetworkResources;
37 import org.onap.so.client.orchestration.AAIServiceInstanceResources;
38 import org.onap.so.client.orchestration.AAIVfModuleResources;
39 import org.onap.so.client.orchestration.AAIVnfResources;
40 import org.onap.so.client.orchestration.AAIVolumeGroupResources;
41 import org.springframework.beans.factory.annotation.Autowired;
42 import org.springframework.stereotype.Component;
45 public class AAIDeleteTasks {
48 private ExceptionBuilder exceptionUtil;
50 private ExtractPojosForBB extractPojosForBB;
52 private AAIServiceInstanceResources aaiSIResources;
54 private AAIVnfResources aaiVnfResources;
56 private AAIVfModuleResources aaiVfModuleResources;
58 private AAINetworkResources aaiNetworkResources;
60 private AAIVolumeGroupResources aaiVolumeGroupResources;
62 private AAIConfigurationResources aaiConfigurationResources;
64 public void deleteVfModule(BuildingBlockExecution execution) throws Exception {
65 GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID));
66 VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID, execution.getLookupMap().get(ResourceKey.VF_MODULE_ID));
68 execution.setVariable("aaiVfModuleRollback", false);
70 aaiVfModuleResources.deleteVfModule(vfModule, genericVnf);
71 execution.setVariable("aaiVfModuleRollback", true);
72 } catch (Exception ex) {
73 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
77 public void deleteVnf(BuildingBlockExecution execution) throws Exception {
78 GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID));
80 execution.setVariable("aaiVnfRollback", false);
82 aaiVnfResources.deleteVnf(genericVnf);
83 execution.setVariable("aaiVnfRollback", true);
84 } catch (Exception ex) {
85 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
89 public void deleteServiceInstance(BuildingBlockExecution execution) throws Exception {
91 ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
92 aaiSIResources.deleteServiceInstance(serviceInstance);
95 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
100 public void deleteNetwork(BuildingBlockExecution execution) throws Exception {
102 L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, execution.getLookupMap().get(ResourceKey.NETWORK_ID));
103 aaiNetworkResources.deleteNetwork(l3network);
104 execution.setVariable("isRollbackNeeded", true);
106 catch(Exception ex) {
107 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
111 public void deleteCollection(BuildingBlockExecution execution) throws Exception {
113 ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
114 aaiNetworkResources.deleteCollection(serviceInstance.getCollection());
116 catch(Exception ex) {
117 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
121 public void deleteInstanceGroup(BuildingBlockExecution execution) throws Exception {
123 ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
124 aaiNetworkResources.deleteNetworkInstanceGroup(serviceInstance.getCollection().getInstanceGroup());
126 catch(Exception ex) {
127 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
131 public void deleteVolumeGroup(BuildingBlockExecution execution) {
133 VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID, execution.getLookupMap().get(ResourceKey.VOLUME_GROUP_ID));
134 CloudRegion cloudRegion = execution.getGeneralBuildingBlock().getCloudRegion();
135 aaiVolumeGroupResources.deleteVolumeGroup(volumeGroup, cloudRegion);
136 } catch (Exception ex) {
137 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
140 public void deleteConfiguration(BuildingBlockExecution execution) {
142 Configuration configuration = extractPojosForBB.extractByKey(execution, ResourceKey.CONFIGURATION_ID, execution.getLookupMap().get(ResourceKey.CONFIGURATION_ID));
143 aaiConfigurationResources.deleteConfiguration(configuration);
144 } catch (Exception ex) {
145 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);