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
34 import java.sql.Timestamp
36 import static org.apache.commons.lang3.StringUtils.isBlank
37 import com.google.gson.JsonObject
38 import com.fasterxml.jackson.databind.ObjectMapper
39 import com.google.gson.JsonArray
40 import org.onap.aai.domain.yang.Relationship
41 import org.onap.aaiclient.client.aai.AAIResourcesClient
42 import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
43 import org.onap.so.beans.nsmf.AllocateTnNssi
44 import org.onap.so.beans.nsmf.EsrInfo
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
57 class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor {
60 ExceptionUtil exceptionUtil = new ExceptionUtil()
61 RequestDBUtil requestDBUtil = new RequestDBUtil()
62 JsonUtils jsonUtil = new JsonUtils()
63 OofUtils oofUtils = new OofUtils()
64 AnNssmfUtils anNssmfUtils = new AnNssmfUtils()
65 ObjectMapper objectMapper = new ObjectMapper();
66 private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil)
68 private static final Logger logger = LoggerFactory.getLogger(DoAllocateAccessNSSI.class)
71 void preProcessRequest(DelegateExecution execution) {
72 logger.debug(Prefix + "preProcessRequest Start")
73 execution.setVariable("prefix", Prefix)
74 execution.setVariable("startTime", System.currentTimeMillis())
78 logger.debug("input variables : msoRequestId - "+execution.getVariable("msoRequestId")
79 +" modelInvariantUuid - "+execution.getVariable("modelInvariantUuid")+
80 " modelUuid - "+execution.getVariable("modelUuid")+
81 " globalSubscriberId - "+execution.getVariable("globalSubscriberId")+
82 " dummyServiceId - "+ execution.getVariable("dummyServiceId")+
83 " nsiId - "+execution.getVariable("nsiId")+
84 " networkType - "+execution.getVariable("networkType")+
85 " subscriptionServiceType - "+execution.getVariable("subscriptionServiceType")+
86 " jobId - "+execution.getVariable("jobId")+
87 " sliceParams - "+execution.getVariable("sliceParams")+
88 " servicename - "+ execution.getVariable("servicename"))
90 //validate slice subnet inputs
92 String sliceParams = execution.getVariable("sliceParams")
93 String sliceProfile = jsonUtil.getJsonValue(sliceParams, "sliceProfile")
94 if (isBlank(sliceProfile)) {
95 msg = "Input sliceProfile is null"
97 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
99 execution.setVariable("sliceProfile", sliceProfile)
101 String sliceProfileId = jsonUtil.getJsonValue(sliceProfile, "sliceProfileId")
102 def snssaiList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceProfile, "snssaiList"))
103 def plmnIdList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceProfile, "plmnIdList"))
104 def coverageAreaTAList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceProfile, "coverageAreaTAList"))
106 if (isBlank(sliceProfileId) || (snssaiList.empty) || (plmnIdList.empty)
107 || (coverageAreaTAList.empty)) {
109 msg = "Mandatory slice profile fields are empty"
111 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
113 execution.setVariable("sliceProfileId", sliceProfileId)
114 execution.setVariable("snssaiList", snssaiList)
115 execution.setVariable("plmnIdList", plmnIdList)
116 execution.setVariable("coverageAreaTAList", coverageAreaTAList)
118 String nsiName = jsonUtil.getJsonValue(sliceParams, "nsiInfo.nsiName")
119 String scriptName = jsonUtil.getJsonValue(sliceParams, "scriptName")
120 execution.setVariable("nsiName", nsiName)
121 execution.setVariable("scriptName", scriptName)
122 //generate RAN,RAN NF NSSIs - will be re assigned if oof returns existing NSSI
123 String RANServiceInstanceId = UUID.randomUUID().toString()
124 String RANNFServiceInstanceId = UUID.randomUUID().toString()
125 logger.debug("RAN serviceInstance Id "+RANServiceInstanceId)
126 logger.debug("RAN NF serviceInstance Id "+RANNFServiceInstanceId)
127 execution.setVariable("RANServiceInstanceId", RANServiceInstanceId)
128 execution.setVariable("RANNFServiceInstanceId", RANNFServiceInstanceId)
129 execution.setVariable("ranNssiPreferReuse", true)
130 execution.setVariable("ranNfNssiPreferReuse", true)
131 execution.setVariable("job_timeout", 10)
134 List<String> BH_endPoints = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceParams, "endPoints"))
135 logger.debug("BH end points list : "+BH_endPoints)
136 if(BH_endPoints.empty) {
137 msg = "End point info is empty"
139 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
141 execution.setVariable("bh_endpoint", BH_endPoints.get(0))
144 } catch(BpmnError e) {
146 } catch(Exception ex) {
147 msg = "Exception in DoAllocateAccessNSSI.preProcessRequest " + ex.getMessage()
149 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
151 logger.debug(Prefix + "preProcessRequest Exit")
155 * Prepare request params for decomposing RAN NSST
158 def prepareDecomposeService = { DelegateExecution execution ->
159 logger.debug(Prefix+"prepareDecomposeService method start")
160 String RANServiceInstanceId = execution.getVariable("RANServiceInstanceId")
161 String modelInvariantUuid = execution.getVariable("modelInvariantUuid")
162 String modelUuid = execution.getVariable("modelUuid")
163 String serviceModelInfo = """{
164 "modelInvariantUuid":"${modelInvariantUuid}",
165 "modelUuid":"${modelUuid}",
168 execution.setVariable("serviceModelInfo", serviceModelInfo)
169 execution.setVariable("serviceInstanceId", RANServiceInstanceId)
170 logger.debug("serviceModelInfo : "+serviceModelInfo)
171 logger.debug("Finish RAN NSST prepareDecomposeService")
174 /* process the decompose service(RAN NSST) response
177 def processDecomposition = { DelegateExecution execution ->
178 logger.debug(Prefix+"processDecomposition method start")
179 ServiceDecomposition ranNsstServiceDecomposition = execution.getVariable("ranNsstServiceDecomposition")
180 logger.debug("ranNsstServiceDecomposition : "+ranNsstServiceDecomposition.toString())
181 //RAN NSST decomposition
182 String ranModelVersion = ranNsstServiceDecomposition.getModelInfo().getModelVersion()
183 String ranModelName = ranNsstServiceDecomposition.getModelInfo().getModelName()
184 List<ServiceProxy> serviceProxyList = ranNsstServiceDecomposition.getServiceProxy()
185 List<String> nsstInfoList = new ArrayList<>()
186 for(ServiceProxy serviceProxy : serviceProxyList)
188 String nsstModelUuid = serviceProxy.getModelInfo().getModelUuid()
189 String nsstModelInvariantUuid = serviceProxy.getModelInfo().getModelInvariantUuid()
190 String name = serviceProxy.getModelInfo().getModelName()
191 String nsstServiceModelInfo = """{
192 "UUID":"${nsstModelUuid}",
193 "invariantUUID":"${nsstModelInvariantUuid}",
196 nsstInfoList.add(nsstServiceModelInfo)
199 int maxIndex=nsstInfoList.size()
202 String msg = "Exception in RAN NSST processDecomposition. There is no NSST associated with RAN NSST "
204 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
206 execution.setVariable("ranNsstInfoList",nsstInfoList)
207 execution.setVariable("ranModelVersion", ranModelVersion)
208 execution.setVariable("ranModelName", ranModelName)
209 execution.setVariable("currentIndex",currentIndex)
210 execution.setVariable("maxIndex",maxIndex)
211 logger.debug(Prefix+"processDecomposition maxIndex value - "+maxIndex)
215 * Function to subnet capabilities from nssmf adapter
217 def getSubnetCapabilities = { DelegateExecution execution ->
218 logger.debug(Prefix+"getSubnetCapabilities method start")
220 String tnNssmfRequest = anNssmfUtils.buildCreateTNNSSMFSubnetCapabilityRequest()
222 String urlString = "/api/rest/provMns/v1/NSS/subnetCapabilityQuery"
224 String tnNssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, tnNssmfRequest)
226 if (tnNssmfResponse != null) {
227 String FHCapabilities= jsonUtil.getJsonValue(tnNssmfResponse, "TN_FH")
228 String MHCapabilities = jsonUtil.getJsonValue(tnNssmfResponse, "TN_MH")
229 execution.setVariable("FHCapabilities",FHCapabilities)
230 execution.setVariable("MHCapabilities",MHCapabilities)
233 logger.error("received error message from NSSMF : "+ tnNssmfResponse)
234 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.")
236 String anNssmfRequest = anNssmfUtils.buildCreateANNFNSSMFSubnetCapabilityRequest()
238 String anNssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, anNssmfRequest)
240 if (anNssmfResponse != null) {
241 String ANNFCapabilities = jsonUtil.getJsonValue(anNssmfResponse, "AN_NF")
242 execution.setVariable("ANNFCapabilities",ANNFCapabilities)
245 logger.error("received error message from NSSMF : "+ anNssmfResponse)
246 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.")
251 * prepare OOF request for RAN NSSI selection
253 def prepareOofRequestForRanNSS = { DelegateExecution execution ->
254 logger.debug(Prefix+"prepareOofRequestForRanNSS method start")
256 String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
257 logger.debug( "get NSSI option OOF Url: " + urlString)
259 //build oof request body
260 boolean ranNssiPreferReuse = execution.getVariable("ranNssiPreferReuse");
261 String requestId = execution.getVariable("msoRequestId")
262 String messageType = "NSISelectionResponse"
263 Map<String, Object> profileInfo = objectMapper.readValue(execution.getVariable("sliceProfile"), Map.class)
264 String modelUuid = execution.getVariable("modelUuid")
265 String modelInvariantUuid = execution.getVariable("modelInvariantUuid")
266 String modelName = execution.getVariable("ranModelName")
267 String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution);
268 List<String> nsstInfoList = objectMapper.readValue(execution.getVariable("nsstInfoList"), List.class)
269 JsonArray capabilitiesList = new JsonArray()
270 String FHCapabilities = execution.getVariable("FHCapabilities")
271 String MHCapabilities = execution.getVariable("MHCapabilities")
272 String ANNFCapabilities = execution.getVariable("ANNFCapabilities")
273 JsonObject FH = new JsonObject()
274 JsonObject MH = new JsonObject()
275 JsonObject ANNF = new JsonObject()
276 FH.addProperty("domainType", "TN_FH")
277 FH.addProperty("capabilityDetails", FHCapabilities)
278 MH.addProperty("domainType", "TN_MH")
279 MH.addProperty("capabilityDetails", MHCapabilities)
280 ANNF.addProperty("domainType", "AN_NF")
281 ANNF.addProperty("capabilityDetails", FHCapabilities)
282 capabilitiesList.add(FH)
283 capabilitiesList.add(MH)
284 capabilitiesList.add(ANNF)
286 execution.setVariable("nssiSelection_Url", "/api/oof/selection/nsi/v1")
287 execution.setVariable("nssiSelection_messageType",messageType)
288 execution.setVariable("nssiSelection_correlator",requestId)
289 execution.setVariable("nssiSelection_timeout",timeout)
291 String oofRequest = anNssmfUtils.buildSelectRANNSSIRequest(requestId, messageType, modelUuid,modelInvariantUuid,
292 modelName, profileInfo, nsstInfoList, capabilitiesList, ranNssiPreferReuse)
294 execution.setVariable("nssiSelection_oofRequest",oofRequest)
295 logger.debug("Sending request to OOF: " + oofRequest)
298 * process OOF response for RAN NSSI selection
300 def processOofResponseForRanNSS = { DelegateExecution execution ->
301 logger.debug(Prefix+"processOofResponseForRanNSS method start")
302 String oofResponse = execution.getVariable("nssiSelection_asyncCallbackResponse")
303 String requestStatus = jsonUtil.getJsonValue(oofResponse, "requestStatus")
304 if(requestStatus.equals("completed")) {
305 List<String> solution = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(oofResponse, "solutions"))
306 boolean existingNSI = jsonUtil.getJsonValue(solution.get(0), "existingNSI")
308 def sharedNSISolution = jsonUtil.getJsonValue(solution.get(0), "sharedNSISolution")
309 execution.setVariable("sharedRanNSSISolution", sharedNSISolution)
310 logger.debug("sharedRanNSSISolution from OOF "+sharedNSISolution)
311 String RANServiceInstanceId = jsonUtil.getJsonValue(solution.get(0), "sharedNSISolution.NSIId")
312 execution.setVariable("RANServiceInstanceId", RANServiceInstanceId)
313 ServiceInstance serviceInstance = new ServiceInstance();
314 serviceInstance.setInstanceId(RANServiceInstanceId);
315 ServiceDecomposition serviceDecomposition = execution.getVariable("ranNsstServiceDecomposition")
316 serviceDecomposition.setServiceInstance(serviceInstance);
317 execution.setVariable("ranNsstServiceDecomposition", serviceDecomposition)
318 execution.setVariable("isRspRanNssi", true)
320 def sliceProfiles = jsonUtil.getJsonValue(solution.get(0), "newNSISolution.sliceProfiles")
321 execution.setVariable("RanConstituentSliceProfiles", sliceProfiles)
322 logger.debug("RanConstituentSliceProfiles list from OOF "+sliceProfiles)
325 String statusMessage = jsonUtil.getJsonValue(oofResponse, "statusMessage")
326 logger.error("received failed status from oof "+ statusMessage)
327 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a failed Async Response from OOF : "+statusMessage)
332 def prepareModifyAccessNssiInputs = { DelegateExecution execution ->
333 logger.debug(Prefix+"prepareModifyAccessNssiInputs method start")
334 String jobId = UUID.randomUUID().toString()
335 execution.setVariable("modifyRanNssiJobId", jobId)
336 String snssaiList = execution.getVariable("snssaiList")
337 String sliceParams = execution.getVariable("sliceParams")
338 String sliceProfileId = execution.getVariable("sliceProfileId")
339 String nsiInfo = jsonUtil.getJsonValue(sliceParams, "nsiInfo")
340 String scriptName = execution.getVariable("scriptName")
342 JsonObject modifySliceParams = new JsonObject()
343 modifySliceParams.addProperty("modifyAction", "allocate")
344 modifySliceParams.addProperty("snssaiList", snssaiList)
345 modifySliceParams.addProperty("sliceProfileId", sliceProfileId)
346 modifySliceParams.addProperty("nsiInfo", nsiInfo)
347 modifySliceParams.addProperty("scriptName", scriptName)
349 execution.setVariable("modifySliceParams", modifySliceParams.toString())
350 //create operation status in request db
351 String serviceId = execution.getVariable("RANServiceInstanceId")
352 String nsiId = execution.getVariable("nsiId")
353 logger.debug("Generated new job for Service Instance serviceId:" + serviceId + "jobId:" + jobId)
355 ResourceOperationStatus initStatus = new ResourceOperationStatus()
356 initStatus.setServiceId(serviceId)
357 initStatus.setOperationId(jobId)
358 initStatus.setResourceTemplateUUID(nsiId)
359 initStatus.setOperType("Modify")
360 requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus)
363 def createModifyNssiQueryJobStatus = { DelegateExecution execution ->
364 logger.debug(Prefix+"createModifyNssiQueryJobStatus method start")
365 EsrInfo esrInfo = new EsrInfo()
366 esrInfo.setNetworkType("AN")
367 esrInfo.setVendor("ONAP")
368 String esrInfoString = objectMapper.writeValueAsString(esrInfo)
369 execution.setVariable("esrInfo", esrInfoString)
370 JsonObject serviceInfo = new JsonObject()
371 serviceInfo.addProperty("nssiId", execution.getVariable("RANServiceInstanceId"))
372 serviceInfo.addProperty("nsiId", execution.getVariable("nsiId"))
373 serviceInfo.addProperty("nssiName", execution.getVariable("servicename"))
374 String sST = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "sST")
375 serviceInfo.addProperty("sST", sST)
376 serviceInfo.addProperty("PLMNIdList", objectMapper.writeValueAsString(execution.getVariable("plmnIdList")))
377 serviceInfo.addProperty("globalSubscriberId", execution.getVariable("globalSubscriberId"))
378 serviceInfo.addProperty("subscriptionServiceType", execution.getVariable("subscriptionServiceType"))
379 serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("modelInvariantUuid"))
380 serviceInfo.addProperty("serviceUuid", execution.getVariable("modelUuid"))
381 execution.setVariable("serviceInfo", serviceInfo.toString())
382 execution.setVariable("responseId", "")
384 def prepareNsstDecomposeService = { DelegateExecution execution ->
385 logger.debug(Prefix+"prepareNsstDecomposeService method start")
386 List<String> nsstInfoList = objectMapper.readValue(execution.getVariable("ranNsstInfoList"), List.class)
387 int currentIndex = execution.getVariable("currentIndex")
388 int maxIndex = execution.getVariable("maxIndex")
389 logger.debug(Prefix+"prepareNsstDecomposeService : currentIndex value - "+currentIndex+" maxIndex : "+maxIndex)
390 if(currentIndex<maxIndex) {
391 String nsstInfo = nsstInfoList.get(currentIndex)
392 String modelInvariantUuid = jsonUtil.getJsonValue(nsstInfo, "invariantUUID")
393 String modelUuid = jsonUtil.getJsonValue(nsstInfo, "UUID")
395 String serviceModelInfo = """{
396 "modelInvariantUuid":"${modelInvariantUuid}",
397 "modelUuid":"${modelUuid}",
400 execution.setVariable("serviceModelInfo", serviceModelInfo)
401 execution.setVariable("serviceInstanceId", "")
402 logger.debug("serviceModelInfo : "+serviceModelInfo)
404 execution.setVariable("currentIndex", currentIndex)
406 logger.error("nsstList decomposition error ")
407 exceptionUtil.buildAndThrowWorkflowException(execution, 1000, "nsstList decomposition error ")
411 def processNsstDecomposition = { DelegateExecution execution ->
412 logger.debug(Prefix+"processNsstDecomposition method start")
413 ServiceDecomposition decomposedNsst = execution.getVariable("nsstServiceDecomposition")
414 logger.debug("decomposedNsst : "+decomposedNsst.toString())
416 String nsstType = decomposedNsst.getServiceRole() //domainType
417 String modelVersion = decomposedNsst.getModelInfo().getModelVersion()
418 String modelName = decomposedNsst.getModelInfo().getModelName()
419 String modelUuid = decomposedNsst.getModelInfo().getModelUuid()
420 String modelInvariantUuid = decomposedNsst.getModelInfo().getModelInvariantUuid()
424 execution.setVariable("ANNF_modelInvariantUuid", modelInvariantUuid)
425 execution.setVariable("ANNF_modelUuid", modelUuid)
426 execution.setVariable("ANNF_modelVersion", modelVersion)
427 execution.setVariable("ANNF_modelName", modelName)
428 execution.setVariable("ANNF_ServiceDecomposition", decomposedNsst)
431 execution.setVariable("TNFH_modelInvariantUuid", modelInvariantUuid)
432 execution.setVariable("TNFH_modelUuid", modelUuid)
433 execution.setVariable("TNFH_modelVersion", modelVersion)
434 execution.setVariable("TNFH_modelName", modelName)
435 execution.setVariable("TNFH_ServiceDecomposition", decomposedNsst)
438 execution.setVariable("TNMH_modelInvariantUuid", modelInvariantUuid)
439 execution.setVariable("TNMH_modelUuid", modelUuid)
440 execution.setVariable("TNMH_modelVersion", modelVersion)
441 execution.setVariable("TNMH_modelName", modelName)
442 execution.setVariable("TNMH_ServiceDecomposition", decomposedNsst)
445 logger.debug("No expected match found for current nsstType")
446 logger.error("No expected match found for current nsstType "+ nsstType)
447 exceptionUtil.buildAndThrowWorkflowException(execution, 1000,"No expected match found for current nsstType "+ nsstType)
449 boolean isAllNsstsDecomposed = false
450 int currentIndex = execution.getVariable("currentIndex")
451 int maxIndex = execution.getVariable("maxIndex")
452 if(currentIndex == maxIndex) {
453 isAllNsstsDecomposed = true
455 execution.setVariable("isAllNsstsDecomposed", isAllNsstsDecomposed)
458 * prepare OOF request for NF RAN NSSI selection
460 def prepareOofRequestForRanNfNSS = { DelegateExecution execution ->
461 logger.debug(Prefix+"prepareOofRequestForRanNfNSS method start")
462 String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
463 logger.debug( "get NSSI option OOF Url: " + urlString)
465 //build oof request body
466 boolean ranNfNssiPreferReuse = execution.getVariable("ranNfNssiPreferReuse");
467 String requestId = execution.getVariable("msoRequestId")
468 String messageType = "NSSISelectionResponse"
469 List<String> ranConstituentSliceProfiles = jsonUtil.StringArrayToList(execution.getVariable("RanConstituentSliceProfiles"))
470 anNssmfUtils.createDomainWiseSliceProfiles(ranConstituentSliceProfiles, execution)
471 Map<String, Object> profileInfo = objectMapper.readValue(execution.getVariable("ranNfSliceProfile"), Map.class)
472 String modelUuid = execution.getVariable("ANNF_modelUuid")
473 String modelInvariantUuid = execution.getVariable("ANNF_modelInvariantUuid")
474 String modelName = execution.getVariable("ANNF_modelName")
475 String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution);
477 execution.setVariable("nssiSelection_Url", "/api/oof/selection/nssi/v1")
478 execution.setVariable("nssiSelection_messageType",messageType)
479 execution.setVariable("nssiSelection_correlator",requestId)
480 execution.setVariable("nssiSelection_timeout",timeout)
482 String oofRequest = oofUtils.buildSelectNSSIRequest(requestId, messageType, modelUuid, modelInvariantUuid, modelName, profileInfo)
484 execution.setVariable("nssiSelection_oofRequest",oofRequest)
487 * process OOF response for RAN NF NSSI selection
489 def processOofResponseForRanNfNSS = { DelegateExecution execution ->
490 logger.debug(Prefix+"processOofResponseForRanNfNSS method start")
491 String oofResponse = execution.getVariable("nfNssiSelection_asyncCallbackResponse")
492 String requestStatus = jsonUtil.getJsonValue(oofResponse, "requestStatus")
493 if(requestStatus.equals("completed")) {
494 List<String> solution = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(oofResponse, "solutions"))
495 if(solution.size()>=1) {
496 String ranNfNssiId = jsonUtil.getJsonValue(solution.get(0), "NSSIId")
497 String invariantUuid = jsonUtil.getJsonValue(solution.get(0), "invariantUUID")
498 String uuid = jsonUtil.getJsonValue(solution.get(0), "UUID")
499 String nssiName = jsonUtil.getJsonValue(solution.get(0), "NSSIName")
500 execution.setVariable("RANNFServiceInstanceId", ranNfNssiId)
501 execution.setVariable("RANNFInvariantUUID", invariantUuid)
502 execution.setVariable("RANNFUUID", uuid)
503 execution.setVariable("RANNFNssiName", nssiName)
504 logger.debug("RANNFServiceInstanceId from OOF "+ranNfNssiId)
506 ServiceInstance serviceInstance = new ServiceInstance();
507 serviceInstance.setInstanceId(ranNfNssiId);
508 ServiceDecomposition serviceDecomposition = execution.getVariable("ANNF_ServiceDecomposition")
509 serviceDecomposition.setServiceInstance(serviceInstance);
510 execution.setVariable("ANNF_ServiceDecomposition", serviceDecomposition)
511 execution.setVariable("isRspRanNfNssi", true)
513 logger.debug("No solutions returned from OOF .. Create new RAN NF NSSI")
516 String statusMessage = jsonUtil.getJsonValue(oofResponse, "statusMessage")
517 logger.error("received failed status from oof "+ statusMessage)
518 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a failed Async Response from OOF : "+statusMessage)
522 def createSliceProfilesInAai = { DelegateExecution execution ->
523 logger.debug(Prefix+"createSliceProfilesInAai method start")
524 anNssmfUtils.createSliceProfilesInAai(execution)
527 def processRanNfModifyRsp = { DelegateExecution execution ->
528 logger.debug(Prefix+"processRanNfModifyRsp method start")
529 anNssmfUtils.processRanNfModifyRsp(execution)
531 org.onap.aai.domain.yang.ServiceInstance ANServiceInstance = new ServiceInstance();
532 //AN instance creation
533 ANServiceInstance.setServiceInstanceId(execution.getVariable("RANServiceInstanceId"))
534 String sliceInstanceName = execution.getVariable("servicename")
535 ANServiceInstance.setServiceInstanceName(sliceInstanceName)
536 String serviceType = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "sST")
537 ANServiceInstance.setServiceType(serviceType)
538 String serviceStatus = "deactivated"
539 ANServiceInstance.setOrchestrationStatus(serviceStatus)
540 String serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "plmnIdList")
541 ANServiceInstance.setServiceInstanceLocationId(serviceInstanceLocationid)
542 String serviceRole = "nssi"
543 ANServiceInstance.setServiceRole(serviceRole)
544 List<String> snssaiList = objectMapper.readValue(execution.getVariable("snssaiList"), List.class)
545 String snssai = snssaiList.get(0)
546 ANServiceInstance.setEnvironmentContext(snssai)
547 ANServiceInstance.setWorkloadContext("AN")
549 logger.debug("completed AN service instance build "+ ANServiceInstance.toString())
553 AAIResourcesClient client = new AAIResourcesClient()
554 AAIResourceUri nssiServiceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(execution.getVariable("RANServiceInstanceId")))
555 client.create(nssiServiceUri, ANServiceInstance)
557 } catch (BpmnError e) {
559 } catch (Exception ex) {
560 msg = "Exception in AnNssmfUtils.createSliceProfilesInAai " + ex.getMessage()
562 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
565 createEndPointsInAai(execution)
568 def createSdnrRequest = { DelegateExecution execution ->
569 logger.debug(Prefix+"createSdnrRequest method start")
570 String callbackUrl = UrnPropertiesReader.getVariable("mso.workflow.message.endpoint") + "/AsyncSdnrResponse/"+execution.getVariable("msoRequestId")
571 String sdnrRequest = buildSdnrAllocateRequest(execution, "allocate", "InstantiateRANSlice", callbackUrl)
572 execution.setVariable("createNSSI_sdnrRequest", sdnrRequest)
573 execution.setVariable("createNSSI_timeout", "PT10M")
574 execution.setVariable("createNSSI_correlator", execution.getVariable("msoRequestId"))
575 execution.setVariable("createNSSI_messageType", "AsyncSdnrResponse");
578 def processSdnrResponse = { DelegateExecution execution ->
579 logger.debug(Prefix+"processSdnrResponse method start")
580 String SDNRResponse = execution.getVariable("SDNR_asyncCallbackResponse")
581 String status = jsonUtil.getJsonValue(SDNRResponse, "status")
582 if(status.equalsIgnoreCase("success")) {
583 String nfIds = jsonUtil.getJsonValue(SDNRResponse, "nfIds")
584 execution.setVariable("ranNfIdsJson", nfIds)
586 String reason = jsonUtil.getJsonValue(SDNRResponse, "reason")
587 logger.error("received failed status from SDNR "+ reason)
588 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from SDNR "+ reason)
590 logger.debug("response from SDNR "+SDNRResponse)
593 def updateAaiWithRANInstances = { DelegateExecution execution ->
594 logger.debug(Prefix+"updateAaiWithRANInstances method start")
596 org.onap.aai.domain.yang.ServiceInstance ANServiceInstance = new ServiceInstance();
597 org.onap.aai.domain.yang.ServiceInstance ANNFServiceInstance = new ServiceInstance();
598 //AN instance creation
599 ANServiceInstance.setServiceInstanceId(execution.getVariable("RANServiceInstanceId"))
600 String sliceInstanceName = execution.getVariable("servicename")
601 ANServiceInstance.setServiceInstanceName(sliceInstanceName)
602 String serviceType = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "sST")
603 ANServiceInstance.setServiceType(serviceType)
604 String serviceStatus = "deactivated"
605 ANServiceInstance.setOrchestrationStatus(serviceStatus)
606 String serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "plmnIdList")
607 ANServiceInstance.setServiceInstanceLocationId(serviceInstanceLocationid)
608 String serviceRole = "nssi"
609 ANServiceInstance.setServiceRole(serviceRole)
610 List<String> snssaiList = objectMapper.readValue(execution.getVariable("snssaiList"), List.class)
611 String snssai = snssaiList.get(0)
612 ANServiceInstance.setEnvironmentContext(snssai)
613 ANServiceInstance.setWorkloadContext("AN")
615 logger.debug("completed AN service instance build "+ ANServiceInstance.toString())
617 ANNFServiceInstance.setServiceInstanceId(execution.getVariable("RANNFServiceInstanceId"))
618 sliceInstanceName = execution.getVariable("ANNF_modelName")
619 ANNFServiceInstance.setServiceInstanceName(sliceInstanceName)
620 ANNFServiceInstance.setServiceType(serviceType)
621 ANNFServiceInstance.setOrchestrationStatus(serviceStatus)
622 serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "plmnIdList")
623 ANNFServiceInstance.setServiceInstanceLocationId(serviceInstanceLocationid)
624 ANNFServiceInstance.setServiceRole(serviceRole)
625 snssaiList = objectMapper.readValue(execution.getVariable("snssaiList"), List.class)
626 snssai = snssaiList.get(0)
627 ANNFServiceInstance.setEnvironmentContext(snssai)
628 ANNFServiceInstance.setWorkloadContext("AN-NF")
629 logger.debug("completed AN service instance build "+ ANNFServiceInstance.toString())
634 AAIResourcesClient client = new AAIResourcesClient()
635 AAIResourceUri nssiServiceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(execution.getVariable("RANServiceInstanceId")))
636 client.create(nssiServiceUri, ANServiceInstance)
638 AAIResourceUri nssiServiceUri1 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(execution.getVariable("RANNFServiceInstanceId")))
639 client.create(nssiServiceUri1, ANNFServiceInstance)
641 } catch (BpmnError e) {
643 } catch (Exception ex) {
644 msg = "Exception in AnNssmfUtils.createSliceProfilesInAai " + ex.getMessage()
646 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
649 createEndPointsInAai(execution)
651 def prepareTnFhRequest = { DelegateExecution execution ->
652 logger.debug(Prefix+"prepareTnFhRequest method start")
654 String nssmfRequest = anNssmfUtils.buildCreateNSSMFRequest(execution, "TN_FH", "allocate")
655 String urlString = "/api/rest/provMns/v1/NSS/SliceProfiles"
656 String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest)
658 if (nssmfResponse != null) {
659 execution.setVariable("nssmfResponse", nssmfResponse)
660 String jobId = jsonUtil.getJsonValue(nssmfResponse, "jobId")
661 execution.setVariable("TNFH_jobId",jobId)
663 logger.error("received error message from NSSMF : "+ nssmfResponse)
664 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.")
666 logger.debug("Exit prepareTnFhRequest")
669 def prepareTnMhRequest = { DelegateExecution execution ->
670 logger.debug(Prefix+"prepareTnMhRequest method start")
672 String nssmfRequest = anNssmfUtils.buildCreateNSSMFRequest(execution, "TN_MH", "allocate")
673 String urlString = "/api/rest/provMns/v1/NSS/SliceProfiles"
674 String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest)
676 if (nssmfResponse != null) {
677 execution.setVariable("nssmfResponse", nssmfResponse)
678 String jobId = jsonUtil.getJsonValue(nssmfResponse, "jobId")
679 execution.setVariable("TNMH_jobId",jobId)
681 logger.error("received error message from NSSMF : "+ nssmfResponse)
682 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.")
684 logger.debug("Exit prepareTnMhRequest")
687 def createFhAllocateNssiJobQuery = { DelegateExecution execution ->
688 logger.debug(Prefix+"createModifyNssiQueryJobStatus method start")
689 createTnAllocateNssiJobQuery(execution, "TN_FH")
692 def createMhAllocateNssiJobQuery = { DelegateExecution execution ->
693 logger.debug(Prefix+"createModifyNssiQueryJobStatus method start")
694 createTnAllocateNssiJobQuery(execution, "TN_MH")
697 private void createTnAllocateNssiJobQuery(DelegateExecution execution, String domainType) {
698 EsrInfo esrInfo = new EsrInfo()
699 esrInfo.setNetworkType("TN")
700 esrInfo.setVendor("ONAP")
701 String esrInfoString = objectMapper.writeValueAsString(esrInfo)
702 execution.setVariable("esrInfo", esrInfoString)
703 JsonObject serviceInfo = new JsonObject()
704 serviceInfo.addProperty("nssiId", null)
705 serviceInfo.addProperty("nsiId", execution.getVariable("nsiId"))
706 String sST = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "sST")
707 serviceInfo.addProperty("sST", sST)
708 serviceInfo.addProperty("PLMNIdList", objectMapper.writeValueAsString(execution.getVariable("plmnIdList")))
709 serviceInfo.addProperty("globalSubscriberId", execution.getVariable("globalSubscriberId"))
710 serviceInfo.addProperty("subscriptionServiceType", execution.getVariable("subscriptionServiceType"))
711 if(domainType.equals("TN_FH")) {
712 serviceInfo.addProperty("nssiName", execution.getVariable("TNFH_modelName"))
713 serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("TNFH_modelInvariantUuid"))
714 serviceInfo.addProperty("serviceUuid", execution.getVariable("TNFH_modelUuid"))
715 }else if(domainType.equals("TN_MH")) {
716 serviceInfo.addProperty("nssiName", execution.getVariable("TNMH_modelName"))
717 serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("TNMH_modelInvariantUuid"))
718 serviceInfo.addProperty("serviceUuid", execution.getVariable("TNMH_modelUuid"))
720 execution.setVariable("serviceInfo", serviceInfo.toString())
721 execution.setVariable("responseId", "")
724 def processFhAllocateNssiJobStatusRsp = { DelegateExecution execution ->
725 logger.debug(Prefix+"processJobStatusRsp method start")
726 String jobResponse = execution.getVariable("TNFH_jobResponse")
727 logger.debug("Job status response "+jobResponse)
728 String status = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.status")
729 String nssi = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.nssi")
730 if(status.equalsIgnoreCase("finished")) {
731 execution.setVariable("TNFH_NSSI", nssi)
732 logger.debug("Job successfully completed ... proceeding with flow for nssi : "+nssi)
735 String statusDescription = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.statusDescription")
736 logger.error("received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
737 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
741 def processMhAllocateNssiJobStatusRsp = { DelegateExecution execution ->
742 logger.debug(Prefix+"processJobStatusRsp method start")
743 String jobResponse = execution.getVariable("TNMH_jobResponse")
744 logger.debug("Job status response "+jobResponse)
745 String status = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.status")
746 String nssi = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.nssi")
747 if(status.equalsIgnoreCase("finished")) {
748 execution.setVariable("TNMH_NSSI", nssi)
749 logger.debug("Job successfully completed ... proceeding with flow for nssi : "+nssi)
752 String statusDescription = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.statusDescription")
753 logger.error("received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
754 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
758 def processModifyJobStatusRsp = { DelegateExecution execution ->
759 logger.debug(Prefix+"processJobStatusRsp method start")
760 String jobResponse = execution.getVariable("jobResponse")
761 logger.debug("Job status response "+jobResponse)
762 String status = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.status")
763 String nssi = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.nssi")
764 if(status.equalsIgnoreCase("finished")) {
765 logger.debug("Job successfully completed ... proceeding with flow for nssi : "+nssi)
768 String statusDescription = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.statusDescription")
769 logger.error("received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
770 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
774 def updateAairelationships = { DelegateExecution execution ->
775 logger.debug(Prefix + "updateAairelationships Start")
778 def ANNF_serviceInstanceId = execution.getVariable("RANNFServiceInstanceId")
779 def TNFH_serviceInstanceId = execution.getVariable("TNFH_NSSI")
780 def TNMH_serviceInstanceId = execution.getVariable("TNMH_NSSI")
781 def AN_profileInstanceId = execution.getVariable("sliceProfileId")
782 def AN_NSSI = execution.getVariable("RANServiceInstanceId")
783 def ANNF_profileInstanceId = execution.getVariable("ANNF_sliceProfileInstanceId")
784 def TNFH_profileInstanceId = execution.getVariable("TNFH_sliceProfileInstanceId")
785 def TNMH_profileInstanceId = execution.getVariable("TNMH_sliceProfileInstanceId")
786 String globalSubscriberId = execution.getVariable("globalSubscriberId")
787 String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
789 Relationship ANNF_relationship = new Relationship()
790 Relationship TNFH_relationship = new Relationship()
791 Relationship TNMH_relationship = new Relationship()
793 String ANNF_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${ANNF_profileInstanceId}"
794 String TNFH_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNFH_profileInstanceId}"
795 String TNMH_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNMH_profileInstanceId}"
797 String ANNF_NSSI_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${ANNF_serviceInstanceId}"
798 String TNFH_NSSI_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNFH_serviceInstanceId}"
799 String TNMH_NSSI_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNMH_serviceInstanceId}"
801 ANNF_relationship.setRelatedLink(ANNF_relatedLink)
802 ANNF_relationship.setRelatedTo("service-instance")
803 ANNF_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
804 TNFH_relationship.setRelatedLink(TNFH_relatedLink)
805 TNFH_relationship.setRelatedTo("service-instance")
806 TNFH_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
807 TNMH_relationship.setRelatedLink(TNMH_relatedLink)
808 TNMH_relationship.setRelatedTo("service-instance")
809 TNMH_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
811 // create SliceProfile and NSSI relationship in AAI
812 anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship,ANNF_serviceInstanceId)
813 anNssmfUtils.createRelationShipInAAI(execution, TNFH_relationship,TNFH_serviceInstanceId)
814 anNssmfUtils.createRelationShipInAAI(execution, TNMH_relationship,TNMH_serviceInstanceId)
815 anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship,AN_profileInstanceId)
816 anNssmfUtils.createRelationShipInAAI(execution, TNFH_relationship,AN_profileInstanceId)
817 anNssmfUtils.createRelationShipInAAI(execution, TNMH_relationship,AN_profileInstanceId)
819 //create AN NSSI and ANNF,TNFH,TNMH relationship in AAI
820 ANNF_relationship.setRelatedLink(ANNF_NSSI_relatedLink)
821 TNFH_relationship.setRelatedLink(TNFH_NSSI_relatedLink)
822 TNMH_relationship.setRelatedLink(TNMH_NSSI_relatedLink)
823 anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship,AN_NSSI)
824 anNssmfUtils.createRelationShipInAAI(execution, TNFH_relationship,AN_NSSI)
825 anNssmfUtils.createRelationShipInAAI(execution, TNMH_relationship,AN_NSSI)
827 } catch (BpmnError e) {
829 } catch (Exception ex) {
831 msg = "Exception in DoCreateE2EServiceInstance.createCustomRelationship. " + ex.getMessage()
833 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
838 * update operation status in request db
841 def prepareOperationStatusUpdate = { DelegateExecution execution ->
842 logger.debug(Prefix + "prepareOperationStatusUpdate Start")
844 String serviceId = execution.getVariable("dummyServiceId")
845 String jobId = execution.getVariable("jobId")
846 String nsiId = execution.getVariable("nsiId")
847 String nssiId = execution.getVariable("RANServiceInstanceId")
848 logger.debug("Service Instance serviceId:" + serviceId + " jobId:" + jobId)
850 ResourceOperationStatus updateStatus = new ResourceOperationStatus()
851 updateStatus.setServiceId(serviceId)
852 updateStatus.setOperationId(jobId)
853 updateStatus.setResourceTemplateUUID(nsiId)
854 updateStatus.setResourceInstanceID(nssiId)
855 updateStatus.setOperType("Allocate")
856 updateStatus.setProgress(100)
857 updateStatus.setStatus("finished")
858 requestDBUtil.prepareUpdateResourceOperationStatus(execution, updateStatus)
860 logger.debug(Prefix + "prepareOperationStatusUpdate Exit")
863 def prepareFailedOperationStatusUpdate = { DelegateExecution execution ->
864 logger.debug(Prefix + "prepareFailedOperationStatusUpdate Start")
866 String serviceId = execution.getVariable("dummyServiceId")
867 String jobId = execution.getVariable("jobId")
868 String nsiId = execution.getVariable("nsiId")
869 String nssiId = execution.getVariable("RANServiceInstanceId")
870 logger.debug("Service Instance serviceId:" + serviceId + " jobId:" + jobId)
872 ResourceOperationStatus updateStatus = new ResourceOperationStatus()
873 updateStatus.setServiceId(serviceId)
874 updateStatus.setOperationId(jobId)
875 updateStatus.setResourceTemplateUUID(nsiId)
876 updateStatus.setResourceInstanceID(nssiId)
877 updateStatus.setOperType("Allocate")
878 updateStatus.setProgress(0)
879 updateStatus.setStatus("failed")
880 requestDBUtil.prepareUpdateResourceOperationStatus(execution, updateStatus)
883 private String buildSdnrAllocateRequest(DelegateExecution execution, String action, String rpcName, String callbackUrl) {
885 String requestId = execution.getVariable("msoRequestId")
886 Date date = new Date().getTime()
887 Timestamp time = new Timestamp(date)
888 Map<String,Object> sliceProfile = objectMapper.readValue(execution.getVariable("ranNfSliceProfile"), Map.class)
889 sliceProfile.put("sliceProfileId", execution.getVariable("ANNF_sliceProfileInstanceId"))
890 sliceProfile.put("maxNumberofConns", sliceProfile.get("maxNumberofPDUSessions"))
891 sliceProfile.put("uLThptPerSlice", sliceProfile.get("expDataRateUL"))
892 sliceProfile.put("dLThptPerSlice", sliceProfile.get("expDataRateDL"))
893 String sliceProfileString = objectMapper.writeValueAsString(sliceProfile)
894 JsonObject response = new JsonObject()
895 JsonObject body = new JsonObject()
896 JsonObject input = new JsonObject()
897 JsonObject commonHeader = new JsonObject()
898 JsonObject payload = new JsonObject()
899 JsonObject payloadInput = new JsonObject()
900 commonHeader.addProperty("TimeStamp", time.toString())
901 commonHeader.addProperty("APIver", "1.0")
902 commonHeader.addProperty("RequestID", requestId)
903 commonHeader.addProperty("SubRequestID", "1")
904 commonHeader.add("RequestTrack", new JsonObject())
905 commonHeader.add("Flags", new JsonObject())
906 payloadInput.addProperty("sliceProfile", sliceProfileString)
907 payloadInput.addProperty("RANNSSIId", execution.getVariable("RANServiceInstanceId"))
908 payloadInput.addProperty("NSIID", execution.getVariable("nsiId"))
909 payloadInput.addProperty("RANNFNSSIId", execution.getVariable("RANNFServiceInstanceId"))
910 payloadInput.addProperty("callbackURL", callbackUrl)
911 payloadInput.add("additionalproperties", new JsonObject())
912 payload.add("input", payloadInput)
913 input.add("CommonHeader", commonHeader)
914 input.addProperty("Action", action)
915 input.add("Payload", payload)
916 body.add("input", input)
917 response.add("body", body)
918 response.addProperty("version", "1.0")
919 response.addProperty("rpc-name", rpcName)
920 response.addProperty("correlation-id", requestId+"-1")
921 response.addProperty("type", "request")
922 return response.toString()
925 private void createEndPointsInAai(DelegateExecution execution) {
926 String type = "endpoint"
927 String function = "transport_EP"
928 int prefixLength = 24
929 String addressFamily = "ipv4"
930 //BH RAN end point update
931 String bh_endpoint = execution.getVariable("bh_endpoint")
932 String bh_routeId = UUID.randomUUID().toString()
933 execution.setVariable("tranportEp_ID_bh", bh_routeId)
935 String CU_IpAddress = jsonUtil.getJsonValue(bh_endpoint, "IpAddress")
936 String LogicalLinkId = jsonUtil.getJsonValue(bh_endpoint, "LogicalLinkId")
937 String nextHopInfo = jsonUtil.getJsonValue(bh_endpoint, "nextHopInfo")
938 NetworkRoute bh_ep = new NetworkRoute()
939 bh_ep.setRouteId(bh_routeId)
940 bh_ep.setFunction(function)
943 bh_ep.setIpAddress(CU_IpAddress)
944 bh_ep.setLogicalInterfaceId(LogicalLinkId)
945 bh_ep.setNextHop(nextHopInfo)
946 bh_ep.setPrefixLength(prefixLength)
947 bh_ep.setAddressFamily(addressFamily)
948 //FH RAN end points update
950 String RU_routeId = UUID.randomUUID().toString()
951 execution.setVariable("tranportEp_ID_RU", RU_routeId)
953 NetworkRoute RU_ep = new NetworkRoute()
954 RU_ep.setRouteId(RU_routeId)
955 RU_ep.setFunction(function)
958 RU_ep.setIpAddress("192.168.100.4")
959 RU_ep.setLogicalInterfaceId("1234")
960 RU_ep.setNextHop("Host1")
961 RU_ep.setPrefixLength(prefixLength)
962 RU_ep.setAddressFamily(addressFamily)
964 String DUIN_routeId = UUID.randomUUID().toString()
965 execution.setVariable("tranportEp_ID_DUIN", DUIN_routeId)
967 NetworkRoute DU_ep = new NetworkRoute()
968 DU_ep.setRouteId(DUIN_routeId)
969 DU_ep.setFunction(function)
972 DU_ep.setIpAddress("192.168.100.5")
973 DU_ep.setLogicalInterfaceId("1234")
974 DU_ep.setNextHop("Host2")
975 DU_ep.setPrefixLength(prefixLength)
976 DU_ep.setAddressFamily(addressFamily)
977 //MH RAN end point update
979 String DUEG_routeId = UUID.randomUUID().toString()
980 execution.setVariable("tranportEp_ID_DUEG", DUEG_routeId)
981 NetworkRoute DUEG_ep = new NetworkRoute()
982 DU_ep.setRouteId(DUEG_routeId)
983 DU_ep.setNextHop("Host3")
985 String CUIN_routeId = UUID.randomUUID().toString()
986 execution.setVariable("tranportEp_ID_CUIN", CUIN_routeId)
987 NetworkRoute CUIN_ep = new NetworkRoute()
988 CUIN_ep.setRouteId(CUIN_routeId)
989 CUIN_ep.setFunction(function)
990 CUIN_ep.setRole(role)
991 CUIN_ep.setType(type)
992 CUIN_ep.setIpAddress("192.168.100.6")
993 CUIN_ep.setLogicalInterfaceId("1234")
994 CUIN_ep.setNextHop("Host4")
995 CUIN_ep.setPrefixLength(prefixLength)
996 CUIN_ep.setAddressFamily(addressFamily)
998 AAIResourcesClient client = new AAIResourcesClient()
999 logger.debug("creating bh endpoint . ID : "+bh_routeId+" node details : "+bh_ep.toString())
1000 AAIResourceUri networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), bh_routeId)
1001 client.create(networkRouteUri, bh_ep)
1002 logger.debug("creating RU endpoint . ID : "+RU_routeId+" node details : "+RU_ep.toString())
1003 networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), RU_routeId)
1004 client.create(networkRouteUri, RU_ep)
1005 logger.debug("creating DUIN endpoint . ID : "+DUIN_routeId+" node details : "+DU_ep.toString())
1006 networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), DUIN_routeId)
1007 client.create(networkRouteUri, DU_ep)
1008 logger.debug("creating DUEG endpoint . ID : "+DUEG_routeId+" node details : "+DU_ep.toString())
1009 networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), DUEG_routeId)
1010 client.create(networkRouteUri, DU_ep)
1011 logger.debug("creating CUIN endpoint . ID : "+CUIN_routeId+" node details : "+CUIN_ep.toString())
1012 networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), CUIN_routeId)
1013 client.create(networkRouteUri, CUIN_ep)
1014 //relationship b/w bh_ep and RAN NSSI
1015 def AN_NSSI = execution.getVariable("RANServiceInstanceId")
1016 Relationship relationship = new Relationship()
1017 String relatedLink = "aai/v21/network/network-routes/network-route/${bh_routeId}"
1018 relationship.setRelatedLink(relatedLink)
1019 relationship.setRelatedTo("network-route")
1020 relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
1021 anNssmfUtils.createRelationShipInAAI(execution, relationship, AN_NSSI)
1022 def ANNF_serviceInstanceId = execution.getVariable("RANNFServiceInstanceId")
1023 relatedLink = "aai/v21/network/network-routes/network-route/${RU_routeId}"
1024 relationship.setRelatedLink(relatedLink)
1025 anNssmfUtils.createRelationShipInAAI(execution, relationship, ANNF_serviceInstanceId)
1026 relatedLink = "aai/v21/network/network-routes/network-route/${DUIN_routeId}"
1027 relationship.setRelatedLink(relatedLink)
1028 anNssmfUtils.createRelationShipInAAI(execution, relationship, ANNF_serviceInstanceId)
1029 relatedLink = "aai/v21/network/network-routes/network-route/${DUEG_routeId}"
1030 relationship.setRelatedLink(relatedLink)
1031 anNssmfUtils.createRelationShipInAAI(execution, relationship, ANNF_serviceInstanceId)
1032 relatedLink = "aai/v21/network/network-routes/network-route/${CUIN_routeId}"
1033 relationship.setRelatedLink(relatedLink)
1034 anNssmfUtils.createRelationShipInAAI(execution, relationship, ANNF_serviceInstanceId)
1035 } catch (BpmnError e) {
1037 } catch (Exception ex) {
1038 String msg = "Exception in createEndPointsInAai " + ex.getMessage()
1040 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)