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 List<ServiceProxy> serviceProxyList = ranNsstServiceDecomposition.getServiceProxy()
194 List<String> nsstInfoList = new ArrayList<>()
195 for(ServiceProxy serviceProxy : serviceProxyList)
197 String nsstModelUuid = serviceProxy.getSourceModelUuid()
198 String nsstModelInvariantUuid = serviceProxy.getModelInfo().getModelInvariantUuid()
199 String name = serviceProxy.getModelInfo().getModelName()
200 String nsstServiceModelInfo = """{
201 "UUID":"${nsstModelUuid}",
202 "invariantUUID":"${nsstModelInvariantUuid}",
205 nsstInfoList.add(nsstServiceModelInfo)
208 int maxIndex=nsstInfoList.size()
211 String msg = "Exception in RAN NSST processDecomposition. There is no NSST associated with RAN NSST "
213 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
215 execution.setVariable("ranNsstInfoList", objectMapper.writeValueAsString(nsstInfoList))
216 execution.setVariable("ranModelVersion", ranModelVersion)
217 execution.setVariable("ranModelName", ranModelName)
218 execution.setVariable("currentIndex",currentIndex)
219 execution.setVariable("maxIndex",maxIndex)
220 logger.debug(Prefix+"processDecomposition maxIndex value - "+maxIndex)
224 * Function to subnet capabilities from nssmf adapter
226 def getSubnetCapabilities = { DelegateExecution execution ->
227 logger.debug(Prefix+"getSubnetCapabilities method start")
229 String tnNssmfRequest = anNssmfUtils.buildCreateTNNSSMFSubnetCapabilityRequest()
231 String urlString = "/api/rest/provMns/v1/NSS/subnetCapabilityQuery"
233 String tnNssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, tnNssmfRequest)
235 if (tnNssmfResponse != null) {
236 String FHCapabilities= jsonUtil.getJsonValue(tnNssmfResponse, "TN_FH")
237 String MHCapabilities = jsonUtil.getJsonValue(tnNssmfResponse, "TN_MH")
238 execution.setVariable("FHCapabilities",FHCapabilities)
239 execution.setVariable("MHCapabilities",MHCapabilities)
242 logger.error("received error message from NSSMF : "+ tnNssmfResponse)
243 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.")
245 String anNssmfRequest = anNssmfUtils.buildCreateANNFNSSMFSubnetCapabilityRequest()
247 String anNssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, anNssmfRequest)
249 if (anNssmfResponse != null) {
250 String ANNFCapabilities = jsonUtil.getJsonValue(anNssmfResponse, "AN_NF")
251 execution.setVariable("ANNFCapabilities",ANNFCapabilities)
254 logger.error("received error message from NSSMF : "+ anNssmfResponse)
255 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.")
260 * prepare OOF request for RAN NSSI selection
262 def prepareOofRequestForRanNSS = { DelegateExecution execution ->
263 logger.debug(Prefix+"prepareOofRequestForRanNSS method start")
265 String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
266 logger.debug( "get NSSI option OOF Url: " + urlString)
267 JsonParser parser = new JsonParser()
268 //build oof request body
269 boolean ranNssiPreferReuse = execution.getVariable("ranNssiPreferReuse");
270 String requestId = execution.getVariable("msoRequestId")
271 String messageType = "NSISelectionResponse"
272 Map<String, Object> profileInfo = objectMapper.readValue(execution.getVariable("sliceProfile"), Map.class)
273 profileInfo.put("sST",execution.getVariable("sst"))
274 String modelUuid = execution.getVariable("modelUuid")
275 String modelInvariantUuid = execution.getVariable("modelInvariantUuid")
276 String modelName = execution.getVariable("ranModelName")
277 String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution);
278 List<String> nsstInfoList = objectMapper.readValue(execution.getVariable("ranNsstInfoList"), List.class)
279 JsonArray capabilitiesList = new JsonArray()
280 String FHCapabilities = execution.getVariable("FHCapabilities")
281 String MHCapabilities = execution.getVariable("MHCapabilities")
282 String ANNFCapabilities = execution.getVariable("ANNFCapabilities")
283 JsonObject FH = new JsonObject()
284 JsonObject MH = new JsonObject()
285 JsonObject ANNF = new JsonObject()
286 FH.addProperty("domainType", "TN_FH")
287 FH.add("capabilityDetails", (JsonObject) parser.parse(FHCapabilities))
288 MH.addProperty("domainType", "TN_MH")
289 MH.add("capabilityDetails", (JsonObject) parser.parse(MHCapabilities))
290 ANNF.addProperty("domainType", "AN_NF")
291 ANNF.add("capabilityDetails", (JsonObject) parser.parse(ANNFCapabilities))
292 capabilitiesList.add(FH)
293 capabilitiesList.add(MH)
294 capabilitiesList.add(ANNF)
296 execution.setVariable("nssiSelection_Url", "/api/oof/selection/nsi/v1")
297 execution.setVariable("nssiSelection_messageType",messageType)
298 execution.setVariable("nssiSelection_correlator",requestId)
299 execution.setVariable("nssiSelection_timeout",timeout)
301 String oofRequest = anNssmfUtils.buildSelectRANNSSIRequest(requestId, messageType, modelUuid,modelInvariantUuid,
302 modelName, profileInfo, nsstInfoList, capabilitiesList, ranNssiPreferReuse)
304 execution.setVariable("nssiSelection_oofRequest",oofRequest)
305 logger.debug("Sending request to OOF: " + oofRequest)
308 * process OOF response for RAN NSSI selection
310 def processOofResponseForRanNSS = { DelegateExecution execution ->
311 logger.debug(Prefix+"processOofResponseForRanNSS method start")
312 String oofResponse = execution.getVariable("nssiSelection_asyncCallbackResponse")
313 String requestStatus = jsonUtil.getJsonValue(oofResponse, "requestStatus")
314 if(requestStatus.equals("completed")) {
315 String solutions = jsonUtil.getJsonValue(oofResponse, "solutions")
316 logger.debug("solutions value : "+solutions)
317 JsonParser parser = new JsonParser()
318 JsonArray solution = parser.parse(solutions)
319 JsonObject sol = solution.get(0)
320 boolean existingNSI = sol.get("existingNSI").getAsBoolean()
321 logger.debug("existingNSI value : "+existingNSI)
323 JsonObject sharedNSISolution = sol.get("sharedNSISolution").getAsJsonObject()
324 execution.setVariable("sharedRanNSSISolution", sharedNSISolution.toString())
325 logger.debug("sharedRanNSSISolution from OOF "+sharedNSISolution)
326 String RANServiceInstanceId = sharedNSISolution.get("NSIId").getAsString()
327 execution.setVariable("RANServiceInstanceId", RANServiceInstanceId)
328 ServiceInstance serviceInstance = new ServiceInstance();
329 serviceInstance.setInstanceId(RANServiceInstanceId);
330 ServiceDecomposition serviceDecomposition = execution.getVariable("ranNsstServiceDecomposition")
331 serviceDecomposition.setServiceInstance(serviceInstance);
332 execution.setVariable("ranNsstServiceDecomposition", serviceDecomposition)
333 execution.setVariable("isRspRanNssi", true)
335 JsonObject newNSISolution = sol.get("newNSISolution").getAsJsonObject()
336 JsonArray sliceProfiles = newNSISolution.get("sliceProfiles").getAsJsonArray()
337 logger.debug("RanConstituentSliceProfiles list from OOF "+sliceProfiles)
338 execution.setVariable("RanConstituentSliceProfiles", sliceProfiles.toString())
341 String statusMessage = jsonUtil.getJsonValue(oofResponse, "statusMessage")
342 logger.error("received failed status from oof "+ statusMessage)
343 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a failed Async Response from OOF : "+statusMessage)
348 def prepareModifyAccessNssiInputs = { DelegateExecution execution ->
349 logger.debug(Prefix+"prepareModifyAccessNssiInputs method start")
350 String jobId = UUID.randomUUID().toString()
351 execution.setVariable("modifyRanNssiJobId", jobId)
352 String snssaiList = execution.getVariable("snssaiList")
353 String sliceParams = execution.getVariable("sliceParams")
354 String sliceProfileId = execution.getVariable("sliceProfileId")
355 String nsiInfo = jsonUtil.getJsonValue(sliceParams, "nsiInfo")
356 String scriptName = execution.getVariable("scriptName")
358 JsonObject modifySliceParams = new JsonObject()
359 modifySliceParams.addProperty("modifyAction", "allocate")
360 modifySliceParams.addProperty("snssaiList", snssaiList)
361 modifySliceParams.addProperty("sliceProfileId", sliceProfileId)
362 modifySliceParams.addProperty("nsiInfo", nsiInfo)
363 modifySliceParams.addProperty("scriptName", scriptName)
365 execution.setVariable("modifySliceParams", modifySliceParams.toString())
366 //create operation status in request db
367 String nsiId = execution.getVariable("nsiId")
368 String modelUuid = execution.getVariable("modelUuid")
369 logger.debug("Generated new job for Service Instance serviceId:" + nsiId + "jobId:" + jobId)
371 ResourceOperationStatus initStatus = new ResourceOperationStatus()
372 initStatus.setServiceId(nsiId)
373 initStatus.setOperationId(jobId)
374 initStatus.setResourceTemplateUUID(modelUuid)
375 initStatus.setOperType("Modify")
376 requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus)
379 def createModifyNssiQueryJobStatus = { DelegateExecution execution ->
380 logger.debug(Prefix+"createModifyNssiQueryJobStatus method start")
381 JsonObject esrInfo = new JsonObject()
382 esrInfo.addProperty("networkType", "tn")
383 esrInfo.addProperty("vendor", "ONAP_internal")
385 execution.setVariable("esrInfo", esrInfo.toString())
386 JsonObject serviceInfo = new JsonObject()
387 serviceInfo.addProperty("nssiId", execution.getVariable("RANServiceInstanceId"))
388 serviceInfo.addProperty("nsiId", execution.getVariable("nsiId"))
389 serviceInfo.addProperty("nssiName", execution.getVariable("servicename"))
390 serviceInfo.addProperty("sST", execution.getVariable("sst"))
391 serviceInfo.addProperty("PLMNIdList", objectMapper.writeValueAsString(execution.getVariable("pLMNIdList")))
392 serviceInfo.addProperty("globalSubscriberId", execution.getVariable("globalSubscriberId"))
393 serviceInfo.addProperty("subscriptionServiceType", execution.getVariable("subscriptionServiceType"))
394 serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("modelInvariantUuid"))
395 serviceInfo.addProperty("serviceUuid", execution.getVariable("modelUuid"))
396 execution.setVariable("serviceInfo", serviceInfo.toString())
397 execution.setVariable("responseId", "")
399 def prepareNsstDecomposeService = { DelegateExecution execution ->
400 logger.debug(Prefix+"prepareNsstDecomposeService method start")
401 List<String> nsstInfoList = objectMapper.readValue(execution.getVariable("ranNsstInfoList"), List.class)
402 int currentIndex = execution.getVariable("currentIndex")
403 int maxIndex = execution.getVariable("maxIndex")
404 logger.debug(Prefix+"prepareNsstDecomposeService : currentIndex value - "+currentIndex+" maxIndex : "+maxIndex)
405 if(currentIndex<maxIndex) {
406 String nsstInfo = nsstInfoList.get(currentIndex)
407 String modelInvariantUuid = jsonUtil.getJsonValue(nsstInfo, "invariantUUID")
408 String modelUuid = jsonUtil.getJsonValue(nsstInfo, "UUID")
410 String serviceModelInfo = """{
411 "modelInvariantUuid":"${modelInvariantUuid}",
412 "modelUuid":"${modelUuid}",
415 execution.setVariable("serviceModelInfo", serviceModelInfo)
416 execution.setVariable("serviceInstanceId", "")
417 logger.debug("serviceModelInfo : "+serviceModelInfo)
419 execution.setVariable("currentIndex", currentIndex)
421 logger.error("nsstList decomposition error ")
422 exceptionUtil.buildAndThrowWorkflowException(execution, 1000, "nsstList decomposition error ")
426 def processNsstDecomposition = { DelegateExecution execution ->
427 logger.debug(Prefix+"processNsstDecomposition method start")
428 ServiceDecomposition decomposedNsst = execution.getVariable("nsstServiceDecomposition")
429 logger.debug("decomposedNsst : "+decomposedNsst.toString())
431 String nsstType = decomposedNsst.getServiceRole() //domainType
432 String modelVersion = decomposedNsst.getModelInfo().getModelVersion()
433 String modelName = decomposedNsst.getModelInfo().getModelName()
434 String modelUuid = decomposedNsst.getModelInfo().getModelUuid()
435 String modelInvariantUuid = decomposedNsst.getModelInfo().getModelInvariantUuid()
439 execution.setVariable("ANNF_modelInvariantUuid", modelInvariantUuid)
440 execution.setVariable("ANNF_modelUuid", modelUuid)
441 execution.setVariable("ANNF_modelVersion", modelVersion)
442 execution.setVariable("ANNF_modelName", modelName)
443 execution.setVariable("ANNF_ServiceDecomposition", decomposedNsst)
446 execution.setVariable("TNFH_modelInvariantUuid", modelInvariantUuid)
447 execution.setVariable("TNFH_modelUuid", modelUuid)
448 execution.setVariable("TNFH_modelVersion", modelVersion)
449 execution.setVariable("TNFH_modelName", modelName)
450 execution.setVariable("TNFH_ServiceDecomposition", decomposedNsst)
453 execution.setVariable("TNMH_modelInvariantUuid", modelInvariantUuid)
454 execution.setVariable("TNMH_modelUuid", modelUuid)
455 execution.setVariable("TNMH_modelVersion", modelVersion)
456 execution.setVariable("TNMH_modelName", modelName)
457 execution.setVariable("TNMH_ServiceDecomposition", decomposedNsst)
460 logger.debug("No expected match found for current nsstType")
461 logger.error("No expected match found for current nsstType "+ nsstType)
462 exceptionUtil.buildAndThrowWorkflowException(execution, 1000,"No expected match found for current nsstType "+ nsstType)
464 boolean isAllNsstsDecomposed = false
465 int currentIndex = execution.getVariable("currentIndex")
466 int maxIndex = execution.getVariable("maxIndex")
467 if(currentIndex == maxIndex) {
468 isAllNsstsDecomposed = true
470 execution.setVariable("isAllNsstsDecomposed", isAllNsstsDecomposed)
473 * prepare OOF request for NF RAN NSSI selection
475 def prepareOofRequestForRanNfNSS = { DelegateExecution execution ->
476 logger.debug(Prefix+"prepareOofRequestForRanNfNSS method start")
477 String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
478 logger.debug( "get NSSI option OOF Url: " + urlString)
480 //build oof request body
481 boolean ranNfNssiPreferReuse = execution.getVariable("ranNfNssiPreferReuse");
482 String requestId = execution.getVariable("msoRequestId")
483 String messageType = "NSSISelectionResponse"
484 List<String> ranConstituentSliceProfiles = jsonUtil.StringArrayToList(execution.getVariable("RanConstituentSliceProfiles"))
485 anNssmfUtils.createDomainWiseSliceProfiles(ranConstituentSliceProfiles, execution)
486 Map<String, Object> profileInfo = objectMapper.readValue(execution.getVariable("ranNfSliceProfile"), Map.class)
487 profileInfo.put("sST",execution.getVariable("sst"))
488 String modelUuid = execution.getVariable("ANNF_modelUuid")
489 String modelInvariantUuid = execution.getVariable("ANNF_modelInvariantUuid")
490 String modelName = execution.getVariable("ANNF_modelName")
491 String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution);
493 execution.setVariable("nssiSelection_Url", "/api/oof/selection/nssi/v1")
494 execution.setVariable("nssiSelection_messageType",messageType)
495 execution.setVariable("nssiSelection_correlator",requestId)
496 execution.setVariable("nssiSelection_timeout",timeout)
498 String oofRequest = oofUtils.buildSelectNSSIRequest(requestId, messageType, modelUuid, modelInvariantUuid, modelName, profileInfo)
500 execution.setVariable("nssiSelection_oofRequest",oofRequest)
503 * process OOF response for RAN NF NSSI selection
505 def processOofResponseForRanNfNSS = { DelegateExecution execution ->
506 logger.debug(Prefix+"processOofResponseForRanNfNSS method start")
507 String oofResponse = execution.getVariable("nfNssiSelection_asyncCallbackResponse")
508 String requestStatus = jsonUtil.getJsonValue(oofResponse, "requestStatus")
509 if(requestStatus.equals("completed")) {
510 String solutions = jsonUtil.getJsonValue(oofResponse, "solutions")
511 logger.debug("nssi solutions value : "+solutions)
512 JsonParser parser = new JsonParser()
513 JsonArray solution = parser.parse(solutions)
514 if(solution.size()>=1) {
515 JsonObject sol = solution.get(0)
516 String ranNfNssiId = sol.get("NSSIId").getAsString()
517 String invariantUuid = sol.get("invariantUUID").getAsString()
518 String uuid = sol.get("UUID").getAsString()
519 String nssiName = sol.get("NSSIName").getAsString()
520 execution.setVariable("RANNFServiceInstanceId", ranNfNssiId)
521 execution.setVariable("RANNFInvariantUUID", invariantUuid)
522 execution.setVariable("RANNFUUID", uuid)
523 execution.setVariable("RANNFNssiName", nssiName)
524 logger.debug("RANNFServiceInstanceId from OOF "+ranNfNssiId)
526 ServiceInstance serviceInstance = new ServiceInstance();
527 serviceInstance.setInstanceId(ranNfNssiId);
528 ServiceDecomposition serviceDecomposition = execution.getVariable("ANNF_ServiceDecomposition")
529 serviceDecomposition.setServiceInstance(serviceInstance);
530 execution.setVariable("ANNF_ServiceDecomposition", serviceDecomposition)
531 execution.setVariable("modifyAction","allocate")
532 execution.setVariable("isRspRanNfNssi", true)
534 logger.debug("No solutions returned from OOF .. Create new RAN NF NSSI")
537 String statusMessage = jsonUtil.getJsonValue(oofResponse, "statusMessage")
538 logger.error("received failed status from oof "+ statusMessage)
539 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a failed Async Response from OOF : "+statusMessage)
543 def createSliceProfilesInAai = { DelegateExecution execution ->
544 logger.debug(Prefix+"createSliceProfilesInAai method start")
545 anNssmfUtils.createSliceProfilesInAai(execution)
548 def processRanNfModifyRsp = { DelegateExecution execution ->
549 logger.debug(Prefix+"processRanNfModifyRsp method start")
550 anNssmfUtils.processRanNfModifyRsp(execution)
552 org.onap.aai.domain.yang.ServiceInstance ANServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
553 //AN instance creation
554 ANServiceInstance.setServiceInstanceId(execution.getVariable("RANServiceInstanceId"))
555 String sliceInstanceName = execution.getVariable("servicename")
556 ANServiceInstance.setServiceInstanceName(sliceInstanceName)
557 String serviceType = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "sST")
558 ANServiceInstance.setServiceType(execution.getVariable("sst"))
559 String serviceStatus = "deactivated"
560 ANServiceInstance.setOrchestrationStatus(serviceStatus)
561 String serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "pLMNIdList")
562 ANServiceInstance.setServiceInstanceLocationId(jsonUtil.StringArrayToList(serviceInstanceLocationid).get(0))
563 String serviceRole = "nssi"
564 ANServiceInstance.setServiceRole(serviceRole)
565 List<String> snssaiList = execution.getVariable("snssaiList")
566 String snssai = snssaiList.get(0)
567 //ANServiceInstance.setEnvironmentContext(snssai)
568 ANServiceInstance.setEnvironmentContext(execution.getVariable("networkType")) //Network Type
569 ANServiceInstance.setWorkloadContext("AN") //domain Type
571 logger.debug("completed AN service instance build "+ ANServiceInstance.toString())
575 AAIResourcesClient client = new AAIResourcesClient()
576 AAIResourceUri nssiServiceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(execution.getVariable("RANServiceInstanceId")))
577 client.create(nssiServiceUri, ANServiceInstance)
579 } catch (BpmnError e) {
581 } catch (Exception ex) {
582 msg = "Exception in AnNssmfUtils.createSliceProfilesInAai " + ex.getMessage()
584 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
587 createEndPointsInAai(execution)
590 def createSdnrRequest = { DelegateExecution execution ->
591 logger.debug(Prefix+"createSdnrRequest method start")
592 String callbackUrl = UrnPropertiesReader.getVariable("mso.workflow.message.endpoint") + "/AsyncSdnrResponse/"+execution.getVariable("msoRequestId")
593 String sdnrRequest = buildSdnrAllocateRequest(execution, "allocate", "instantiateRANSlice", callbackUrl)
594 execution.setVariable("createNSSI_sdnrRequest", sdnrRequest)
595 execution.setVariable("createNSSI_timeout", "PT10M")
596 execution.setVariable("createNSSI_correlator", execution.getVariable("msoRequestId"))
597 execution.setVariable("createNSSI_messageType", "AsyncSdnrResponse");
600 def processSdnrResponse = { DelegateExecution execution ->
601 logger.debug(Prefix+"processSdnrResponse method start")
602 String SDNRResponse = execution.getVariable("SDNR_asyncCallbackResponse")
603 String status = jsonUtil.getJsonValue(SDNRResponse, "status")
604 if(status.equalsIgnoreCase("success")) {
605 String nfIds = jsonUtil.getJsonValue(SDNRResponse, "nfIds")
606 execution.setVariable("ranNfIdsJson", nfIds)
608 String reason = jsonUtil.getJsonValue(SDNRResponse, "reason")
609 logger.error("received failed status from SDNR "+ reason)
610 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from SDNR "+ reason)
612 logger.debug("response from SDNR "+SDNRResponse)
615 def updateAaiWithRANInstances = { DelegateExecution execution ->
616 logger.debug(Prefix+"updateAaiWithRANInstances method start")
618 org.onap.aai.domain.yang.ServiceInstance ANServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
619 org.onap.aai.domain.yang.ServiceInstance ANNFServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
620 //AN instance creation
621 ANServiceInstance.setServiceInstanceId(execution.getVariable("RANServiceInstanceId"))
622 String sliceInstanceName = execution.getVariable("servicename")
623 ANServiceInstance.setServiceInstanceName(sliceInstanceName)
624 String serviceType = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "sST")
625 ANServiceInstance.setServiceType(execution.getVariable("sst"))
626 String serviceStatus = "deactivated"
627 ANServiceInstance.setOrchestrationStatus(serviceStatus)
628 String serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "pLMNIdList")
629 ANServiceInstance.setServiceInstanceLocationId(serviceInstanceLocationid)
630 String serviceRole = "nssi"
631 ANServiceInstance.setServiceRole(serviceRole)
632 List<String> snssaiList = execution.getVariable("snssaiList")
633 String snssai = snssaiList.get(0)
634 //ANServiceInstance.setEnvironmentContext(snssai)
635 ANServiceInstance.setEnvironmentContext(execution.getVariable("networkType"))
636 String modelInvariantUuid = execution.getVariable("modelInvariantUuid")
637 String modelUuid = execution.getVariable("modelUuid")
638 ANServiceInstance.setModelInvariantId(modelInvariantUuid)
639 ANServiceInstance.setModelVersionId(modelUuid)
640 ANServiceInstance.setWorkloadContext("AN")
641 String serviceFunctionAn = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "resourceSharingLevel")
642 ANServiceInstance.setServiceFunction(serviceFunctionAn)
643 logger.debug("completed AN service instance build "+ ANServiceInstance.toString())
645 ANNFServiceInstance.setServiceInstanceId(execution.getVariable("RANNFServiceInstanceId"))
646 String ANNF_nssiInstanceId = UUID.randomUUID().toString()
647 sliceInstanceName = "nssi_an_nf_"+ANNF_nssiInstanceId
648 ANNFServiceInstance.setServiceInstanceName(sliceInstanceName)
649 ANNFServiceInstance.setServiceType(execution.getVariable("sst"))
650 ANNFServiceInstance.setOrchestrationStatus(serviceStatus)
651 serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "pLMNIdList")
652 ANNFServiceInstance.setServiceInstanceLocationId(jsonUtil.StringArrayToList(serviceInstanceLocationid).get(0))
653 ANNFServiceInstance.setServiceRole(serviceRole)
654 snssaiList = execution.getVariable("snssaiList")
655 snssai = snssaiList.get(0)
656 //ANNFServiceInstance.setEnvironmentContext(snssai)
657 ANNFServiceInstance.setEnvironmentContext(execution.getVariable("networkType"))
658 ANNFServiceInstance.setModelInvariantId(execution.getVariable("ANNF_modelInvariantUuid"))
659 ANNFServiceInstance.setModelVersionId(execution.getVariable("ANNF_modelUuid"))
660 ANNFServiceInstance.setWorkloadContext("AN_NF")
661 String serviceFunctionAnnf = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "resourceSharingLevel")
662 ANNFServiceInstance.setServiceFunction(serviceFunctionAnnf)
663 logger.debug("completed AN service instance build "+ ANNFServiceInstance.toString())
668 AAIResourcesClient client = new AAIResourcesClient()
669 AAIResourceUri nssiServiceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(execution.getVariable("RANServiceInstanceId")))
670 client.create(nssiServiceUri, ANServiceInstance)
672 AAIResourceUri nssiServiceUri1 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(execution.getVariable("RANNFServiceInstanceId")))
673 client.create(nssiServiceUri1, ANNFServiceInstance)
675 } catch (BpmnError e) {
677 } catch (Exception ex) {
678 msg = "Exception in AnNssmfUtils.createSliceProfilesInAai " + ex.getMessage()
680 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
683 createEndPointsInAai(execution)
685 def prepareTnFhRequest = { DelegateExecution execution ->
686 logger.debug(Prefix+"prepareTnFhRequest method start")
688 String nssmfRequest = anNssmfUtils.buildCreateNSSMFRequest(execution, "TN_FH", "allocate")
689 String urlString = "/api/rest/provMns/v1/NSS/SliceProfiles"
690 String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest)
692 if (nssmfResponse != null) {
693 execution.setVariable("nssmfResponse", nssmfResponse)
694 String jobId = jsonUtil.getJsonValue(nssmfResponse, "jobId")
695 execution.setVariable("TNFH_jobId",jobId)
697 logger.error("received error message from NSSMF : "+ nssmfResponse)
698 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.")
700 logger.debug("Exit prepareTnFhRequest")
703 def prepareTnMhRequest = { DelegateExecution execution ->
704 logger.debug(Prefix+"prepareTnMhRequest method start")
706 String nssmfRequest = anNssmfUtils.buildCreateNSSMFRequest(execution, "TN_MH", "allocate")
707 String urlString = "/api/rest/provMns/v1/NSS/SliceProfiles"
708 String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest)
710 if (nssmfResponse != null) {
711 execution.setVariable("nssmfResponse", nssmfResponse)
712 String jobId = jsonUtil.getJsonValue(nssmfResponse, "jobId")
713 execution.setVariable("TNMH_jobId",jobId)
715 logger.error("received error message from NSSMF : "+ nssmfResponse)
716 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.")
718 logger.debug("Exit prepareTnMhRequest")
721 def createFhAllocateNssiJobQuery = { DelegateExecution execution ->
722 logger.debug(Prefix+"createFhAllocateNssiJobQuery method start")
723 createTnAllocateNssiJobQuery(execution, "TN_FH")
726 def createMhAllocateNssiJobQuery = { DelegateExecution execution ->
727 logger.debug(Prefix+"createMhAllocateNssiJobQuery method start")
728 createTnAllocateNssiJobQuery(execution, "TN_MH")
731 private void createTnAllocateNssiJobQuery(DelegateExecution execution, String domainType) {
732 JsonObject esrInfo = new JsonObject()
733 esrInfo.addProperty("networkType", "tn")
734 esrInfo.addProperty("vendor", "ONAP_internal")
735 execution.setVariable("esrInfo", esrInfo.toString())
736 JsonObject serviceInfo = new JsonObject()
737 serviceInfo.addProperty("nsiId", execution.getVariable("nsiId"))
738 serviceInfo.addProperty("sST", execution.getVariable("sst"))
739 serviceInfo.addProperty("PLMNIdList", objectMapper.writeValueAsString(execution.getVariable("pLMNIdList")))
740 serviceInfo.addProperty("globalSubscriberId", execution.getVariable("globalSubscriberId"))
741 serviceInfo.addProperty("subscriptionServiceType", execution.getVariable("subscriptionServiceType"))
742 if(domainType.equals("TN_FH")) {
743 serviceInfo.addProperty("nssiName", execution.getVariable("TNFH_modelName"))
744 serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("TNFH_modelInvariantUuid"))
745 serviceInfo.addProperty("serviceUuid", execution.getVariable("TNFH_modelUuid"))
746 }else if(domainType.equals("TN_MH")) {
747 serviceInfo.addProperty("nssiName", execution.getVariable("TNMH_modelName"))
748 serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("TNMH_modelInvariantUuid"))
749 serviceInfo.addProperty("serviceUuid", execution.getVariable("TNMH_modelUuid"))
751 execution.setVariable("serviceInfo", serviceInfo.toString())
752 execution.setVariable("responseId", "")
755 def processFhAllocateNssiJobStatusRsp = { DelegateExecution execution ->
756 logger.debug(Prefix+"processJobStatusRsp method start")
757 String jobResponse = execution.getVariable("TNFH_jobResponse")
758 logger.debug("Job status response "+jobResponse)
759 String status = jsonUtil.getJsonValue(jobResponse, "status")
760 String nssi = jsonUtil.getJsonValue(jobResponse, "nssiId")
761 if(status.equalsIgnoreCase("finished")) {
762 execution.setVariable("TNFH_NSSI", nssi)
763 logger.debug("Job successfully completed ... proceeding with flow for nssi : "+nssi)
766 String statusDescription = jsonUtil.getJsonValue(jobResponse, "statusDescription")
767 logger.error("received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
768 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
772 def processMhAllocateNssiJobStatusRsp = { DelegateExecution execution ->
773 logger.debug(Prefix+"processJobStatusRsp method start")
774 String jobResponse = execution.getVariable("TNMH_jobResponse")
775 logger.debug("Job status response "+jobResponse)
776 String status = jsonUtil.getJsonValue(jobResponse, "status")
777 String nssi = jsonUtil.getJsonValue(jobResponse, "nssiId")
778 if(status.equalsIgnoreCase("finished")) {
779 execution.setVariable("TNMH_NSSI", nssi)
780 logger.debug("Job successfully completed ... proceeding with flow for nssi : "+nssi)
783 String statusDescription = jsonUtil.getJsonValue(jobResponse, "statusDescription")
784 logger.error("received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
785 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
789 def processModifyJobStatusRsp = { DelegateExecution execution ->
790 logger.debug(Prefix+"processJobStatusRsp method start")
791 String jobResponse = execution.getVariable("jobResponse")
792 logger.debug("Job status response "+jobResponse)
793 String status = jsonUtil.getJsonValue(jobResponse, "status")
794 String nssi = jsonUtil.getJsonValue(jobResponse, "nssiId")
795 if(status.equalsIgnoreCase("finished")) {
796 logger.debug("Job successfully completed ... proceeding with flow for nssi : "+nssi)
799 String statusDescription = jsonUtil.getJsonValue(jobResponse, "statusDescription")
800 logger.error("received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
801 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
805 def updateAairelationships = { DelegateExecution execution ->
806 logger.debug(Prefix + "updateAairelationships Start")
809 def ANNF_serviceInstanceId = execution.getVariable("RANNFServiceInstanceId")
810 def TNFH_serviceInstanceId = execution.getVariable("TNFH_NSSI")
811 def TNMH_serviceInstanceId = execution.getVariable("TNMH_NSSI")
812 def AN_profileInstanceId = execution.getVariable("sliceProfileId")
813 def AN_NSSI = execution.getVariable("RANServiceInstanceId")
814 def ANNF_profileInstanceId = execution.getVariable("ANNF_sliceProfileInstanceId")
815 def TNFH_profileInstanceId = execution.getVariable("TNFH_sliceProfileInstanceId")
816 def TNMH_profileInstanceId = execution.getVariable("TNMH_sliceProfileInstanceId")
817 String globalSubscriberId = execution.getVariable("globalSubscriberId")
818 String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
820 Relationship ANNF_relationship = new Relationship()
821 Relationship TNFH_relationship = new Relationship()
822 Relationship TNMH_relationship = new Relationship()
824 String ANNF_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${ANNF_profileInstanceId}"
825 String TNFH_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNFH_profileInstanceId}"
826 String TNMH_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNMH_profileInstanceId}"
828 String ANNF_NSSI_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${ANNF_serviceInstanceId}"
829 String TNFH_NSSI_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNFH_serviceInstanceId}"
830 String TNMH_NSSI_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNMH_serviceInstanceId}"
832 ANNF_relationship.setRelatedLink(ANNF_relatedLink)
833 ANNF_relationship.setRelatedTo("service-instance")
834 ANNF_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
835 TNFH_relationship.setRelatedLink(TNFH_relatedLink)
836 TNFH_relationship.setRelatedTo("service-instance")
837 TNFH_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
838 TNMH_relationship.setRelatedLink(TNMH_relatedLink)
839 TNMH_relationship.setRelatedTo("service-instance")
840 TNMH_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
842 // create SliceProfile and NSSI relationship in AAI
843 anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship,ANNF_serviceInstanceId)
844 anNssmfUtils.createRelationShipInAAI(execution, TNFH_relationship,TNFH_serviceInstanceId)
845 anNssmfUtils.createRelationShipInAAI(execution, TNMH_relationship,TNMH_serviceInstanceId)
846 anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship,AN_profileInstanceId)
847 anNssmfUtils.createRelationShipInAAI(execution, TNFH_relationship,AN_profileInstanceId)
848 anNssmfUtils.createRelationShipInAAI(execution, TNMH_relationship,AN_profileInstanceId)
850 //create AN NSSI and ANNF,TNFH,TNMH relationship in AAI
851 ANNF_relationship.setRelatedLink(ANNF_NSSI_relatedLink)
852 TNFH_relationship.setRelatedLink(TNFH_NSSI_relatedLink)
853 TNMH_relationship.setRelatedLink(TNMH_NSSI_relatedLink)
854 anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship,AN_NSSI)
855 anNssmfUtils.createRelationShipInAAI(execution, TNFH_relationship,AN_NSSI)
856 anNssmfUtils.createRelationShipInAAI(execution, TNMH_relationship,AN_NSSI)
858 } catch (BpmnError e) {
860 } catch (Exception ex) {
862 msg = "Exception in DoCreateE2EServiceInstance.createCustomRelationship. " + ex.getMessage()
864 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
869 * update operation status in request db
872 def prepareOperationStatusUpdate = { DelegateExecution execution ->
873 logger.debug(Prefix + "prepareOperationStatusUpdate Start")
875 String jobId = execution.getVariable("jobId")
876 String nsiId = execution.getVariable("nsiId")
877 String modelUuid = execution.getVariable("modelUuid")
878 String nssiId = execution.getVariable("RANServiceInstanceId")
879 logger.debug("Service Instance serviceId:" + nsiId + " jobId:" + jobId)
881 ResourceOperationStatus updateStatus = new ResourceOperationStatus()
882 updateStatus.setServiceId(nsiId)
883 updateStatus.setOperationId(jobId)
884 updateStatus.setResourceTemplateUUID(modelUuid)
885 updateStatus.setResourceInstanceID(nssiId)
886 updateStatus.setOperType("Allocate")
887 updateStatus.setProgress("100")
888 updateStatus.setStatus("finished")
889 requestDBUtil.prepareUpdateResourceOperationStatus(execution, updateStatus)
891 logger.debug(Prefix + "prepareOperationStatusUpdate Exit")
894 def prepareFailedOperationStatusUpdate = { DelegateExecution execution ->
895 logger.debug(Prefix + "prepareFailedOperationStatusUpdate Start")
897 String jobId = execution.getVariable("jobId")
898 String nsiId = execution.getVariable("nsiId")
899 String modelUuid = execution.getVariable("modelUuid")
900 String nssiId = execution.getVariable("RANServiceInstanceId")
901 logger.debug("Service Instance serviceId:" + nsiId + " jobId:" + jobId)
903 ResourceOperationStatus updateStatus = new ResourceOperationStatus()
904 updateStatus.setServiceId(nsiId)
905 updateStatus.setOperationId(jobId)
906 updateStatus.setResourceTemplateUUID(modelUuid)
907 updateStatus.setResourceInstanceID(nssiId)
908 updateStatus.setOperType("Allocate")
909 updateStatus.setProgress("0")
910 updateStatus.setStatus("failed")
911 requestDBUtil.prepareUpdateResourceOperationStatus(execution, updateStatus)
914 private String buildSdnrAllocateRequest(DelegateExecution execution, String action, String rpcName, String callbackUrl) {
916 String requestId = execution.getVariable("msoRequestId")
917 Map<String,Object> sliceProfile = objectMapper.readValue(execution.getVariable("ranNfSliceProfile"), Map.class)
918 sliceProfile.put("sliceProfileId", execution.getVariable("ANNF_sliceProfileInstanceId"))
919 sliceProfile.put("maxNumberofConns", sliceProfile.get("maxNumberofPDUSession"))
920 sliceProfile.put("uLThptPerSlice", sliceProfile.get("expDataRateUL"))
921 sliceProfile.put("dLThptPerSlice", sliceProfile.get("expDataRateDL"))
923 JsonObject response = new JsonObject()
924 JsonObject body = new JsonObject()
925 JsonObject input = new JsonObject()
926 JsonObject commonHeader = new JsonObject()
927 JsonObject payload = new JsonObject()
928 JsonObject payloadInput = new JsonObject()
929 commonHeader.addProperty("timestamp",new Date(System.currentTimeMillis()).format("yyyy-MM-dd'T'HH:mm:ss.sss'Z'", TimeZone.getDefault()))
930 commonHeader.addProperty("api-ver", "1.0")
931 commonHeader.addProperty("originator-id", "testing")
932 commonHeader.addProperty("request-id", requestId)
933 commonHeader.addProperty("sub-request-id", "1")
934 commonHeader.add("flags", new JsonObject())
935 Gson jsonConverter = new Gson()
936 payloadInput.add("sliceProfile", jsonConverter.toJsonTree(sliceProfile))
937 payloadInput.addProperty("RANNSSIId", execution.getVariable("RANServiceInstanceId"))
938 payloadInput.addProperty("NSIID", execution.getVariable("nsiId"))
939 payloadInput.addProperty("RANNFNSSIId", execution.getVariable("RANNFServiceInstanceId"))
940 payloadInput.addProperty("callbackURL", callbackUrl)
941 payloadInput.addProperty("globalSubscriberId", execution.getVariable("globalSubscriberId"))
942 payloadInput.addProperty("subscriptionServiceType", execution.getVariable("subscriptionServiceType"))
943 payloadInput.add("additionalproperties", new JsonObject())
944 payload.add("input", payloadInput)
945 input.add("common-header", commonHeader)
946 input.addProperty("action", action)
947 input.addProperty("payload", payload.toString())
948 body.add("input", input)
949 response.add("body", body)
950 response.addProperty("version", "1.0")
951 response.addProperty("rpc-name", rpcName)
952 response.addProperty("correlation-id", (requestId+"-1"))
953 response.addProperty("type", "request")
954 return response.toString()
957 private void createEndPointsInAai(DelegateExecution execution) {
958 String type = "endpoint"
959 String function = "transport_EP"
960 int prefixLength = 24
961 String addressFamily = "ipv4"
962 //BH RAN end point update
963 String bh_endpoint = execution.getVariable("bh_endpoint")
964 String bh_routeId = UUID.randomUUID().toString()
965 execution.setVariable("tranportEp_ID_bh", bh_routeId)
967 String CU_IpAddress = jsonUtil.getJsonValue(bh_endpoint, "ipAddress")
968 String LogicalLinkId = jsonUtil.getJsonValue(bh_endpoint, "logicInterfaceId")
969 String nextHopInfo = jsonUtil.getJsonValue(bh_endpoint, "nextHopInfo")
970 NetworkRoute bh_ep = new NetworkRoute()
971 bh_ep.setRouteId(bh_routeId)
972 bh_ep.setFunction(function)
975 bh_ep.setIpAddress(CU_IpAddress)
976 bh_ep.setLogicalInterfaceId(LogicalLinkId)
977 bh_ep.setNextHop(nextHopInfo)
978 bh_ep.setPrefixLength(prefixLength)
979 bh_ep.setAddressFamily(addressFamily)
980 //FH RAN end points update
982 String RU_routeId = UUID.randomUUID().toString()
983 execution.setVariable("tranportEp_ID_RU", RU_routeId)
985 NetworkRoute RU_ep = new NetworkRoute()
986 RU_ep.setRouteId(RU_routeId)
987 RU_ep.setFunction(function)
990 RU_ep.setIpAddress("192.168.100.4")
991 RU_ep.setLogicalInterfaceId("1234")
992 RU_ep.setNextHop("Host1")
993 RU_ep.setPrefixLength(prefixLength)
994 RU_ep.setAddressFamily(addressFamily)
996 String DUIN_routeId = UUID.randomUUID().toString()
997 execution.setVariable("tranportEp_ID_DUIN", DUIN_routeId)
999 NetworkRoute DU_ep = new NetworkRoute()
1000 DU_ep.setRouteId(DUIN_routeId)
1001 DU_ep.setFunction(function)
1004 DU_ep.setIpAddress("192.168.100.5")
1005 DU_ep.setLogicalInterfaceId("1234")
1006 DU_ep.setNextHop("Host2")
1007 DU_ep.setPrefixLength(prefixLength)
1008 DU_ep.setAddressFamily(addressFamily)
1009 //MH RAN end point update
1011 String DUEG_routeId = UUID.randomUUID().toString()
1012 execution.setVariable("tranportEp_ID_DUEG", DUEG_routeId)
1013 NetworkRoute DUEG_ep = new NetworkRoute()
1014 DUEG_ep.setRouteId(DUEG_routeId)
1015 DUEG_ep.setFunction(function)
1016 DUEG_ep.setRole(role)
1017 DUEG_ep.setType(type)
1018 DUEG_ep.setIpAddress("192.168.100.5")
1019 DUEG_ep.setLogicalInterfaceId("1234")
1020 DUEG_ep.setPrefixLength(prefixLength)
1021 DUEG_ep.setAddressFamily(addressFamily)
1022 DUEG_ep.setNextHop("Host3")
1024 String CUIN_routeId = UUID.randomUUID().toString()
1025 execution.setVariable("tranportEp_ID_CUIN", CUIN_routeId)
1026 NetworkRoute CUIN_ep = new NetworkRoute()
1027 CUIN_ep.setRouteId(CUIN_routeId)
1028 CUIN_ep.setFunction(function)
1029 CUIN_ep.setRole(role)
1030 CUIN_ep.setType(type)
1031 CUIN_ep.setIpAddress("192.168.100.6")
1032 CUIN_ep.setLogicalInterfaceId("1234")
1033 CUIN_ep.setNextHop("Host4")
1034 CUIN_ep.setPrefixLength(prefixLength)
1035 CUIN_ep.setAddressFamily(addressFamily)
1037 AAIResourcesClient client = new AAIResourcesClient()
1038 logger.debug("creating bh endpoint . ID : "+bh_routeId+" node details : "+bh_ep.toString())
1039 AAIResourceUri networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), bh_routeId)
1040 client.create(networkRouteUri, bh_ep)
1041 logger.debug("creating RU endpoint . ID : "+RU_routeId+" node details : "+RU_ep.toString())
1042 networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), RU_routeId)
1043 client.create(networkRouteUri, RU_ep)
1044 logger.debug("creating DUIN endpoint . ID : "+DUIN_routeId+" node details : "+DU_ep.toString())
1045 networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), DUIN_routeId)
1046 client.create(networkRouteUri, DU_ep)
1047 logger.debug("creating DUEG endpoint . ID : "+DUEG_routeId+" node details : "+DUEG_ep.toString())
1048 networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), DUEG_routeId)
1049 client.create(networkRouteUri, DUEG_ep)
1050 logger.debug("creating CUIN endpoint . ID : "+CUIN_routeId+" node details : "+CUIN_ep.toString())
1051 networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), CUIN_routeId)
1052 client.create(networkRouteUri, CUIN_ep)
1053 //relationship b/w bh_ep and RAN NSSI
1054 def AN_NSSI = execution.getVariable("RANServiceInstanceId")
1055 Relationship relationship = new Relationship()
1056 String relatedLink = "aai/v21/network/network-routes/network-route/${bh_routeId}"
1057 relationship.setRelatedLink(relatedLink)
1058 relationship.setRelatedTo("network-route")
1059 relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
1060 anNssmfUtils.createRelationShipInAAI(execution, relationship, AN_NSSI)
1061 def ANNF_serviceInstanceId = execution.getVariable("RANNFServiceInstanceId")
1062 relatedLink = "aai/v21/network/network-routes/network-route/${RU_routeId}"
1063 relationship.setRelatedLink(relatedLink)
1064 anNssmfUtils.createRelationShipInAAI(execution, relationship, ANNF_serviceInstanceId)
1065 relatedLink = "aai/v21/network/network-routes/network-route/${DUIN_routeId}"
1066 relationship.setRelatedLink(relatedLink)
1067 anNssmfUtils.createRelationShipInAAI(execution, relationship, ANNF_serviceInstanceId)
1068 relatedLink = "aai/v21/network/network-routes/network-route/${DUEG_routeId}"
1069 relationship.setRelatedLink(relatedLink)
1070 anNssmfUtils.createRelationShipInAAI(execution, relationship, ANNF_serviceInstanceId)
1071 relatedLink = "aai/v21/network/network-routes/network-route/${CUIN_routeId}"
1072 relationship.setRelatedLink(relatedLink)
1073 anNssmfUtils.createRelationShipInAAI(execution, relationship, ANNF_serviceInstanceId)
1074 } catch (BpmnError e) {
1076 } catch (Exception ex) {
1077 String msg = "Exception in createEndPointsInAai " + ex.getMessage()
1079 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)