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.namingservice.tasks;
23 import java.util.List;
24 import java.util.Optional;
25 import org.onap.aai.domain.yang.Zone;
26 import org.onap.so.bpmn.common.BuildingBlockExecution;
27 import org.onap.so.bpmn.common.InjectionHelper;
28 import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
29 import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup;
30 import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
31 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
32 import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding;
33 import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
34 import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
35 import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils;
36 import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
37 import org.onap.so.client.aai.AAIObjectType;
38 import org.onap.so.client.aai.entities.AAIResultWrapper;
39 import org.onap.so.client.aai.entities.Relationships;
40 import org.onap.so.client.aai.entities.uri.AAIResourceUri;
41 import org.onap.so.client.aai.entities.uri.AAIUriFactory;
42 import org.onap.so.client.exception.ExceptionBuilder;
43 import org.onap.so.client.namingservice.NamingRequestObject;
44 import org.onap.so.client.namingservice.NamingServiceConstants;
45 import org.onap.so.client.orchestration.NamingServiceResources;
46 import org.springframework.beans.factory.annotation.Autowired;
47 import org.springframework.stereotype.Component;
50 public class NamingServiceCreateTasks {
53 private ExceptionBuilder exceptionUtil;
55 private ExtractPojosForBB extractPojosForBB;
58 private NamingServiceResources namingServiceResources;
60 protected InjectionHelper injectionHelper;
62 protected BBInputSetupUtils bbInputSetupUtils;
64 public void setBbInputSetupUtils(BBInputSetupUtils bbInputSetupUtils) {
65 this.bbInputSetupUtils = bbInputSetupUtils;
68 public void createInstanceGroupName(BuildingBlockExecution execution) throws Exception {
69 InstanceGroup instanceGroup = extractPojosForBB.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID);
70 String policyInstanceName = execution.getVariable("policyInstanceName");
71 String nfNamingCode = execution.getVariable("nfNamingCode");
72 String generatedInstanceGroupName = "";
74 generatedInstanceGroupName =
75 namingServiceResources.generateInstanceGroupName(instanceGroup, policyInstanceName, nfNamingCode);
76 } catch (Exception ex) {
77 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
79 instanceGroup.setInstanceGroupName(generatedInstanceGroupName);
82 public void createWanTransportServiceName(BuildingBlockExecution execution) throws Exception {
83 ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
84 NamingRequestObject namingRequestObject = new NamingRequestObject();
85 namingRequestObject.setExternalKeyValue(serviceInstance.getServiceInstanceId());
86 namingRequestObject.setNamingTypeValue(NamingServiceConstants.NAMING_TYPE_SERVICE);
87 namingRequestObject.setResourceNameValue(NamingServiceConstants.RESOURCE_NAME_SERVICE_INSTANCE_NAME);
88 namingRequestObject.setPolicyInstanceNameValue(serviceInstance.getModelInfoServiceInstance().getNamingPolicy());
89 namingRequestObject.setServiceModelNameValue(serviceInstance.getModelInfoServiceInstance().getModelName());
90 namingRequestObject.setModelVersionValue(serviceInstance.getModelInfoServiceInstance().getModelVersion());
92 String generatedWanTransportServiceName = "";
94 generatedWanTransportServiceName = namingServiceResources.generateServiceInstanceName(namingRequestObject);
95 } catch (Exception ex) {
96 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
98 serviceInstance.setServiceInstanceName(generatedWanTransportServiceName);
101 public void createVpnBondingServiceName(BuildingBlockExecution execution) throws Exception {
102 ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
103 L3Network network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
104 VpnBinding vpnBinding = extractPojosForBB.extractByKey(execution, ResourceKey.VPN_ID);
105 NamingRequestObject namingRequestObject = new NamingRequestObject();
106 namingRequestObject.setExternalKeyValue(serviceInstance.getServiceInstanceId());
107 namingRequestObject.setPolicyInstanceNameValue(serviceInstance.getModelInfoServiceInstance().getNamingPolicy());
108 namingRequestObject.setNamingTypeValue(NamingServiceConstants.NAMING_TYPE_SERVICE);
109 namingRequestObject.setServiceModelNameValue(serviceInstance.getModelInfoServiceInstance().getModelName());
110 namingRequestObject.setModelVersionValue(serviceInstance.getModelInfoServiceInstance().getModelVersion());
111 namingRequestObject.setNetworkNameValue(network.getNetworkName());
112 namingRequestObject.setVpnNameValue(vpnBinding.getVpnName());
113 namingRequestObject.setResourceNameValue(NamingServiceConstants.RESOURCE_NAME_SERVICE_INSTANCE_NAME);
115 String generatedVpnBondingServiceName = "";
117 generatedVpnBondingServiceName = namingServiceResources.generateServiceInstanceName(namingRequestObject);
118 } catch (Exception ex) {
119 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
121 serviceInstance.setServiceInstanceName(generatedVpnBondingServiceName);