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 sliceInstanceName = "nssi_"+execution.getVariable("ANNF_modelName")
658 ANNFServiceInstance.setServiceInstanceName(sliceInstanceName)
659 ANNFServiceInstance.setServiceType(execution.getVariable("sst") as String)
660 ANNFServiceInstance.setOrchestrationStatus(serviceStatus)
661 serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile") as String, "pLMNIdList")
662 ANNFServiceInstance.setServiceInstanceLocationId(jsonUtil.StringArrayToList(serviceInstanceLocationid).get(0))
663 ANNFServiceInstance.setServiceRole(serviceRole)
664 snssaiList = jsonUtil.StringArrayToList(execution.getVariable("snssaiList") as String)
665 snssai = snssaiList.get(0)
666 ANNFServiceInstance.setEnvironmentContext(snssai)
667 ANNFServiceInstance.setModelInvariantId(execution.getVariable("ANNF_modelInvariantUuid"))
668 ANNFServiceInstance.setModelVersionId(execution.getVariable("ANNF_modelUuid"))
669 ANNFServiceInstance.setWorkloadContext("AN_NF")
670 String serviceFunctionAnnf = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile") as String, "resourceSharingLevel")
671 ANNFServiceInstance.setServiceFunction(serviceFunctionAnnf)
672 logger.debug("completed AN service instance build "+ ANNFServiceInstance.toString())
677 AAIResourcesClient client = new AAIResourcesClient()
678 AAIResourceUri nssiServiceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId") as String).serviceSubscription(execution.getVariable("subscriptionServiceType") as String).serviceInstance(execution.getVariable("RANServiceInstanceId") as String))
679 client.create(nssiServiceUri, ANServiceInstance)
681 AAIResourceUri nssiServiceUri1 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId") as String).serviceSubscription(execution.getVariable("subscriptionServiceType") as String).serviceInstance(execution.getVariable("RANNFServiceInstanceId") as String))
682 client.create(nssiServiceUri1, ANNFServiceInstance)
684 } catch (BpmnError e) {
686 } catch (Exception ex) {
687 msg = "Exception in AnNssmfUtils.createSliceProfilesInAai " + ex.getMessage()
689 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
692 if (!execution.getVariable("IsRANNfAlonePresent")) {
693 createEndPointsInAai(execution)
696 def prepareTnFhRequest = { DelegateExecution execution ->
697 logger.debug(Prefix+"prepareTnFhRequest method start")
699 String nssmfRequest = anNssmfUtils.buildCreateNSSMFRequest(execution, "TN_FH", "allocate")
700 String urlString = "/api/rest/provMns/v1/NSS/SliceProfiles"
701 String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest)
703 if (nssmfResponse != null) {
704 execution.setVariable("nssmfResponse", nssmfResponse)
705 String jobId = jsonUtil.getJsonValue(nssmfResponse, "jobId")
706 execution.setVariable("TNFH_jobId",jobId)
708 logger.error("received error message from NSSMF : "+ nssmfResponse)
709 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.")
711 logger.debug("Exit prepareTnFhRequest")
714 def prepareTnMhRequest = { DelegateExecution execution ->
715 logger.debug(Prefix+"prepareTnMhRequest method start")
717 String nssmfRequest = anNssmfUtils.buildCreateNSSMFRequest(execution, "TN_MH", "allocate")
718 String urlString = "/api/rest/provMns/v1/NSS/SliceProfiles"
719 String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest)
721 if (nssmfResponse != null) {
722 execution.setVariable("nssmfResponse", nssmfResponse)
723 String jobId = jsonUtil.getJsonValue(nssmfResponse, "jobId")
724 execution.setVariable("TNMH_jobId",jobId)
726 logger.error("received error message from NSSMF : "+ nssmfResponse)
727 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.")
729 logger.debug("Exit prepareTnMhRequest")
732 def createFhAllocateNssiJobQuery = { DelegateExecution execution ->
733 logger.debug(Prefix+"createFhAllocateNssiJobQuery method start")
734 createTnAllocateNssiJobQuery(execution, "TN_FH")
737 def createMhAllocateNssiJobQuery = { DelegateExecution execution ->
738 logger.debug(Prefix+"createMhAllocateNssiJobQuery method start")
739 createTnAllocateNssiJobQuery(execution, "TN_MH")
742 private void createTnAllocateNssiJobQuery(DelegateExecution execution, String domainType) {
743 JsonObject esrInfo = new JsonObject()
744 esrInfo.addProperty("networkType", "tn")
745 esrInfo.addProperty("vendor", "ONAP_internal")
746 execution.setVariable("esrInfo", esrInfo.toString())
747 JsonObject serviceInfo = new JsonObject()
748 serviceInfo.addProperty("nsiId", execution.getVariable("nsiId"))
749 serviceInfo.addProperty("sST", execution.getVariable("sst"))
750 serviceInfo.addProperty("PLMNIdList", objectMapper.writeValueAsString(execution.getVariable("pLMNIdList")))
751 serviceInfo.addProperty("globalSubscriberId", execution.getVariable("globalSubscriberId"))
752 serviceInfo.addProperty("subscriptionServiceType", execution.getVariable("subscriptionServiceType"))
753 if(domainType.equals("TN_FH")) {
754 serviceInfo.addProperty("nssiName", execution.getVariable("TNFH_modelName"))
755 serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("TNFH_modelInvariantUuid"))
756 serviceInfo.addProperty("serviceUuid", execution.getVariable("TNFH_modelUuid"))
757 }else if(domainType.equals("TN_MH")) {
758 serviceInfo.addProperty("nssiName", execution.getVariable("TNMH_modelName"))
759 serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("TNMH_modelInvariantUuid"))
760 serviceInfo.addProperty("serviceUuid", execution.getVariable("TNMH_modelUuid"))
762 execution.setVariable("serviceInfo", serviceInfo.toString())
763 execution.setVariable("responseId", "")
766 def processFhAllocateNssiJobStatusRsp = { DelegateExecution execution ->
767 logger.debug(Prefix+"processJobStatusRsp method start")
768 String jobResponse = execution.getVariable("TNFH_jobResponse")
769 logger.debug("Job status response "+jobResponse)
770 String status = jsonUtil.getJsonValue(jobResponse, "status")
771 String nssi = jsonUtil.getJsonValue(jobResponse, "nssiId")
772 if(status.equalsIgnoreCase("finished")) {
773 execution.setVariable("TNFH_NSSI", nssi)
774 logger.debug("Job successfully completed ... proceeding with flow for nssi : "+nssi)
777 String statusDescription = jsonUtil.getJsonValue(jobResponse, "statusDescription")
778 logger.error("received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
779 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
783 def processMhAllocateNssiJobStatusRsp = { DelegateExecution execution ->
784 logger.debug(Prefix+"processJobStatusRsp method start")
785 String jobResponse = execution.getVariable("TNMH_jobResponse")
786 logger.debug("Job status response "+jobResponse)
787 String status = jsonUtil.getJsonValue(jobResponse, "status")
788 String nssi = jsonUtil.getJsonValue(jobResponse, "nssiId")
789 if(status.equalsIgnoreCase("finished")) {
790 execution.setVariable("TNMH_NSSI", nssi)
791 logger.debug("Job successfully completed ... proceeding with flow for nssi : "+nssi)
794 String statusDescription = jsonUtil.getJsonValue(jobResponse, "statusDescription")
795 logger.error("received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
796 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
800 def processModifyJobStatusRsp = { DelegateExecution execution ->
801 logger.debug(Prefix+"processJobStatusRsp method start")
802 String jobResponse = execution.getVariable("jobResponse")
803 logger.debug("Job status response "+jobResponse)
804 String status = jsonUtil.getJsonValue(jobResponse, "status")
805 String nssi = jsonUtil.getJsonValue(jobResponse, "nssiId")
806 if(status.equalsIgnoreCase("finished")) {
807 logger.debug("Job successfully completed ... proceeding with flow for nssi : "+nssi)
810 String statusDescription = jsonUtil.getJsonValue(jobResponse, "statusDescription")
811 logger.error("received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
812 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
816 def updateAairelationships = { DelegateExecution execution ->
817 logger.debug(Prefix + "updateAairelationships Start")
818 String serviceCategory = execution.getVariable("serviceCategory")
820 if (execution.getVariable("IsRANNfAlonePresent")) {
822 def ANNF_serviceInstanceId = execution.getVariable("RANNFServiceInstanceId")
823 def AN_profileInstanceId = execution.getVariable("sliceProfileId")
824 def AN_NSSI = execution.getVariable("RANServiceInstanceId")
825 def ANNF_profileInstanceId = execution.getVariable("ANNF_sliceProfileInstanceId")
826 String globalSubscriberId = execution.getVariable("globalSubscriberId")
827 String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
829 Relationship ANNF_relationship = new Relationship()
830 String ANNF_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${ANNF_profileInstanceId}"
831 String ANNF_NSSI_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${ANNF_serviceInstanceId}"
832 ANNF_relationship.setRelatedLink(ANNF_relatedLink)
833 ANNF_relationship.setRelatedTo("service-instance")
834 ANNF_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
835 anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship, ANNF_serviceInstanceId)
836 anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship, AN_profileInstanceId)
837 ANNF_relationship.setRelatedLink(ANNF_NSSI_relatedLink)
838 anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship, AN_NSSI)
840 } catch (BpmnError e) {
842 } catch (Exception ex) {
844 msg = "Exception in DoCreateE2EServiceInstance.createCustomRelationship. " + ex.getMessage()
846 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
851 def ANNF_serviceInstanceId = execution.getVariable("RANNFServiceInstanceId")
852 def TNFH_serviceInstanceId = execution.getVariable("TNFH_NSSI")
853 def TNMH_serviceInstanceId = execution.getVariable("TNMH_NSSI")
854 def AN_profileInstanceId = execution.getVariable("sliceProfileId")
855 def AN_NSSI = execution.getVariable("RANServiceInstanceId")
856 def ANNF_profileInstanceId = execution.getVariable("ANNF_sliceProfileInstanceId")
857 def TNFH_profileInstanceId = execution.getVariable("TNFH_sliceProfileInstanceId")
858 def TNMH_profileInstanceId = execution.getVariable("TNMH_sliceProfileInstanceId")
859 String globalSubscriberId = execution.getVariable("globalSubscriberId")
860 String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
862 Relationship ANNF_relationship = new Relationship()
863 Relationship TNFH_relationship = new Relationship()
864 Relationship TNMH_relationship = new Relationship()
866 String ANNF_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${ANNF_profileInstanceId}"
867 String TNFH_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNFH_profileInstanceId}"
868 String TNMH_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNMH_profileInstanceId}"
870 String ANNF_NSSI_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${ANNF_serviceInstanceId}"
871 String TNFH_NSSI_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNFH_serviceInstanceId}"
872 String TNMH_NSSI_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNMH_serviceInstanceId}"
874 ANNF_relationship.setRelatedLink(ANNF_relatedLink)
875 ANNF_relationship.setRelatedTo("service-instance")
876 ANNF_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
877 TNFH_relationship.setRelatedLink(TNFH_relatedLink)
878 TNFH_relationship.setRelatedTo("service-instance")
879 TNFH_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
880 TNMH_relationship.setRelatedLink(TNMH_relatedLink)
881 TNMH_relationship.setRelatedTo("service-instance")
882 TNMH_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
884 // create SliceProfile and NSSI relationship in AAI
885 anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship, ANNF_serviceInstanceId)
886 anNssmfUtils.createRelationShipInAAI(execution, TNFH_relationship, TNFH_serviceInstanceId)
887 anNssmfUtils.createRelationShipInAAI(execution, TNMH_relationship, TNMH_serviceInstanceId)
888 anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship, AN_profileInstanceId)
889 anNssmfUtils.createRelationShipInAAI(execution, TNFH_relationship, AN_profileInstanceId)
890 anNssmfUtils.createRelationShipInAAI(execution, TNMH_relationship, AN_profileInstanceId)
892 //create AN NSSI and ANNF,TNFH,TNMH relationship in AAI
893 ANNF_relationship.setRelatedLink(ANNF_NSSI_relatedLink)
894 TNFH_relationship.setRelatedLink(TNFH_NSSI_relatedLink)
895 TNMH_relationship.setRelatedLink(TNMH_NSSI_relatedLink)
896 anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship, AN_NSSI)
897 anNssmfUtils.createRelationShipInAAI(execution, TNFH_relationship, AN_NSSI)
898 anNssmfUtils.createRelationShipInAAI(execution, TNMH_relationship, AN_NSSI)
900 } catch (BpmnError e) {
902 } catch (Exception ex) {
904 msg = "Exception in DoCreateE2EServiceInstance.createCustomRelationship. " + ex.getMessage()
906 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
912 * update operation status in request db
915 def prepareOperationStatusUpdate = { DelegateExecution execution ->
916 logger.debug(Prefix + "prepareOperationStatusUpdate Start")
918 String jobId = execution.getVariable("jobId")
919 String nsiId = execution.getVariable("nsiId")
920 String modelUuid = execution.getVariable("modelUuid")
921 String nssiId = execution.getVariable("RANServiceInstanceId")
922 logger.debug("Service Instance serviceId:" + nsiId + " jobId:" + jobId)
924 ResourceOperationStatus updateStatus = new ResourceOperationStatus()
925 updateStatus.setServiceId(nsiId)
926 updateStatus.setOperationId(jobId)
927 updateStatus.setResourceTemplateUUID(modelUuid)
928 updateStatus.setResourceInstanceID(nssiId)
929 updateStatus.setOperType("Allocate")
930 updateStatus.setProgress("100")
931 updateStatus.setStatus("finished")
932 requestDBUtil.prepareUpdateResourceOperationStatus(execution, updateStatus)
934 logger.debug(Prefix + "prepareOperationStatusUpdate Exit")
937 def prepareFailedOperationStatusUpdate = { DelegateExecution execution ->
938 logger.debug(Prefix + "prepareFailedOperationStatusUpdate Start")
940 String jobId = execution.getVariable("jobId")
941 String nsiId = execution.getVariable("nsiId")
942 String modelUuid = execution.getVariable("modelUuid")
943 String nssiId = execution.getVariable("RANServiceInstanceId")
944 logger.debug("Service Instance serviceId:" + nsiId + " jobId:" + jobId)
946 ResourceOperationStatus updateStatus = new ResourceOperationStatus()
947 updateStatus.setServiceId(nsiId)
948 updateStatus.setOperationId(jobId)
949 updateStatus.setResourceTemplateUUID(modelUuid)
950 updateStatus.setResourceInstanceID(nssiId)
951 updateStatus.setOperType("Allocate")
952 updateStatus.setProgress("0")
953 updateStatus.setStatus("failed")
954 requestDBUtil.prepareUpdateResourceOperationStatus(execution, updateStatus)
957 private String buildSdnrAllocateRequest(DelegateExecution execution, String action, String rpcName, String callbackUrl) {
959 String requestId = execution.getVariable("msoRequestId")
960 Map<String,Object> sliceProfile = objectMapper.readValue(execution.getVariable("ranNfSliceProfile"), Map.class)
961 sliceProfile.put("sliceProfileId", execution.getVariable("ANNF_sliceProfileInstanceId"))
962 sliceProfile.put("maxNumberofConns", sliceProfile.get("maxNumberofPDUSession"))
963 sliceProfile.put("uLThptPerSlice", sliceProfile.get("expDataRateUL"))
964 sliceProfile.put("dLThptPerSlice", sliceProfile.get("expDataRateDL"))
966 JsonObject response = new JsonObject()
967 JsonObject body = new JsonObject()
968 JsonObject input = new JsonObject()
969 JsonObject commonHeader = new JsonObject()
970 JsonObject payload = new JsonObject()
971 JsonObject payloadInput = new JsonObject()
972 commonHeader.addProperty("timestamp",new Date(System.currentTimeMillis()).format("yyyy-MM-dd'T'HH:mm:ss.sss'Z'", TimeZone.getDefault()))
973 commonHeader.addProperty("api-ver", "1.0")
974 commonHeader.addProperty("originator-id", "testing")
975 commonHeader.addProperty("request-id", requestId)
976 commonHeader.addProperty("sub-request-id", "1")
977 commonHeader.add("flags", new JsonObject())
978 Gson jsonConverter = new Gson()
979 payloadInput.add("sliceProfile", jsonConverter.toJsonTree(sliceProfile))
980 payloadInput.addProperty("RANNSSIId", execution.getVariable("RANServiceInstanceId"))
981 payloadInput.addProperty("NSIID", execution.getVariable("nsiId"))
982 payloadInput.addProperty("RANNFNSSIId", execution.getVariable("RANNFServiceInstanceId"))
983 payloadInput.addProperty("callbackURL", callbackUrl)
984 payloadInput.addProperty("globalSubscriberId", execution.getVariable("globalSubscriberId"))
985 payloadInput.addProperty("subscriptionServiceType", execution.getVariable("subscriptionServiceType"))
986 payloadInput.add("additionalproperties", new JsonObject())
987 payload.add("input", payloadInput)
988 input.add("common-header", commonHeader)
989 input.addProperty("action", action)
990 input.addProperty("payload", payload.toString())
991 body.add("input", input)
992 response.add("body", body)
993 response.addProperty("version", "1.0")
994 response.addProperty("rpc-name", rpcName)
995 response.addProperty("correlation-id", (requestId+"-1"))
996 response.addProperty("type", "request")
997 return response.toString()
1000 private void createEndPointsInAai(DelegateExecution execution) {
1001 String type = "endpoint"
1002 String function = "transport_EP"
1003 int prefixLength = 24
1004 String addressFamily = "ipv4"
1005 //BH RAN end point update
1006 String bh_endpoint = execution.getVariable("bh_endpoint")
1007 String bh_routeId = UUID.randomUUID().toString()
1008 execution.setVariable("tranportEp_ID_bh", bh_routeId)
1010 String CU_IpAddress = jsonUtil.getJsonValue(bh_endpoint, "ipAddress")
1011 String LogicalLinkId = jsonUtil.getJsonValue(bh_endpoint, "logicInterfaceId")
1012 String nextHopInfo = jsonUtil.getJsonValue(bh_endpoint, "nextHopInfo")
1013 NetworkRoute bh_ep = new NetworkRoute()
1014 bh_ep.setRouteId(bh_routeId)
1015 bh_ep.setFunction(function)
1018 bh_ep.setIpAddress(CU_IpAddress)
1019 bh_ep.setLogicalInterfaceId(LogicalLinkId)
1020 bh_ep.setNextHop(nextHopInfo)
1021 bh_ep.setPrefixLength(prefixLength)
1022 bh_ep.setAddressFamily(addressFamily)
1023 //FH RAN end points update
1025 String RU_routeId = UUID.randomUUID().toString()
1026 execution.setVariable("tranportEp_ID_RU", RU_routeId)
1028 NetworkRoute RU_ep = new NetworkRoute()
1029 RU_ep.setRouteId(RU_routeId)
1030 RU_ep.setFunction(function)
1033 RU_ep.setIpAddress("192.168.100.4")
1034 RU_ep.setLogicalInterfaceId("1234")
1035 RU_ep.setNextHop("Host1")
1036 RU_ep.setPrefixLength(prefixLength)
1037 RU_ep.setAddressFamily(addressFamily)
1039 String DUIN_routeId = UUID.randomUUID().toString()
1040 execution.setVariable("tranportEp_ID_DUIN", DUIN_routeId)
1042 NetworkRoute DU_ep = new NetworkRoute()
1043 DU_ep.setRouteId(DUIN_routeId)
1044 DU_ep.setFunction(function)
1047 DU_ep.setIpAddress("192.168.100.5")
1048 DU_ep.setLogicalInterfaceId("1234")
1049 DU_ep.setNextHop("Host2")
1050 DU_ep.setPrefixLength(prefixLength)
1051 DU_ep.setAddressFamily(addressFamily)
1052 //MH RAN end point update
1054 String DUEG_routeId = UUID.randomUUID().toString()
1055 execution.setVariable("tranportEp_ID_DUEG", DUEG_routeId)
1056 NetworkRoute DUEG_ep = new NetworkRoute()
1057 DUEG_ep.setRouteId(DUEG_routeId)
1058 DUEG_ep.setFunction(function)
1059 DUEG_ep.setRole(role)
1060 DUEG_ep.setType(type)
1061 DUEG_ep.setIpAddress("192.168.100.5")
1062 DUEG_ep.setLogicalInterfaceId("1234")
1063 DUEG_ep.setPrefixLength(prefixLength)
1064 DUEG_ep.setAddressFamily(addressFamily)
1065 DUEG_ep.setNextHop("Host3")
1067 String CUIN_routeId = UUID.randomUUID().toString()
1068 execution.setVariable("tranportEp_ID_CUIN", CUIN_routeId)
1069 NetworkRoute CUIN_ep = new NetworkRoute()
1070 CUIN_ep.setRouteId(CUIN_routeId)
1071 CUIN_ep.setFunction(function)
1072 CUIN_ep.setRole(role)
1073 CUIN_ep.setType(type)
1074 CUIN_ep.setIpAddress("192.168.100.6")
1075 CUIN_ep.setLogicalInterfaceId("1234")
1076 CUIN_ep.setNextHop("Host4")
1077 CUIN_ep.setPrefixLength(prefixLength)
1078 CUIN_ep.setAddressFamily(addressFamily)
1080 AAIResourcesClient client = new AAIResourcesClient()
1081 logger.debug("creating bh endpoint . ID : "+bh_routeId+" node details : "+bh_ep.toString())
1082 AAIResourceUri networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), bh_routeId)
1083 client.create(networkRouteUri, bh_ep)
1084 logger.debug("creating RU endpoint . ID : "+RU_routeId+" node details : "+RU_ep.toString())
1085 networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), RU_routeId)
1086 client.create(networkRouteUri, RU_ep)
1087 logger.debug("creating DUIN endpoint . ID : "+DUIN_routeId+" node details : "+DU_ep.toString())
1088 networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), DUIN_routeId)
1089 client.create(networkRouteUri, DU_ep)
1090 logger.debug("creating DUEG endpoint . ID : "+DUEG_routeId+" node details : "+DUEG_ep.toString())
1091 networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), DUEG_routeId)
1092 client.create(networkRouteUri, DUEG_ep)
1093 logger.debug("creating CUIN endpoint . ID : "+CUIN_routeId+" node details : "+CUIN_ep.toString())
1094 networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), CUIN_routeId)
1095 client.create(networkRouteUri, CUIN_ep)
1096 //relationship b/w bh_ep and RAN NSSI
1097 def AN_NSSI = execution.getVariable("RANServiceInstanceId")
1098 Relationship relationship = new Relationship()
1099 String relatedLink = "aai/v21/network/network-routes/network-route/${bh_routeId}"
1100 relationship.setRelatedLink(relatedLink)
1101 relationship.setRelatedTo("network-route")
1102 relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
1103 anNssmfUtils.createRelationShipInAAI(execution, relationship, AN_NSSI)
1104 def ANNF_serviceInstanceId = execution.getVariable("RANNFServiceInstanceId")
1105 relatedLink = "aai/v21/network/network-routes/network-route/${RU_routeId}"
1106 relationship.setRelatedLink(relatedLink)
1107 anNssmfUtils.createRelationShipInAAI(execution, relationship, ANNF_serviceInstanceId)
1108 relatedLink = "aai/v21/network/network-routes/network-route/${DUIN_routeId}"
1109 relationship.setRelatedLink(relatedLink)
1110 anNssmfUtils.createRelationShipInAAI(execution, relationship, ANNF_serviceInstanceId)
1111 relatedLink = "aai/v21/network/network-routes/network-route/${DUEG_routeId}"
1112 relationship.setRelatedLink(relatedLink)
1113 anNssmfUtils.createRelationShipInAAI(execution, relationship, ANNF_serviceInstanceId)
1114 relatedLink = "aai/v21/network/network-routes/network-route/${CUIN_routeId}"
1115 relationship.setRelatedLink(relatedLink)
1116 anNssmfUtils.createRelationShipInAAI(execution, relationship, ANNF_serviceInstanceId)
1117 } catch (BpmnError e) {
1119 } catch (Exception ex) {
1120 String msg = "Exception in createEndPointsInAai " + ex.getMessage()
1122 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)