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 sliceInstanceName = "nssi_"+execution.getVariable("ANNF_modelName")
647 ANNFServiceInstance.setServiceInstanceName(sliceInstanceName)
648 ANNFServiceInstance.setServiceType(execution.getVariable("sst"))
649 ANNFServiceInstance.setOrchestrationStatus(serviceStatus)
650 serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "pLMNIdList")
651 ANNFServiceInstance.setServiceInstanceLocationId(jsonUtil.StringArrayToList(serviceInstanceLocationid).get(0))
652 ANNFServiceInstance.setServiceRole(serviceRole)
653 snssaiList = execution.getVariable("snssaiList")
654 snssai = snssaiList.get(0)
655 //ANNFServiceInstance.setEnvironmentContext(snssai)
656 ANNFServiceInstance.setEnvironmentContext(execution.getVariable("networkType"))
657 ANNFServiceInstance.setModelInvariantId(execution.getVariable("ANNF_modelInvariantUuid"))
658 ANNFServiceInstance.setModelVersionId(execution.getVariable("ANNF_modelUuid"))
659 ANNFServiceInstance.setWorkloadContext("AN_NF")
660 String serviceFunctionAnnf = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "resourceSharingLevel")
661 ANNFServiceInstance.setServiceFunction(serviceFunctionAnnf)
662 logger.debug("completed AN service instance build "+ ANNFServiceInstance.toString())
667 AAIResourcesClient client = new AAIResourcesClient()
668 AAIResourceUri nssiServiceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(execution.getVariable("RANServiceInstanceId")))
669 client.create(nssiServiceUri, ANServiceInstance)
671 AAIResourceUri nssiServiceUri1 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(execution.getVariable("RANNFServiceInstanceId")))
672 client.create(nssiServiceUri1, ANNFServiceInstance)
674 } catch (BpmnError e) {
676 } catch (Exception ex) {
677 msg = "Exception in AnNssmfUtils.createSliceProfilesInAai " + ex.getMessage()
679 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
682 createEndPointsInAai(execution)
684 def prepareTnFhRequest = { DelegateExecution execution ->
685 logger.debug(Prefix+"prepareTnFhRequest method start")
687 String nssmfRequest = anNssmfUtils.buildCreateNSSMFRequest(execution, "TN_FH", "allocate")
688 String urlString = "/api/rest/provMns/v1/NSS/SliceProfiles"
689 String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest)
691 if (nssmfResponse != null) {
692 execution.setVariable("nssmfResponse", nssmfResponse)
693 String jobId = jsonUtil.getJsonValue(nssmfResponse, "jobId")
694 execution.setVariable("TNFH_jobId",jobId)
696 logger.error("received error message from NSSMF : "+ nssmfResponse)
697 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.")
699 logger.debug("Exit prepareTnFhRequest")
702 def prepareTnMhRequest = { DelegateExecution execution ->
703 logger.debug(Prefix+"prepareTnMhRequest method start")
705 String nssmfRequest = anNssmfUtils.buildCreateNSSMFRequest(execution, "TN_MH", "allocate")
706 String urlString = "/api/rest/provMns/v1/NSS/SliceProfiles"
707 String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest)
709 if (nssmfResponse != null) {
710 execution.setVariable("nssmfResponse", nssmfResponse)
711 String jobId = jsonUtil.getJsonValue(nssmfResponse, "jobId")
712 execution.setVariable("TNMH_jobId",jobId)
714 logger.error("received error message from NSSMF : "+ nssmfResponse)
715 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.")
717 logger.debug("Exit prepareTnMhRequest")
720 def createFhAllocateNssiJobQuery = { DelegateExecution execution ->
721 logger.debug(Prefix+"createFhAllocateNssiJobQuery method start")
722 createTnAllocateNssiJobQuery(execution, "TN_FH")
725 def createMhAllocateNssiJobQuery = { DelegateExecution execution ->
726 logger.debug(Prefix+"createMhAllocateNssiJobQuery method start")
727 createTnAllocateNssiJobQuery(execution, "TN_MH")
730 private void createTnAllocateNssiJobQuery(DelegateExecution execution, String domainType) {
731 JsonObject esrInfo = new JsonObject()
732 esrInfo.addProperty("networkType", "tn")
733 esrInfo.addProperty("vendor", "ONAP_internal")
734 execution.setVariable("esrInfo", esrInfo.toString())
735 JsonObject serviceInfo = new JsonObject()
736 serviceInfo.addProperty("nsiId", execution.getVariable("nsiId"))
737 serviceInfo.addProperty("sST", execution.getVariable("sst"))
738 serviceInfo.addProperty("PLMNIdList", objectMapper.writeValueAsString(execution.getVariable("pLMNIdList")))
739 serviceInfo.addProperty("globalSubscriberId", execution.getVariable("globalSubscriberId"))
740 serviceInfo.addProperty("subscriptionServiceType", execution.getVariable("subscriptionServiceType"))
741 if(domainType.equals("TN_FH")) {
742 serviceInfo.addProperty("nssiName", execution.getVariable("TNFH_modelName"))
743 serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("TNFH_modelInvariantUuid"))
744 serviceInfo.addProperty("serviceUuid", execution.getVariable("TNFH_modelUuid"))
745 }else if(domainType.equals("TN_MH")) {
746 serviceInfo.addProperty("nssiName", execution.getVariable("TNMH_modelName"))
747 serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("TNMH_modelInvariantUuid"))
748 serviceInfo.addProperty("serviceUuid", execution.getVariable("TNMH_modelUuid"))
750 execution.setVariable("serviceInfo", serviceInfo.toString())
751 execution.setVariable("responseId", "")
754 def processFhAllocateNssiJobStatusRsp = { DelegateExecution execution ->
755 logger.debug(Prefix+"processJobStatusRsp method start")
756 String jobResponse = execution.getVariable("TNFH_jobResponse")
757 logger.debug("Job status response "+jobResponse)
758 String status = jsonUtil.getJsonValue(jobResponse, "status")
759 String nssi = jsonUtil.getJsonValue(jobResponse, "nssiId")
760 if(status.equalsIgnoreCase("finished")) {
761 execution.setVariable("TNFH_NSSI", nssi)
762 logger.debug("Job successfully completed ... proceeding with flow for nssi : "+nssi)
765 String statusDescription = jsonUtil.getJsonValue(jobResponse, "statusDescription")
766 logger.error("received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
767 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
771 def processMhAllocateNssiJobStatusRsp = { DelegateExecution execution ->
772 logger.debug(Prefix+"processJobStatusRsp method start")
773 String jobResponse = execution.getVariable("TNMH_jobResponse")
774 logger.debug("Job status response "+jobResponse)
775 String status = jsonUtil.getJsonValue(jobResponse, "status")
776 String nssi = jsonUtil.getJsonValue(jobResponse, "nssiId")
777 if(status.equalsIgnoreCase("finished")) {
778 execution.setVariable("TNMH_NSSI", nssi)
779 logger.debug("Job successfully completed ... proceeding with flow for nssi : "+nssi)
782 String statusDescription = jsonUtil.getJsonValue(jobResponse, "statusDescription")
783 logger.error("received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
784 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
788 def processModifyJobStatusRsp = { DelegateExecution execution ->
789 logger.debug(Prefix+"processJobStatusRsp method start")
790 String jobResponse = execution.getVariable("jobResponse")
791 logger.debug("Job status response "+jobResponse)
792 String status = jsonUtil.getJsonValue(jobResponse, "status")
793 String nssi = jsonUtil.getJsonValue(jobResponse, "nssiId")
794 if(status.equalsIgnoreCase("finished")) {
795 logger.debug("Job successfully completed ... proceeding with flow for nssi : "+nssi)
798 String statusDescription = jsonUtil.getJsonValue(jobResponse, "statusDescription")
799 logger.error("received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
800 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
804 def updateAairelationships = { DelegateExecution execution ->
805 logger.debug(Prefix + "updateAairelationships Start")
808 def ANNF_serviceInstanceId = execution.getVariable("RANNFServiceInstanceId")
809 def TNFH_serviceInstanceId = execution.getVariable("TNFH_NSSI")
810 def TNMH_serviceInstanceId = execution.getVariable("TNMH_NSSI")
811 def AN_profileInstanceId = execution.getVariable("sliceProfileId")
812 def AN_NSSI = execution.getVariable("RANServiceInstanceId")
813 def ANNF_profileInstanceId = execution.getVariable("ANNF_sliceProfileInstanceId")
814 def TNFH_profileInstanceId = execution.getVariable("TNFH_sliceProfileInstanceId")
815 def TNMH_profileInstanceId = execution.getVariable("TNMH_sliceProfileInstanceId")
816 String globalSubscriberId = execution.getVariable("globalSubscriberId")
817 String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
819 Relationship ANNF_relationship = new Relationship()
820 Relationship TNFH_relationship = new Relationship()
821 Relationship TNMH_relationship = new Relationship()
823 String ANNF_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${ANNF_profileInstanceId}"
824 String TNFH_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNFH_profileInstanceId}"
825 String TNMH_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNMH_profileInstanceId}"
827 String ANNF_NSSI_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${ANNF_serviceInstanceId}"
828 String TNFH_NSSI_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNFH_serviceInstanceId}"
829 String TNMH_NSSI_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNMH_serviceInstanceId}"
831 ANNF_relationship.setRelatedLink(ANNF_relatedLink)
832 ANNF_relationship.setRelatedTo("service-instance")
833 ANNF_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
834 TNFH_relationship.setRelatedLink(TNFH_relatedLink)
835 TNFH_relationship.setRelatedTo("service-instance")
836 TNFH_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
837 TNMH_relationship.setRelatedLink(TNMH_relatedLink)
838 TNMH_relationship.setRelatedTo("service-instance")
839 TNMH_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
841 // create SliceProfile and NSSI relationship in AAI
842 anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship,ANNF_serviceInstanceId)
843 anNssmfUtils.createRelationShipInAAI(execution, TNFH_relationship,TNFH_serviceInstanceId)
844 anNssmfUtils.createRelationShipInAAI(execution, TNMH_relationship,TNMH_serviceInstanceId)
845 anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship,AN_profileInstanceId)
846 anNssmfUtils.createRelationShipInAAI(execution, TNFH_relationship,AN_profileInstanceId)
847 anNssmfUtils.createRelationShipInAAI(execution, TNMH_relationship,AN_profileInstanceId)
849 //create AN NSSI and ANNF,TNFH,TNMH relationship in AAI
850 ANNF_relationship.setRelatedLink(ANNF_NSSI_relatedLink)
851 TNFH_relationship.setRelatedLink(TNFH_NSSI_relatedLink)
852 TNMH_relationship.setRelatedLink(TNMH_NSSI_relatedLink)
853 anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship,AN_NSSI)
854 anNssmfUtils.createRelationShipInAAI(execution, TNFH_relationship,AN_NSSI)
855 anNssmfUtils.createRelationShipInAAI(execution, TNMH_relationship,AN_NSSI)
857 } catch (BpmnError e) {
859 } catch (Exception ex) {
861 msg = "Exception in DoCreateE2EServiceInstance.createCustomRelationship. " + ex.getMessage()
863 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
868 * update operation status in request db
871 def prepareOperationStatusUpdate = { DelegateExecution execution ->
872 logger.debug(Prefix + "prepareOperationStatusUpdate Start")
874 String jobId = execution.getVariable("jobId")
875 String nsiId = execution.getVariable("nsiId")
876 String modelUuid = execution.getVariable("modelUuid")
877 String nssiId = execution.getVariable("RANServiceInstanceId")
878 logger.debug("Service Instance serviceId:" + nsiId + " jobId:" + jobId)
880 ResourceOperationStatus updateStatus = new ResourceOperationStatus()
881 updateStatus.setServiceId(nsiId)
882 updateStatus.setOperationId(jobId)
883 updateStatus.setResourceTemplateUUID(modelUuid)
884 updateStatus.setResourceInstanceID(nssiId)
885 updateStatus.setOperType("Allocate")
886 updateStatus.setProgress("100")
887 updateStatus.setStatus("finished")
888 requestDBUtil.prepareUpdateResourceOperationStatus(execution, updateStatus)
890 logger.debug(Prefix + "prepareOperationStatusUpdate Exit")
893 def prepareFailedOperationStatusUpdate = { DelegateExecution execution ->
894 logger.debug(Prefix + "prepareFailedOperationStatusUpdate Start")
896 String jobId = execution.getVariable("jobId")
897 String nsiId = execution.getVariable("nsiId")
898 String modelUuid = execution.getVariable("modelUuid")
899 String nssiId = execution.getVariable("RANServiceInstanceId")
900 logger.debug("Service Instance serviceId:" + nsiId + " jobId:" + jobId)
902 ResourceOperationStatus updateStatus = new ResourceOperationStatus()
903 updateStatus.setServiceId(nsiId)
904 updateStatus.setOperationId(jobId)
905 updateStatus.setResourceTemplateUUID(modelUuid)
906 updateStatus.setResourceInstanceID(nssiId)
907 updateStatus.setOperType("Allocate")
908 updateStatus.setProgress("0")
909 updateStatus.setStatus("failed")
910 requestDBUtil.prepareUpdateResourceOperationStatus(execution, updateStatus)
913 private String buildSdnrAllocateRequest(DelegateExecution execution, String action, String rpcName, String callbackUrl) {
915 String requestId = execution.getVariable("msoRequestId")
916 Map<String,Object> sliceProfile = objectMapper.readValue(execution.getVariable("ranNfSliceProfile"), Map.class)
917 sliceProfile.put("sliceProfileId", execution.getVariable("ANNF_sliceProfileInstanceId"))
918 sliceProfile.put("maxNumberofConns", sliceProfile.get("maxNumberofPDUSession"))
919 sliceProfile.put("uLThptPerSlice", sliceProfile.get("expDataRateUL"))
920 sliceProfile.put("dLThptPerSlice", sliceProfile.get("expDataRateDL"))
922 JsonObject response = new JsonObject()
923 JsonObject body = new JsonObject()
924 JsonObject input = new JsonObject()
925 JsonObject commonHeader = new JsonObject()
926 JsonObject payload = new JsonObject()
927 JsonObject payloadInput = new JsonObject()
928 commonHeader.addProperty("timestamp",new Date(System.currentTimeMillis()).format("yyyy-MM-dd'T'HH:mm:ss.sss'Z'", TimeZone.getDefault()))
929 commonHeader.addProperty("api-ver", "1.0")
930 commonHeader.addProperty("originator-id", "testing")
931 commonHeader.addProperty("request-id", requestId)
932 commonHeader.addProperty("sub-request-id", "1")
933 commonHeader.add("flags", new JsonObject())
934 Gson jsonConverter = new Gson()
935 payloadInput.add("sliceProfile", jsonConverter.toJsonTree(sliceProfile))
936 payloadInput.addProperty("RANNSSIId", execution.getVariable("RANServiceInstanceId"))
937 payloadInput.addProperty("NSIID", execution.getVariable("nsiId"))
938 payloadInput.addProperty("RANNFNSSIId", execution.getVariable("RANNFServiceInstanceId"))
939 payloadInput.addProperty("callbackURL", callbackUrl)
940 payloadInput.addProperty("globalSubscriberId", execution.getVariable("globalSubscriberId"))
941 payloadInput.addProperty("subscriptionServiceType", execution.getVariable("subscriptionServiceType"))
942 payloadInput.add("additionalproperties", new JsonObject())
943 payload.add("input", payloadInput)
944 input.add("common-header", commonHeader)
945 input.addProperty("action", action)
946 input.addProperty("payload", payload.toString())
947 body.add("input", input)
948 response.add("body", body)
949 response.addProperty("version", "1.0")
950 response.addProperty("rpc-name", rpcName)
951 response.addProperty("correlation-id", (requestId+"-1"))
952 response.addProperty("type", "request")
953 return response.toString()
956 private void createEndPointsInAai(DelegateExecution execution) {
957 String type = "endpoint"
958 String function = "transport_EP"
959 int prefixLength = 24
960 String addressFamily = "ipv4"
961 //BH RAN end point update
962 String bh_endpoint = execution.getVariable("bh_endpoint")
963 String bh_routeId = UUID.randomUUID().toString()
964 execution.setVariable("tranportEp_ID_bh", bh_routeId)
966 String CU_IpAddress = jsonUtil.getJsonValue(bh_endpoint, "ipAddress")
967 String LogicalLinkId = jsonUtil.getJsonValue(bh_endpoint, "logicInterfaceId")
968 String nextHopInfo = jsonUtil.getJsonValue(bh_endpoint, "nextHopInfo")
969 NetworkRoute bh_ep = new NetworkRoute()
970 bh_ep.setRouteId(bh_routeId)
971 bh_ep.setFunction(function)
974 bh_ep.setIpAddress(CU_IpAddress)
975 bh_ep.setLogicalInterfaceId(LogicalLinkId)
976 bh_ep.setNextHop(nextHopInfo)
977 bh_ep.setPrefixLength(prefixLength)
978 bh_ep.setAddressFamily(addressFamily)
979 //FH RAN end points update
981 String RU_routeId = UUID.randomUUID().toString()
982 execution.setVariable("tranportEp_ID_RU", RU_routeId)
984 NetworkRoute RU_ep = new NetworkRoute()
985 RU_ep.setRouteId(RU_routeId)
986 RU_ep.setFunction(function)
989 RU_ep.setIpAddress("192.168.100.4")
990 RU_ep.setLogicalInterfaceId("1234")
991 RU_ep.setNextHop("Host1")
992 RU_ep.setPrefixLength(prefixLength)
993 RU_ep.setAddressFamily(addressFamily)
995 String DUIN_routeId = UUID.randomUUID().toString()
996 execution.setVariable("tranportEp_ID_DUIN", DUIN_routeId)
998 NetworkRoute DU_ep = new NetworkRoute()
999 DU_ep.setRouteId(DUIN_routeId)
1000 DU_ep.setFunction(function)
1003 DU_ep.setIpAddress("192.168.100.5")
1004 DU_ep.setLogicalInterfaceId("1234")
1005 DU_ep.setNextHop("Host2")
1006 DU_ep.setPrefixLength(prefixLength)
1007 DU_ep.setAddressFamily(addressFamily)
1008 //MH RAN end point update
1010 String DUEG_routeId = UUID.randomUUID().toString()
1011 execution.setVariable("tranportEp_ID_DUEG", DUEG_routeId)
1012 NetworkRoute DUEG_ep = new NetworkRoute()
1013 DUEG_ep.setRouteId(DUEG_routeId)
1014 DUEG_ep.setFunction(function)
1015 DUEG_ep.setRole(role)
1016 DUEG_ep.setType(type)
1017 DUEG_ep.setIpAddress("192.168.100.5")
1018 DUEG_ep.setLogicalInterfaceId("1234")
1019 DUEG_ep.setPrefixLength(prefixLength)
1020 DUEG_ep.setAddressFamily(addressFamily)
1021 DUEG_ep.setNextHop("Host3")
1023 String CUIN_routeId = UUID.randomUUID().toString()
1024 execution.setVariable("tranportEp_ID_CUIN", CUIN_routeId)
1025 NetworkRoute CUIN_ep = new NetworkRoute()
1026 CUIN_ep.setRouteId(CUIN_routeId)
1027 CUIN_ep.setFunction(function)
1028 CUIN_ep.setRole(role)
1029 CUIN_ep.setType(type)
1030 CUIN_ep.setIpAddress("192.168.100.6")
1031 CUIN_ep.setLogicalInterfaceId("1234")
1032 CUIN_ep.setNextHop("Host4")
1033 CUIN_ep.setPrefixLength(prefixLength)
1034 CUIN_ep.setAddressFamily(addressFamily)
1036 AAIResourcesClient client = new AAIResourcesClient()
1037 logger.debug("creating bh endpoint . ID : "+bh_routeId+" node details : "+bh_ep.toString())
1038 AAIResourceUri networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), bh_routeId)
1039 client.create(networkRouteUri, bh_ep)
1040 logger.debug("creating RU endpoint . ID : "+RU_routeId+" node details : "+RU_ep.toString())
1041 networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), RU_routeId)
1042 client.create(networkRouteUri, RU_ep)
1043 logger.debug("creating DUIN endpoint . ID : "+DUIN_routeId+" node details : "+DU_ep.toString())
1044 networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), DUIN_routeId)
1045 client.create(networkRouteUri, DU_ep)
1046 logger.debug("creating DUEG endpoint . ID : "+DUEG_routeId+" node details : "+DUEG_ep.toString())
1047 networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), DUEG_routeId)
1048 client.create(networkRouteUri, DUEG_ep)
1049 logger.debug("creating CUIN endpoint . ID : "+CUIN_routeId+" node details : "+CUIN_ep.toString())
1050 networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), CUIN_routeId)
1051 client.create(networkRouteUri, CUIN_ep)
1052 //relationship b/w bh_ep and RAN NSSI
1053 def AN_NSSI = execution.getVariable("RANServiceInstanceId")
1054 Relationship relationship = new Relationship()
1055 String relatedLink = "aai/v21/network/network-routes/network-route/${bh_routeId}"
1056 relationship.setRelatedLink(relatedLink)
1057 relationship.setRelatedTo("network-route")
1058 relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
1059 anNssmfUtils.createRelationShipInAAI(execution, relationship, AN_NSSI)
1060 def ANNF_serviceInstanceId = execution.getVariable("RANNFServiceInstanceId")
1061 relatedLink = "aai/v21/network/network-routes/network-route/${RU_routeId}"
1062 relationship.setRelatedLink(relatedLink)
1063 anNssmfUtils.createRelationShipInAAI(execution, relationship, ANNF_serviceInstanceId)
1064 relatedLink = "aai/v21/network/network-routes/network-route/${DUIN_routeId}"
1065 relationship.setRelatedLink(relatedLink)
1066 anNssmfUtils.createRelationShipInAAI(execution, relationship, ANNF_serviceInstanceId)
1067 relatedLink = "aai/v21/network/network-routes/network-route/${DUEG_routeId}"
1068 relationship.setRelatedLink(relatedLink)
1069 anNssmfUtils.createRelationShipInAAI(execution, relationship, ANNF_serviceInstanceId)
1070 relatedLink = "aai/v21/network/network-routes/network-route/${CUIN_routeId}"
1071 relationship.setRelatedLink(relatedLink)
1072 anNssmfUtils.createRelationShipInAAI(execution, relationship, ANNF_serviceInstanceId)
1073 } catch (BpmnError e) {
1075 } catch (Exception ex) {
1076 String msg = "Exception in createEndPointsInAai " + ex.getMessage()
1078 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)