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.bbobjects.VolumeGroup;
31 import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
32 import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
33 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
34 import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
35 import org.onap.so.client.exception.BBObjectNotFoundException;
36 import org.onap.so.client.exception.ExceptionBuilder;
37 import org.onap.so.client.orchestration.SDNCNetworkResources;
38 import org.onap.so.client.orchestration.SDNCServiceInstanceResources;
39 import org.onap.so.client.orchestration.SDNCVfModuleResources;
40 import org.onap.so.client.orchestration.SDNCVnfResources;
41 import org.onap.so.logger.MsoLogger;
42 import org.springframework.beans.factory.annotation.Autowired;
43 import org.springframework.stereotype.Component;
46 public class SDNCAssignTasks {
47 private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, SDNCAssignTasks.class);
49 private SDNCServiceInstanceResources sdncSIResources;
51 private SDNCVnfResources sdncVnfResources;
53 private SDNCVfModuleResources sdncVfModuleResources;
55 private ExceptionBuilder exceptionUtil;
57 private ExtractPojosForBB extractPojosForBB;
59 private SDNCNetworkResources sdncNetworkResources;
61 public void assignServiceInstance(BuildingBlockExecution execution) {
63 GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
64 RequestContext requestContext = gBBInput.getRequestContext();
65 ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
66 Customer customer = gBBInput.getCustomer();
67 String response = sdncSIResources.assignServiceInstance(serviceInstance, customer, requestContext);
68 execution.setVariable("SDNCResponse", response);
69 } catch (Exception ex) {
70 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
74 public void assignVnf(BuildingBlockExecution execution) {
76 GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
77 RequestContext requestContext = gBBInput.getRequestContext();
78 ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
79 GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID));
80 Customer customer = gBBInput.getCustomer();
81 CloudRegion cloudRegion = gBBInput.getCloudRegion();
82 String response = sdncVnfResources.assignVnf(vnf, serviceInstance, customer, cloudRegion, requestContext, vnf.isCallHoming());
83 execution.setVariable("SDNCResponse", response);
84 } catch (Exception ex) {
85 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
89 public void assignVfModule(BuildingBlockExecution execution) {
91 GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
92 RequestContext requestContext = gBBInput.getRequestContext();
93 ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
94 GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID));
95 VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID, execution.getLookupMap().get(ResourceKey.VF_MODULE_ID));
96 VolumeGroup volumeGroup = null;
98 volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID, execution.getLookupMap().get(ResourceKey.VOLUME_GROUP_ID));
99 } catch (BBObjectNotFoundException e){
100 msoLogger.info("No volume group was found.");
102 Customer customer = gBBInput.getCustomer();
103 CloudRegion cloudRegion = gBBInput.getCloudRegion();
105 String response = sdncVfModuleResources.assignVfModule(vfModule, volumeGroup, vnf, serviceInstance, customer, cloudRegion, requestContext);
106 execution.setVariable("SDNCAssignResponse_"+ vfModule.getVfModuleId(), response);
107 } catch (Exception ex) {
108 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
113 * BPMN access method to perform Assign action on SDNC for L3Network
117 public void assignNetwork(BuildingBlockExecution execution) {
119 GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
121 L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, execution.getLookupMap().get(ResourceKey.NETWORK_ID));
122 ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
124 Customer customer = gBBInput.getCustomer();
125 RequestContext requestContext = gBBInput.getRequestContext();
126 CloudRegion cloudRegion = gBBInput.getCloudRegion();
128 sdncNetworkResources.assignNetwork(l3network, serviceInstance, customer, requestContext, cloudRegion);
129 } catch (Exception ex) {
130 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);