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("slice_profiles").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 serviceId = execution.getVariable("RANServiceInstanceId")
358 String nsiId = execution.getVariable("nsiId")
359 logger.debug("Generated new job for Service Instance serviceId:" + serviceId + "jobId:" + jobId)
361 ResourceOperationStatus initStatus = new ResourceOperationStatus()
362 initStatus.setServiceId(serviceId)
363 initStatus.setOperationId(jobId)
364 initStatus.setResourceTemplateUUID(nsiId)
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 ANServiceInstance.setWorkloadContext("AN")
624 String serviceFunctionAn = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "resourceSharingLevel")
625 ANServiceInstance.setServiceFunction(serviceFunctionAn)
626 logger.debug("completed AN service instance build "+ ANServiceInstance.toString())
628 ANNFServiceInstance.setServiceInstanceId(execution.getVariable("RANNFServiceInstanceId"))
629 sliceInstanceName = execution.getVariable("ANNF_modelName")
630 ANNFServiceInstance.setServiceInstanceName(sliceInstanceName)
631 ANNFServiceInstance.setServiceType(serviceType)
632 ANNFServiceInstance.setOrchestrationStatus(serviceStatus)
633 serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "pLMNIdList")
634 ANNFServiceInstance.setServiceInstanceLocationId(serviceInstanceLocationid)
635 ANNFServiceInstance.setServiceRole(serviceRole)
636 snssaiList = execution.getVariable("snssaiList")
637 snssai = snssaiList.get(0)
638 ANNFServiceInstance.setEnvironmentContext(snssai)
639 ANNFServiceInstance.setWorkloadContext("AN-NF")
640 String serviceFunctionAnnf = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "resourceSharingLevel")
641 ANNFServiceInstance.setServiceFunction(serviceFunctionAnnf)
642 logger.debug("completed AN service instance build "+ ANNFServiceInstance.toString())
647 AAIResourcesClient client = new AAIResourcesClient()
648 AAIResourceUri nssiServiceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(execution.getVariable("RANServiceInstanceId")))
649 client.create(nssiServiceUri, ANServiceInstance)
651 AAIResourceUri nssiServiceUri1 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(execution.getVariable("RANNFServiceInstanceId")))
652 client.create(nssiServiceUri1, ANNFServiceInstance)
654 } catch (BpmnError e) {
656 } catch (Exception ex) {
657 msg = "Exception in AnNssmfUtils.createSliceProfilesInAai " + ex.getMessage()
659 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
662 createEndPointsInAai(execution)
664 def prepareTnFhRequest = { DelegateExecution execution ->
665 logger.debug(Prefix+"prepareTnFhRequest method start")
667 String nssmfRequest = anNssmfUtils.buildCreateNSSMFRequest(execution, "TN_FH", "allocate")
668 String urlString = "/api/rest/provMns/v1/NSS/SliceProfiles"
669 String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest)
671 if (nssmfResponse != null) {
672 execution.setVariable("nssmfResponse", nssmfResponse)
673 String jobId = jsonUtil.getJsonValue(nssmfResponse, "jobId")
674 execution.setVariable("TNFH_jobId",jobId)
676 logger.error("received error message from NSSMF : "+ nssmfResponse)
677 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.")
679 logger.debug("Exit prepareTnFhRequest")
682 def prepareTnMhRequest = { DelegateExecution execution ->
683 logger.debug(Prefix+"prepareTnMhRequest method start")
685 String nssmfRequest = anNssmfUtils.buildCreateNSSMFRequest(execution, "TN_MH", "allocate")
686 String urlString = "/api/rest/provMns/v1/NSS/SliceProfiles"
687 String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest)
689 if (nssmfResponse != null) {
690 execution.setVariable("nssmfResponse", nssmfResponse)
691 String jobId = jsonUtil.getJsonValue(nssmfResponse, "jobId")
692 execution.setVariable("TNMH_jobId",jobId)
694 logger.error("received error message from NSSMF : "+ nssmfResponse)
695 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.")
697 logger.debug("Exit prepareTnMhRequest")
700 def createFhAllocateNssiJobQuery = { DelegateExecution execution ->
701 logger.debug(Prefix+"createFhAllocateNssiJobQuery method start")
702 createTnAllocateNssiJobQuery(execution, "TN_FH")
705 def createMhAllocateNssiJobQuery = { DelegateExecution execution ->
706 logger.debug(Prefix+"createMhAllocateNssiJobQuery method start")
707 createTnAllocateNssiJobQuery(execution, "TN_MH")
710 private void createTnAllocateNssiJobQuery(DelegateExecution execution, String domainType) {
711 JsonObject esrInfo = new JsonObject()
712 esrInfo.addProperty("networkType", "tn")
713 esrInfo.addProperty("vendor", "ONAP_internal")
714 execution.setVariable("esrInfo", esrInfo.toString())
715 JsonObject serviceInfo = new JsonObject()
716 serviceInfo.addProperty("nsiId", execution.getVariable("nsiId"))
717 String sST = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "sST")
718 serviceInfo.addProperty("sST", sST)
719 serviceInfo.addProperty("PLMNIdList", objectMapper.writeValueAsString(execution.getVariable("plmnIdList")))
720 serviceInfo.addProperty("globalSubscriberId", execution.getVariable("globalSubscriberId"))
721 serviceInfo.addProperty("subscriptionServiceType", execution.getVariable("subscriptionServiceType"))
722 if(domainType.equals("TN_FH")) {
723 serviceInfo.addProperty("nssiName", execution.getVariable("TNFH_modelName"))
724 serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("TNFH_modelInvariantUuid"))
725 serviceInfo.addProperty("serviceUuid", execution.getVariable("TNFH_modelUuid"))
726 }else if(domainType.equals("TN_MH")) {
727 serviceInfo.addProperty("nssiName", execution.getVariable("TNMH_modelName"))
728 serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("TNMH_modelInvariantUuid"))
729 serviceInfo.addProperty("serviceUuid", execution.getVariable("TNMH_modelUuid"))
731 execution.setVariable("serviceInfo", serviceInfo.toString())
732 execution.setVariable("responseId", "")
735 def processFhAllocateNssiJobStatusRsp = { DelegateExecution execution ->
736 logger.debug(Prefix+"processJobStatusRsp method start")
737 String jobResponse = execution.getVariable("TNFH_jobResponse")
738 logger.debug("Job status response "+jobResponse)
739 String status = jsonUtil.getJsonValue(jobResponse, "status")
740 String nssi = jsonUtil.getJsonValue(jobResponse, "nssiId")
741 if(status.equalsIgnoreCase("finished")) {
742 execution.setVariable("TNFH_NSSI", nssi)
743 logger.debug("Job successfully completed ... proceeding with flow for nssi : "+nssi)
746 String statusDescription = jsonUtil.getJsonValue(jobResponse, "statusDescription")
747 logger.error("received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
748 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
752 def processMhAllocateNssiJobStatusRsp = { DelegateExecution execution ->
753 logger.debug(Prefix+"processJobStatusRsp method start")
754 String jobResponse = execution.getVariable("TNMH_jobResponse")
755 logger.debug("Job status response "+jobResponse)
756 String status = jsonUtil.getJsonValue(jobResponse, "status")
757 String nssi = jsonUtil.getJsonValue(jobResponse, "nssiId")
758 if(status.equalsIgnoreCase("finished")) {
759 execution.setVariable("TNMH_NSSI", nssi)
760 logger.debug("Job successfully completed ... proceeding with flow for nssi : "+nssi)
763 String statusDescription = jsonUtil.getJsonValue(jobResponse, "statusDescription")
764 logger.error("received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
765 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
769 def processModifyJobStatusRsp = { DelegateExecution execution ->
770 logger.debug(Prefix+"processJobStatusRsp method start")
771 String jobResponse = execution.getVariable("jobResponse")
772 logger.debug("Job status response "+jobResponse)
773 String status = jsonUtil.getJsonValue(jobResponse, "status")
774 String nssi = jsonUtil.getJsonValue(jobResponse, "nssiId")
775 if(status.equalsIgnoreCase("finished")) {
776 logger.debug("Job successfully completed ... proceeding with flow for nssi : "+nssi)
779 String statusDescription = jsonUtil.getJsonValue(jobResponse, "statusDescription")
780 logger.error("received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
781 exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
785 def updateAairelationships = { DelegateExecution execution ->
786 logger.debug(Prefix + "updateAairelationships Start")
789 def ANNF_serviceInstanceId = execution.getVariable("RANNFServiceInstanceId")
790 def TNFH_serviceInstanceId = execution.getVariable("TNFH_NSSI")
791 def TNMH_serviceInstanceId = execution.getVariable("TNMH_NSSI")
792 def AN_profileInstanceId = execution.getVariable("sliceProfileId")
793 def AN_NSSI = execution.getVariable("RANServiceInstanceId")
794 def ANNF_profileInstanceId = execution.getVariable("ANNF_sliceProfileInstanceId")
795 def TNFH_profileInstanceId = execution.getVariable("TNFH_sliceProfileInstanceId")
796 def TNMH_profileInstanceId = execution.getVariable("TNMH_sliceProfileInstanceId")
797 String globalSubscriberId = execution.getVariable("globalSubscriberId")
798 String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
800 Relationship ANNF_relationship = new Relationship()
801 Relationship TNFH_relationship = new Relationship()
802 Relationship TNMH_relationship = new Relationship()
804 String ANNF_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${ANNF_profileInstanceId}"
805 String TNFH_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNFH_profileInstanceId}"
806 String TNMH_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNMH_profileInstanceId}"
808 String ANNF_NSSI_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${ANNF_serviceInstanceId}"
809 String TNFH_NSSI_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNFH_serviceInstanceId}"
810 String TNMH_NSSI_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNMH_serviceInstanceId}"
812 ANNF_relationship.setRelatedLink(ANNF_relatedLink)
813 ANNF_relationship.setRelatedTo("service-instance")
814 ANNF_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
815 TNFH_relationship.setRelatedLink(TNFH_relatedLink)
816 TNFH_relationship.setRelatedTo("service-instance")
817 TNFH_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
818 TNMH_relationship.setRelatedLink(TNMH_relatedLink)
819 TNMH_relationship.setRelatedTo("service-instance")
820 TNMH_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
822 // create SliceProfile and NSSI relationship in AAI
823 anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship,ANNF_serviceInstanceId)
824 anNssmfUtils.createRelationShipInAAI(execution, TNFH_relationship,TNFH_serviceInstanceId)
825 anNssmfUtils.createRelationShipInAAI(execution, TNMH_relationship,TNMH_serviceInstanceId)
826 anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship,AN_profileInstanceId)
827 anNssmfUtils.createRelationShipInAAI(execution, TNFH_relationship,AN_profileInstanceId)
828 anNssmfUtils.createRelationShipInAAI(execution, TNMH_relationship,AN_profileInstanceId)
830 //create AN NSSI and ANNF,TNFH,TNMH relationship in AAI
831 ANNF_relationship.setRelatedLink(ANNF_NSSI_relatedLink)
832 TNFH_relationship.setRelatedLink(TNFH_NSSI_relatedLink)
833 TNMH_relationship.setRelatedLink(TNMH_NSSI_relatedLink)
834 anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship,AN_NSSI)
835 anNssmfUtils.createRelationShipInAAI(execution, TNFH_relationship,AN_NSSI)
836 anNssmfUtils.createRelationShipInAAI(execution, TNMH_relationship,AN_NSSI)
838 } catch (BpmnError e) {
840 } catch (Exception ex) {
842 msg = "Exception in DoCreateE2EServiceInstance.createCustomRelationship. " + ex.getMessage()
844 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
849 * update operation status in request db
852 def prepareOperationStatusUpdate = { DelegateExecution execution ->
853 logger.debug(Prefix + "prepareOperationStatusUpdate Start")
855 String serviceId = execution.getVariable("dummyServiceId")
856 String jobId = execution.getVariable("jobId")
857 String nsiId = execution.getVariable("nsiId")
858 String nssiId = execution.getVariable("RANServiceInstanceId")
859 logger.debug("Service Instance serviceId:" + serviceId + " jobId:" + jobId)
861 ResourceOperationStatus updateStatus = new ResourceOperationStatus()
862 updateStatus.setServiceId(serviceId)
863 updateStatus.setOperationId(jobId)
864 updateStatus.setResourceTemplateUUID(nsiId)
865 updateStatus.setResourceInstanceID(nssiId)
866 updateStatus.setOperType("Allocate")
867 updateStatus.setProgress("100")
868 updateStatus.setStatus("finished")
869 requestDBUtil.prepareUpdateResourceOperationStatus(execution, updateStatus)
871 logger.debug(Prefix + "prepareOperationStatusUpdate Exit")
874 def prepareFailedOperationStatusUpdate = { DelegateExecution execution ->
875 logger.debug(Prefix + "prepareFailedOperationStatusUpdate Start")
877 String serviceId = execution.getVariable("dummyServiceId")
878 String jobId = execution.getVariable("jobId")
879 String nsiId = execution.getVariable("nsiId")
880 String nssiId = execution.getVariable("RANServiceInstanceId")
881 logger.debug("Service Instance serviceId:" + serviceId + " jobId:" + jobId)
883 ResourceOperationStatus updateStatus = new ResourceOperationStatus()
884 updateStatus.setServiceId(serviceId)
885 updateStatus.setOperationId(jobId)
886 updateStatus.setResourceTemplateUUID(nsiId)
887 updateStatus.setResourceInstanceID(nssiId)
888 updateStatus.setOperType("Allocate")
889 updateStatus.setProgress("0")
890 updateStatus.setStatus("failed")
891 requestDBUtil.prepareUpdateResourceOperationStatus(execution, updateStatus)
894 private String buildSdnrAllocateRequest(DelegateExecution execution, String action, String rpcName, String callbackUrl) {
896 String requestId = execution.getVariable("msoRequestId")
897 Map<String,Object> sliceProfile = objectMapper.readValue(execution.getVariable("ranNfSliceProfile"), Map.class)
898 sliceProfile.put("sliceProfileId", execution.getVariable("ANNF_sliceProfileInstanceId"))
899 sliceProfile.put("maxNumberofConns", sliceProfile.get("maxNumberofPDUSessions"))
900 sliceProfile.put("uLThptPerSlice", sliceProfile.get("expDataRateUL"))
901 sliceProfile.put("dLThptPerSlice", sliceProfile.get("expDataRateDL"))
903 JsonObject response = new JsonObject()
904 JsonObject body = new JsonObject()
905 JsonObject input = new JsonObject()
906 JsonObject commonHeader = new JsonObject()
907 JsonObject payload = new JsonObject()
908 JsonObject payloadInput = new JsonObject()
909 commonHeader.addProperty("TimeStamp",new Date(System.currentTimeMillis()).format("yyyy-MM-dd'T'HH:mm:ss.sss'Z'", TimeZone.getDefault()))
910 commonHeader.addProperty("api-ver", "1.0")
911 commonHeader.addProperty("request-id", requestId)
912 commonHeader.addProperty("sub-request-id", "1")
913 commonHeader.add("request-track", new JsonObject())
914 commonHeader.add("flags", new JsonObject())
915 Gson jsonConverter = new Gson()
916 payloadInput.add("sliceProfile", jsonConverter.toJsonTree(sliceProfile))
917 payloadInput.addProperty("RANNSSIId", execution.getVariable("RANServiceInstanceId"))
918 payloadInput.addProperty("NSIID", execution.getVariable("nsiId"))
919 payloadInput.addProperty("RANNFNSSIId", execution.getVariable("RANNFServiceInstanceId"))
920 payloadInput.addProperty("callbackURL", callbackUrl)
921 payloadInput.add("additionalproperties", new JsonObject())
922 payload.add("input", payloadInput)
923 input.add("common-header", commonHeader)
924 input.addProperty("action", action)
925 input.addProperty("payload", payload.toString())
926 body.add("input", input)
927 response.add("body", body)
928 response.addProperty("version", "1.0")
929 response.addProperty("rpc-name", rpcName)
930 response.addProperty("correlation-id", (requestId+"-1"))
931 response.addProperty("type", "request")
932 return response.toString()
935 private void createEndPointsInAai(DelegateExecution execution) {
936 String type = "endpoint"
937 String function = "transport_EP"
938 int prefixLength = 24
939 String addressFamily = "ipv4"
940 //BH RAN end point update
941 String bh_endpoint = execution.getVariable("bh_endpoint")
942 String bh_routeId = UUID.randomUUID().toString()
943 execution.setVariable("tranportEp_ID_bh", bh_routeId)
945 String CU_IpAddress = jsonUtil.getJsonValue(bh_endpoint, "IpAddress")
946 String LogicalLinkId = jsonUtil.getJsonValue(bh_endpoint, "LogicalLinkId")
947 String nextHopInfo = jsonUtil.getJsonValue(bh_endpoint, "nextHopInfo")
948 NetworkRoute bh_ep = new NetworkRoute()
949 bh_ep.setRouteId(bh_routeId)
950 bh_ep.setFunction(function)
953 bh_ep.setIpAddress(CU_IpAddress)
954 bh_ep.setLogicalInterfaceId(LogicalLinkId)
955 bh_ep.setNextHop(nextHopInfo)
956 bh_ep.setPrefixLength(prefixLength)
957 bh_ep.setAddressFamily(addressFamily)
958 //FH RAN end points update
960 String RU_routeId = UUID.randomUUID().toString()
961 execution.setVariable("tranportEp_ID_RU", RU_routeId)
963 NetworkRoute RU_ep = new NetworkRoute()
964 RU_ep.setRouteId(RU_routeId)
965 RU_ep.setFunction(function)
968 RU_ep.setIpAddress("192.168.100.4")
969 RU_ep.setLogicalInterfaceId("1234")
970 RU_ep.setNextHop("Host1")
971 RU_ep.setPrefixLength(prefixLength)
972 RU_ep.setAddressFamily(addressFamily)
974 String DUIN_routeId = UUID.randomUUID().toString()
975 execution.setVariable("tranportEp_ID_DUIN", DUIN_routeId)
977 NetworkRoute DU_ep = new NetworkRoute()
978 DU_ep.setRouteId(DUIN_routeId)
979 DU_ep.setFunction(function)
982 DU_ep.setIpAddress("192.168.100.5")
983 DU_ep.setLogicalInterfaceId("1234")
984 DU_ep.setNextHop("Host2")
985 DU_ep.setPrefixLength(prefixLength)
986 DU_ep.setAddressFamily(addressFamily)
987 //MH RAN end point update
989 String DUEG_routeId = UUID.randomUUID().toString()
990 execution.setVariable("tranportEp_ID_DUEG", DUEG_routeId)
991 NetworkRoute DUEG_ep = new NetworkRoute()
992 DUEG_ep.setRouteId(DUEG_routeId)
993 DUEG_ep.setFunction(function)
994 DUEG_ep.setRole(role)
995 DUEG_ep.setType(type)
996 DUEG_ep.setIpAddress("192.168.100.5")
997 DUEG_ep.setLogicalInterfaceId("1234")
998 DUEG_ep.setPrefixLength(prefixLength)
999 DUEG_ep.setAddressFamily(addressFamily)
1000 DUEG_ep.setNextHop("Host3")
1002 String CUIN_routeId = UUID.randomUUID().toString()
1003 execution.setVariable("tranportEp_ID_CUIN", CUIN_routeId)
1004 NetworkRoute CUIN_ep = new NetworkRoute()
1005 CUIN_ep.setRouteId(CUIN_routeId)
1006 CUIN_ep.setFunction(function)
1007 CUIN_ep.setRole(role)
1008 CUIN_ep.setType(type)
1009 CUIN_ep.setIpAddress("192.168.100.6")
1010 CUIN_ep.setLogicalInterfaceId("1234")
1011 CUIN_ep.setNextHop("Host4")
1012 CUIN_ep.setPrefixLength(prefixLength)
1013 CUIN_ep.setAddressFamily(addressFamily)
1015 AAIResourcesClient client = new AAIResourcesClient()
1016 logger.debug("creating bh endpoint . ID : "+bh_routeId+" node details : "+bh_ep.toString())
1017 AAIResourceUri networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), bh_routeId)
1018 client.create(networkRouteUri, bh_ep)
1019 logger.debug("creating RU endpoint . ID : "+RU_routeId+" node details : "+RU_ep.toString())
1020 networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), RU_routeId)
1021 client.create(networkRouteUri, RU_ep)
1022 logger.debug("creating DUIN endpoint . ID : "+DUIN_routeId+" node details : "+DU_ep.toString())
1023 networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), DUIN_routeId)
1024 client.create(networkRouteUri, DU_ep)
1025 logger.debug("creating DUEG endpoint . ID : "+DUEG_routeId+" node details : "+DUEG_ep.toString())
1026 networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), DUEG_routeId)
1027 client.create(networkRouteUri, DUEG_ep)
1028 logger.debug("creating CUIN endpoint . ID : "+CUIN_routeId+" node details : "+CUIN_ep.toString())
1029 networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), CUIN_routeId)
1030 client.create(networkRouteUri, CUIN_ep)
1031 //relationship b/w bh_ep and RAN NSSI
1032 def AN_NSSI = execution.getVariable("RANServiceInstanceId")
1033 Relationship relationship = new Relationship()
1034 String relatedLink = "aai/v21/network/network-routes/network-route/${bh_routeId}"
1035 relationship.setRelatedLink(relatedLink)
1036 relationship.setRelatedTo("network-route")
1037 relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
1038 anNssmfUtils.createRelationShipInAAI(execution, relationship, AN_NSSI)
1039 def ANNF_serviceInstanceId = execution.getVariable("RANNFServiceInstanceId")
1040 relatedLink = "aai/v21/network/network-routes/network-route/${RU_routeId}"
1041 relationship.setRelatedLink(relatedLink)
1042 anNssmfUtils.createRelationShipInAAI(execution, relationship, ANNF_serviceInstanceId)
1043 relatedLink = "aai/v21/network/network-routes/network-route/${DUIN_routeId}"
1044 relationship.setRelatedLink(relatedLink)
1045 anNssmfUtils.createRelationShipInAAI(execution, relationship, ANNF_serviceInstanceId)
1046 relatedLink = "aai/v21/network/network-routes/network-route/${DUEG_routeId}"
1047 relationship.setRelatedLink(relatedLink)
1048 anNssmfUtils.createRelationShipInAAI(execution, relationship, ANNF_serviceInstanceId)
1049 relatedLink = "aai/v21/network/network-routes/network-route/${CUIN_routeId}"
1050 relationship.setRelatedLink(relatedLink)
1051 anNssmfUtils.createRelationShipInAAI(execution, relationship, ANNF_serviceInstanceId)
1052 } catch (BpmnError e) {
1054 } catch (Exception ex) {
1055 String msg = "Exception in createEndPointsInAai " + ex.getMessage()
1057 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)