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
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.getSourceModelUuid()
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", objectMapper.writeValueAsString(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)
258 JsonParser parser = new JsonParser()
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("ranNsstInfoList"), 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.add("capabilityDetails", (JsonObject) parser.parse(FHCapabilities))
278 MH.addProperty("domainType", "TN_MH")
279 MH.add("capabilityDetails", (JsonObject) parser.parse(MHCapabilities))
280 ANNF.addProperty("domainType", "AN_NF")
281 ANNF.add("capabilityDetails", (JsonObject) parser.parse(ANNFCapabilities))
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 String solutions = jsonUtil.getJsonValue(oofResponse, "solutions")
306 logger.debug("solutions value : "+solutions)
307 JsonParser parser = new JsonParser()
308 JsonArray solution = parser.parse(solutions)
309 JsonObject sol = solution.get(0)
310 boolean existingNSI = sol.get("existingNSI").getAsBoolean()
311 logger.debug("existingNSI value : "+existingNSI)
313 JsonObject sharedNSISolution = sol.get("sharedNSISolution").getAsJsonObject()
314 execution.setVariable("sharedRanNSSISolution", sharedNSISolution.toString())
315 logger.debug("sharedRanNSSISolution from OOF "+sharedNSISolution)
316 String RANServiceInstanceId = sharedNSISolution.get("NSIId").getAsString()
317 execution.setVariable("RANServiceInstanceId", RANServiceInstanceId)
318 ServiceInstance serviceInstance = new ServiceInstance();
319 serviceInstance.setInstanceId(RANServiceInstanceId);
320 ServiceDecomposition serviceDecomposition = execution.getVariable("ranNsstServiceDecomposition")
321 serviceDecomposition.setServiceInstance(serviceInstance);
322 execution.setVariable("ranNsstServiceDecomposition", serviceDecomposition)
323 execution.setVariable("isRspRanNssi", true)
325 JsonObject newNSISolution = sol.get("newNSISolution").getAsJsonObject()
326 JsonArray sliceProfiles = newNSISolution.get("sliceProfiles").getAsJsonArray()
327 logger.debug("RanConstituentSliceProfiles list from OOF "+sliceProfiles)
328 execution.setVariable("RanConstituentSliceProfiles", sliceProfiles.toString())
331 String statusMessage = jsonUtil.getJsonValue(oofResponse, "statusMessage")
332 logger.error("received failed status from oof "+ statusMessage)
333 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a failed Async Response from OOF : "+statusMessage)
338 def prepareModifyAccessNssiInputs = { DelegateExecution execution ->
339 logger.debug(Prefix+"prepareModifyAccessNssiInputs method start")
340 String jobId = UUID.randomUUID().toString()
341 execution.setVariable("modifyRanNssiJobId", jobId)
342 String snssaiList = execution.getVariable("snssaiList")
343 String sliceParams = execution.getVariable("sliceParams")
344 String sliceProfileId = execution.getVariable("sliceProfileId")
345 String nsiInfo = jsonUtil.getJsonValue(sliceParams, "nsiInfo")
346 String scriptName = execution.getVariable("scriptName")
348 JsonObject modifySliceParams = new JsonObject()
349 modifySliceParams.addProperty("modifyAction", "allocate")
350 modifySliceParams.addProperty("snssaiList", snssaiList)
351 modifySliceParams.addProperty("sliceProfileId", sliceProfileId)
352 modifySliceParams.addProperty("nsiInfo", nsiInfo)
353 modifySliceParams.addProperty("scriptName", scriptName)
355 execution.setVariable("modifySliceParams", modifySliceParams.toString())
356 //create operation status in request db
357 String nsiId = execution.getVariable("nsiId")
358 String modelUuid = execution.getVariable("modelUuid")
359 logger.debug("Generated new job for Service Instance serviceId:" + nsiId + "jobId:" + jobId)
361 ResourceOperationStatus initStatus = new ResourceOperationStatus()
362 initStatus.setServiceId(nsiId)
363 initStatus.setOperationId(jobId)
364 initStatus.setResourceTemplateUUID(modelUuid)
365 initStatus.setOperType("Modify")
366 requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus)
369 def createModifyNssiQueryJobStatus = { DelegateExecution execution ->
370 logger.debug(Prefix+"createModifyNssiQueryJobStatus method start")
371 JsonObject esrInfo = new JsonObject()
372 esrInfo.addProperty("networkType", "tn")
373 esrInfo.addProperty("vendor", "ONAP_internal")
375 execution.setVariable("esrInfo", esrInfo.toString())
376 JsonObject serviceInfo = new JsonObject()
377 serviceInfo.addProperty("nssiId", execution.getVariable("RANServiceInstanceId"))
378 serviceInfo.addProperty("nsiId", execution.getVariable("nsiId"))
379 serviceInfo.addProperty("nssiName", execution.getVariable("servicename"))
380 String sST = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "sST")
381 serviceInfo.addProperty("sST", sST)
382 serviceInfo.addProperty("PLMNIdList", objectMapper.writeValueAsString(execution.getVariable("plmnIdList")))
383 serviceInfo.addProperty("globalSubscriberId", execution.getVariable("globalSubscriberId"))
384 serviceInfo.addProperty("subscriptionServiceType", execution.getVariable("subscriptionServiceType"))
385 serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("modelInvariantUuid"))
386 serviceInfo.addProperty("serviceUuid", execution.getVariable("modelUuid"))
387 execution.setVariable("serviceInfo", serviceInfo.toString())
388 execution.setVariable("responseId", "")
390 def prepareNsstDecomposeService = { DelegateExecution execution ->
391 logger.debug(Prefix+"prepareNsstDecomposeService method start")
392 List<String> nsstInfoList = objectMapper.readValue(execution.getVariable("ranNsstInfoList"), List.class)
393 int currentIndex = execution.getVariable("currentIndex")
394 int maxIndex = execution.getVariable("maxIndex")
395 logger.debug(Prefix+"prepareNsstDecomposeService : currentIndex value - "+currentIndex+" maxIndex : "+maxIndex)
396 if(currentIndex<maxIndex) {
397 String nsstInfo = nsstInfoList.get(currentIndex)
398 String modelInvariantUuid = jsonUtil.getJsonValue(nsstInfo, "invariantUUID")
399 String modelUuid = jsonUtil.getJsonValue(nsstInfo, "UUID")
401 String serviceModelInfo = """{
402 "modelInvariantUuid":"${modelInvariantUuid}",
403 "modelUuid":"${modelUuid}",
406 execution.setVariable("serviceModelInfo", serviceModelInfo)
407 execution.setVariable("serviceInstanceId", "")
408 logger.debug("serviceModelInfo : "+serviceModelInfo)
410 execution.setVariable("currentIndex", currentIndex)
412 logger.error("nsstList decomposition error ")
413 exceptionUtil.buildAndThrowWorkflowException(execution, 1000, "nsstList decomposition error ")
417 def processNsstDecomposition = { DelegateExecution execution ->
418 logger.debug(Prefix+"processNsstDecomposition method start")
419 ServiceDecomposition decomposedNsst = execution.getVariable("nsstServiceDecomposition")
420 logger.debug("decomposedNsst : "+decomposedNsst.toString())
422 String nsstType = decomposedNsst.getServiceRole() //domainType
423 String modelVersion = decomposedNsst.getModelInfo().getModelVersion()
424 String modelName = decomposedNsst.getModelInfo().getModelName()
425 String modelUuid = decomposedNsst.getModelInfo().getModelUuid()
426 String modelInvariantUuid = decomposedNsst.getModelInfo().getModelInvariantUuid()
430 execution.setVariable("ANNF_modelInvariantUuid", modelInvariantUuid)
431 execution.setVariable("ANNF_modelUuid", modelUuid)
432 execution.setVariable("ANNF_modelVersion", modelVersion)
433 execution.setVariable("ANNF_modelName", modelName)
434 execution.setVariable("ANNF_ServiceDecomposition", decomposedNsst)
437 execution.setVariable("TNFH_modelInvariantUuid", modelInvariantUuid)
438 execution.setVariable("TNFH_modelUuid", modelUuid)
439 execution.setVariable("TNFH_modelVersion", modelVersion)
440 execution.setVariable("TNFH_modelName", modelName)
441 execution.setVariable("TNFH_ServiceDecomposition", decomposedNsst)
444 execution.setVariable("TNMH_modelInvariantUuid", modelInvariantUuid)
445 execution.setVariable("TNMH_modelUuid", modelUuid)
446 execution.setVariable("TNMH_modelVersion", modelVersion)
447 execution.setVariable("TNMH_modelName", modelName)
448 execution.setVariable("TNMH_ServiceDecomposition", decomposedNsst)
451 logger.debug("No expected match found for current nsstType")
452 logger.error("No expected match found for current nsstType "+ nsstType)
453 exceptionUtil.buildAndThrowWorkflowException(execution, 1000,"No expected match found for current nsstType "+ nsstType)
455 boolean isAllNsstsDecomposed = false
456 int currentIndex = execution.getVariable("currentIndex")
457 int maxIndex = execution.getVariable("maxIndex")
458 if(currentIndex == maxIndex) {
459 isAllNsstsDecomposed = true
461 execution.setVariable("isAllNsstsDecomposed", isAllNsstsDecomposed)
464 * prepare OOF request for NF RAN NSSI selection
466 def prepareOofRequestForRanNfNSS = { DelegateExecution execution ->
467 logger.debug(Prefix+"prepareOofRequestForRanNfNSS method start")
468 String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
469 logger.debug( "get NSSI option OOF Url: " + urlString)
471 //build oof request body
472 boolean ranNfNssiPreferReuse = execution.getVariable("ranNfNssiPreferReuse");
473 String requestId = execution.getVariable("msoRequestId")
474 String messageType = "NSSISelectionResponse"
475 List<String> ranConstituentSliceProfiles = jsonUtil.StringArrayToList(execution.getVariable("RanConstituentSliceProfiles"))
476 anNssmfUtils.createDomainWiseSliceProfiles(ranConstituentSliceProfiles, execution)
477 Map<String, Object> profileInfo = objectMapper.readValue(execution.getVariable("ranNfSliceProfile"), Map.class)
478 String modelUuid = execution.getVariable("ANNF_modelUuid")
479 String modelInvariantUuid = execution.getVariable("ANNF_modelInvariantUuid")
480 String modelName = execution.getVariable("ANNF_modelName")
481 String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution);
483 execution.setVariable("nssiSelection_Url", "/api/oof/selection/nssi/v1")
484 execution.setVariable("nssiSelection_messageType",messageType)
485 execution.setVariable("nssiSelection_correlator",requestId)
486 execution.setVariable("nssiSelection_timeout",timeout)
488 String oofRequest = oofUtils.buildSelectNSSIRequest(requestId, messageType, modelUuid, modelInvariantUuid, modelName, profileInfo)
490 execution.setVariable("nssiSelection_oofRequest",oofRequest)
493 * process OOF response for RAN NF NSSI selection
495 def processOofResponseForRanNfNSS = { DelegateExecution execution ->
496 logger.debug(Prefix+"processOofResponseForRanNfNSS method start")
497 String oofResponse = execution.getVariable("nfNssiSelection_asyncCallbackResponse")
498 String requestStatus = jsonUtil.getJsonValue(oofResponse, "requestStatus")
499 if(requestStatus.equals("completed")) {
500 String solutions = jsonUtil.getJsonValue(oofResponse, "solutions")
501 logger.debug("nssi solutions value : "+solutions)
502 JsonParser parser = new JsonParser()
503 JsonArray solution = parser.parse(solutions)
504 if(solution.size()>=1) {
505 JsonObject sol = solution.get(0)
506 String ranNfNssiId = sol.get("NSSIId").getAsString()
507 String invariantUuid = sol.get("invariantUUID").getAsString()
508 String uuid = sol.get("UUID").getAsString()
509 String nssiName = sol.get("NSSIName").getAsString()
510 execution.setVariable("RANNFServiceInstanceId", ranNfNssiId)
511 execution.setVariable("RANNFInvariantUUID", invariantUuid)
512 execution.setVariable("RANNFUUID", uuid)
513 execution.setVariable("RANNFNssiName", nssiName)
514 logger.debug("RANNFServiceInstanceId from OOF "+ranNfNssiId)
516 ServiceInstance serviceInstance = new ServiceInstance();
517 serviceInstance.setInstanceId(ranNfNssiId);
518 ServiceDecomposition serviceDecomposition = execution.getVariable("ANNF_ServiceDecomposition")
519 serviceDecomposition.setServiceInstance(serviceInstance);
520 execution.setVariable("ANNF_ServiceDecomposition", serviceDecomposition)
521 execution.setVariable("isRspRanNfNssi", true)
523 logger.debug("No solutions returned from OOF .. Create new RAN NF NSSI")
526 String statusMessage = jsonUtil.getJsonValue(oofResponse, "statusMessage")
527 logger.error("received failed status from oof "+ statusMessage)
528 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a failed Async Response from OOF : "+statusMessage)
532 def createSliceProfilesInAai = { DelegateExecution execution ->
533 logger.debug(Prefix+"createSliceProfilesInAai method start")
534 anNssmfUtils.createSliceProfilesInAai(execution)
537 def processRanNfModifyRsp = { DelegateExecution execution ->
538 logger.debug(Prefix+"processRanNfModifyRsp method start")
539 anNssmfUtils.processRanNfModifyRsp(execution)
541 org.onap.aai.domain.yang.ServiceInstance ANServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
542 //AN instance creation
543 ANServiceInstance.setServiceInstanceId(execution.getVariable("RANServiceInstanceId"))
544 String sliceInstanceName = execution.getVariable("servicename")
545 ANServiceInstance.setServiceInstanceName(sliceInstanceName)
546 String serviceType = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "sST")
547 ANServiceInstance.setServiceType(serviceType)
548 String serviceStatus = "deactivated"
549 ANServiceInstance.setOrchestrationStatus(serviceStatus)
550 String serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "plmnIdList")
551 ANServiceInstance.setServiceInstanceLocationId(serviceInstanceLocationid)
552 String serviceRole = "nssi"
553 ANServiceInstance.setServiceRole(serviceRole)
554 List<String> snssaiList = objectMapper.readValue(execution.getVariable("snssaiList"), List.class)
555 String snssai = snssaiList.get(0)
556 ANServiceInstance.setEnvironmentContext(snssai)
557 ANServiceInstance.setWorkloadContext("AN")
559 logger.debug("completed AN service instance build "+ ANServiceInstance.toString())
563 AAIResourcesClient client = new AAIResourcesClient()
564 AAIResourceUri nssiServiceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(execution.getVariable("RANServiceInstanceId")))
565 client.create(nssiServiceUri, ANServiceInstance)
567 } catch (BpmnError e) {
569 } catch (Exception ex) {
570 msg = "Exception in AnNssmfUtils.createSliceProfilesInAai " + ex.getMessage()
572 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
575 createEndPointsInAai(execution)
578 def createSdnrRequest = { DelegateExecution execution ->
579 logger.debug(Prefix+"createSdnrRequest method start")
580 String callbackUrl = UrnPropertiesReader.getVariable("mso.workflow.message.endpoint") + "/AsyncSdnrResponse/"+execution.getVariable("msoRequestId")
581 String sdnrRequest = buildSdnrAllocateRequest(execution, "allocate", "instantiateRANSlice", callbackUrl)
582 execution.setVariable("createNSSI_sdnrRequest", sdnrRequest)
583 execution.setVariable("createNSSI_timeout", "PT10M")
584 execution.setVariable("createNSSI_correlator", execution.getVariable("msoRequestId"))
585 execution.setVariable("createNSSI_messageType", "AsyncSdnrResponse");
588 def processSdnrResponse = { DelegateExecution execution ->
589 logger.debug(Prefix+"processSdnrResponse method start")
590 String SDNRResponse = execution.getVariable("SDNR_asyncCallbackResponse")
591 String status = jsonUtil.getJsonValue(SDNRResponse, "status")
592 if(status.equalsIgnoreCase("success")) {
593 String nfIds = jsonUtil.getJsonValue(SDNRResponse, "nfIds")
594 execution.setVariable("ranNfIdsJson", nfIds)
596 String reason = jsonUtil.getJsonValue(SDNRResponse, "reason")
597 logger.error("received failed status from SDNR "+ reason)
598 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from SDNR "+ reason)
600 logger.debug("response from SDNR "+SDNRResponse)
603 def updateAaiWithRANInstances = { DelegateExecution execution ->
604 logger.debug(Prefix+"updateAaiWithRANInstances method start")
606 org.onap.aai.domain.yang.ServiceInstance ANServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
607 org.onap.aai.domain.yang.ServiceInstance ANNFServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
608 //AN instance creation
609 ANServiceInstance.setServiceInstanceId(execution.getVariable("RANServiceInstanceId"))
610 String sliceInstanceName = execution.getVariable("servicename")
611 ANServiceInstance.setServiceInstanceName(sliceInstanceName)
612 String serviceType = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "sST")
613 ANServiceInstance.setServiceType(serviceType)
614 String serviceStatus = "deactivated"
615 ANServiceInstance.setOrchestrationStatus(serviceStatus)
616 String serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "plmnIdList")
617 ANServiceInstance.setServiceInstanceLocationId(serviceInstanceLocationid)
618 String serviceRole = "nssi"
619 ANServiceInstance.setServiceRole(serviceRole)
620 List<String> snssaiList = execution.getVariable("snssaiList")
621 String snssai = snssaiList.get(0)
622 ANServiceInstance.setEnvironmentContext(snssai)
623 String modelInvariantUuid = execution.getVariable("modelInvariantUuid")
624 String modelUuid = execution.getVariable("modelUuid")
625 ANServiceInstance.setModelInvariantId(modelInvariantUuid)
626 ANServiceInstance.setModelVersionId(modelUuid)
627 ANServiceInstance.setWorkloadContext("AN")
628 String serviceFunctionAn = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "resourceSharingLevel")
629 ANServiceInstance.setServiceFunction(serviceFunctionAn)
630 logger.debug("completed AN service instance build "+ ANServiceInstance.toString())
632 ANNFServiceInstance.setServiceInstanceId(execution.getVariable("RANNFServiceInstanceId"))
633 sliceInstanceName = execution.getVariable("ANNF_modelName")
634 ANNFServiceInstance.setServiceInstanceName(sliceInstanceName)
635 ANNFServiceInstance.setServiceType(serviceType)
636 ANNFServiceInstance.setOrchestrationStatus(serviceStatus)
637 serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "plmnIdList")
638 ANNFServiceInstance.setServiceInstanceLocationId(serviceInstanceLocationid)
639 ANNFServiceInstance.setServiceRole(serviceRole)
640 snssaiList = execution.getVariable("snssaiList")
641 snssai = snssaiList.get(0)
642 ANNFServiceInstance.setEnvironmentContext(snssai)
643 ANNFServiceInstance.setModelInvariantId(execution.getVariable("ANNF_modelInvariantUuid"))
644 ANNFServiceInstance.setModelVersionId(execution.getVariable("ANNF_modelUuid"))
645 ANNFServiceInstance.setWorkloadContext("AN-NF")
646 String serviceFunctionAnnf = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "resourceSharingLevel")
647 ANNFServiceInstance.setServiceFunction(serviceFunctionAnnf)
648 logger.debug("completed AN service instance build "+ ANNFServiceInstance.toString())
653 AAIResourcesClient client = new AAIResourcesClient()
654 AAIResourceUri nssiServiceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(execution.getVariable("RANServiceInstanceId")))
655 client.create(nssiServiceUri, ANServiceInstance)
657 AAIResourceUri nssiServiceUri1 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(execution.getVariable("RANNFServiceInstanceId")))
658 client.create(nssiServiceUri1, ANNFServiceInstance)
660 } catch (BpmnError e) {
662 } catch (Exception ex) {
663 msg = "Exception in AnNssmfUtils.createSliceProfilesInAai " + ex.getMessage()
665 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
668 createEndPointsInAai(execution)
670 def prepareTnFhRequest = { DelegateExecution execution ->
671 logger.debug(Prefix+"prepareTnFhRequest method start")
673 String nssmfRequest = anNssmfUtils.buildCreateNSSMFRequest(execution, "TN_FH", "allocate")
674 String urlString = "/api/rest/provMns/v1/NSS/SliceProfiles"
675 String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest)
677 if (nssmfResponse != null) {
678 execution.setVariable("nssmfResponse", nssmfResponse)
679 String jobId = jsonUtil.getJsonValue(nssmfResponse, "jobId")
680 execution.setVariable("TNFH_jobId",jobId)
682 logger.error("received error message from NSSMF : "+ nssmfResponse)
683 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.")
685 logger.debug("Exit prepareTnFhRequest")
688 def prepareTnMhRequest = { DelegateExecution execution ->
689 logger.debug(Prefix+"prepareTnMhRequest method start")
691 String nssmfRequest = anNssmfUtils.buildCreateNSSMFRequest(execution, "TN_MH", "allocate")
692 String urlString = "/api/rest/provMns/v1/NSS/SliceProfiles"
693 String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest)
695 if (nssmfResponse != null) {
696 execution.setVariable("nssmfResponse", nssmfResponse)
697 String jobId = jsonUtil.getJsonValue(nssmfResponse, "jobId")
698 execution.setVariable("TNMH_jobId",jobId)
700 logger.error("received error message from NSSMF : "+ nssmfResponse)
701 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.")
703 logger.debug("Exit prepareTnMhRequest")
706 def createFhAllocateNssiJobQuery = { DelegateExecution execution ->
707 logger.debug(Prefix+"createFhAllocateNssiJobQuery method start")
708 createTnAllocateNssiJobQuery(execution, "TN_FH")
711 def createMhAllocateNssiJobQuery = { DelegateExecution execution ->
712 logger.debug(Prefix+"createMhAllocateNssiJobQuery method start")
713 createTnAllocateNssiJobQuery(execution, "TN_MH")
716 private void createTnAllocateNssiJobQuery(DelegateExecution execution, String domainType) {
717 JsonObject esrInfo = new JsonObject()
718 esrInfo.addProperty("networkType", "tn")
719 esrInfo.addProperty("vendor", "ONAP_internal")
720 execution.setVariable("esrInfo", esrInfo.toString())
721 JsonObject serviceInfo = new JsonObject()
722 serviceInfo.addProperty("nsiId", execution.getVariable("nsiId"))
723 String sST = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "sST")
724 serviceInfo.addProperty("sST", sST)
725 serviceInfo.addProperty("PLMNIdList", objectMapper.writeValueAsString(execution.getVariable("plmnIdList")))
726 serviceInfo.addProperty("globalSubscriberId", execution.getVariable("globalSubscriberId"))
727 serviceInfo.addProperty("subscriptionServiceType", execution.getVariable("subscriptionServiceType"))
728 if(domainType.equals("TN_FH")) {
729 serviceInfo.addProperty("nssiName", execution.getVariable("TNFH_modelName"))
730 serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("TNFH_modelInvariantUuid"))
731 serviceInfo.addProperty("serviceUuid", execution.getVariable("TNFH_modelUuid"))
732 }else if(domainType.equals("TN_MH")) {
733 serviceInfo.addProperty("nssiName", execution.getVariable("TNMH_modelName"))
734 serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("TNMH_modelInvariantUuid"))
735 serviceInfo.addProperty("serviceUuid", execution.getVariable("TNMH_modelUuid"))
737 execution.setVariable("serviceInfo", serviceInfo.toString())
738 execution.setVariable("responseId", "")
741 def processFhAllocateNssiJobStatusRsp = { DelegateExecution execution ->
742 logger.debug(Prefix+"processJobStatusRsp method start")
743 String jobResponse = execution.getVariable("TNFH_jobResponse")
744 logger.debug("Job status response "+jobResponse)
745 String status = jsonUtil.getJsonValue(jobResponse, "status")
746 String nssi = jsonUtil.getJsonValue(jobResponse, "nssiId")
747 if(status.equalsIgnoreCase("finished")) {
748 execution.setVariable("TNFH_NSSI", nssi)
749 logger.debug("Job successfully completed ... proceeding with flow for nssi : "+nssi)
752 String statusDescription = jsonUtil.getJsonValue(jobResponse, "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 processMhAllocateNssiJobStatusRsp = { DelegateExecution execution ->
759 logger.debug(Prefix+"processJobStatusRsp method start")
760 String jobResponse = execution.getVariable("TNMH_jobResponse")
761 logger.debug("Job status response "+jobResponse)
762 String status = jsonUtil.getJsonValue(jobResponse, "status")
763 String nssi = jsonUtil.getJsonValue(jobResponse, "nssiId")
764 if(status.equalsIgnoreCase("finished")) {
765 execution.setVariable("TNMH_NSSI", nssi)
766 logger.debug("Job successfully completed ... proceeding with flow for nssi : "+nssi)
769 String statusDescription = jsonUtil.getJsonValue(jobResponse, "statusDescription")
770 logger.error("received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
771 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
775 def processModifyJobStatusRsp = { DelegateExecution execution ->
776 logger.debug(Prefix+"processJobStatusRsp method start")
777 String jobResponse = execution.getVariable("jobResponse")
778 logger.debug("Job status response "+jobResponse)
779 String status = jsonUtil.getJsonValue(jobResponse, "status")
780 String nssi = jsonUtil.getJsonValue(jobResponse, "nssiId")
781 if(status.equalsIgnoreCase("finished")) {
782 logger.debug("Job successfully completed ... proceeding with flow for nssi : "+nssi)
785 String statusDescription = jsonUtil.getJsonValue(jobResponse, "statusDescription")
786 logger.error("received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
787 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
791 def updateAairelationships = { DelegateExecution execution ->
792 logger.debug(Prefix + "updateAairelationships Start")
795 def ANNF_serviceInstanceId = execution.getVariable("RANNFServiceInstanceId")
796 def TNFH_serviceInstanceId = execution.getVariable("TNFH_NSSI")
797 def TNMH_serviceInstanceId = execution.getVariable("TNMH_NSSI")
798 def AN_profileInstanceId = execution.getVariable("sliceProfileId")
799 def AN_NSSI = execution.getVariable("RANServiceInstanceId")
800 def ANNF_profileInstanceId = execution.getVariable("ANNF_sliceProfileInstanceId")
801 def TNFH_profileInstanceId = execution.getVariable("TNFH_sliceProfileInstanceId")
802 def TNMH_profileInstanceId = execution.getVariable("TNMH_sliceProfileInstanceId")
803 String globalSubscriberId = execution.getVariable("globalSubscriberId")
804 String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
806 Relationship ANNF_relationship = new Relationship()
807 Relationship TNFH_relationship = new Relationship()
808 Relationship TNMH_relationship = new Relationship()
810 String ANNF_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${ANNF_profileInstanceId}"
811 String TNFH_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNFH_profileInstanceId}"
812 String TNMH_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNMH_profileInstanceId}"
814 String ANNF_NSSI_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${ANNF_serviceInstanceId}"
815 String TNFH_NSSI_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNFH_serviceInstanceId}"
816 String TNMH_NSSI_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNMH_serviceInstanceId}"
818 ANNF_relationship.setRelatedLink(ANNF_relatedLink)
819 ANNF_relationship.setRelatedTo("service-instance")
820 ANNF_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
821 TNFH_relationship.setRelatedLink(TNFH_relatedLink)
822 TNFH_relationship.setRelatedTo("service-instance")
823 TNFH_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
824 TNMH_relationship.setRelatedLink(TNMH_relatedLink)
825 TNMH_relationship.setRelatedTo("service-instance")
826 TNMH_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
828 // create SliceProfile and NSSI relationship in AAI
829 anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship,ANNF_serviceInstanceId)
830 anNssmfUtils.createRelationShipInAAI(execution, TNFH_relationship,TNFH_serviceInstanceId)
831 anNssmfUtils.createRelationShipInAAI(execution, TNMH_relationship,TNMH_serviceInstanceId)
832 anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship,AN_profileInstanceId)
833 anNssmfUtils.createRelationShipInAAI(execution, TNFH_relationship,AN_profileInstanceId)
834 anNssmfUtils.createRelationShipInAAI(execution, TNMH_relationship,AN_profileInstanceId)
836 //create AN NSSI and ANNF,TNFH,TNMH relationship in AAI
837 ANNF_relationship.setRelatedLink(ANNF_NSSI_relatedLink)
838 TNFH_relationship.setRelatedLink(TNFH_NSSI_relatedLink)
839 TNMH_relationship.setRelatedLink(TNMH_NSSI_relatedLink)
840 anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship,AN_NSSI)
841 anNssmfUtils.createRelationShipInAAI(execution, TNFH_relationship,AN_NSSI)
842 anNssmfUtils.createRelationShipInAAI(execution, TNMH_relationship,AN_NSSI)
844 } catch (BpmnError e) {
846 } catch (Exception ex) {
848 msg = "Exception in DoCreateE2EServiceInstance.createCustomRelationship. " + ex.getMessage()
850 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
855 * update operation status in request db
858 def prepareOperationStatusUpdate = { DelegateExecution execution ->
859 logger.debug(Prefix + "prepareOperationStatusUpdate Start")
861 String jobId = execution.getVariable("jobId")
862 String nsiId = execution.getVariable("nsiId")
863 String modelUuid = execution.getVariable("modelUuid")
864 String nssiId = execution.getVariable("RANServiceInstanceId")
865 logger.debug("Service Instance serviceId:" + nsiId + " jobId:" + jobId)
867 ResourceOperationStatus updateStatus = new ResourceOperationStatus()
868 updateStatus.setServiceId(nsiId)
869 updateStatus.setOperationId(jobId)
870 updateStatus.setResourceTemplateUUID(modelUuid)
871 updateStatus.setResourceInstanceID(nssiId)
872 updateStatus.setOperType("Allocate")
873 updateStatus.setProgress("100")
874 updateStatus.setStatus("finished")
875 requestDBUtil.prepareUpdateResourceOperationStatus(execution, updateStatus)
877 logger.debug(Prefix + "prepareOperationStatusUpdate Exit")
880 def prepareFailedOperationStatusUpdate = { DelegateExecution execution ->
881 logger.debug(Prefix + "prepareFailedOperationStatusUpdate Start")
883 String jobId = execution.getVariable("jobId")
884 String nsiId = execution.getVariable("nsiId")
885 String modelUuid = execution.getVariable("modelUuid")
886 String nssiId = execution.getVariable("RANServiceInstanceId")
887 logger.debug("Service Instance serviceId:" + nsiId + " jobId:" + jobId)
889 ResourceOperationStatus updateStatus = new ResourceOperationStatus()
890 updateStatus.setServiceId(nsiId)
891 updateStatus.setOperationId(jobId)
892 updateStatus.setResourceTemplateUUID(modelUuid)
893 updateStatus.setResourceInstanceID(nssiId)
894 updateStatus.setOperType("Allocate")
895 updateStatus.setProgress("0")
896 updateStatus.setStatus("failed")
897 requestDBUtil.prepareUpdateResourceOperationStatus(execution, updateStatus)
900 private String buildSdnrAllocateRequest(DelegateExecution execution, String action, String rpcName, String callbackUrl) {
902 String requestId = execution.getVariable("msoRequestId")
903 Map<String,Object> sliceProfile = objectMapper.readValue(execution.getVariable("ranNfSliceProfile"), Map.class)
904 sliceProfile.put("sliceProfileId", execution.getVariable("ANNF_sliceProfileInstanceId"))
905 sliceProfile.put("maxNumberofConns", sliceProfile.get("maxNumberofPDUSessions"))
906 sliceProfile.put("uLThptPerSlice", sliceProfile.get("expDataRateUL"))
907 sliceProfile.put("dLThptPerSlice", sliceProfile.get("expDataRateDL"))
909 JsonObject response = new JsonObject()
910 JsonObject body = new JsonObject()
911 JsonObject input = new JsonObject()
912 JsonObject commonHeader = new JsonObject()
913 JsonObject payload = new JsonObject()
914 JsonObject payloadInput = new JsonObject()
915 commonHeader.addProperty("TimeStamp",new Date(System.currentTimeMillis()).format("yyyy-MM-dd'T'HH:mm:ss.sss'Z'", TimeZone.getDefault()))
916 commonHeader.addProperty("api-ver", "1.0")
917 commonHeader.addProperty("request-id", requestId)
918 commonHeader.addProperty("sub-request-id", "1")
919 commonHeader.add("request-track", new JsonObject())
920 commonHeader.add("flags", new JsonObject())
921 Gson jsonConverter = new Gson()
922 payloadInput.add("sliceProfile", jsonConverter.toJsonTree(sliceProfile))
923 payloadInput.addProperty("RANNSSIId", execution.getVariable("RANServiceInstanceId"))
924 payloadInput.addProperty("NSIID", execution.getVariable("nsiId"))
925 payloadInput.addProperty("RANNFNSSIId", execution.getVariable("RANNFServiceInstanceId"))
926 payloadInput.addProperty("callbackURL", callbackUrl)
927 payloadInput.add("additionalproperties", new JsonObject())
928 payload.add("input", payloadInput)
929 input.add("common-header", commonHeader)
930 input.addProperty("action", action)
931 input.addProperty("payload", payload.toString())
932 body.add("input", input)
933 response.add("body", body)
934 response.addProperty("version", "1.0")
935 response.addProperty("rpc-name", rpcName)
936 response.addProperty("correlation-id", (requestId+"-1"))
937 response.addProperty("type", "request")
938 return response.toString()
941 private void createEndPointsInAai(DelegateExecution execution) {
942 String type = "endpoint"
943 String function = "transport_EP"
944 int prefixLength = 24
945 String addressFamily = "ipv4"
946 //BH RAN end point update
947 String bh_endpoint = execution.getVariable("bh_endpoint")
948 String bh_routeId = UUID.randomUUID().toString()
949 execution.setVariable("tranportEp_ID_bh", bh_routeId)
951 String CU_IpAddress = jsonUtil.getJsonValue(bh_endpoint, "IpAddress")
952 String LogicalLinkId = jsonUtil.getJsonValue(bh_endpoint, "LogicalLinkId")
953 String nextHopInfo = jsonUtil.getJsonValue(bh_endpoint, "nextHopInfo")
954 NetworkRoute bh_ep = new NetworkRoute()
955 bh_ep.setRouteId(bh_routeId)
956 bh_ep.setFunction(function)
959 bh_ep.setIpAddress(CU_IpAddress)
960 bh_ep.setLogicalInterfaceId(LogicalLinkId)
961 bh_ep.setNextHop(nextHopInfo)
962 bh_ep.setPrefixLength(prefixLength)
963 bh_ep.setAddressFamily(addressFamily)
964 //FH RAN end points update
966 String RU_routeId = UUID.randomUUID().toString()
967 execution.setVariable("tranportEp_ID_RU", RU_routeId)
969 NetworkRoute RU_ep = new NetworkRoute()
970 RU_ep.setRouteId(RU_routeId)
971 RU_ep.setFunction(function)
974 RU_ep.setIpAddress("192.168.100.4")
975 RU_ep.setLogicalInterfaceId("1234")
976 RU_ep.setNextHop("Host1")
977 RU_ep.setPrefixLength(prefixLength)
978 RU_ep.setAddressFamily(addressFamily)
980 String DUIN_routeId = UUID.randomUUID().toString()
981 execution.setVariable("tranportEp_ID_DUIN", DUIN_routeId)
983 NetworkRoute DU_ep = new NetworkRoute()
984 DU_ep.setRouteId(DUIN_routeId)
985 DU_ep.setFunction(function)
988 DU_ep.setIpAddress("192.168.100.5")
989 DU_ep.setLogicalInterfaceId("1234")
990 DU_ep.setNextHop("Host2")
991 DU_ep.setPrefixLength(prefixLength)
992 DU_ep.setAddressFamily(addressFamily)
993 //MH RAN end point update
995 String DUEG_routeId = UUID.randomUUID().toString()
996 execution.setVariable("tranportEp_ID_DUEG", DUEG_routeId)
997 NetworkRoute DUEG_ep = new NetworkRoute()
998 DUEG_ep.setRouteId(DUEG_routeId)
999 DUEG_ep.setFunction(function)
1000 DUEG_ep.setRole(role)
1001 DUEG_ep.setType(type)
1002 DUEG_ep.setIpAddress("192.168.100.5")
1003 DUEG_ep.setLogicalInterfaceId("1234")
1004 DUEG_ep.setPrefixLength(prefixLength)
1005 DUEG_ep.setAddressFamily(addressFamily)
1006 DUEG_ep.setNextHop("Host3")
1008 String CUIN_routeId = UUID.randomUUID().toString()
1009 execution.setVariable("tranportEp_ID_CUIN", CUIN_routeId)
1010 NetworkRoute CUIN_ep = new NetworkRoute()
1011 CUIN_ep.setRouteId(CUIN_routeId)
1012 CUIN_ep.setFunction(function)
1013 CUIN_ep.setRole(role)
1014 CUIN_ep.setType(type)
1015 CUIN_ep.setIpAddress("192.168.100.6")
1016 CUIN_ep.setLogicalInterfaceId("1234")
1017 CUIN_ep.setNextHop("Host4")
1018 CUIN_ep.setPrefixLength(prefixLength)
1019 CUIN_ep.setAddressFamily(addressFamily)
1021 AAIResourcesClient client = new AAIResourcesClient()
1022 logger.debug("creating bh endpoint . ID : "+bh_routeId+" node details : "+bh_ep.toString())
1023 AAIResourceUri networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), bh_routeId)
1024 client.create(networkRouteUri, bh_ep)
1025 logger.debug("creating RU endpoint . ID : "+RU_routeId+" node details : "+RU_ep.toString())
1026 networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), RU_routeId)
1027 client.create(networkRouteUri, RU_ep)
1028 logger.debug("creating DUIN endpoint . ID : "+DUIN_routeId+" node details : "+DU_ep.toString())
1029 networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), DUIN_routeId)
1030 client.create(networkRouteUri, DU_ep)
1031 logger.debug("creating DUEG endpoint . ID : "+DUEG_routeId+" node details : "+DUEG_ep.toString())
1032 networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), DUEG_routeId)
1033 client.create(networkRouteUri, DUEG_ep)
1034 logger.debug("creating CUIN endpoint . ID : "+CUIN_routeId+" node details : "+CUIN_ep.toString())
1035 networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), CUIN_routeId)
1036 client.create(networkRouteUri, CUIN_ep)
1037 //relationship b/w bh_ep and RAN NSSI
1038 def AN_NSSI = execution.getVariable("RANServiceInstanceId")
1039 Relationship relationship = new Relationship()
1040 String relatedLink = "aai/v21/network/network-routes/network-route/${bh_routeId}"
1041 relationship.setRelatedLink(relatedLink)
1042 relationship.setRelatedTo("network-route")
1043 relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
1044 anNssmfUtils.createRelationShipInAAI(execution, relationship, AN_NSSI)
1045 def ANNF_serviceInstanceId = execution.getVariable("RANNFServiceInstanceId")
1046 relatedLink = "aai/v21/network/network-routes/network-route/${RU_routeId}"
1047 relationship.setRelatedLink(relatedLink)
1048 anNssmfUtils.createRelationShipInAAI(execution, relationship, ANNF_serviceInstanceId)
1049 relatedLink = "aai/v21/network/network-routes/network-route/${DUIN_routeId}"
1050 relationship.setRelatedLink(relatedLink)
1051 anNssmfUtils.createRelationShipInAAI(execution, relationship, ANNF_serviceInstanceId)
1052 relatedLink = "aai/v21/network/network-routes/network-route/${DUEG_routeId}"
1053 relationship.setRelatedLink(relatedLink)
1054 anNssmfUtils.createRelationShipInAAI(execution, relationship, ANNF_serviceInstanceId)
1055 relatedLink = "aai/v21/network/network-routes/network-route/${CUIN_routeId}"
1056 relationship.setRelatedLink(relatedLink)
1057 anNssmfUtils.createRelationShipInAAI(execution, relationship, ANNF_serviceInstanceId)
1058 } catch (BpmnError e) {
1060 } catch (Exception ex) {
1061 String msg = "Exception in createEndPointsInAai " + ex.getMessage()
1063 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)