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.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation;
24 import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation;
25 import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation;
26 import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation;
27 import org.onap.so.bpmn.common.BuildingBlockExecution;
28 import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
29 import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
30 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
31 import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
32 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
33 import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
34 import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
35 import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
36 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
37 import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
38 import org.onap.so.client.exception.ExceptionBuilder;
39 import org.onap.so.client.orchestration.SDNCNetworkResources;
40 import org.onap.so.client.orchestration.SDNCServiceInstanceResources;
41 import org.onap.so.client.orchestration.SDNCVfModuleResources;
42 import org.onap.so.client.orchestration.SDNCVnfResources;
43 import org.onap.so.client.sdnc.beans.SDNCRequest;
44 import org.onap.so.client.sdnc.endpoint.SDNCTopology;
45 import org.springframework.beans.factory.annotation.Autowired;
46 import org.springframework.stereotype.Component;
49 public class SDNCChangeAssignTasks {
51 private SDNCNetworkResources sdncNetworkResources;
53 private SDNCServiceInstanceResources sdncServiceInstanceResources;
55 private SDNCVnfResources sdncVnfResources;
57 private ExtractPojosForBB extractPojosForBB;
59 private ExceptionBuilder exceptionUtil;
61 private SDNCVfModuleResources sdncVfModuleResources;
63 public void changeModelServiceInstance(BuildingBlockExecution execution) {
65 GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
66 ServiceInstance serviceInstance =
67 extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
68 GenericResourceApiServiceOperationInformation req = sdncServiceInstanceResources
69 .changeModelServiceInstance(serviceInstance, gBBInput.getCustomer(), gBBInput.getRequestContext());
70 SDNCRequest sdncRequest = new SDNCRequest();
71 sdncRequest.setSDNCPayload(req);
72 sdncRequest.setTopology(SDNCTopology.SERVICE);
73 execution.setVariable("SDNCRequest", sdncRequest);
74 } catch (Exception ex) {
75 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
79 public void changeModelVnf(BuildingBlockExecution execution) {
81 GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
82 GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
83 ServiceInstance serviceInstance =
84 extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
85 GenericResourceApiVnfOperationInformation req = sdncVnfResources.changeModelVnf(genericVnf, serviceInstance,
86 gBBInput.getCustomer(), gBBInput.getCloudRegion(), gBBInput.getRequestContext());
87 SDNCRequest sdncRequest = new SDNCRequest();
88 sdncRequest.setSDNCPayload(req);
89 sdncRequest.setTopology(SDNCTopology.VNF);
90 execution.setVariable("SDNCRequest", sdncRequest);
91 } catch (Exception ex) {
92 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
96 public void changeAssignNetwork(BuildingBlockExecution execution) {
98 GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
99 L3Network network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
100 ServiceInstance serviceInstance =
101 extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
102 GenericResourceApiNetworkOperationInformation req = sdncNetworkResources.changeAssignNetwork(network,
103 serviceInstance, gBBInput.getCustomer(), gBBInput.getRequestContext(), gBBInput.getCloudRegion());
104 SDNCRequest sdncRequest = new SDNCRequest();
105 sdncRequest.setSDNCPayload(req);
106 sdncRequest.setTopology(SDNCTopology.NETWORK);
107 execution.setVariable("SDNCRequest", sdncRequest);
108 } catch (Exception ex) {
109 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
113 public void changeAssignModelVfModule(BuildingBlockExecution execution) throws Exception {
115 GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
116 RequestContext requestContext = gBBInput.getRequestContext();
117 CloudRegion cloudRegion = gBBInput.getCloudRegion();
118 ServiceInstance serviceInstance =
119 extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
120 GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
121 VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
122 Customer customer = gBBInput.getCustomer();
123 GenericResourceApiVfModuleOperationInformation req = sdncVfModuleResources.changeAssignVfModule(vfModule,
124 vnf, serviceInstance, customer, cloudRegion, requestContext);
125 SDNCRequest sdncRequest = new SDNCRequest();
126 sdncRequest.setSDNCPayload(req);
127 sdncRequest.setTopology(SDNCTopology.VFMODULE);
128 execution.setVariable("SDNCRequest", sdncRequest);
129 } catch (Exception ex) {
130 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);