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
23 import org.camunda.bpm.engine.delegate.BpmnError
24 import org.camunda.bpm.engine.delegate.DelegateExecution
25 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
26 import org.onap.so.bpmn.common.scripts.ExceptionUtil
27 import org.onap.so.bpmn.common.scripts.NssmfAdapterUtils
28 import org.onap.so.bpmn.common.scripts.OofUtils
29 import org.onap.so.bpmn.common.scripts.RequestDBUtil
30 import org.onap.so.bpmn.core.json.JsonUtils
31 import org.onap.so.db.request.beans.ResourceOperationStatus
32 import org.slf4j.Logger
33 import org.slf4j.LoggerFactory
35 import static org.apache.commons.lang3.StringUtils.isBlank
36 import com.google.gson.JsonObject
37 import com.google.gson.Gson
38 import com.fasterxml.jackson.databind.ObjectMapper
39 import com.google.gson.JsonArray
40 import com.google.gson.JsonParser
41 import org.onap.aai.domain.yang.Relationship
42 import org.onap.aaiclient.client.aai.AAIResourcesClient
43 import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
44 import org.onap.so.beans.nsmf.AllocateTnNssi
45 import org.onap.so.bpmn.core.UrnPropertiesReader
46 import org.onap.so.bpmn.core.domain.ServiceDecomposition
47 import org.onap.so.bpmn.core.domain.ServiceInstance
48 import org.onap.so.bpmn.core.domain.ServiceProxy
49 import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
50 import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder
51 import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types
52 import org.onap.aaiclient.client.aai.AAINamespaceConstants
53 import org.onap.aaiclient.client.aai.AAIObjectType
54 import org.onap.aai.domain.yang.NetworkPolicy
55 import org.onap.aai.domain.yang.NetworkRoute
56 import org.json.JSONArray
58 class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor {
61 ExceptionUtil exceptionUtil = new ExceptionUtil()
62 RequestDBUtil requestDBUtil = new RequestDBUtil()
63 JsonUtils jsonUtil = new JsonUtils()
64 OofUtils oofUtils = new OofUtils()
65 AnNssmfUtils anNssmfUtils = new AnNssmfUtils()
66 ObjectMapper objectMapper = new ObjectMapper();
67 private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil)
69 private static final Logger logger = LoggerFactory.getLogger(DoAllocateAccessNSSI.class)
72 void preProcessRequest(DelegateExecution execution) {
73 logger.debug(Prefix + "preProcessRequest Start")
74 execution.setVariable("prefix", Prefix)
75 execution.setVariable("startTime", System.currentTimeMillis())
79 logger.debug("input variables : msoRequestId - "+execution.getVariable("msoRequestId")
80 +" modelInvariantUuid - "+execution.getVariable("modelInvariantUuid")+
81 " modelUuid - "+execution.getVariable("modelUuid")+
82 " globalSubscriberId - "+execution.getVariable("globalSubscriberId")+
83 " dummyServiceId - "+ execution.getVariable("dummyServiceId")+
84 " nsiId - "+execution.getVariable("nsiId")+
85 " networkType - "+execution.getVariable("networkType")+
86 " subscriptionServiceType - "+execution.getVariable("subscriptionServiceType")+
87 " jobId - "+execution.getVariable("jobId")+
88 " sliceParams - "+execution.getVariable("sliceParams")+
89 " servicename - "+ execution.getVariable("servicename")+
90 " sst - "+ execution.getVariable("sst"))
92 //validate slice subnet inputs
94 String sliceParams = execution.getVariable("sliceParams")
95 String sliceProfile = jsonUtil.getJsonValue(sliceParams, "sliceProfile")
96 if (isBlank(sliceProfile)) {
97 msg = "Input sliceProfile is null"
99 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
101 execution.setVariable("sliceProfile", sliceProfile)
103 String sliceProfileId = jsonUtil.getJsonValue(sliceProfile, "sliceProfileId")
104 def snssaiList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceProfile, "snssaiList"))
105 def plmnIdList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceProfile, "pLMNIdList"))
106 String jsonArray = jsonUtil.getJsonValue(sliceProfile, "coverageAreaTAList")
107 List<Integer> list = new ArrayList<>();
108 JSONArray arr = new JSONArray(jsonArray);
109 for (int i = 0; i < arr.length(); i++) {
110 int s = (int) arr.get(i);
113 def coverageAreaTAList = list;
115 if (isBlank(sliceProfileId) || (snssaiList.empty) || (plmnIdList.empty)
116 || (coverageAreaTAList.empty)) {
118 msg = "Mandatory slice profile fields are empty"
120 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
122 execution.setVariable("sliceProfileId", sliceProfileId)
123 execution.setVariable("snssaiList", snssaiList)
124 execution.setVariable("pLMNIdList", plmnIdList)
125 execution.setVariable("coverageAreaTAList", coverageAreaTAList)
127 String nsiName = jsonUtil.getJsonValue(sliceParams, "nsiInfo.nsiName")
128 String scriptName = jsonUtil.getJsonValue(sliceParams, "scriptName")
129 execution.setVariable("nsiName", nsiName)
130 execution.setVariable("scriptName", scriptName)
131 //generate RAN,RAN NF NSSIs - will be re assigned if oof returns existing NSSI
132 String RANServiceInstanceId = UUID.randomUUID().toString()
133 String RANNFServiceInstanceId = UUID.randomUUID().toString()
134 logger.debug("RAN serviceInstance Id "+RANServiceInstanceId)
135 logger.debug("RAN NF serviceInstance Id "+RANNFServiceInstanceId)
136 execution.setVariable("RANServiceInstanceId", RANServiceInstanceId)
137 execution.setVariable("RANNFServiceInstanceId", RANNFServiceInstanceId)
138 execution.setVariable("ranNssiPreferReuse", true)
139 execution.setVariable("ranNfNssiPreferReuse", true)
140 execution.setVariable("job_timeout", 10)
143 def BH_endPoints = jsonUtil.getJsonValue(sliceParams, "endPoint")
144 logger.debug("BH end points list : "+BH_endPoints)
145 if(isBlank(BH_endPoints)) {
146 msg = "End point info is empty"
148 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
150 execution.setVariable("bh_endpoint", BH_endPoints)
153 } catch(BpmnError e) {
155 } catch(Exception ex) {
156 msg = "Exception in DoAllocateAccessNSSI.preProcessRequest " + ex.getMessage()
158 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
160 logger.debug(Prefix + "preProcessRequest Exit")
164 * Prepare request params for decomposing RAN NSST
167 def prepareDecomposeService = { DelegateExecution execution ->
168 logger.debug(Prefix+"prepareDecomposeService method start")
169 String RANServiceInstanceId = execution.getVariable("RANServiceInstanceId")
170 String modelInvariantUuid = execution.getVariable("modelInvariantUuid")
171 String modelUuid = execution.getVariable("modelUuid")
172 String serviceModelInfo = """{
173 "modelInvariantUuid":"${modelInvariantUuid}",
174 "modelUuid":"${modelUuid}",
177 execution.setVariable("serviceModelInfo", serviceModelInfo)
178 execution.setVariable("serviceInstanceId", RANServiceInstanceId)
179 logger.debug("serviceModelInfo : "+serviceModelInfo)
180 logger.debug("Finish RAN NSST prepareDecomposeService")
183 /* process the decompose service(RAN NSST) response
186 def processDecomposition = { DelegateExecution execution ->
187 logger.debug(Prefix+"processDecomposition method start")
188 ServiceDecomposition ranNsstServiceDecomposition = execution.getVariable("ranNsstServiceDecomposition")
189 logger.debug("ranNsstServiceDecomposition : "+ranNsstServiceDecomposition.toString())
190 //RAN NSST decomposition
191 String ranModelVersion = ranNsstServiceDecomposition.getModelInfo().getModelVersion()
192 String ranModelName = ranNsstServiceDecomposition.getModelInfo().getModelName()
193 String serviceCategory=ranNsstServiceDecomposition.getServiceCategory()
194 logger.debug("serviceCategory : "+serviceCategory)
195 List<ServiceProxy> serviceProxyList = ranNsstServiceDecomposition.getServiceProxy()
196 List<String> nsstInfoList = new ArrayList<>()
197 for(ServiceProxy serviceProxy : serviceProxyList)
199 String nsstModelUuid = serviceProxy.getSourceModelUuid()
200 String nsstModelInvariantUuid = serviceProxy.getModelInfo().getModelInvariantUuid()
201 String name = serviceProxy.getModelInfo().getModelName()
202 String nsstServiceModelInfo = """{
203 "UUID":"${nsstModelUuid}",
204 "invariantUUID":"${nsstModelInvariantUuid}",
207 nsstInfoList.add(nsstServiceModelInfo)
210 int maxIndex=nsstInfoList.size()
213 String msg = "Exception in RAN NSST processDecomposition. There is no NSST associated with RAN NSST "
215 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
218 logger.info("RAN NSST have only RAN NF NSST")
219 execution.setVariable("ranNfSliceProfile", execution.getVariable("sliceProfile"))
220 execution.setVariable("IsRANNfAlonePresent", true)
222 execution.setVariable("ranNsstInfoList", objectMapper.writeValueAsString(nsstInfoList))
223 execution.setVariable("currentIndex",currentIndex)
224 execution.setVariable("maxIndex",maxIndex)
225 execution.setVariable("ranModelVersion", ranModelVersion)
226 execution.setVariable("ranModelName", ranModelName)
227 logger.debug(Prefix+"processDecomposition maxIndex value - "+maxIndex)
229 execution.setVariable("serviceCategory",serviceCategory)
233 * Function to subnet capabilities from nssmf adapter
235 def getSubnetCapabilities = { DelegateExecution execution ->
236 logger.debug(Prefix+"getSubnetCapabilities method start")
238 String tnNssmfRequest = anNssmfUtils.buildCreateTNNSSMFSubnetCapabilityRequest()
240 String urlString = "/api/rest/provMns/v1/NSS/subnetCapabilityQuery"
242 String tnNssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, tnNssmfRequest)
244 if (tnNssmfResponse != null) {
245 String FHCapabilities= jsonUtil.getJsonValue(tnNssmfResponse, "TN_FH")
246 String MHCapabilities = jsonUtil.getJsonValue(tnNssmfResponse, "TN_MH")
247 execution.setVariable("FHCapabilities",FHCapabilities)
248 execution.setVariable("MHCapabilities",MHCapabilities)
251 logger.error("received error message from NSSMF : "+ tnNssmfResponse)
252 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.")
254 String anNssmfRequest = anNssmfUtils.buildCreateANNFNSSMFSubnetCapabilityRequest()
256 String anNssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, anNssmfRequest)
258 if (anNssmfResponse != null) {
259 String ANNFCapabilities = jsonUtil.getJsonValue(anNssmfResponse, "AN_NF")
260 execution.setVariable("ANNFCapabilities",ANNFCapabilities)
263 logger.error("received error message from NSSMF : "+ anNssmfResponse)
264 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.")
269 * prepare OOF request for RAN NSSI selection
271 def prepareOofRequestForRanNSS = { DelegateExecution execution ->
272 logger.debug(Prefix+"prepareOofRequestForRanNSS method start")
274 String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
275 logger.debug( "get NSSI option OOF Url: " + urlString)
276 JsonParser parser = new JsonParser()
277 //build oof request body
278 boolean ranNssiPreferReuse = execution.getVariable("ranNssiPreferReuse");
279 String requestId = execution.getVariable("msoRequestId")
280 String messageType = "NSISelectionResponse"
281 Map<String, Object> profileInfo = objectMapper.readValue(execution.getVariable("sliceProfile"), Map.class)
282 profileInfo.put("sST",execution.getVariable("sst"))
283 String modelUuid = execution.getVariable("modelUuid")
284 String modelInvariantUuid = execution.getVariable("modelInvariantUuid")
285 String modelName = execution.getVariable("ranModelName")
286 String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution);
287 List<String> nsstInfoList = objectMapper.readValue(execution.getVariable("ranNsstInfoList"), List.class)
288 JsonArray capabilitiesList = new JsonArray()
289 String FHCapabilities = execution.getVariable("FHCapabilities")
290 String MHCapabilities = execution.getVariable("MHCapabilities")
291 String ANNFCapabilities = execution.getVariable("ANNFCapabilities")
292 JsonObject FH = new JsonObject()
293 JsonObject MH = new JsonObject()
294 JsonObject ANNF = new JsonObject()
295 FH.addProperty("domainType", "TN_FH")
296 FH.add("capabilityDetails", (JsonObject) parser.parse(FHCapabilities))
297 MH.addProperty("domainType", "TN_MH")
298 MH.add("capabilityDetails", (JsonObject) parser.parse(MHCapabilities))
299 ANNF.addProperty("domainType", "AN_NF")
300 ANNF.add("capabilityDetails", (JsonObject) parser.parse(ANNFCapabilities))
301 capabilitiesList.add(FH)
302 capabilitiesList.add(MH)
303 capabilitiesList.add(ANNF)
305 execution.setVariable("nssiSelection_Url", "/api/oof/selection/nsi/v1")
306 execution.setVariable("nssiSelection_messageType",messageType)
307 execution.setVariable("nssiSelection_correlator",requestId)
308 execution.setVariable("nssiSelection_timeout",timeout)
310 String oofRequest = anNssmfUtils.buildSelectRANNSSIRequest(requestId, messageType, modelUuid,modelInvariantUuid,
311 modelName, profileInfo, nsstInfoList, capabilitiesList, ranNssiPreferReuse)
313 execution.setVariable("nssiSelection_oofRequest",oofRequest)
314 logger.debug("Sending request to OOF: " + oofRequest)
317 * process OOF response for RAN NSSI selection
319 def processOofResponseForRanNSS = { DelegateExecution execution ->
320 logger.debug(Prefix+"processOofResponseForRanNSS method start")
321 String oofResponse = execution.getVariable("nssiSelection_asyncCallbackResponse")
322 String requestStatus = jsonUtil.getJsonValue(oofResponse, "requestStatus")
323 if(requestStatus.equals("completed")) {
324 String solutions = jsonUtil.getJsonValue(oofResponse, "solutions")
325 logger.debug("solutions value : "+solutions)
326 JsonParser parser = new JsonParser()
327 JsonArray solution = parser.parse(solutions)
328 JsonObject sol = solution.get(0)
329 boolean existingNSI = sol.get("existingNSI").getAsBoolean()
330 logger.debug("existingNSI value : "+existingNSI)
332 JsonObject sharedNSISolution = sol.get("sharedNSISolution").getAsJsonObject()
333 execution.setVariable("sharedRanNSSISolution", sharedNSISolution.toString())
334 logger.debug("sharedRanNSSISolution from OOF "+sharedNSISolution)
335 String RANServiceInstanceId = sharedNSISolution.get("NSIId").getAsString()
336 execution.setVariable("RANServiceInstanceId", RANServiceInstanceId)
337 ServiceInstance serviceInstance = new ServiceInstance();
338 serviceInstance.setInstanceId(RANServiceInstanceId);
339 ServiceDecomposition serviceDecomposition = execution.getVariable("ranNsstServiceDecomposition")
340 serviceDecomposition.setServiceInstance(serviceInstance);
341 execution.setVariable("ranNsstServiceDecomposition", serviceDecomposition)
342 execution.setVariable("isRspRanNssi", true)
344 JsonObject newNSISolution = sol.get("newNSISolution").getAsJsonObject()
345 JsonArray sliceProfiles = newNSISolution.get("sliceProfiles").getAsJsonArray()
346 logger.debug("RanConstituentSliceProfiles list from OOF "+sliceProfiles)
347 execution.setVariable("RanConstituentSliceProfiles", sliceProfiles.toString())
350 String statusMessage = jsonUtil.getJsonValue(oofResponse, "statusMessage")
351 logger.error("received failed status from oof "+ statusMessage)
352 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a failed Async Response from OOF : "+statusMessage)
357 def prepareModifyAccessNssiInputs = { DelegateExecution execution ->
358 logger.debug(Prefix+"prepareModifyAccessNssiInputs method start")
359 String jobId = UUID.randomUUID().toString()
360 execution.setVariable("modifyRanNssiJobId", jobId)
361 String snssaiList = execution.getVariable("snssaiList")
362 String sliceParams = execution.getVariable("sliceParams")
363 String sliceProfileId = execution.getVariable("sliceProfileId")
364 String nsiInfo = jsonUtil.getJsonValue(sliceParams, "nsiInfo")
365 String scriptName = execution.getVariable("scriptName")
367 JsonObject modifySliceParams = new JsonObject()
368 modifySliceParams.addProperty("modifyAction", "allocate")
369 modifySliceParams.addProperty("snssaiList", snssaiList)
370 modifySliceParams.addProperty("sliceProfileId", sliceProfileId)
371 modifySliceParams.addProperty("nsiInfo", nsiInfo)
372 modifySliceParams.addProperty("scriptName", scriptName)
374 execution.setVariable("modifySliceParams", modifySliceParams.toString())
375 //create operation status in request db
376 String nsiId = execution.getVariable("nsiId")
377 String modelUuid = execution.getVariable("modelUuid")
378 logger.debug("Generated new job for Service Instance serviceId:" + nsiId + "jobId:" + jobId)
380 ResourceOperationStatus initStatus = new ResourceOperationStatus()
381 initStatus.setServiceId(nsiId)
382 initStatus.setOperationId(jobId)
383 initStatus.setResourceTemplateUUID(modelUuid)
384 initStatus.setOperType("Modify")
385 requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus)
388 def createModifyNssiQueryJobStatus = { DelegateExecution execution ->
389 logger.debug(Prefix+"createModifyNssiQueryJobStatus method start")
390 JsonObject esrInfo = new JsonObject()
391 esrInfo.addProperty("networkType", "tn")
392 esrInfo.addProperty("vendor", "ONAP_internal")
394 execution.setVariable("esrInfo", esrInfo.toString())
395 JsonObject serviceInfo = new JsonObject()
396 serviceInfo.addProperty("nssiId", execution.getVariable("RANServiceInstanceId"))
397 serviceInfo.addProperty("nsiId", execution.getVariable("nsiId"))
398 serviceInfo.addProperty("nssiName", execution.getVariable("servicename"))
399 serviceInfo.addProperty("sST", execution.getVariable("sst"))
400 serviceInfo.addProperty("PLMNIdList", objectMapper.writeValueAsString(execution.getVariable("pLMNIdList")))
401 serviceInfo.addProperty("globalSubscriberId", execution.getVariable("globalSubscriberId"))
402 serviceInfo.addProperty("subscriptionServiceType", execution.getVariable("subscriptionServiceType"))
403 serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("modelInvariantUuid"))
404 serviceInfo.addProperty("serviceUuid", execution.getVariable("modelUuid"))
405 execution.setVariable("serviceInfo", serviceInfo.toString())
406 execution.setVariable("responseId", "")
408 def prepareNsstDecomposeService = { DelegateExecution execution ->
409 logger.debug(Prefix+"prepareNsstDecomposeService method start")
410 List<String> nsstInfoList = objectMapper.readValue(execution.getVariable("ranNsstInfoList"), List.class)
411 int currentIndex = execution.getVariable("currentIndex")
412 int maxIndex = execution.getVariable("maxIndex")
413 logger.debug(Prefix+"prepareNsstDecomposeService : currentIndex value - "+currentIndex+" maxIndex : "+maxIndex)
414 if(currentIndex<maxIndex) {
415 String nsstInfo = nsstInfoList.get(currentIndex)
416 String modelInvariantUuid = jsonUtil.getJsonValue(nsstInfo, "invariantUUID")
417 String modelUuid = jsonUtil.getJsonValue(nsstInfo, "UUID")
419 String serviceModelInfo = """{
420 "modelInvariantUuid":"${modelInvariantUuid}",
421 "modelUuid":"${modelUuid}",
424 execution.setVariable("serviceModelInfo", serviceModelInfo)
425 execution.setVariable("serviceInstanceId", "")
426 logger.debug("serviceModelInfo : "+serviceModelInfo)
428 execution.setVariable("currentIndex", currentIndex)
430 logger.error("nsstList decomposition error ")
431 exceptionUtil.buildAndThrowWorkflowException(execution, 1000, "nsstList decomposition error ")
435 def processNsstDecomposition = { DelegateExecution execution ->
436 logger.debug(Prefix+"processNsstDecomposition method start")
437 ServiceDecomposition decomposedNsst = execution.getVariable("nsstServiceDecomposition")
438 logger.debug("decomposedNsst : "+decomposedNsst.toString())
440 String nsstType = decomposedNsst.getServiceCategory() //domainType
441 String modelVersion = decomposedNsst.getModelInfo().getModelVersion()
442 String modelName = decomposedNsst.getModelInfo().getModelName()
443 String modelUuid = decomposedNsst.getModelInfo().getModelUuid()
444 String modelInvariantUuid = decomposedNsst.getModelInfo().getModelInvariantUuid()
448 execution.setVariable("ANNF_modelInvariantUuid", modelInvariantUuid)
449 execution.setVariable("ANNF_modelUuid", modelUuid)
450 execution.setVariable("ANNF_modelVersion", modelVersion)
451 execution.setVariable("ANNF_modelName", modelName)
452 execution.setVariable("ANNF_ServiceDecomposition", decomposedNsst)
455 execution.setVariable("TNFH_modelInvariantUuid", modelInvariantUuid)
456 execution.setVariable("TNFH_modelUuid", modelUuid)
457 execution.setVariable("TNFH_modelVersion", modelVersion)
458 execution.setVariable("TNFH_modelName", modelName)
459 execution.setVariable("TNFH_ServiceDecomposition", decomposedNsst)
462 execution.setVariable("TNMH_modelInvariantUuid", modelInvariantUuid)
463 execution.setVariable("TNMH_modelUuid", modelUuid)
464 execution.setVariable("TNMH_modelVersion", modelVersion)
465 execution.setVariable("TNMH_modelName", modelName)
466 execution.setVariable("TNMH_ServiceDecomposition", decomposedNsst)
469 logger.debug("No expected match found for current nsstType")
470 logger.error("No expected match found for current nsstType "+ nsstType)
471 exceptionUtil.buildAndThrowWorkflowException(execution, 1000,"No expected match found for current nsstType "+ nsstType)
473 boolean isAllNsstsDecomposed = false
474 int currentIndex = execution.getVariable("currentIndex")
475 int maxIndex = execution.getVariable("maxIndex")
476 if(currentIndex == maxIndex) {
477 isAllNsstsDecomposed = true
479 execution.setVariable("isAllNsstsDecomposed", isAllNsstsDecomposed)
482 * prepare OOF request for NF RAN NSSI selection
484 def prepareOofRequestForRanNfNSS = { DelegateExecution execution ->
485 logger.debug(Prefix+"prepareOofRequestForRanNfNSS method start")
486 String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
487 logger.debug( "get NSSI option OOF Url: " + urlString)
489 //build oof request body
490 boolean ranNfNssiPreferReuse = execution.getVariable("ranNfNssiPreferReuse");
491 String requestId = execution.getVariable("msoRequestId")
492 String serviceCategory = execution.getVariable("serviceCategory")
493 String messageType = "NSSISelectionResponse"
494 if(execution.getVariable("maxIndex") > 1) {
495 List<String> ranConstituentSliceProfiles = jsonUtil.StringArrayToList(execution.getVariable("RanConstituentSliceProfiles") as String)
496 anNssmfUtils.createDomainWiseSliceProfiles(ranConstituentSliceProfiles, execution)
498 Map<String, Object> profileInfo = objectMapper.readValue(execution.getVariable("ranNfSliceProfile"), Map.class)
499 profileInfo.put("sST",execution.getVariable("sst"))
500 String modelUuid = execution.getVariable("ANNF_modelUuid")
501 String modelInvariantUuid = execution.getVariable("ANNF_modelInvariantUuid")
502 String modelName = execution.getVariable("ANNF_modelName")
503 String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution);
505 execution.setVariable("nssiSelection_Url", "/api/oof/selection/nssi/v1")
506 execution.setVariable("nssiSelection_messageType",messageType)
507 execution.setVariable("nssiSelection_correlator",requestId)
508 execution.setVariable("nssiSelection_timeout",timeout)
510 String oofRequest = oofUtils.buildSelectNSSIRequest(requestId, messageType, modelUuid, modelInvariantUuid, modelName, profileInfo)
512 execution.setVariable("nssiSelection_oofRequest",oofRequest)
515 * process OOF response for RAN NF NSSI selection
517 def processOofResponseForRanNfNSS = { DelegateExecution execution ->
518 logger.debug(Prefix+"processOofResponseForRanNfNSS method start")
519 String oofResponse = execution.getVariable("nfNssiSelection_asyncCallbackResponse")
520 String requestStatus = jsonUtil.getJsonValue(oofResponse, "requestStatus")
521 if(requestStatus.equals("completed")) {
522 String solutions = jsonUtil.getJsonValue(oofResponse, "solutions")
523 logger.debug("nssi solutions value : "+solutions)
524 JsonParser parser = new JsonParser()
525 JsonArray solution = parser.parse(solutions)
526 if(solution.size()>=1) {
527 JsonObject sol = solution.get(0)
528 String ranNfNssiId = sol.get("NSSIId").getAsString()
529 String invariantUuid = sol.get("invariantUUID").getAsString()
530 String uuid = sol.get("UUID").getAsString()
531 String nssiName = sol.get("NSSIName").getAsString()
532 execution.setVariable("RANNFServiceInstanceId", ranNfNssiId)
533 execution.setVariable("RANNFInvariantUUID", invariantUuid)
534 execution.setVariable("RANNFUUID", uuid)
535 execution.setVariable("RANNFNssiName", nssiName)
536 logger.debug("RANNFServiceInstanceId from OOF "+ranNfNssiId)
538 ServiceInstance serviceInstance = new ServiceInstance();
539 serviceInstance.setInstanceId(ranNfNssiId);
540 ServiceDecomposition serviceDecomposition = execution.getVariable("ANNF_ServiceDecomposition")
541 serviceDecomposition.setServiceInstance(serviceInstance);
542 execution.setVariable("ANNF_ServiceDecomposition", serviceDecomposition)
543 execution.setVariable("modifyAction","allocate")
544 execution.setVariable("isRspRanNfNssi", true)
546 logger.debug("No solutions returned from OOF .. Create new RAN NF NSSI")
549 String statusMessage = jsonUtil.getJsonValue(oofResponse, "statusMessage")
550 logger.error("received failed status from oof "+ statusMessage)
551 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a failed Async Response from OOF : "+statusMessage)
555 def createSliceProfilesInAai = { DelegateExecution execution ->
556 logger.debug(Prefix+"createSliceProfilesInAai method start")
557 anNssmfUtils.createSliceProfilesInAai(execution)
560 def processRanNfModifyRsp = { DelegateExecution execution ->
561 logger.debug(Prefix+"processRanNfModifyRsp method start")
562 anNssmfUtils.processRanNfModifyRsp(execution)
564 org.onap.aai.domain.yang.ServiceInstance ANServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
565 //AN instance creation
566 ANServiceInstance.setServiceInstanceId(execution.getVariable("RANServiceInstanceId"))
567 String sliceInstanceName = execution.getVariable("servicename")
568 ANServiceInstance.setServiceInstanceName(sliceInstanceName)
569 String serviceType = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "sST")
570 ANServiceInstance.setServiceType(execution.getVariable("sst"))
571 String serviceStatus = "deactivated"
572 ANServiceInstance.setOrchestrationStatus(serviceStatus)
573 String serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "pLMNIdList")
574 ANServiceInstance.setServiceInstanceLocationId(jsonUtil.StringArrayToList(serviceInstanceLocationid).get(0))
575 String serviceRole = "nssi"
576 ANServiceInstance.setServiceRole(serviceRole)
577 List<String> snssaiList = execution.getVariable("snssaiList")
578 String snssai = snssaiList.get(0)
579 //ANServiceInstance.setEnvironmentContext(snssai)
580 ANServiceInstance.setEnvironmentContext(execution.getVariable("networkType")) //Network Type
581 ANServiceInstance.setWorkloadContext("AN") //domain Type
583 logger.debug("completed AN service instance build "+ ANServiceInstance.toString())
587 AAIResourcesClient client = new AAIResourcesClient()
588 AAIResourceUri nssiServiceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(execution.getVariable("RANServiceInstanceId")))
589 client.create(nssiServiceUri, ANServiceInstance)
591 } catch (BpmnError e) {
593 } catch (Exception ex) {
594 msg = "Exception in AnNssmfUtils.createSliceProfilesInAai " + ex.getMessage()
596 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
599 createEndPointsInAai(execution)
602 def createSdnrRequest = { DelegateExecution execution ->
603 logger.debug(Prefix+"createSdnrRequest method start")
604 String callbackUrl = UrnPropertiesReader.getVariable("mso.workflow.message.endpoint") + "/AsyncSdnrResponse/"+execution.getVariable("msoRequestId")
605 String sdnrRequest = buildSdnrAllocateRequest(execution, "allocate", "instantiateRANSlice", callbackUrl)
606 execution.setVariable("createNSSI_sdnrRequest", sdnrRequest)
607 execution.setVariable("createNSSI_timeout", "PT10M")
608 execution.setVariable("createNSSI_correlator", execution.getVariable("msoRequestId"))
609 execution.setVariable("createNSSI_messageType", "AsyncSdnrResponse");
612 def processSdnrResponse = { DelegateExecution execution ->
613 logger.debug(Prefix+"processSdnrResponse method start")
614 String SDNRResponse = execution.getVariable("SDNR_asyncCallbackResponse")
615 String status = jsonUtil.getJsonValue(SDNRResponse, "status")
616 if(status.equalsIgnoreCase("success")) {
617 String nfIds = jsonUtil.getJsonValue(SDNRResponse, "nfIds")
618 execution.setVariable("ranNfIdsJson", nfIds)
620 String reason = jsonUtil.getJsonValue(SDNRResponse, "reason")
621 logger.error("received failed status from SDNR "+ reason)
622 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from SDNR "+ reason)
624 logger.debug("response from SDNR "+SDNRResponse)
627 def updateAaiWithRANInstances = { DelegateExecution execution ->
628 logger.debug(Prefix+"updateAaiWithRANInstances method start")
630 org.onap.aai.domain.yang.ServiceInstance ANServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
631 org.onap.aai.domain.yang.ServiceInstance ANNFServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
632 String serviceCategory = execution.getVariable("serviceCategory")
633 String serviceStatus = "deactivated"
634 String serviceRole = "nssi"
635 //AN instance creation
636 ANServiceInstance.setServiceInstanceId(execution.getVariable("RANServiceInstanceId") as String)
637 String sliceInstanceName = execution.getVariable("servicename")
638 ANServiceInstance.setServiceInstanceName(sliceInstanceName)
639 ANServiceInstance.setServiceType(execution.getVariable("sst") as String)
640 ANServiceInstance.setOrchestrationStatus(serviceStatus)
641 String serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "pLMNIdList") as String
642 ANServiceInstance.setServiceInstanceLocationId(serviceInstanceLocationid)
643 ANServiceInstance.setServiceRole(serviceRole)
644 List<String> snssaiList = jsonUtil.StringArrayToList(execution.getVariable("snssaiList") as String)
645 String snssai = snssaiList.get(0)
646 ANServiceInstance.setEnvironmentContext(snssai)
647 String modelInvariantUuid = execution.getVariable("modelInvariantUuid")
648 String modelUuid = execution.getVariable("modelUuid") as String
649 ANServiceInstance.setModelInvariantId(modelInvariantUuid)
650 ANServiceInstance.setModelVersionId(modelUuid)
651 ANServiceInstance.setWorkloadContext("AN")
652 String serviceFunctionAn = jsonUtil.getJsonValue(execution.getVariable("sliceProfile") as String, "resourceSharingLevel")
653 ANServiceInstance.setServiceFunction(serviceFunctionAn)
654 logger.debug("completed AN service instance build " + ANServiceInstance.toString())
656 ANNFServiceInstance.setServiceInstanceId(execution.getVariable("RANNFServiceInstanceId") as String)
657 String ANNF_nssiInstanceId = UUID.randomUUID().toString()
658 sliceInstanceName = "nssi_an_nf_" + ANNF_nssiInstanceId
659 ANNFServiceInstance.setServiceInstanceName(sliceInstanceName)
660 ANNFServiceInstance.setServiceType(execution.getVariable("sst") as String)
661 ANNFServiceInstance.setOrchestrationStatus(serviceStatus)
662 serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile") as String, "pLMNIdList")
663 ANNFServiceInstance.setServiceInstanceLocationId(jsonUtil.StringArrayToList(serviceInstanceLocationid).get(0))
664 ANNFServiceInstance.setServiceRole(serviceRole)
665 snssaiList = jsonUtil.StringArrayToList(execution.getVariable("snssaiList") as String)
666 snssai = snssaiList.get(0)
667 ANNFServiceInstance.setEnvironmentContext(execution.getVariable("networkType") as String)
668 ANNFServiceInstance.setModelInvariantId(execution.getVariable("ANNF_modelInvariantUuid"))
669 ANNFServiceInstance.setModelVersionId(execution.getVariable("ANNF_modelUuid"))
670 ANNFServiceInstance.setWorkloadContext("AN_NF")
671 String serviceFunctionAnnf = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile") as String, "resourceSharingLevel")
672 ANNFServiceInstance.setServiceFunction(serviceFunctionAnnf)
673 logger.debug("completed AN service instance build "+ ANNFServiceInstance.toString())
678 AAIResourcesClient client = new AAIResourcesClient()
679 AAIResourceUri nssiServiceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId") as String).serviceSubscription(execution.getVariable("subscriptionServiceType") as String).serviceInstance(execution.getVariable("RANServiceInstanceId") as String))
680 client.create(nssiServiceUri, ANServiceInstance)
682 AAIResourceUri nssiServiceUri1 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId") as String).serviceSubscription(execution.getVariable("subscriptionServiceType") as String).serviceInstance(execution.getVariable("RANNFServiceInstanceId") as String))
683 client.create(nssiServiceUri1, ANNFServiceInstance)
685 } catch (BpmnError e) {
687 } catch (Exception ex) {
688 msg = "Exception in AnNssmfUtils.createSliceProfilesInAai " + ex.getMessage()
690 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
693 if (!execution.getVariable("IsRANNfAlonePresent")) {
694 createEndPointsInAai(execution)
697 def prepareTnFhRequest = { DelegateExecution execution ->
698 logger.debug(Prefix+"prepareTnFhRequest method start")
700 String nssmfRequest = anNssmfUtils.buildCreateNSSMFRequest(execution, "TN_FH", "allocate")
701 String urlString = "/api/rest/provMns/v1/NSS/SliceProfiles"
702 String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest)
704 if (nssmfResponse != null) {
705 execution.setVariable("nssmfResponse", nssmfResponse)
706 String jobId = jsonUtil.getJsonValue(nssmfResponse, "jobId")
707 execution.setVariable("TNFH_jobId",jobId)
709 logger.error("received error message from NSSMF : "+ nssmfResponse)
710 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.")
712 logger.debug("Exit prepareTnFhRequest")
715 def prepareTnMhRequest = { DelegateExecution execution ->
716 logger.debug(Prefix+"prepareTnMhRequest method start")
718 String nssmfRequest = anNssmfUtils.buildCreateNSSMFRequest(execution, "TN_MH", "allocate")
719 String urlString = "/api/rest/provMns/v1/NSS/SliceProfiles"
720 String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest)
722 if (nssmfResponse != null) {
723 execution.setVariable("nssmfResponse", nssmfResponse)
724 String jobId = jsonUtil.getJsonValue(nssmfResponse, "jobId")
725 execution.setVariable("TNMH_jobId",jobId)
727 logger.error("received error message from NSSMF : "+ nssmfResponse)
728 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.")
730 logger.debug("Exit prepareTnMhRequest")
733 def createFhAllocateNssiJobQuery = { DelegateExecution execution ->
734 logger.debug(Prefix+"createFhAllocateNssiJobQuery method start")
735 createTnAllocateNssiJobQuery(execution, "TN_FH")
738 def createMhAllocateNssiJobQuery = { DelegateExecution execution ->
739 logger.debug(Prefix+"createMhAllocateNssiJobQuery method start")
740 createTnAllocateNssiJobQuery(execution, "TN_MH")
743 private void createTnAllocateNssiJobQuery(DelegateExecution execution, String domainType) {
744 JsonObject esrInfo = new JsonObject()
745 esrInfo.addProperty("networkType", "tn")
746 esrInfo.addProperty("vendor", "ONAP_internal")
747 execution.setVariable("esrInfo", esrInfo.toString())
748 JsonObject serviceInfo = new JsonObject()
749 serviceInfo.addProperty("nsiId", execution.getVariable("nsiId"))
750 serviceInfo.addProperty("sST", execution.getVariable("sst"))
751 serviceInfo.addProperty("PLMNIdList", objectMapper.writeValueAsString(execution.getVariable("pLMNIdList")))
752 serviceInfo.addProperty("globalSubscriberId", execution.getVariable("globalSubscriberId"))
753 serviceInfo.addProperty("subscriptionServiceType", execution.getVariable("subscriptionServiceType"))
754 if(domainType.equals("TN_FH")) {
755 serviceInfo.addProperty("nssiName", execution.getVariable("TNFH_modelName"))
756 serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("TNFH_modelInvariantUuid"))
757 serviceInfo.addProperty("serviceUuid", execution.getVariable("TNFH_modelUuid"))
758 }else if(domainType.equals("TN_MH")) {
759 serviceInfo.addProperty("nssiName", execution.getVariable("TNMH_modelName"))
760 serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("TNMH_modelInvariantUuid"))
761 serviceInfo.addProperty("serviceUuid", execution.getVariable("TNMH_modelUuid"))
763 execution.setVariable("serviceInfo", serviceInfo.toString())
764 execution.setVariable("responseId", "")
767 def processFhAllocateNssiJobStatusRsp = { DelegateExecution execution ->
768 logger.debug(Prefix+"processJobStatusRsp method start")
769 String jobResponse = execution.getVariable("TNFH_jobResponse")
770 logger.debug("Job status response "+jobResponse)
771 String status = jsonUtil.getJsonValue(jobResponse, "status")
772 String nssi = jsonUtil.getJsonValue(jobResponse, "nssiId")
773 if(status.equalsIgnoreCase("finished")) {
774 execution.setVariable("TNFH_NSSI", nssi)
775 logger.debug("Job successfully completed ... proceeding with flow for nssi : "+nssi)
778 String statusDescription = jsonUtil.getJsonValue(jobResponse, "statusDescription")
779 logger.error("received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
780 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
784 def processMhAllocateNssiJobStatusRsp = { DelegateExecution execution ->
785 logger.debug(Prefix+"processJobStatusRsp method start")
786 String jobResponse = execution.getVariable("TNMH_jobResponse")
787 logger.debug("Job status response "+jobResponse)
788 String status = jsonUtil.getJsonValue(jobResponse, "status")
789 String nssi = jsonUtil.getJsonValue(jobResponse, "nssiId")
790 if(status.equalsIgnoreCase("finished")) {
791 execution.setVariable("TNMH_NSSI", nssi)
792 logger.debug("Job successfully completed ... proceeding with flow for nssi : "+nssi)
795 String statusDescription = jsonUtil.getJsonValue(jobResponse, "statusDescription")
796 logger.error("received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
797 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
801 def processModifyJobStatusRsp = { DelegateExecution execution ->
802 logger.debug(Prefix+"processJobStatusRsp method start")
803 String jobResponse = execution.getVariable("jobResponse")
804 logger.debug("Job status response "+jobResponse)
805 String status = jsonUtil.getJsonValue(jobResponse, "status")
806 String nssi = jsonUtil.getJsonValue(jobResponse, "nssiId")
807 if(status.equalsIgnoreCase("finished")) {
808 logger.debug("Job successfully completed ... proceeding with flow for nssi : "+nssi)
811 String statusDescription = jsonUtil.getJsonValue(jobResponse, "statusDescription")
812 logger.error("received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
813 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
817 def updateAairelationships = { DelegateExecution execution ->
818 logger.debug(Prefix + "updateAairelationships Start")
819 String serviceCategory = execution.getVariable("serviceCategory")
821 if (execution.getVariable("IsRANNfAlonePresent")) {
823 def ANNF_serviceInstanceId = execution.getVariable("RANNFServiceInstanceId")
824 def AN_profileInstanceId = execution.getVariable("sliceProfileId")
825 def AN_NSSI = execution.getVariable("RANServiceInstanceId")
826 def ANNF_profileInstanceId = execution.getVariable("ANNF_sliceProfileInstanceId")
827 String globalSubscriberId = execution.getVariable("globalSubscriberId")
828 String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
830 Relationship ANNF_relationship = new Relationship()
831 String ANNF_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${ANNF_profileInstanceId}"
832 String ANNF_NSSI_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${ANNF_serviceInstanceId}"
833 ANNF_relationship.setRelatedLink(ANNF_relatedLink)
834 ANNF_relationship.setRelatedTo("service-instance")
835 ANNF_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
836 anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship, ANNF_serviceInstanceId)
837 anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship, AN_profileInstanceId)
838 ANNF_relationship.setRelatedLink(ANNF_NSSI_relatedLink)
839 anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship, AN_NSSI)
841 } catch (BpmnError e) {
843 } catch (Exception ex) {
845 msg = "Exception in DoCreateE2EServiceInstance.createCustomRelationship. " + ex.getMessage()
847 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
852 def ANNF_serviceInstanceId = execution.getVariable("RANNFServiceInstanceId")
853 def TNFH_serviceInstanceId = execution.getVariable("TNFH_NSSI")
854 def TNMH_serviceInstanceId = execution.getVariable("TNMH_NSSI")
855 def AN_profileInstanceId = execution.getVariable("sliceProfileId")
856 def AN_NSSI = execution.getVariable("RANServiceInstanceId")
857 def ANNF_profileInstanceId = execution.getVariable("ANNF_sliceProfileInstanceId")
858 def TNFH_profileInstanceId = execution.getVariable("TNFH_sliceProfileInstanceId")
859 def TNMH_profileInstanceId = execution.getVariable("TNMH_sliceProfileInstanceId")
860 String globalSubscriberId = execution.getVariable("globalSubscriberId")
861 String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
863 Relationship ANNF_relationship = new Relationship()
864 Relationship TNFH_relationship = new Relationship()
865 Relationship TNMH_relationship = new Relationship()
867 String ANNF_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${ANNF_profileInstanceId}"
868 String TNFH_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNFH_profileInstanceId}"
869 String TNMH_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNMH_profileInstanceId}"
871 String ANNF_NSSI_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${ANNF_serviceInstanceId}"
872 String TNFH_NSSI_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNFH_serviceInstanceId}"
873 String TNMH_NSSI_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNMH_serviceInstanceId}"
875 ANNF_relationship.setRelatedLink(ANNF_relatedLink)
876 ANNF_relationship.setRelatedTo("service-instance")
877 ANNF_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
878 TNFH_relationship.setRelatedLink(TNFH_relatedLink)
879 TNFH_relationship.setRelatedTo("service-instance")
880 TNFH_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
881 TNMH_relationship.setRelatedLink(TNMH_relatedLink)
882 TNMH_relationship.setRelatedTo("service-instance")
883 TNMH_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
885 // create SliceProfile and NSSI relationship in AAI
886 anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship, ANNF_serviceInstanceId)
887 anNssmfUtils.createRelationShipInAAI(execution, TNFH_relationship, TNFH_serviceInstanceId)
888 anNssmfUtils.createRelationShipInAAI(execution, TNMH_relationship, TNMH_serviceInstanceId)
889 anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship, AN_profileInstanceId)
890 anNssmfUtils.createRelationShipInAAI(execution, TNFH_relationship, AN_profileInstanceId)
891 anNssmfUtils.createRelationShipInAAI(execution, TNMH_relationship, AN_profileInstanceId)
893 //create AN NSSI and ANNF,TNFH,TNMH relationship in AAI
894 ANNF_relationship.setRelatedLink(ANNF_NSSI_relatedLink)
895 TNFH_relationship.setRelatedLink(TNFH_NSSI_relatedLink)
896 TNMH_relationship.setRelatedLink(TNMH_NSSI_relatedLink)
897 anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship, AN_NSSI)
898 anNssmfUtils.createRelationShipInAAI(execution, TNFH_relationship, AN_NSSI)
899 anNssmfUtils.createRelationShipInAAI(execution, TNMH_relationship, AN_NSSI)
901 } catch (BpmnError e) {
903 } catch (Exception ex) {
905 msg = "Exception in DoCreateE2EServiceInstance.createCustomRelationship. " + ex.getMessage()
907 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
913 * update operation status in request db
916 def prepareOperationStatusUpdate = { DelegateExecution execution ->
917 logger.debug(Prefix + "prepareOperationStatusUpdate Start")
919 String jobId = execution.getVariable("jobId")
920 String nsiId = execution.getVariable("nsiId")
921 String modelUuid = execution.getVariable("modelUuid")
922 String nssiId = execution.getVariable("RANServiceInstanceId")
923 logger.debug("Service Instance serviceId:" + nsiId + " jobId:" + jobId)
925 ResourceOperationStatus updateStatus = new ResourceOperationStatus()
926 updateStatus.setServiceId(nsiId)
927 updateStatus.setOperationId(jobId)
928 updateStatus.setResourceTemplateUUID(modelUuid)
929 updateStatus.setResourceInstanceID(nssiId)
930 updateStatus.setOperType("Allocate")
931 updateStatus.setProgress("100")
932 updateStatus.setStatus("finished")
933 requestDBUtil.prepareUpdateResourceOperationStatus(execution, updateStatus)
935 logger.debug(Prefix + "prepareOperationStatusUpdate Exit")
938 def prepareFailedOperationStatusUpdate = { DelegateExecution execution ->
939 logger.debug(Prefix + "prepareFailedOperationStatusUpdate Start")
941 String jobId = execution.getVariable("jobId")
942 String nsiId = execution.getVariable("nsiId")
943 String modelUuid = execution.getVariable("modelUuid")
944 String nssiId = execution.getVariable("RANServiceInstanceId")
945 logger.debug("Service Instance serviceId:" + nsiId + " jobId:" + jobId)
947 ResourceOperationStatus updateStatus = new ResourceOperationStatus()
948 updateStatus.setServiceId(nsiId)
949 updateStatus.setOperationId(jobId)
950 updateStatus.setResourceTemplateUUID(modelUuid)
951 updateStatus.setResourceInstanceID(nssiId)
952 updateStatus.setOperType("Allocate")
953 updateStatus.setProgress("0")
954 updateStatus.setStatus("failed")
955 requestDBUtil.prepareUpdateResourceOperationStatus(execution, updateStatus)
958 private String buildSdnrAllocateRequest(DelegateExecution execution, String action, String rpcName, String callbackUrl) {
960 String requestId = execution.getVariable("msoRequestId")
961 Map<String,Object> sliceProfile = objectMapper.readValue(execution.getVariable("ranNfSliceProfile"), Map.class)
962 sliceProfile.put("sliceProfileId", execution.getVariable("ANNF_sliceProfileInstanceId"))
963 sliceProfile.put("maxNumberofConns", sliceProfile.get("maxNumberofPDUSession"))
964 sliceProfile.put("uLThptPerSlice", sliceProfile.get("expDataRateUL"))
965 sliceProfile.put("dLThptPerSlice", sliceProfile.get("expDataRateDL"))
967 JsonObject response = new JsonObject()
968 JsonObject body = new JsonObject()
969 JsonObject input = new JsonObject()
970 JsonObject commonHeader = new JsonObject()
971 JsonObject payload = new JsonObject()
972 JsonObject payloadInput = new JsonObject()
973 commonHeader.addProperty("timestamp",new Date(System.currentTimeMillis()).format("yyyy-MM-dd'T'HH:mm:ss.sss'Z'", TimeZone.getDefault()))
974 commonHeader.addProperty("api-ver", "1.0")
975 commonHeader.addProperty("originator-id", "testing")
976 commonHeader.addProperty("request-id", requestId)
977 commonHeader.addProperty("sub-request-id", "1")
978 commonHeader.add("flags", new JsonObject())
979 Gson jsonConverter = new Gson()
980 payloadInput.add("sliceProfile", jsonConverter.toJsonTree(sliceProfile))
981 payloadInput.addProperty("RANNSSIId", execution.getVariable("RANServiceInstanceId"))
982 payloadInput.addProperty("NSIID", execution.getVariable("nsiId"))
983 payloadInput.addProperty("RANNFNSSIId", execution.getVariable("RANNFServiceInstanceId"))
984 payloadInput.addProperty("callbackURL", callbackUrl)
985 payloadInput.addProperty("globalSubscriberId", execution.getVariable("globalSubscriberId"))
986 payloadInput.addProperty("subscriptionServiceType", execution.getVariable("subscriptionServiceType"))
987 payloadInput.add("additionalproperties", new JsonObject())
988 payload.add("input", payloadInput)
989 input.add("common-header", commonHeader)
990 input.addProperty("action", action)
991 input.addProperty("payload", payload.toString())
992 body.add("input", input)
993 response.add("body", body)
994 response.addProperty("version", "1.0")
995 response.addProperty("rpc-name", rpcName)
996 response.addProperty("correlation-id", (requestId+"-1"))
997 response.addProperty("type", "request")
998 return response.toString()
1001 private void createEndPointsInAai(DelegateExecution execution) {
1002 String type = "endpoint"
1003 String function = "transport_EP"
1004 int prefixLength = 24
1005 String addressFamily = "ipv4"
1006 //BH RAN end point update
1007 String bh_endpoint = execution.getVariable("bh_endpoint")
1008 String bh_routeId = UUID.randomUUID().toString()
1009 execution.setVariable("tranportEp_ID_bh", bh_routeId)
1011 String CU_IpAddress = jsonUtil.getJsonValue(bh_endpoint, "ipAddress")
1012 String LogicalLinkId = jsonUtil.getJsonValue(bh_endpoint, "logicInterfaceId")
1013 String nextHopInfo = jsonUtil.getJsonValue(bh_endpoint, "nextHopInfo")
1014 NetworkRoute bh_ep = new NetworkRoute()
1015 bh_ep.setRouteId(bh_routeId)
1016 bh_ep.setFunction(function)
1019 bh_ep.setIpAddress(CU_IpAddress)
1020 bh_ep.setLogicalInterfaceId(LogicalLinkId)
1021 bh_ep.setNextHop(nextHopInfo)
1022 bh_ep.setPrefixLength(prefixLength)
1023 bh_ep.setAddressFamily(addressFamily)
1024 //FH RAN end points update
1026 String RU_routeId = UUID.randomUUID().toString()
1027 execution.setVariable("tranportEp_ID_RU", RU_routeId)
1029 NetworkRoute RU_ep = new NetworkRoute()
1030 RU_ep.setRouteId(RU_routeId)
1031 RU_ep.setFunction(function)
1034 RU_ep.setIpAddress("192.168.100.4")
1035 RU_ep.setLogicalInterfaceId("1234")
1036 RU_ep.setNextHop("Host1")
1037 RU_ep.setPrefixLength(prefixLength)
1038 RU_ep.setAddressFamily(addressFamily)
1040 String DUIN_routeId = UUID.randomUUID().toString()
1041 execution.setVariable("tranportEp_ID_DUIN", DUIN_routeId)
1043 NetworkRoute DU_ep = new NetworkRoute()
1044 DU_ep.setRouteId(DUIN_routeId)
1045 DU_ep.setFunction(function)
1048 DU_ep.setIpAddress("192.168.100.5")
1049 DU_ep.setLogicalInterfaceId("1234")
1050 DU_ep.setNextHop("Host2")
1051 DU_ep.setPrefixLength(prefixLength)
1052 DU_ep.setAddressFamily(addressFamily)
1053 //MH RAN end point update
1055 String DUEG_routeId = UUID.randomUUID().toString()
1056 execution.setVariable("tranportEp_ID_DUEG", DUEG_routeId)
1057 NetworkRoute DUEG_ep = new NetworkRoute()
1058 DUEG_ep.setRouteId(DUEG_routeId)
1059 DUEG_ep.setFunction(function)
1060 DUEG_ep.setRole(role)
1061 DUEG_ep.setType(type)
1062 DUEG_ep.setIpAddress("192.168.100.5")
1063 DUEG_ep.setLogicalInterfaceId("1234")
1064 DUEG_ep.setPrefixLength(prefixLength)
1065 DUEG_ep.setAddressFamily(addressFamily)
1066 DUEG_ep.setNextHop("Host3")
1068 String CUIN_routeId = UUID.randomUUID().toString()
1069 execution.setVariable("tranportEp_ID_CUIN", CUIN_routeId)
1070 NetworkRoute CUIN_ep = new NetworkRoute()
1071 CUIN_ep.setRouteId(CUIN_routeId)
1072 CUIN_ep.setFunction(function)
1073 CUIN_ep.setRole(role)
1074 CUIN_ep.setType(type)
1075 CUIN_ep.setIpAddress("192.168.100.6")
1076 CUIN_ep.setLogicalInterfaceId("1234")
1077 CUIN_ep.setNextHop("Host4")
1078 CUIN_ep.setPrefixLength(prefixLength)
1079 CUIN_ep.setAddressFamily(addressFamily)
1081 AAIResourcesClient client = new AAIResourcesClient()
1082 logger.debug("creating bh endpoint . ID : "+bh_routeId+" node details : "+bh_ep.toString())
1083 AAIResourceUri networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), bh_routeId)
1084 client.create(networkRouteUri, bh_ep)
1085 logger.debug("creating RU endpoint . ID : "+RU_routeId+" node details : "+RU_ep.toString())
1086 networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), RU_routeId)
1087 client.create(networkRouteUri, RU_ep)
1088 logger.debug("creating DUIN endpoint . ID : "+DUIN_routeId+" node details : "+DU_ep.toString())
1089 networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), DUIN_routeId)
1090 client.create(networkRouteUri, DU_ep)
1091 logger.debug("creating DUEG endpoint . ID : "+DUEG_routeId+" node details : "+DUEG_ep.toString())
1092 networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), DUEG_routeId)
1093 client.create(networkRouteUri, DUEG_ep)
1094 logger.debug("creating CUIN endpoint . ID : "+CUIN_routeId+" node details : "+CUIN_ep.toString())
1095 networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), CUIN_routeId)
1096 client.create(networkRouteUri, CUIN_ep)
1097 //relationship b/w bh_ep and RAN NSSI
1098 def AN_NSSI = execution.getVariable("RANServiceInstanceId")
1099 Relationship relationship = new Relationship()
1100 String relatedLink = "aai/v21/network/network-routes/network-route/${bh_routeId}"
1101 relationship.setRelatedLink(relatedLink)
1102 relationship.setRelatedTo("network-route")
1103 relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
1104 anNssmfUtils.createRelationShipInAAI(execution, relationship, AN_NSSI)
1105 def ANNF_serviceInstanceId = execution.getVariable("RANNFServiceInstanceId")
1106 relatedLink = "aai/v21/network/network-routes/network-route/${RU_routeId}"
1107 relationship.setRelatedLink(relatedLink)
1108 anNssmfUtils.createRelationShipInAAI(execution, relationship, ANNF_serviceInstanceId)
1109 relatedLink = "aai/v21/network/network-routes/network-route/${DUIN_routeId}"
1110 relationship.setRelatedLink(relatedLink)
1111 anNssmfUtils.createRelationShipInAAI(execution, relationship, ANNF_serviceInstanceId)
1112 relatedLink = "aai/v21/network/network-routes/network-route/${DUEG_routeId}"
1113 relationship.setRelatedLink(relatedLink)
1114 anNssmfUtils.createRelationShipInAAI(execution, relationship, ANNF_serviceInstanceId)
1115 relatedLink = "aai/v21/network/network-routes/network-route/${CUIN_routeId}"
1116 relationship.setRelatedLink(relatedLink)
1117 anNssmfUtils.createRelationShipInAAI(execution, relationship, ANNF_serviceInstanceId)
1118 } catch (BpmnError e) {
1120 } catch (Exception ex) {
1121 String msg = "Exception in createEndPointsInAai " + ex.getMessage()
1123 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)