2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 # Copyright (c) 2020, Wipro Limited.
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
24 import com.google.gson.JsonArray
25 import org.camunda.bpm.engine.delegate.BpmnError
26 import org.camunda.bpm.engine.delegate.DelegateExecution
27 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
28 import org.onap.so.bpmn.common.scripts.ExceptionUtil
29 import org.onap.so.bpmn.common.scripts.NssmfAdapterUtils
30 import org.onap.so.bpmn.common.scripts.OofUtils
31 import org.onap.so.bpmn.common.scripts.RequestDBUtil
32 import org.onap.so.bpmn.core.json.JsonUtils
33 import org.onap.so.db.request.beans.ResourceOperationStatus
34 import org.slf4j.Logger
35 import org.slf4j.LoggerFactory
36 import java.sql.Timestamp
38 import static org.apache.commons.lang3.StringUtils.isBlank
39 import com.google.gson.JsonObject
40 import com.google.gson.JsonParser
41 import com.fasterxml.jackson.databind.ObjectMapper
42 import org.onap.aaiclient.client.aai.AAIObjectType
43 import org.onap.aaiclient.client.aai.AAIResourcesClient
44 import org.onap.aaiclient.client.aai.entities.AAIResultWrapper
45 import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
46 import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
47 import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder
48 import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types
49 import javax.ws.rs.NotFoundException
50 import org.onap.so.beans.nsmf.AllocateTnNssi
51 import org.onap.so.beans.nsmf.DeAllocateNssi
52 import org.onap.so.beans.nsmf.ServiceInfo
53 import org.onap.so.bpmn.core.UrnPropertiesReader
54 import org.onap.aai.domain.yang.ServiceInstance
55 import org.onap.aai.domain.yang.SliceProfile
56 import org.onap.aai.domain.yang.SliceProfiles
57 import org.onap.aai.domain.yang.Relationship
58 import com.google.gson.Gson
62 private static final Logger logger = LoggerFactory.getLogger(AnNssmfUtils.class)
63 ObjectMapper objectMapper = new ObjectMapper();
64 ExceptionUtil exceptionUtil = new ExceptionUtil()
65 JsonUtils jsonUtil = new JsonUtils()
66 public String buildSelectRANNSSIRequest(String requestId, String messageType, String UUID,String invariantUUID,
67 String name, Map<String, Object> profileInfo, List<String> nsstInfoList, JsonArray capabilitiesList, Boolean preferReuse){
68 JsonParser parser = new JsonParser()
69 def transactionId = requestId
70 logger.debug( "transactionId is: " + transactionId)
71 String correlator = requestId
72 String callbackUrl = UrnPropertiesReader.getVariable("mso.adapters.oof.callback.endpoint") + "/" + messageType + "/" + correlator
73 String profileJson = objectMapper.writeValueAsString(profileInfo);
74 String nsstInfoListString = objectMapper.writeValueAsString(nsstInfoList);
75 //Prepare requestInfo object
76 JsonObject requestInfo = new JsonObject()
77 requestInfo.addProperty("transactionId", transactionId)
78 requestInfo.addProperty("requestId", requestId)
79 requestInfo.addProperty("callbackUrl", callbackUrl)
80 requestInfo.addProperty("sourceId","SO" )
81 requestInfo.addProperty("timeout", 600)
82 requestInfo.addProperty("numSolutions", 1)
84 //Prepare serviceInfo object
85 JsonObject ranNsstInfo = new JsonObject()
86 ranNsstInfo.addProperty("UUID", UUID)
87 ranNsstInfo.addProperty("invariantUUID", invariantUUID)
88 ranNsstInfo.addProperty("name", name)
90 JsonObject json = new JsonObject()
91 json.add("requestInfo", requestInfo)
92 json.add("NSTInfo", ranNsstInfo)
93 json.add("serviceProfile", (JsonObject) parser.parse(profileJson))
94 //json.add("NSSTInfo", (JsonArray) parser.parse(nsstInfoListString))
95 json.add("subnetCapabilities", capabilitiesList)
96 json.addProperty("preferReuse", preferReuse)
98 return json.toString()
101 public String buildCreateTNNSSMFSubnetCapabilityRequest() {
102 JsonObject esrInfo = new JsonObject()
103 esrInfo.addProperty("networkType", "tn")
104 esrInfo.addProperty("vendor", "ONAP_internal")
106 JsonArray subnetTypes = new JsonArray()
107 subnetTypes.add("TN_FH")
108 subnetTypes.add("TN_MH")
109 JsonObject response = new JsonObject()
110 JsonObject subnetTypesObj = new JsonObject()
111 subnetTypesObj.add("subnetTypes", subnetTypes)
112 response.add("subnetCapabilityQuery", subnetTypesObj)
113 response.add("esrInfo", esrInfo)
114 return response.toString()
117 public String buildCreateANNFNSSMFSubnetCapabilityRequest() {
118 JsonObject esrInfo = new JsonObject()
119 esrInfo.addProperty("networkType", "an")
120 esrInfo.addProperty("vendor", "ONAP_internal")
122 JsonArray subnetTypes = new JsonArray()
123 subnetTypes.add("AN_NF")
124 JsonObject response = new JsonObject()
125 JsonObject subnetTypesObj = new JsonObject()
126 subnetTypesObj.add("subnetTypes", subnetTypes)
127 response.add("subnetCapabilityQuery", subnetTypesObj)
128 response.add("esrInfo", esrInfo)
129 return response.toString()
131 public void createDomainWiseSliceProfiles(List<String> ranConstituentSliceProfiles, DelegateExecution execution) {
133 for(String profile : ranConstituentSliceProfiles) {
134 String domainType = jsonUtil.getJsonValue(profile, "domainType")
137 execution.setVariable("ranNfSliceProfile", profile)
140 execution.setVariable("tnFhSliceProfile", profile)
143 execution.setVariable("tnMhSliceProfile", profile)
146 logger.debug("No expected match found for current domainType")
147 logger.error("No expected match found for current domainType "+ domainType)
148 exceptionUtil.buildAndThrowWorkflowException(execution, 1000,"No expected match found for current domainType "+ domainType)
154 public void createSliceProfilesInAai(DelegateExecution execution) {
156 String serviceCategory = execution.getVariable("serviceCategory")
157 if (execution.getVariable("IsRANNfAlonePresent")) {
158 ServiceInstance ANNF_sliceProfileInstance = new ServiceInstance();
159 String ANNF_sliceProfileInstanceId = UUID.randomUUID().toString()
160 String ANNF_sliceProfileId = UUID.randomUUID().toString()
161 execution.setVariable("ANNF_sliceProfileInstanceId", ANNF_sliceProfileInstanceId)
162 execution.setVariable("ANNF_sliceProfileId", ANNF_sliceProfileId)
163 SliceProfiles ANNF_SliceProfiles = new SliceProfiles()
164 SliceProfile ANNF_SliceProfile = createSliceProfile("AN_NF", execution)
165 ANNF_SliceProfiles.getSliceProfile().add(ANNF_SliceProfile)
166 logger.debug("sliceProfiles : 1. " + ANNF_SliceProfiles.toString())
167 //ANNF slice profile instance creation
168 ANNF_sliceProfileInstance.setServiceInstanceId(ANNF_sliceProfileInstanceId)
169 String sliceInstanceName = "sliceprofile_" + ANNF_sliceProfileId
170 ANNF_sliceProfileInstance.setServiceInstanceName(sliceInstanceName)
171 String serviceType = execution.getVariable("sst") as String
172 ANNF_sliceProfileInstance.setServiceType(serviceType)
173 String serviceStatus = "deactivated"
174 ANNF_sliceProfileInstance.setOrchestrationStatus(serviceStatus)
175 String serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile") as String, "pLMNIdList")
176 ANNF_sliceProfileInstance.setServiceInstanceLocationId(jsonUtil.StringArrayToList(serviceInstanceLocationid).get(0))
177 String serviceRole = "slice-profile-instance"
178 ANNF_sliceProfileInstance.setServiceRole(serviceRole)
179 ArrayList<String> snssaiList = jsonUtil.StringArrayToList(execution.getVariable("snssaiList") as String)
180 String snssai = snssaiList.get(0)
181 ANNF_sliceProfileInstance.setEnvironmentContext(snssai)
182 ANNF_sliceProfileInstance.setWorkloadContext("AN_NF")
183 ANNF_sliceProfileInstance.setSliceProfiles(ANNF_SliceProfiles)
184 String serviceFunctionAnnf = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile") as String, "resourceSharingLevel")
185 ANNF_sliceProfileInstance.setServiceFunction(serviceFunctionAnnf)
186 logger.debug("completed ANNF sliceprofileinstance build : " + ANNF_sliceProfileInstance.toString())
190 AAIResourcesClient client = new AAIResourcesClient()
191 AAIResourceUri sliceProfileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId") as String).serviceSubscription(execution.getVariable("subscriptionServiceType") as String).serviceInstance(ANNF_sliceProfileInstanceId))
192 client.create(sliceProfileUri, ANNF_sliceProfileInstance)
193 } catch (BpmnError e) {
195 } catch (Exception ex) {
196 msg = "Exception in AnNssmfUtils.createSliceProfilesInAai " + ex.getMessage()
198 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
202 org.onap.aai.domain.yang.ServiceInstance ANNF_sliceProfileInstance = new ServiceInstance();
203 org.onap.aai.domain.yang.ServiceInstance TNFH_sliceProfileInstance = new ServiceInstance();
204 org.onap.aai.domain.yang.ServiceInstance TNMH_sliceProfileInstance = new ServiceInstance();
205 //generate slice profile ids and slice profile instance ids
206 String ANNF_sliceProfileInstanceId = UUID.randomUUID().toString()
207 String ANNF_sliceProfileId = UUID.randomUUID().toString()
208 String TNFH_sliceProfileInstanceId = UUID.randomUUID().toString()
209 String TNFH_sliceProfileId = UUID.randomUUID().toString()
210 String TNMH_sliceProfileInstanceId = UUID.randomUUID().toString()
211 String TNMH_sliceProfileId = UUID.randomUUID().toString()
212 execution.setVariable("ANNF_sliceProfileInstanceId", ANNF_sliceProfileInstanceId)
213 execution.setVariable("ANNF_sliceProfileId", ANNF_sliceProfileId)
214 execution.setVariable("TNFH_sliceProfileInstanceId", TNFH_sliceProfileInstanceId)
215 execution.setVariable("TNFH_sliceProfileId", TNFH_sliceProfileId)
216 execution.setVariable("TNMH_sliceProfileInstanceId", TNMH_sliceProfileInstanceId)
217 execution.setVariable("TNMH_sliceProfileId", TNMH_sliceProfileId)
218 //slice profiles assignment
219 org.onap.aai.domain.yang.SliceProfiles ANNF_SliceProfiles = new SliceProfiles()
220 org.onap.aai.domain.yang.SliceProfiles TNFH_SliceProfiles = new SliceProfiles()
221 org.onap.aai.domain.yang.SliceProfiles TNMH_SliceProfiles = new SliceProfiles()
222 org.onap.aai.domain.yang.SliceProfile ANNF_SliceProfile = new SliceProfile()
223 org.onap.aai.domain.yang.SliceProfile TNFH_SliceProfile = new SliceProfile()
224 org.onap.aai.domain.yang.SliceProfile TNMH_SliceProfile = new SliceProfile()
225 ANNF_SliceProfile = createSliceProfile("AN_NF", execution)
226 TNFH_SliceProfile = createSliceProfile("TN_FH", execution)
227 TNMH_SliceProfile = createSliceProfile("TN_MH", execution)
229 ANNF_SliceProfiles.getSliceProfile().add(ANNF_SliceProfile)
230 TNFH_SliceProfiles.getSliceProfile().add(TNFH_SliceProfile)
231 TNMH_SliceProfiles.getSliceProfile().add(TNMH_SliceProfile)
233 logger.debug("sliceProfiles : 1. " + ANNF_SliceProfiles.toString() + "\n 2. " + TNFH_SliceProfiles.toString() + "\n 3. " + TNMH_SliceProfiles.toString())
234 //ANNF slice profile instance creation
235 ANNF_sliceProfileInstance.setServiceInstanceId(ANNF_sliceProfileInstanceId)
236 String sliceInstanceName = "sliceprofile_" + ANNF_sliceProfileId
237 ANNF_sliceProfileInstance.setServiceInstanceName(sliceInstanceName)
238 String serviceType = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "sST")
239 ANNF_sliceProfileInstance.setServiceType(serviceType)
240 String serviceStatus = "deactivated"
241 ANNF_sliceProfileInstance.setOrchestrationStatus(serviceStatus)
242 String serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "pLMNIdList")
243 ANNF_sliceProfileInstance.setServiceInstanceLocationId(jsonUtil.StringArrayToList(serviceInstanceLocationid).get(0))
244 String serviceRole = "slice-profile-instance"
245 ANNF_sliceProfileInstance.setServiceRole(serviceRole)
246 ArrayList<String> snssaiList = jsonUtil.StringArrayToList(execution.getVariable("snssaiList") as String)
247 String snssai = snssaiList.get(0)
248 ANNF_sliceProfileInstance.setEnvironmentContext(snssai)
249 ANNF_sliceProfileInstance.setWorkloadContext("AN_NF")
250 ANNF_sliceProfileInstance.setSliceProfiles(ANNF_SliceProfiles)
251 String serviceFunctionAnnf = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "resourceSharingLevel")
252 ANNF_sliceProfileInstance.setServiceFunction(serviceFunctionAnnf)
253 logger.debug("completed ANNF sliceprofileinstance build : "+ ANNF_sliceProfileInstance.toString())
255 //TNFH slice profile instance creation
256 TNFH_sliceProfileInstance.setServiceInstanceId(TNFH_sliceProfileInstanceId)
257 sliceInstanceName = "sliceprofile_"+TNFH_sliceProfileId
258 TNFH_sliceProfileInstance.setServiceInstanceName(sliceInstanceName)
259 serviceType = jsonUtil.getJsonValue(execution.getVariable("tnFhSliceProfile"), "sST")
260 TNFH_sliceProfileInstance.setServiceType(serviceType)
261 TNFH_sliceProfileInstance.setOrchestrationStatus(serviceStatus)
262 serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("tnFhSliceProfile"), "pLMNIdList")
263 TNFH_sliceProfileInstance.setServiceInstanceLocationId(jsonUtil.StringArrayToList(serviceInstanceLocationid).get(0))
264 TNFH_sliceProfileInstance.setServiceRole(serviceRole)
265 TNFH_sliceProfileInstance.setEnvironmentContext(snssai)
266 TNFH_sliceProfileInstance.setWorkloadContext("TN_FH")
267 TNFH_sliceProfileInstance.setSliceProfiles(TNFH_SliceProfiles)
268 String serviceFunctionTnFH = jsonUtil.getJsonValue(execution.getVariable("tnFhSliceProfile"), "resourceSharingLevel")
269 TNFH_sliceProfileInstance.setServiceFunction(serviceFunctionTnFH)
270 logger.debug("completed TNFH sliceprofileinstance build : "+TNFH_sliceProfileInstance)
272 //TNMH slice profile instance creation
273 TNMH_sliceProfileInstance.setServiceInstanceId(TNMH_sliceProfileInstanceId)
274 sliceInstanceName = "sliceprofile_"+TNMH_sliceProfileId
275 TNMH_sliceProfileInstance.setServiceInstanceName(sliceInstanceName)
276 serviceType = jsonUtil.getJsonValue(execution.getVariable("tnMhSliceProfile"), "sST")
277 TNMH_sliceProfileInstance.setServiceType(serviceType)
278 TNMH_sliceProfileInstance.setOrchestrationStatus(serviceStatus)
279 serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("tnMhSliceProfile"), "pLMNIdList")
280 TNMH_sliceProfileInstance.setServiceInstanceLocationId(jsonUtil.StringArrayToList(serviceInstanceLocationid).get(0))
281 TNMH_sliceProfileInstance.setServiceRole(serviceRole)
282 TNMH_sliceProfileInstance.setEnvironmentContext(snssai)
283 TNMH_sliceProfileInstance.setWorkloadContext("TN_MH")
284 TNMH_sliceProfileInstance.setSliceProfiles(TNMH_SliceProfiles)
285 String serviceFunctionTnMH = jsonUtil.getJsonValue(execution.getVariable("tnMhSliceProfile"), "resourceSharingLevel")
286 TNMH_sliceProfileInstance.setServiceFunction(serviceFunctionTnMH)
287 logger.debug("completed TNMH sliceprofileinstance build : "+TNMH_sliceProfileInstance)
292 AAIResourcesClient client = new AAIResourcesClient()
293 AAIResourceUri sliceProfileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(ANNF_sliceProfileInstanceId))
294 client.create(sliceProfileUri, ANNF_sliceProfileInstance)
296 AAIResourceUri sliceProfileUri1 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(TNFH_sliceProfileInstanceId))
297 client.create(sliceProfileUri1, TNFH_sliceProfileInstance)
299 AAIResourceUri sliceProfileUri2 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(TNMH_sliceProfileInstanceId))
300 client.create(sliceProfileUri2, TNMH_sliceProfileInstance)
302 } catch (BpmnError e) {
304 } catch (Exception ex) {
305 msg = "Exception in AnNssmfUtils.createSliceProfilesInAai " + ex.getMessage()
307 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
312 private SliceProfile createSliceProfile(String domainType, DelegateExecution execution) {
314 SliceProfile result = new SliceProfile()
315 Map<String,Object> profile
318 profile = objectMapper.readValue(execution.getVariable("ranNfSliceProfile"), Map.class)//pending fields - cSReliabilityMeanTime, cSAvailabilityTarget, terminalDensity, msgSizeByte
319 result.setJitter(profile.get("jitter"))
320 result.setLatency(profile.get("latency"))
321 result.setMaxBandwidth(profile.get("maxbandwidth"))
322 result.setResourceSharingLevel(profile.get("resourceSharingLevel"))
323 result.setUeMobilityLevel(profile.get("uEMobilityLevel"))
324 result.setMaxNumberOfUEs(profile.get("maxNumberofUEs"))
325 result.setActivityFactor(profile.get("activityFactor"))
326 result.setCoverageAreaTAList(profile.get("coverageAreaTAList").toString())
327 result.setExpDataRateDL(profile.get("expDataRateDL"))
328 result.setExpDataRateUL(profile.get("expDataRateUL"))
329 result.setSurvivalTime(profile.get("survivalTime"))
330 result.setMaxNumberOfPDUSession(profile.get("maxNumberOfPDUSession"))
331 result.setAreaTrafficCapDL(profile.get("areaTrafficCapDL"))
332 result.setAreaTrafficCapUL(profile.get("areaTrafficCapUL"))
333 result.setOverallUserDensity(profile.get("overallUserDensity"))
334 result.setTransferIntervalTarget(profile.get("transferIntervalTarget"))
335 result.setExpDataRate(profile.get("expDataRate"))
336 result.setProfileId(execution.getVariable("ANNF_sliceProfileId"))
339 profile = objectMapper.readValue(execution.getVariable("tnFhSliceProfile"), Map.class)
340 result.setJitter(profile.get("jitter"))
341 result.setLatency(profile.get("latency"))
342 result.setMaxBandwidth(profile.get("maxbandwidth"))
343 result.setResourceSharingLevel(profile.get("resourceSharingLevel"))
344 result.setProfileId(execution.getVariable("TNFH_sliceProfileId"))
347 profile = objectMapper.readValue(execution.getVariable("tnMhSliceProfile"), Map.class)
348 result.setJitter(profile.get("jitter"))
349 result.setLatency(profile.get("latency"))
350 result.setMaxBandwidth(profile.get("maxbandwidth"))
351 result.setResourceSharingLevel(profile.get("resourceSharingLevel"))
352 result.setProfileId(execution.getVariable("TNMH_sliceProfileId"))
355 logger.debug("No expected match found for current domainType")
356 logger.error("No expected match found for current domainType "+ domainType)
357 exceptionUtil.buildAndThrowWorkflowException(execution, 1000,"No expected match found for current domainType "+ domainType)
363 * create relationship in AAI
365 public createRelationShipInAAI = { DelegateExecution execution, final Relationship relationship, String instanceId ->
366 logger.debug("createRelationShipInAAI Start")
368 AAIResourcesClient client = new AAIResourcesClient()
370 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(instanceId)).relationshipAPI()
371 client.create(uri, relationship)
373 } catch (BpmnError e) {
375 } catch (Exception ex) {
376 msg = "Exception in AN NSSMF Utils : CreateRelationShipInAAI. " + ex.getMessage()
378 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
380 logger.debug("createRelationShipInAAI Exit")
384 public void processRanNfModifyRsp(DelegateExecution execution) {
385 String status = execution.getVariable("ranNfStatus")
386 if(status.equals("success")) {
387 logger.debug("completed Ran NF NSSI modification ... proceeding with the flow")
390 logger.error("failed to modify ran Nf nssi")
391 exceptionUtil.buildAndThrowWorkflowException(execution, 1000, "modify ran nf nssi not successfull")
395 public String buildCreateNSSMFRequest(DelegateExecution execution, String domainType, String action) {
396 JsonObject esrInfo = new JsonObject()
397 esrInfo.addProperty("networkType", "tn")
398 esrInfo.addProperty("vendor", "ONAP_internal")
399 JsonObject response = new JsonObject()
400 JsonObject allocateTnNssi = new JsonObject()
401 JsonObject serviceInfo = new JsonObject()
402 JsonArray transportSliceNetworksList = new JsonArray()
403 JsonArray connectionLinksList = new JsonArray()
404 JsonObject connectionLinks = new JsonObject()
405 Gson jsonConverter = new Gson()
406 String TNFH_nssiInstanceId = UUID.randomUUID().toString()
407 String TNMH_nssiInstanceId = UUID.randomUUID().toString()
409 if(action.equals("allocate")){
410 JsonObject endpoints = new JsonObject()
411 if(domainType.equals("TN_FH")) {
412 serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("TNFH_modelInvariantUuid"))
413 serviceInfo.addProperty("serviceUuid", execution.getVariable("TNFH_modelUuid"))
414 serviceInfo.addProperty("nssiName", "nssi_tn_fh_"+TNFH_nssiInstanceId)
415 serviceInfo.addProperty("sst", execution.getVariable("sst"))
416 allocateTnNssi.addProperty("nsstId", execution.getVariable("TNFH_modelUuid"))
417 allocateTnNssi.addProperty("nssiName", execution.getVariable("TNFH_modelName"))
418 Map<String,Object> sliceProfile = objectMapper.readValue(execution.getVariable("tnFhSliceProfile"), Map.class)
419 sliceProfile.put("sliceProfileId", execution.getVariable("TNFH_sliceProfileInstanceId"))
420 allocateTnNssi.add("sliceProfile", jsonConverter.toJsonTree(sliceProfile))
421 endpoints.addProperty("transportEndpointA", execution.getVariable("tranportEp_ID_RU"))
422 endpoints.addProperty("transportEndpointB", execution.getVariable("tranportEp_ID_DUIN"))
423 connectionLinksList.add(endpoints)
424 }else if(domainType.equals("TN_MH")) {
425 serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("TNMH_modelInvariantUuid"))
426 serviceInfo.addProperty("serviceUuid", execution.getVariable("TNMH_modelUuid"))
427 serviceInfo.addProperty("nssiName", "nssi_tn_mh_"+TNMH_nssiInstanceId)
428 serviceInfo.addProperty("sst", execution.getVariable("sst"))
429 allocateTnNssi.addProperty("nsstId", execution.getVariable("TNMH_modelUuid"))
430 allocateTnNssi.addProperty("nssiName", execution.getVariable("TNMH_modelName"))
431 Map<String,Object> sliceProfile = objectMapper.readValue(execution.getVariable("tnMhSliceProfile"), Map.class)
432 sliceProfile.put("sliceProfileId", execution.getVariable("TNMH_sliceProfileInstanceId"))
433 allocateTnNssi.add("sliceProfile", jsonConverter.toJsonTree(sliceProfile))
434 endpoints.addProperty("transportEndpointA", execution.getVariable("tranportEp_ID_DUEG"))
435 endpoints.addProperty("transportEndpointB", execution.getVariable("tranportEp_ID_CUIN"))
436 connectionLinksList.add(endpoints)
438 }else if(action.equals("modify-allocate")) {
439 JsonObject endpoints = new JsonObject()
440 if(domainType.equals("TN_FH")) {
441 allocateTnNssi.addProperty("nssiName", execution.getVariable("TNFH_nssiName"))
442 allocateTnNssi.addProperty("sliceProfileId", execution.getVariable("TNFH_sliceProfileInstanceId"))
443 allocateTnNssi.addProperty("nssiId", execution.getVariable("TNFH_NSSI"))
444 serviceInfo.addProperty("nssiId", execution.getVariable("TNFH_NSSI"))
445 serviceInfo.addProperty("nssiName", execution.getVariable("TNFH_nssiName"))
446 Map<String,Object> sliceProfile = objectMapper.readValue(execution.getVariable("tnFhSliceProfile"), Map.class)
447 sliceProfile.put("sliceProfileId", execution.getVariable("TNFH_sliceProfileInstanceId"))
448 allocateTnNssi.add("sliceProfile", jsonConverter.toJsonTree(sliceProfile))
449 endpoints.addProperty("transportEndpointA", execution.getVariable("tranportEp_ID_RU"))
450 endpoints.addProperty("transportEndpointB", execution.getVariable("tranportEp_ID_DUIN"))
451 connectionLinksList.add(endpoints)
452 }else if(domainType.equals("TN_MH")) {
453 allocateTnNssi.addProperty("nssiName", execution.getVariable("TNMH_nssiName"))
454 allocateTnNssi.addProperty("sliceProfileId", execution.getVariable("TNMH_sliceProfileInstanceId"))
455 allocateTnNssi.addProperty("nssiId", execution.getVariable("TNMH_NSSI"))
456 serviceInfo.addProperty("nssiId", execution.getVariable("TNMH_NSSI"))
457 serviceInfo.addProperty("nssiName", execution.getVariable("TNMH_nssiName"))
458 Map<String,Object> sliceProfile = objectMapper.readValue(execution.getVariable("tnMhSliceProfile"), Map.class)
459 sliceProfile.put("sliceProfileId", execution.getVariable("TNMH_sliceProfileInstanceId"))
460 allocateTnNssi.add("sliceProfile", jsonConverter.toJsonTree(sliceProfile))
461 endpoints.addProperty("transportEndpointA", execution.getVariable("tranportEp_ID_DUEG"))
462 endpoints.addProperty("transportEndpointB", execution.getVariable("tranportEp_ID_CUIN"))
463 connectionLinksList.add(endpoints)
468 connectionLinks.add("connectionLinks", connectionLinksList)
469 transportSliceNetworksList.add(connectionLinks)
470 allocateTnNssi.add("transportSliceNetworks", transportSliceNetworksList)
472 JsonParser parser = new JsonParser()
473 String nsiInfo = jsonUtil.getJsonValue(execution.getVariable("sliceParams"), "nsiInfo")
474 allocateTnNssi.add("nsiInfo",(JsonObject) parser.parse(nsiInfo))
475 allocateTnNssi.addProperty("scriptName", "TN1")
476 serviceInfo.addProperty("nsiId", execution.getVariable("nsiId"))
477 serviceInfo.addProperty("globalSubscriberId", execution.getVariable("globalSubscriberId"))
478 serviceInfo.addProperty("subscriptionServiceType", execution.getVariable("subscriptionServiceType"))
479 response.add("esrInfo", esrInfo)
480 response.add("serviceInfo", serviceInfo)
481 response.add("allocateTnNssi", allocateTnNssi)
482 return response.toString()
485 public String buildDeallocateNssiRequest(DelegateExecution execution,String domainType) {
486 String globalSubscriberId = execution.getVariable("globalSubscriberId")
487 String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
489 List<String> sNssaiList = execution.getVariable("snssaiList") as List<String>
491 DeAllocateNssi deallocateNssi = new DeAllocateNssi()
492 deallocateNssi.setNsiId(execution.getVariable("nsiId") as String)
493 deallocateNssi.setScriptName("TN1")
494 deallocateNssi.setSnssaiList(sNssaiList)
495 deallocateNssi.setTerminateNssiOption(0)
497 JsonObject esrInfo = new JsonObject()
498 esrInfo.addProperty("networkType", "tn")
499 esrInfo.addProperty("vendor", "ONAP_internal")
501 JsonObject serviceInfo = new JsonObject()
502 serviceInfo.addProperty("globalSubscriberId", globalSubscriberId)
503 serviceInfo.addProperty("subscriptionServiceType", subscriptionServiceType)
504 serviceInfo.addProperty("modifyAction", true)
506 if(domainType.equals("TN_FH")) {
507 deallocateNssi.setNssiId(execution.getVariable("TNFH_NSSI") as String)
508 deallocateNssi.setSliceProfileId(execution.getVariable("TNFH_sliceProfileInstanceId") as String)
509 serviceInfo.addProperty("nssiId", execution.getVariable("TNFH_NSSI") as String)
510 }else if(domainType.equals("TN_MH")) {
511 deallocateNssi.setNssiId(execution.getVariable("TNMH_NSSI") as String)
512 deallocateNssi.setSliceProfileId(execution.getVariable("TNMH_sliceProfileInstanceId") as String)
513 serviceInfo.addProperty("nssiId", execution.getVariable("TNMH_NSSI") as String)
516 JsonObject json = new JsonObject()
517 Gson jsonConverter = new Gson()
518 json.add("deAllocateNssi", jsonConverter.toJsonTree(deallocateNssi))
519 json.add("esrInfo", esrInfo)
520 json.add("serviceInfo", serviceInfo)
521 return json.toString()
525 public String getModelUuid(DelegateExecution execution, String instanceId) {
526 String globalSubscriberId = execution.getVariable("globalSubscriberId")
527 String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
528 ServiceInstance serviceInstance = new ServiceInstance()
529 AAIResourcesClient client = new AAIResourcesClient()
530 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(instanceId))
531 if (!client.exists(uri)) {
532 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai : ${instanceId}")
534 AAIResultWrapper wrapper = client.get(uri, NotFoundException.class)
535 Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class)
538 serviceInstance = si.get()
540 return serviceInstance.getModelVersionId()