2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 Telecom Italia
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.scripts
23 import com.fasterxml.jackson.databind.ObjectMapper
24 import org.camunda.bpm.engine.delegate.BpmnError
25 import org.camunda.bpm.engine.delegate.DelegateExecution
26 import org.onap.aai.domain.yang.CloudRegion
27 import org.onap.aai.domain.yang.Customer
28 import org.onap.aai.domain.yang.GenericVnf
29 import org.onap.aai.domain.yang.ModelVer
30 import org.onap.aai.domain.yang.ServiceInstance
31 import org.onap.aai.domain.yang.ServiceSubscription
32 import org.onap.aai.domain.yang.SliceProfile
33 import org.onap.aai.domain.yang.Tenant
34 import org.onap.aai.domain.yang.VfModule
35 import org.onap.aaiclient.client.aai.AAIObjectType
36 import org.onap.aaiclient.client.aai.AAIResourcesClient
37 import org.onap.aaiclient.client.aai.entities.AAIEdgeLabel
38 import org.onap.aaiclient.client.aai.entities.AAIResultWrapper
39 import org.onap.aaiclient.client.aai.entities.Relationships
40 import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
41 import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
42 import org.onap.logging.filter.base.ONAPComponents
43 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
44 import org.onap.so.bpmn.common.scripts.ExceptionUtil
45 import org.onap.so.bpmn.common.scripts.MsoUtils
46 import org.onap.so.bpmn.common.scripts.RequestDBUtil
47 import org.onap.so.bpmn.core.UrnPropertiesReader
48 import org.onap.so.bpmn.core.json.JsonUtils
49 import org.onap.so.client.HttpClient
50 import org.onap.so.db.request.beans.OperationStatus
51 import org.onap.so.requestsdb.RequestsDbConstant
52 import org.onap.so.serviceinstancebeans.CloudConfiguration
53 import org.onap.so.serviceinstancebeans.ModelInfo
54 import org.onap.so.serviceinstancebeans.ModelType
55 import org.onap.so.serviceinstancebeans.OwningEntity
56 import org.onap.so.serviceinstancebeans.Project
57 import org.onap.so.serviceinstancebeans.RequestDetails
58 import org.onap.so.serviceinstancebeans.RequestInfo
59 import org.onap.so.serviceinstancebeans.RequestParameters
60 import org.onap.so.serviceinstancebeans.Resources
61 import org.onap.so.serviceinstancebeans.Service
62 import org.onap.so.serviceinstancebeans.SubscriberInfo
63 import org.onap.so.serviceinstancebeans.VfModules
64 import org.onap.so.serviceinstancebeans.Vnfs
65 import org.slf4j.Logger
66 import org.slf4j.LoggerFactory
68 import javax.ws.rs.core.Response
70 class DoModifyCoreNSSI extends DoCommonCoreNSSI {
72 private final String PREFIX ="DoModifyCoreNSSI"
74 private ExceptionUtil exceptionUtil = new ExceptionUtil()
75 private RequestDBUtil requestDBUtil = new RequestDBUtil()
76 private MsoUtils utils = new MsoUtils()
77 private JsonUtils jsonUtil = new JsonUtils()
79 private static final Logger LOGGER = LoggerFactory.getLogger( DoModifyCoreNSSI.class)
83 * Creates Slice Profile Instance
86 void createSliceProfileInstance(DelegateExecution execution) {
87 LOGGER.trace("${PREFIX} Start createSliceProfileInstance")
89 def currentNSSI = execution.getVariable("currentNSSI")
91 String sliceProfileID = execution.getVariable("sliceProfileID")
92 Map<String, Object> sliceProfileMap = execution.getVariable("sliceProfileCn")
93 Map<String, Object> serviceProfileMap = execution.getVariable("serviceProfile")
95 String globalSubscriberId = currentNSSI['globalSubscriberId']
96 String serviceType = currentNSSI['serviceType']
97 String nssiId = currentNSSI['nssiId']
99 SliceProfile sliceProfile = new SliceProfile()
100 sliceProfile.setServiceAreaDimension("")
101 sliceProfile.setPayloadSize(0)
102 sliceProfile.setJitter(0)
103 sliceProfile.setSurvivalTime(0)
104 sliceProfile.setExpDataRate(0)
105 sliceProfile.setTrafficDensity(0)
106 sliceProfile.setConnDensity(0)
107 sliceProfile.setSNssai(sliceProfileMap.get("sNSSAI").toString())
108 sliceProfile.setExpDataRateUL(Integer.parseInt(sliceProfileMap.get("expDataRateUL").toString()))
109 sliceProfile.setExpDataRateDL(Integer.parseInt(sliceProfileMap.get("expDataRateDL").toString()))
110 sliceProfile.setActivityFactor(Integer.parseInt(sliceProfileMap.get("activityFactor").toString()))
111 sliceProfile.setResourceSharingLevel(sliceProfileMap.get("activityFactor").toString())
112 sliceProfile.setUeMobilityLevel(serviceProfileMap.get("uEMobilityLevel").toString())
113 sliceProfile.setCoverageAreaTAList(serviceProfileMap.get("coverageAreaTAList").toString())
114 sliceProfile.setMaxNumberOfUEs(Integer.parseInt(sliceProfileMap.get("activityFactor").toString()))
115 sliceProfile.setLatency(Integer.parseInt(sliceProfileMap.get("latency").toString()))
116 sliceProfile.setProfileId(sliceProfileID)
117 sliceProfile.setE2ELatency(0)
120 AAIResourcesClient client = getAAIClient()
121 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE, globalSubscriberId, serviceType, nssiId, sliceProfileID)
122 client.create(uri, sliceProfile)
124 currentNSSI['createdSliceProfile'] = sliceProfile
125 } catch (Exception ex) {
126 exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile create call:" + ex.getMessage())
129 LOGGER.trace("${PREFIX} Exit createSliceProfileInstance")
134 * Creates Slice Profile association with NSSI
137 void associateSliceProfileInstanceWithNSSI(DelegateExecution execution) {
138 LOGGER.trace("${PREFIX} Start associateSliceProfileInstanceWithNSSI")
140 String sliceProfileID = execution.getVariable("sliceProfileID")
142 def currentNSSI = execution.getVariable("currentNSSI")
144 String globalSubscriberId = currentNSSI['globalSubscriberId']
145 String serviceType = currentNSSI['serviceType']
146 String nssiId = currentNSSI['nssiId']
148 AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nssiId)
149 AAIResourceUri sliceProfileUri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE, globalSubscriberId, serviceType, nssiId, sliceProfileID)
152 SliceProfile createdSliceProfile = (SliceProfile)currentNSSI['createdSliceProfile']
153 ServiceInstance nssi = (ServiceInstance)currentNSSI['nssi']
154 List<SliceProfile> associatedProfiles = nssi.getSliceProfiles().getSliceProfile()
155 associatedProfiles.add(createdSliceProfile)
157 getAAIClient().update(nssiUri, nssi)
159 getAAIClient().connect(sliceProfileUri, nssiUri, AAIEdgeLabel.BELONGS_TO)
161 exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile association with NSSI disconnect call: " + e.getMessage())
164 LOGGER.trace("${PREFIX} Exit associateSliceProfileInstanceWithNSSI")