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.sdnc.tasks;
23 import org.onap.so.bpmn.common.BuildingBlockExecution;
24 import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
25 import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
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.entities.GeneralBuildingBlock;
31 import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
32 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
33 import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
34 import org.onap.so.client.exception.ExceptionBuilder;
35 import org.onap.so.client.orchestration.SDNCNetworkResources;
36 import org.onap.so.client.orchestration.SDNCServiceInstanceResources;
37 import org.onap.so.client.orchestration.SDNCVfModuleResources;
38 import org.onap.so.client.orchestration.SDNCVnfResources;
39 import org.springframework.beans.factory.annotation.Autowired;
40 import org.springframework.stereotype.Component;
43 public class SDNCChangeAssignTasks {
45 private SDNCNetworkResources sdncNetworkResources;
47 private SDNCServiceInstanceResources sdncServiceInstanceResources;
49 private SDNCVnfResources sdncVnfResources;
51 private ExtractPojosForBB extractPojosForBB;
53 private ExceptionBuilder exceptionUtil;
55 private SDNCVfModuleResources sdncVfModuleResources;
57 public void changeModelServiceInstance(BuildingBlockExecution execution) {
59 GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
60 ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
62 String response = sdncServiceInstanceResources.changeModelServiceInstance(serviceInstance, gBBInput.getCustomer(), gBBInput.getRequestContext());
63 execution.setVariable("SDNCChangeAssignTasks.changeModelServiceInstance.response", response);
64 } catch(Exception ex) {
65 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
69 public void changeModelVnf(BuildingBlockExecution execution) {
71 GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
72 GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID));
73 ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
75 String response = sdncVnfResources.changeModelVnf(genericVnf, serviceInstance, gBBInput.getCustomer(), gBBInput.getCloudRegion(), gBBInput.getRequestContext());
76 execution.setVariable("SDNCChangeModelVnfResponse", response);
77 } catch(Exception ex) {
78 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
82 public void changeAssignNetwork(BuildingBlockExecution execution) {
84 GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
85 L3Network network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, execution.getLookupMap().get(ResourceKey.NETWORK_ID));
86 ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
88 String sdncResponse = sdncNetworkResources.changeAssignNetwork(network, serviceInstance, gBBInput.getCustomer(), gBBInput.getRequestContext(), gBBInput.getCloudRegion());
89 execution.setVariable("SDNCChangeAssignNetworkResponse", sdncResponse);
90 } catch(Exception ex) {
91 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
95 public void changeAssignModelVfModule(BuildingBlockExecution execution) throws Exception {
97 GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
98 RequestContext requestContext = gBBInput.getRequestContext();
99 CloudRegion cloudRegion = gBBInput.getCloudRegion();
100 ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
101 GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID));
102 VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID, execution.getLookupMap().get(ResourceKey.VF_MODULE_ID));
103 Customer customer = gBBInput.getCustomer();
104 String response = sdncVfModuleResources.changeAssignVfModule(vfModule, vnf, serviceInstance, customer, cloudRegion, requestContext);
105 execution.setVariable("SDNCChangeAssignVfModuleResponse", response);
106 } catch (Exception ex) {
107 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);