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.sdnc.tasks;
25 import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation;
26 import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation;
27 import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation;
28 import org.onap.so.bpmn.common.BuildingBlockExecution;
29 import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
30 import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
31 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
32 import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
33 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
34 import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
35 import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
36 import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
37 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
38 import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
39 import org.onap.so.client.exception.BBObjectNotFoundException;
40 import org.onap.so.client.exception.ExceptionBuilder;
41 import org.onap.so.client.orchestration.SDNCNetworkResources;
42 import org.onap.so.client.orchestration.SDNCVfModuleResources;
43 import org.onap.so.client.orchestration.SDNCVnfResources;
44 import org.onap.so.client.sdnc.beans.SDNCRequest;
45 import org.onap.so.client.sdnc.endpoint.SDNCTopology;
46 import org.slf4j.Logger;
47 import org.slf4j.LoggerFactory;
48 import org.springframework.beans.factory.annotation.Autowired;
49 import org.springframework.stereotype.Component;
52 public class SDNCActivateTasks {
53 private static final Logger logger = LoggerFactory.getLogger(SDNCActivateTasks.class);
55 private SDNCVnfResources sdncVnfResources;
57 private ExceptionBuilder exceptionUtil;
59 private ExtractPojosForBB extractPojosForBB;
61 private SDNCNetworkResources sdncNetworkResources;
63 private SDNCVfModuleResources sdncVfModuleResources;
66 public void activateVnf(BuildingBlockExecution execution) {
68 GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
69 RequestContext requestContext = gBBInput.getRequestContext();
70 ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
71 GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
72 CloudRegion cloudRegion = gBBInput.getCloudRegion();
73 Customer customer = gBBInput.getCustomer();
74 GenericResourceApiVnfOperationInformation req = sdncVnfResources.activateVnf(vnf, serviceInstance, customer, cloudRegion, requestContext);
75 SDNCRequest sdncRequest = new SDNCRequest();
76 sdncRequest.setSDNCPayload(req);
77 sdncRequest.setTopology(SDNCTopology.VNF);
78 execution.setVariable("SDNCRequest", sdncRequest);
79 } catch (Exception ex) {
80 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
85 * BPMN access method to perform Assign action on SDNC for L3Network
87 * @throws BBObjectNotFoundException
89 public void activateNetwork(BuildingBlockExecution execution) throws BBObjectNotFoundException {
91 GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
92 L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
93 ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
94 Customer customer = gBBInput.getCustomer();
95 RequestContext requestContext = gBBInput.getRequestContext();
96 CloudRegion cloudRegion = gBBInput.getCloudRegion();
97 GenericResourceApiNetworkOperationInformation req = sdncNetworkResources.activateNetwork(l3network, serviceInstance, customer, requestContext, cloudRegion);
98 SDNCRequest sdncRequest = new SDNCRequest();
99 sdncRequest.setSDNCPayload(req);
100 sdncRequest.setTopology(SDNCTopology.NETWORK);
101 execution.setVariable("SDNCRequest", sdncRequest);
102 } catch (Exception ex) {
103 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
107 public void activateVfModule(BuildingBlockExecution execution) {
108 GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
109 RequestContext requestContext = gBBInput.getRequestContext();
110 ServiceInstance serviceInstance = null;
111 GenericVnf vnf = null;
112 VfModule vfModule = null;
114 serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
115 vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
116 vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
117 Customer customer = gBBInput.getCustomer();
118 CloudRegion cloudRegion = gBBInput.getCloudRegion();
119 GenericResourceApiVfModuleOperationInformation req = sdncVfModuleResources.activateVfModule(vfModule, vnf, serviceInstance, customer,
120 cloudRegion, requestContext);
121 SDNCRequest sdncRequest = new SDNCRequest();
122 sdncRequest.setSDNCPayload(req);
123 sdncRequest.setTopology(SDNCTopology.VFMODULE);
124 execution.setVariable("SDNCRequest", sdncRequest);
125 } catch (Exception ex) {
126 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);