2  * ============LICENSE_START=======================================================
 
   4  * ================================================================================
 
   5  # Copyright (c) 2020, Wipro Limited.
 
   7  # Licensed under the Apache License, Version 2.0 (the "License")
 
   8  # you may not use this file except in compliance with the License.
 
   9  # You may obtain a copy of the License at
 
  11  #       http://www.apache.org/licenses/LICENSE-2.0
 
  13  # Unless required by applicable law or agreed to in writing, software
 
  14  # distributed under the License is distributed on an "AS IS" BASIS,
 
  15  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  16  # See the License for the specific language governing permissions and
 
  17  # limitations under the License.
 
  18  * ============LICENSE_END=========================================================
 
  21 package org.onap.so.bpmn.infrastructure.scripts
 
  23 import org.camunda.bpm.engine.delegate.BpmnError
 
  24 import org.camunda.bpm.engine.delegate.DelegateExecution
 
  25 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
 
  26 import org.onap.so.bpmn.common.scripts.ExceptionUtil
 
  27 import org.onap.so.bpmn.common.scripts.NssmfAdapterUtils
 
  28 import org.onap.so.bpmn.common.scripts.OofUtils
 
  29 import org.onap.so.bpmn.common.scripts.RequestDBUtil
 
  30 import org.onap.so.bpmn.core.json.JsonUtils
 
  31 import org.onap.so.db.request.beans.ResourceOperationStatus
 
  32 import org.slf4j.Logger
 
  33 import org.slf4j.LoggerFactory
 
  34 import java.sql.Timestamp
 
  36 import static org.apache.commons.lang3.StringUtils.isBlank
 
  37 import com.google.gson.JsonObject
 
  38 import com.fasterxml.jackson.databind.ObjectMapper
 
  39 import com.google.gson.JsonArray
 
  40 import org.onap.aai.domain.yang.Relationship
 
  41 import org.onap.aaiclient.client.aai.AAIResourcesClient
 
  42 import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
 
  43 import org.onap.so.beans.nsmf.AllocateTnNssi
 
  44 import org.onap.so.beans.nsmf.EsrInfo
 
  45 import org.onap.so.bpmn.core.UrnPropertiesReader
 
  46 import org.onap.so.bpmn.core.domain.ServiceDecomposition
 
  47 import org.onap.so.bpmn.core.domain.ServiceInstance
 
  48 import org.onap.so.bpmn.core.domain.ServiceProxy
 
  49 import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
 
  50 import org.onap.aaiclient.client.aai.AAINamespaceConstants
 
  51 import org.onap.aaiclient.client.aai.AAIObjectType
 
  52 import org.onap.aai.domain.yang.NetworkPolicy
 
  53 import org.onap.aai.domain.yang.NetworkRoute
 
  55 class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor {
 
  58         ExceptionUtil exceptionUtil = new ExceptionUtil()
 
  59         RequestDBUtil requestDBUtil = new RequestDBUtil()
 
  60         JsonUtils jsonUtil = new JsonUtils()
 
  61         OofUtils oofUtils = new OofUtils()
 
  62         AnNssmfUtils anNssmfUtils = new AnNssmfUtils()
 
  63         ObjectMapper objectMapper = new ObjectMapper();
 
  64         private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil)
 
  66         private static final Logger logger = LoggerFactory.getLogger(DoAllocateAccessNSSI.class)
 
  69         void preProcessRequest(DelegateExecution execution) {
 
  70                 logger.debug(Prefix + "preProcessRequest Start")
 
  71                 execution.setVariable("prefix", Prefix)
 
  72                 execution.setVariable("startTime", System.currentTimeMillis())
 
  76                         logger.debug("input variables : msoRequestId - "+execution.getVariable("msoRequestId")
 
  77                                         +" modelInvariantUuid - "+execution.getVariable("modelInvariantUuid")+
 
  78                                         " modelUuid - "+execution.getVariable("modelUuid")+
 
  79                                         " globalSubscriberId - "+execution.getVariable("globalSubscriberId")+
 
  80                                         " dummyServiceId - "+ execution.getVariable("dummyServiceId")+
 
  81                                         " nsiId - "+execution.getVariable("nsiId")+
 
  82                                         " networkType - "+execution.getVariable("networkType")+
 
  83                                         " subscriptionServiceType - "+execution.getVariable("subscriptionServiceType")+
 
  84                                         " jobId - "+execution.getVariable("jobId")+
 
  85                                         " sliceParams - "+execution.getVariable("sliceParams")+
 
  86                                         " servicename - "+ execution.getVariable("servicename"))
 
  88                         //validate slice subnet inputs
 
  90                         String sliceParams = execution.getVariable("sliceParams")
 
  91                         String sliceProfile = jsonUtil.getJsonValue(sliceParams, "sliceProfile")
 
  92                         if (isBlank(sliceProfile)) {
 
  93                                 msg = "Input sliceProfile is null"
 
  95                                 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
 
  97                                 execution.setVariable("sliceProfile", sliceProfile)
 
  99                         String sliceProfileId = jsonUtil.getJsonValue(sliceProfile, "sliceProfileId")
 
 100                         def snssaiList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceProfile, "snssaiList"))
 
 101                         def plmnIdList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceProfile, "plmnIdList"))
 
 102                         def coverageAreaTAList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceProfile, "coverageAreaTAList"))
 
 104                         if (isBlank(sliceProfileId) || (snssaiList.empty) || (plmnIdList.empty)
 
 105                         || (coverageAreaTAList.empty)) {
 
 107                                 msg = "Mandatory slice profile fields are empty"
 
 109                                 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
 
 111                                 execution.setVariable("sliceProfileId", sliceProfileId)
 
 112                                 execution.setVariable("snssaiList", snssaiList)
 
 113                                 execution.setVariable("plmnIdList", plmnIdList)
 
 114                                 execution.setVariable("coverageAreaTAList", coverageAreaTAList)
 
 116                         String nsiName = jsonUtil.getJsonValue(sliceParams, "nsiInfo.nsiName")
 
 117                         String scriptName = jsonUtil.getJsonValue(sliceParams, "scriptName")
 
 118                         execution.setVariable("nsiName", nsiName)
 
 119                         execution.setVariable("scriptName", scriptName)
 
 120                         //generate RAN,RAN NF NSSIs - will be re assigned if oof returns existing NSSI
 
 121                         String RANServiceInstanceId = UUID.randomUUID().toString()
 
 122                         String RANNFServiceInstanceId = UUID.randomUUID().toString()
 
 123                         logger.debug("RAN serviceInstance Id "+RANServiceInstanceId)
 
 124                         logger.debug("RAN NF serviceInstance Id "+RANNFServiceInstanceId)                       
 
 125                         execution.setVariable("RANServiceInstanceId", RANServiceInstanceId)
 
 126                         execution.setVariable("RANNFServiceInstanceId", RANNFServiceInstanceId)
 
 127                         execution.setVariable("ranNssiPreferReuse", true)
 
 128                         execution.setVariable("ranNfNssiPreferReuse", true)
 
 129                         execution.setVariable("job_timeout", 10)
 
 132                         List<String> BH_endPoints = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceParams, "endPoints"))
 
 133                         logger.debug("BH end points list : "+BH_endPoints)
 
 134                         if(BH_endPoints.empty) {
 
 135                                 msg = "End point info is empty"
 
 137                                 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
 
 139                                 execution.setVariable("bh_endpoint", BH_endPoints.get(0))
 
 142                 } catch(BpmnError e) {
 
 144                 } catch(Exception ex) {
 
 145                         msg = "Exception in DoAllocateAccessNSSI.preProcessRequest " + ex.getMessage()
 
 147                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
 
 149                 logger.debug(Prefix + "preProcessRequest Exit")
 
 153          * Prepare request params for decomposing RAN NSST
 
 156         def prepareDecomposeService = { DelegateExecution execution ->
 
 157                 logger.debug(Prefix+"prepareDecomposeService method start")
 
 158                 String RANServiceInstanceId = execution.getVariable("RANServiceInstanceId")
 
 159                 String modelInvariantUuid = execution.getVariable("modelInvariantUuid")
 
 160                 String modelUuid = execution.getVariable("modelUuid")
 
 161                 String serviceModelInfo = """{
 
 162             "modelInvariantUuid":"${modelInvariantUuid}",
 
 163             "modelUuid":"${modelUuid}",
 
 166                 execution.setVariable("serviceModelInfo", serviceModelInfo)
 
 167                 execution.setVariable("serviceInstanceId", RANServiceInstanceId)
 
 168                 logger.debug("serviceModelInfo : "+serviceModelInfo)
 
 169                 logger.debug("Finish RAN NSST prepareDecomposeService")
 
 172         /* process the decompose service(RAN NSST) response
 
 175         def processDecomposition = { DelegateExecution execution ->
 
 176                 logger.debug(Prefix+"processDecomposition method start")
 
 177                 ServiceDecomposition ranNsstServiceDecomposition = execution.getVariable("ranNsstServiceDecomposition")
 
 178                 logger.debug("ranNsstServiceDecomposition : "+ranNsstServiceDecomposition.toString())
 
 179                 //RAN NSST decomposition
 
 180                 String ranModelVersion = ranNsstServiceDecomposition.getModelInfo().getModelVersion()
 
 181                 String ranModelName = ranNsstServiceDecomposition.getModelInfo().getModelName()
 
 182                 List<ServiceProxy> serviceProxyList = ranNsstServiceDecomposition.getServiceProxy()
 
 183                 List<String> nsstInfoList = new ArrayList<>()
 
 184                 for(ServiceProxy serviceProxy : serviceProxyList)
 
 186                         String nsstModelUuid = serviceProxy.getModelInfo().getModelUuid()
 
 187                         String nsstModelInvariantUuid = serviceProxy.getModelInfo().getModelInvariantUuid()
 
 188                         String name = serviceProxy.getModelInfo().getModelName()
 
 189                         String nsstServiceModelInfo = """{
 
 190             "UUID":"${nsstModelUuid}",
 
 191             "invariantUUID":"${nsstModelInvariantUuid}",
 
 194                         nsstInfoList.add(nsstServiceModelInfo)
 
 197                 int maxIndex=nsstInfoList.size()
 
 200                         String msg = "Exception in RAN NSST processDecomposition. There is no NSST associated with RAN NSST "
 
 202                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
 
 204                 execution.setVariable("ranNsstInfoList",nsstInfoList)
 
 205                 execution.setVariable("ranModelVersion", ranModelVersion)
 
 206                 execution.setVariable("ranModelName", ranModelName)
 
 207                 execution.setVariable("currentIndex",currentIndex)
 
 208                 execution.setVariable("maxIndex",maxIndex)
 
 209                 logger.debug(Prefix+"processDecomposition maxIndex value - "+maxIndex)
 
 213          * Function to subnet capabilities from nssmf adapter
 
 215         def getSubnetCapabilities = { DelegateExecution execution ->
 
 216                 logger.debug(Prefix+"getSubnetCapabilities method start")
 
 218                 String tnNssmfRequest = anNssmfUtils.buildCreateTNNSSMFSubnetCapabilityRequest()
 
 220                 String urlString = "/api/rest/provMns/v1/NSS/subnetCapabilityQuery"
 
 222                 String tnNssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, tnNssmfRequest)
 
 224                 if (tnNssmfResponse != null) {
 
 225                         String FHCapabilities= jsonUtil.getJsonValue(tnNssmfResponse, "TN_FH")
 
 226                         String MHCapabilities = jsonUtil.getJsonValue(tnNssmfResponse, "TN_MH")
 
 227                         execution.setVariable("FHCapabilities",FHCapabilities)
 
 228                         execution.setVariable("MHCapabilities",MHCapabilities)
 
 231                         logger.error("received error message from NSSMF : "+ tnNssmfResponse)
 
 232                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.")
 
 234                 String anNssmfRequest = anNssmfUtils.buildCreateANNFNSSMFSubnetCapabilityRequest()
 
 236                 String anNssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, anNssmfRequest)
 
 238                 if (anNssmfResponse != null) {
 
 239                         String ANNFCapabilities = jsonUtil.getJsonValue(anNssmfResponse, "AN_NF")
 
 240                         execution.setVariable("ANNFCapabilities",ANNFCapabilities)
 
 243                         logger.error("received error message from NSSMF : "+ anNssmfResponse)
 
 244                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.")
 
 249          * prepare OOF request for RAN NSSI selection
 
 251         def prepareOofRequestForRanNSS = { DelegateExecution execution ->
 
 252                 logger.debug(Prefix+"prepareOofRequestForRanNSS method start")
 
 254                 String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
 
 255                 logger.debug( "get NSSI option OOF Url: " + urlString)
 
 257                 //build oof request body
 
 258                 boolean ranNssiPreferReuse = execution.getVariable("ranNssiPreferReuse");
 
 259                 String requestId = execution.getVariable("msoRequestId")
 
 260                 String messageType = "NSISelectionResponse"
 
 261                 Map<String, Object> profileInfo = objectMapper.readValue(execution.getVariable("sliceProfile"), Map.class)
 
 262                 String modelUuid = execution.getVariable("modelUuid")
 
 263                 String modelInvariantUuid = execution.getVariable("modelInvariantUuid")
 
 264                 String modelName = execution.getVariable("ranModelName")
 
 265                 String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution);
 
 266                 List<String> nsstInfoList =  objectMapper.readValue(execution.getVariable("nsstInfoList"), List.class)
 
 267                 JsonArray capabilitiesList = new JsonArray()
 
 268                 String FHCapabilities = execution.getVariable("FHCapabilities")
 
 269                 String MHCapabilities = execution.getVariable("MHCapabilities")
 
 270                 String ANNFCapabilities = execution.getVariable("ANNFCapabilities")
 
 271                 JsonObject FH = new JsonObject()
 
 272                 JsonObject MH = new JsonObject()
 
 273                 JsonObject ANNF = new JsonObject()
 
 274                 FH.addProperty("domainType", "TN_FH")
 
 275                 FH.addProperty("capabilityDetails", FHCapabilities)
 
 276                 MH.addProperty("domainType", "TN_MH")
 
 277                 MH.addProperty("capabilityDetails", MHCapabilities)
 
 278                 ANNF.addProperty("domainType", "AN_NF")
 
 279                 ANNF.addProperty("capabilityDetails", FHCapabilities)
 
 280                 capabilitiesList.add(FH)
 
 281                 capabilitiesList.add(MH)
 
 282                 capabilitiesList.add(ANNF)
 
 284                 execution.setVariable("nssiSelection_Url", "/api/oof/selection/nsi/v1")
 
 285                 execution.setVariable("nssiSelection_messageType",messageType)
 
 286                 execution.setVariable("nssiSelection_correlator",requestId)
 
 287                 execution.setVariable("nssiSelection_timeout",timeout)
 
 289                 String oofRequest = anNssmfUtils.buildSelectRANNSSIRequest(requestId, messageType, modelUuid,modelInvariantUuid,
 
 290                                 modelName, profileInfo, nsstInfoList, capabilitiesList, ranNssiPreferReuse)
 
 292                 execution.setVariable("nssiSelection_oofRequest",oofRequest)
 
 293                 logger.debug("Sending request to OOF: " + oofRequest)
 
 296          * process OOF response for RAN NSSI selection
 
 298         def processOofResponseForRanNSS = { DelegateExecution execution ->
 
 299                 logger.debug(Prefix+"processOofResponseForRanNSS method start")
 
 300                 String oofResponse = execution.getVariable("nssiSelection_asyncCallbackResponse")
 
 301                 String requestStatus = jsonUtil.getJsonValue(oofResponse, "requestStatus")
 
 302                 if(requestStatus.equals("completed")) {
 
 303                         List<String> solution = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(oofResponse, "solutions"))
 
 304                         boolean existingNSI = jsonUtil.getJsonValue(solution.get(0), "existingNSI")
 
 306                                 def sharedNSISolution = jsonUtil.getJsonValue(solution.get(0), "sharedNSISolution")
 
 307                                 execution.setVariable("sharedRanNSSISolution", sharedNSISolution)
 
 308                                 logger.debug("sharedRanNSSISolution from OOF "+sharedNSISolution)
 
 309                                 String RANServiceInstanceId = jsonUtil.getJsonValue(solution.get(0), "sharedNSISolution.NSIId")
 
 310                                 execution.setVariable("RANServiceInstanceId", RANServiceInstanceId)
 
 311                                 ServiceInstance serviceInstance = new ServiceInstance();
 
 312                                 serviceInstance.setInstanceId(RANServiceInstanceId);
 
 313                                 ServiceDecomposition serviceDecomposition = execution.getVariable("ranNsstServiceDecomposition")
 
 314                                 serviceDecomposition.setServiceInstance(serviceInstance);
 
 315                                 execution.setVariable("ranNsstServiceDecomposition", serviceDecomposition)
 
 316                                 execution.setVariable("isRspRanNssi", true)
 
 318                                 def sliceProfiles = jsonUtil.getJsonValue(solution.get(0), "newNSISolution.sliceProfiles")
 
 319                                 execution.setVariable("RanConstituentSliceProfiles", sliceProfiles)
 
 320                                 logger.debug("RanConstituentSliceProfiles list from OOF "+sliceProfiles)
 
 323                         String statusMessage = jsonUtil.getJsonValue(oofResponse, "statusMessage")
 
 324                         logger.error("received failed status from oof "+ statusMessage)
 
 325                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a failed Async Response from OOF : "+statusMessage)
 
 330         def prepareModifyAccessNssiInputs = { DelegateExecution execution ->
 
 331                 logger.debug(Prefix+"prepareModifyAccessNssiInputs method start")
 
 332                 String jobId = UUID.randomUUID().toString()
 
 333                 execution.setVariable("modifyRanNssiJobId", jobId)              
 
 334                 String snssaiList = execution.getVariable("snssaiList")
 
 335                 String sliceParams = execution.getVariable("sliceParams")
 
 336                 String sliceProfileId = execution.getVariable("sliceProfileId")
 
 337                 String nsiInfo = jsonUtil.getJsonValue(sliceParams, "nsiInfo")
 
 338                 String scriptName = execution.getVariable("scriptName")
 
 340                 JsonObject modifySliceParams = new JsonObject()
 
 341                 modifySliceParams.addProperty("modifyAction", "allocate")
 
 342                 modifySliceParams.addProperty("snssaiList", snssaiList)
 
 343                 modifySliceParams.addProperty("sliceProfileId", sliceProfileId)
 
 344                 modifySliceParams.addProperty("nsiInfo", nsiInfo)
 
 345                 modifySliceParams.addProperty("scriptName", scriptName)
 
 347                 execution.setVariable("modifySliceParams", modifySliceParams.toString())
 
 348                 //create operation status in request db
 
 349                 String serviceId = execution.getVariable("RANServiceInstanceId")
 
 350                 String nsiId = execution.getVariable("nsiId")
 
 351                 logger.debug("Generated new job for Service Instance serviceId:" + serviceId + "jobId:" + jobId)
 
 353                 ResourceOperationStatus initStatus = new ResourceOperationStatus()
 
 354                 initStatus.setServiceId(serviceId)
 
 355                 initStatus.setOperationId(jobId)
 
 356                 initStatus.setResourceTemplateUUID(nsiId)
 
 357                 initStatus.setOperType("Modify")
 
 358                 requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus)
 
 361         def createModifyNssiQueryJobStatus = { DelegateExecution execution ->
 
 362                 logger.debug(Prefix+"createModifyNssiQueryJobStatus method start")
 
 363                 EsrInfo esrInfo = new EsrInfo()
 
 364                 esrInfo.setNetworkType("AN")
 
 365                 esrInfo.setVendor("ONAP")
 
 366                 String esrInfoString = objectMapper.writeValueAsString(esrInfo)
 
 367                 execution.setVariable("esrInfo", esrInfoString)
 
 368                 JsonObject serviceInfo = new JsonObject()
 
 369                 serviceInfo.addProperty("nssiId", execution.getVariable("RANServiceInstanceId"))
 
 370                 serviceInfo.addProperty("nsiId", execution.getVariable("nsiId"))
 
 371                 serviceInfo.addProperty("nssiName", execution.getVariable("servicename"))
 
 372                 String sST = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "sST")
 
 373                 serviceInfo.addProperty("sST", sST)
 
 374                 serviceInfo.addProperty("PLMNIdList", objectMapper.writeValueAsString(execution.getVariable("plmnIdList")))
 
 375                 serviceInfo.addProperty("globalSubscriberId", execution.getVariable("globalSubscriberId"))
 
 376                 serviceInfo.addProperty("subscriptionServiceType", execution.getVariable("subscriptionServiceType"))
 
 377                 serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("modelInvariantUuid"))
 
 378                 serviceInfo.addProperty("serviceUuid", execution.getVariable("modelUuid"))
 
 379                 execution.setVariable("serviceInfo", serviceInfo.toString())
 
 380                 execution.setVariable("responseId", "")
 
 382         def prepareNsstDecomposeService = { DelegateExecution execution ->
 
 383                 logger.debug(Prefix+"prepareNsstDecomposeService method start")
 
 384                 List<String> nsstInfoList = objectMapper.readValue(execution.getVariable("ranNsstInfoList"), List.class)
 
 385                 int currentIndex = execution.getVariable("currentIndex")
 
 386                 int maxIndex = execution.getVariable("maxIndex")
 
 387                 logger.debug(Prefix+"prepareNsstDecomposeService : currentIndex value - "+currentIndex+" maxIndex : "+maxIndex)
 
 388                 if(currentIndex<maxIndex) {
 
 389                         String nsstInfo = nsstInfoList.get(currentIndex)
 
 390                         String modelInvariantUuid = jsonUtil.getJsonValue(nsstInfo, "invariantUUID")
 
 391                         String modelUuid = jsonUtil.getJsonValue(nsstInfo, "UUID")
 
 393                         String serviceModelInfo = """{
 
 394             "modelInvariantUuid":"${modelInvariantUuid}",
 
 395             "modelUuid":"${modelUuid}",
 
 398                         execution.setVariable("serviceModelInfo", serviceModelInfo)
 
 399                         execution.setVariable("serviceInstanceId", "")
 
 400                         logger.debug("serviceModelInfo : "+serviceModelInfo)
 
 402                         execution.setVariable("currentIndex", currentIndex)
 
 404                         logger.error("nsstList decomposition error ")
 
 405                         exceptionUtil.buildAndThrowWorkflowException(execution, 1000, "nsstList decomposition error ")
 
 409         def processNsstDecomposition = { DelegateExecution execution ->
 
 410                 logger.debug(Prefix+"processNsstDecomposition method start")
 
 411                 ServiceDecomposition decomposedNsst = execution.getVariable("nsstServiceDecomposition")
 
 412                 logger.debug("decomposedNsst : "+decomposedNsst.toString())
 
 414                 String nsstType = decomposedNsst.getServiceRole() //domainType
 
 415                 String modelVersion = decomposedNsst.getModelInfo().getModelVersion()
 
 416                 String modelName = decomposedNsst.getModelInfo().getModelName()
 
 417                 String modelUuid = decomposedNsst.getModelInfo().getModelUuid()
 
 418                 String modelInvariantUuid = decomposedNsst.getModelInfo().getModelInvariantUuid()
 
 422                                 execution.setVariable("ANNF_modelInvariantUuid", modelInvariantUuid)
 
 423                                 execution.setVariable("ANNF_modelUuid", modelUuid)
 
 424                                 execution.setVariable("ANNF_modelVersion", modelVersion)
 
 425                                 execution.setVariable("ANNF_modelName", modelName)
 
 426                                 execution.setVariable("ANNF_ServiceDecomposition", decomposedNsst)
 
 429                                 execution.setVariable("TNFH_modelInvariantUuid", modelInvariantUuid)
 
 430                                 execution.setVariable("TNFH_modelUuid", modelUuid)
 
 431                                 execution.setVariable("TNFH_modelVersion", modelVersion)
 
 432                                 execution.setVariable("TNFH_modelName", modelName)
 
 433                                 execution.setVariable("TNFH_ServiceDecomposition", decomposedNsst)
 
 436                                 execution.setVariable("TNMH_modelInvariantUuid", modelInvariantUuid)
 
 437                                 execution.setVariable("TNMH_modelUuid", modelUuid)
 
 438                                 execution.setVariable("TNMH_modelVersion", modelVersion)
 
 439                                 execution.setVariable("TNMH_modelName", modelName)
 
 440                                 execution.setVariable("TNMH_ServiceDecomposition", decomposedNsst)
 
 443                                 logger.debug("No expected match found for current nsstType")
 
 444                                 logger.error("No expected match found for current nsstType "+ nsstType)
 
 445                                 exceptionUtil.buildAndThrowWorkflowException(execution, 1000,"No expected match found for current nsstType "+ nsstType)
 
 447                 boolean isAllNsstsDecomposed = false
 
 448                 int currentIndex = execution.getVariable("currentIndex")
 
 449                 int maxIndex = execution.getVariable("maxIndex")
 
 450                 if(currentIndex == maxIndex) {
 
 451                         isAllNsstsDecomposed = true
 
 453                 execution.setVariable("isAllNsstsDecomposed", isAllNsstsDecomposed)
 
 456          * prepare OOF request for NF RAN NSSI selection
 
 458         def prepareOofRequestForRanNfNSS = { DelegateExecution execution ->
 
 459                 logger.debug(Prefix+"prepareOofRequestForRanNfNSS method start")
 
 460                 String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
 
 461                 logger.debug( "get NSSI option OOF Url: " + urlString)
 
 463                 //build oof request body
 
 464                 boolean ranNfNssiPreferReuse = execution.getVariable("ranNfNssiPreferReuse");
 
 465                 String requestId = execution.getVariable("msoRequestId")
 
 466                 String messageType = "NSSISelectionResponse"
 
 467                 List<String> ranConstituentSliceProfiles = jsonUtil.StringArrayToList(execution.getVariable("RanConstituentSliceProfiles"))
 
 468                 anNssmfUtils.createDomainWiseSliceProfiles(ranConstituentSliceProfiles, execution)
 
 469                 Map<String, Object> profileInfo = objectMapper.readValue(execution.getVariable("ranNfSliceProfile"), Map.class)
 
 470                 String modelUuid = execution.getVariable("ANNF_modelUuid")
 
 471                 String modelInvariantUuid = execution.getVariable("ANNF_modelInvariantUuid")
 
 472                 String modelName = execution.getVariable("ANNF_modelName")
 
 473                 String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution);
 
 475                 execution.setVariable("nssiSelection_Url", "/api/oof/selection/nssi/v1")
 
 476                 execution.setVariable("nssiSelection_messageType",messageType)
 
 477                 execution.setVariable("nssiSelection_correlator",requestId)
 
 478                 execution.setVariable("nssiSelection_timeout",timeout)
 
 480                 String oofRequest = oofUtils.buildSelectNSSIRequest(requestId, messageType, modelUuid, modelInvariantUuid, modelName, profileInfo)
 
 482                 execution.setVariable("nssiSelection_oofRequest",oofRequest)
 
 485          * process OOF response for RAN NF NSSI selection
 
 487         def processOofResponseForRanNfNSS = { DelegateExecution execution ->
 
 488                 logger.debug(Prefix+"processOofResponseForRanNfNSS method start")
 
 489                 String oofResponse = execution.getVariable("nfNssiSelection_asyncCallbackResponse")
 
 490                 String requestStatus = jsonUtil.getJsonValue(oofResponse, "requestStatus")
 
 491                 if(requestStatus.equals("completed")) {
 
 492                         List<String> solution = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(oofResponse, "solutions"))             
 
 493                         if(solution.size()>=1) {
 
 494                                 String ranNfNssiId = jsonUtil.getJsonValue(solution.get(0), "NSSIId")
 
 495                                 String invariantUuid = jsonUtil.getJsonValue(solution.get(0), "invariantUUID")
 
 496                                 String uuid = jsonUtil.getJsonValue(solution.get(0), "UUID")
 
 497                                 String nssiName = jsonUtil.getJsonValue(solution.get(0), "NSSIName")
 
 498                                 execution.setVariable("RANNFServiceInstanceId", ranNfNssiId)
 
 499                                 execution.setVariable("RANNFInvariantUUID", invariantUuid)
 
 500                                 execution.setVariable("RANNFUUID", uuid)
 
 501                                 execution.setVariable("RANNFNssiName", nssiName)
 
 502                                 logger.debug("RANNFServiceInstanceId from OOF "+ranNfNssiId)
 
 504                                 ServiceInstance serviceInstance = new ServiceInstance();
 
 505                                 serviceInstance.setInstanceId(ranNfNssiId);
 
 506                                 ServiceDecomposition serviceDecomposition = execution.getVariable("ANNF_ServiceDecomposition")
 
 507                                 serviceDecomposition.setServiceInstance(serviceInstance);
 
 508                                 execution.setVariable("ANNF_ServiceDecomposition", serviceDecomposition)
 
 509                                 execution.setVariable("isRspRanNfNssi", true)
 
 511                                 logger.debug("No solutions returned from OOF .. Create new RAN NF NSSI")
 
 514                         String statusMessage = jsonUtil.getJsonValue(oofResponse, "statusMessage")
 
 515                         logger.error("received failed status from oof "+ statusMessage)
 
 516                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a failed Async Response from OOF : "+statusMessage)
 
 520         def createSliceProfilesInAai = { DelegateExecution execution ->
 
 521                 logger.debug(Prefix+"createSliceProfilesInAai method start")
 
 522                 anNssmfUtils.createSliceProfilesInAai(execution)
 
 525         def processRanNfModifyRsp = { DelegateExecution execution ->
 
 526                 logger.debug(Prefix+"processRanNfModifyRsp method start")
 
 527                 anNssmfUtils.processRanNfModifyRsp(execution)
 
 529                 org.onap.aai.domain.yang.ServiceInstance ANServiceInstance = new ServiceInstance();
 
 530                 //AN instance creation
 
 531                 ANServiceInstance.setServiceInstanceId(execution.getVariable("RANServiceInstanceId"))
 
 532                 String sliceInstanceName = execution.getVariable("servicename")
 
 533                 ANServiceInstance.setServiceInstanceName(sliceInstanceName)
 
 534                 String serviceType = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "sST")
 
 535                 ANServiceInstance.setServiceType(serviceType)
 
 536                 String serviceStatus = "deactivated"
 
 537                 ANServiceInstance.setOrchestrationStatus(serviceStatus)
 
 538                 String serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "plmnIdList")
 
 539                 ANServiceInstance.setServiceInstanceLocationId(serviceInstanceLocationid)
 
 540                 String serviceRole = "nssi"
 
 541                 ANServiceInstance.setServiceRole(serviceRole)
 
 542                 List<String> snssaiList = objectMapper.readValue(execution.getVariable("snssaiList"), List.class)
 
 543                 String snssai = snssaiList.get(0)
 
 544                 ANServiceInstance.setEnvironmentContext(snssai)
 
 545                 ANServiceInstance.setWorkloadContext("AN")
 
 547                 logger.debug("completed AN service instance build "+ ANServiceInstance.toString())
 
 551                         AAIResourcesClient client = new AAIResourcesClient()
 
 552                         AAIResourceUri nssiServiceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), execution.getVariable("RANServiceInstanceId"))
 
 553                         client.create(nssiServiceUri, ANServiceInstance)
 
 555                 } catch (BpmnError e) {
 
 557                 } catch (Exception ex) {
 
 558                         msg = "Exception in AnNssmfUtils.createSliceProfilesInAai " + ex.getMessage()
 
 560                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
 
 563                 createEndPointsInAai(execution)
 
 566         def createSdnrRequest = { DelegateExecution execution ->
 
 567                 logger.debug(Prefix+"createSdnrRequest method start")
 
 568                 String callbackUrl = UrnPropertiesReader.getVariable("mso.workflow.message.endpoint") + "/AsyncSdnrResponse/"+execution.getVariable("msoRequestId")
 
 569                 String sdnrRequest = buildSdnrAllocateRequest(execution, "allocate", "InstantiateRANSlice", callbackUrl)
 
 570                 execution.setVariable("createNSSI_sdnrRequest", sdnrRequest)
 
 571                 execution.setVariable("createNSSI_timeout", "PT10M")
 
 572                 execution.setVariable("createNSSI_correlator", execution.getVariable("msoRequestId"))
 
 573                 execution.setVariable("createNSSI_messageType", "AsyncSdnrResponse");
 
 576         def processSdnrResponse = { DelegateExecution execution ->
 
 577                 logger.debug(Prefix+"processSdnrResponse method start")
 
 578                 String SDNRResponse = execution.getVariable("SDNR_asyncCallbackResponse")
 
 579                 String status = jsonUtil.getJsonValue(SDNRResponse, "status")
 
 580                 if(status.equalsIgnoreCase("success")) {
 
 581                         String nfIds = jsonUtil.getJsonValue(SDNRResponse, "nfIds")
 
 582                         execution.setVariable("ranNfIdsJson", nfIds)
 
 584                         String reason = jsonUtil.getJsonValue(SDNRResponse, "reason")
 
 585                         logger.error("received failed status from SDNR "+ reason)
 
 586                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from SDNR "+ reason)
 
 588                 logger.debug("response from SDNR "+SDNRResponse)
 
 591         def updateAaiWithRANInstances = { DelegateExecution execution ->
 
 592                 logger.debug(Prefix+"updateAaiWithRANInstances method start")
 
 594                 org.onap.aai.domain.yang.ServiceInstance ANServiceInstance = new ServiceInstance();
 
 595                 org.onap.aai.domain.yang.ServiceInstance ANNFServiceInstance = new ServiceInstance();
 
 596                 //AN instance creation
 
 597                 ANServiceInstance.setServiceInstanceId(execution.getVariable("RANServiceInstanceId"))
 
 598                 String sliceInstanceName = execution.getVariable("servicename")
 
 599                 ANServiceInstance.setServiceInstanceName(sliceInstanceName)
 
 600                 String serviceType = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "sST")
 
 601                 ANServiceInstance.setServiceType(serviceType)
 
 602                 String serviceStatus = "deactivated"
 
 603                 ANServiceInstance.setOrchestrationStatus(serviceStatus)
 
 604                 String serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "plmnIdList")
 
 605                 ANServiceInstance.setServiceInstanceLocationId(serviceInstanceLocationid)
 
 606                 String serviceRole = "nssi"
 
 607                 ANServiceInstance.setServiceRole(serviceRole)
 
 608                 List<String> snssaiList = objectMapper.readValue(execution.getVariable("snssaiList"), List.class)
 
 609                 String snssai = snssaiList.get(0)
 
 610                 ANServiceInstance.setEnvironmentContext(snssai)
 
 611                 ANServiceInstance.setWorkloadContext("AN")
 
 613                 logger.debug("completed AN service instance build "+ ANServiceInstance.toString())
 
 615                 ANNFServiceInstance.setServiceInstanceId(execution.getVariable("RANNFServiceInstanceId"))
 
 616                 sliceInstanceName = execution.getVariable("ANNF_modelName")
 
 617                 ANNFServiceInstance.setServiceInstanceName(sliceInstanceName)
 
 618                 ANNFServiceInstance.setServiceType(serviceType)
 
 619                 ANNFServiceInstance.setOrchestrationStatus(serviceStatus)
 
 620                 serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "plmnIdList")
 
 621                 ANNFServiceInstance.setServiceInstanceLocationId(serviceInstanceLocationid)
 
 622                 ANNFServiceInstance.setServiceRole(serviceRole)
 
 623                 snssaiList = objectMapper.readValue(execution.getVariable("snssaiList"), List.class)
 
 624                 snssai = snssaiList.get(0)
 
 625                 ANNFServiceInstance.setEnvironmentContext(snssai)
 
 626                 ANNFServiceInstance.setWorkloadContext("AN-NF")
 
 627                 logger.debug("completed AN service instance build "+ ANNFServiceInstance.toString())
 
 632                         AAIResourcesClient client = new AAIResourcesClient()
 
 633                         AAIResourceUri nssiServiceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), execution.getVariable("RANServiceInstanceId"))
 
 634                         client.create(nssiServiceUri, ANServiceInstance)
 
 636                         AAIResourceUri nssiServiceUri1 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), execution.getVariable("RANNFServiceInstanceId"))
 
 637                         client.create(nssiServiceUri1, ANNFServiceInstance)
 
 639                 } catch (BpmnError e) {
 
 641                 } catch (Exception ex) {
 
 642                         msg = "Exception in AnNssmfUtils.createSliceProfilesInAai " + ex.getMessage()
 
 644                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
 
 647                 createEndPointsInAai(execution)
 
 649         def prepareTnFhRequest = { DelegateExecution execution ->
 
 650                 logger.debug(Prefix+"prepareTnFhRequest method start")
 
 652                 String nssmfRequest = anNssmfUtils.buildCreateNSSMFRequest(execution, "TN_FH", "allocate")
 
 653                 String urlString = "/api/rest/provMns/v1/NSS/SliceProfiles"
 
 654                 String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest)
 
 656                 if (nssmfResponse != null) {
 
 657                         execution.setVariable("nssmfResponse", nssmfResponse)
 
 658                         String jobId = jsonUtil.getJsonValue(nssmfResponse, "jobId")
 
 659                         execution.setVariable("TNFH_jobId",jobId)
 
 661                         logger.error("received error message from NSSMF : "+ nssmfResponse)
 
 662                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.")
 
 664                 logger.debug("Exit prepareTnFhRequest")
 
 667         def prepareTnMhRequest = { DelegateExecution execution ->
 
 668                 logger.debug(Prefix+"prepareTnMhRequest method start")
 
 670                 String nssmfRequest = anNssmfUtils.buildCreateNSSMFRequest(execution, "TN_MH", "allocate")
 
 671                 String urlString = "/api/rest/provMns/v1/NSS/SliceProfiles"
 
 672                 String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest)
 
 674                 if (nssmfResponse != null) {
 
 675                         execution.setVariable("nssmfResponse", nssmfResponse)
 
 676                         String jobId = jsonUtil.getJsonValue(nssmfResponse, "jobId")
 
 677                         execution.setVariable("TNMH_jobId",jobId)
 
 679                         logger.error("received error message from NSSMF : "+ nssmfResponse)
 
 680                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.")
 
 682                 logger.debug("Exit prepareTnMhRequest")
 
 685         def createFhAllocateNssiJobQuery = { DelegateExecution execution ->
 
 686                 logger.debug(Prefix+"createModifyNssiQueryJobStatus method start")
 
 687                 createTnAllocateNssiJobQuery(execution, "TN_FH")                
 
 690         def createMhAllocateNssiJobQuery = { DelegateExecution execution ->
 
 691                 logger.debug(Prefix+"createModifyNssiQueryJobStatus method start")
 
 692                 createTnAllocateNssiJobQuery(execution, "TN_MH")
 
 695         private void createTnAllocateNssiJobQuery(DelegateExecution execution, String domainType) {
 
 696                 EsrInfo esrInfo = new EsrInfo()
 
 697                 esrInfo.setNetworkType("TN")
 
 698                 esrInfo.setVendor("ONAP")
 
 699                 String esrInfoString = objectMapper.writeValueAsString(esrInfo)
 
 700                 execution.setVariable("esrInfo", esrInfoString)
 
 701                 JsonObject serviceInfo = new JsonObject()
 
 702                 serviceInfo.addProperty("nssiId", null)
 
 703                 serviceInfo.addProperty("nsiId", execution.getVariable("nsiId"))
 
 704                 String sST = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "sST")
 
 705                 serviceInfo.addProperty("sST", sST)
 
 706                 serviceInfo.addProperty("PLMNIdList", objectMapper.writeValueAsString(execution.getVariable("plmnIdList")))
 
 707                 serviceInfo.addProperty("globalSubscriberId", execution.getVariable("globalSubscriberId"))
 
 708                 serviceInfo.addProperty("subscriptionServiceType", execution.getVariable("subscriptionServiceType"))
 
 709                 if(domainType.equals("TN_FH")) {
 
 710                         serviceInfo.addProperty("nssiName", execution.getVariable("TNFH_modelName"))
 
 711                         serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("TNFH_modelInvariantUuid"))
 
 712                         serviceInfo.addProperty("serviceUuid", execution.getVariable("TNFH_modelUuid"))
 
 713                 }else if(domainType.equals("TN_MH")) {
 
 714                         serviceInfo.addProperty("nssiName", execution.getVariable("TNMH_modelName"))
 
 715                         serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("TNMH_modelInvariantUuid"))
 
 716                         serviceInfo.addProperty("serviceUuid", execution.getVariable("TNMH_modelUuid"))
 
 718                 execution.setVariable("serviceInfo", serviceInfo.toString())
 
 719                 execution.setVariable("responseId", "")
 
 722         def processFhAllocateNssiJobStatusRsp = { DelegateExecution execution ->
 
 723                 logger.debug(Prefix+"processJobStatusRsp method start")
 
 724                 String jobResponse = execution.getVariable("TNFH_jobResponse")
 
 725                 logger.debug("Job status response "+jobResponse)
 
 726                 String status = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.status")
 
 727                 String nssi = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.nssi")
 
 728                 if(status.equalsIgnoreCase("finished")) {
 
 729                         execution.setVariable("TNFH_NSSI", nssi)
 
 730                         logger.debug("Job successfully completed ... proceeding with flow for nssi : "+nssi)
 
 733                         String statusDescription = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.statusDescription")
 
 734                         logger.error("received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
 
 735                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
 
 739         def processMhAllocateNssiJobStatusRsp = { DelegateExecution execution ->
 
 740                 logger.debug(Prefix+"processJobStatusRsp method start")
 
 741                 String jobResponse = execution.getVariable("TNMH_jobResponse")
 
 742                 logger.debug("Job status response "+jobResponse)
 
 743                 String status = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.status")
 
 744                 String nssi = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.nssi")
 
 745                 if(status.equalsIgnoreCase("finished")) {
 
 746                         execution.setVariable("TNMH_NSSI", nssi)
 
 747                         logger.debug("Job successfully completed ... proceeding with flow for nssi : "+nssi)
 
 750                         String statusDescription = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.statusDescription")
 
 751                         logger.error("received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
 
 752                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
 
 756         def processModifyJobStatusRsp = { DelegateExecution execution ->
 
 757                 logger.debug(Prefix+"processJobStatusRsp method start")
 
 758                 String jobResponse = execution.getVariable("jobResponse")
 
 759                 logger.debug("Job status response "+jobResponse)
 
 760                 String status = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.status")
 
 761                 String nssi = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.nssi")
 
 762                 if(status.equalsIgnoreCase("finished")) {
 
 763                         logger.debug("Job successfully completed ... proceeding with flow for nssi : "+nssi)
 
 766                         String statusDescription = jsonUtil.getJsonValue(jobResponse, "responseDescriptor.statusDescription")
 
 767                         logger.error("received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
 
 768                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"received failed status from job status query for nssi : "+nssi+" with status description : "+ statusDescription)
 
 772         def updateAairelationships = { DelegateExecution execution ->
 
 773                 logger.debug(Prefix + "updateAairelationships Start")
 
 776                         def ANNF_serviceInstanceId = execution.getVariable("RANNFServiceInstanceId")
 
 777                         def TNFH_serviceInstanceId = execution.getVariable("TNFH_NSSI")
 
 778                         def TNMH_serviceInstanceId = execution.getVariable("TNMH_NSSI")
 
 779                         def AN_profileInstanceId = execution.getVariable("sliceProfileId")
 
 780                         def AN_NSSI = execution.getVariable("RANServiceInstanceId")
 
 781                         def ANNF_profileInstanceId = execution.getVariable("ANNF_sliceProfileInstanceId")
 
 782                         def TNFH_profileInstanceId = execution.getVariable("TNFH_sliceProfileInstanceId")
 
 783                         def TNMH_profileInstanceId = execution.getVariable("TNMH_sliceProfileInstanceId")
 
 784                         String globalSubscriberId = execution.getVariable("globalSubscriberId")
 
 785                         String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
 
 787                         Relationship ANNF_relationship = new Relationship()
 
 788                         Relationship TNFH_relationship = new Relationship()
 
 789                         Relationship TNMH_relationship = new Relationship()
 
 791                         String ANNF_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${ANNF_profileInstanceId}"
 
 792                         String TNFH_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNFH_profileInstanceId}"
 
 793                         String TNMH_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNMH_profileInstanceId}"
 
 795                         String ANNF_NSSI_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${ANNF_serviceInstanceId}"
 
 796                         String TNFH_NSSI_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNFH_serviceInstanceId}"
 
 797                         String TNMH_NSSI_relatedLink = "aai/v21/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${TNMH_serviceInstanceId}"
 
 799                         ANNF_relationship.setRelatedLink(ANNF_relatedLink)
 
 800                         ANNF_relationship.setRelatedTo("service-instance")
 
 801                         ANNF_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
 
 802                         TNFH_relationship.setRelatedLink(TNFH_relatedLink)
 
 803                         TNFH_relationship.setRelatedTo("service-instance")
 
 804                         TNFH_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
 
 805                         TNMH_relationship.setRelatedLink(TNMH_relatedLink)
 
 806                         TNMH_relationship.setRelatedTo("service-instance")
 
 807                         TNMH_relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
 
 809                         // create SliceProfile and NSSI relationship in AAI
 
 810                         anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship,ANNF_serviceInstanceId)
 
 811                         anNssmfUtils.createRelationShipInAAI(execution, TNFH_relationship,TNFH_serviceInstanceId)
 
 812                         anNssmfUtils.createRelationShipInAAI(execution, TNMH_relationship,TNMH_serviceInstanceId)
 
 813                         anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship,AN_profileInstanceId)
 
 814                         anNssmfUtils.createRelationShipInAAI(execution, TNFH_relationship,AN_profileInstanceId)
 
 815                         anNssmfUtils.createRelationShipInAAI(execution, TNMH_relationship,AN_profileInstanceId)
 
 817                         //create AN NSSI and ANNF,TNFH,TNMH relationship in AAI
 
 818                         ANNF_relationship.setRelatedLink(ANNF_NSSI_relatedLink)
 
 819                         TNFH_relationship.setRelatedLink(TNFH_NSSI_relatedLink)
 
 820                         TNMH_relationship.setRelatedLink(TNMH_NSSI_relatedLink)
 
 821                         anNssmfUtils.createRelationShipInAAI(execution, ANNF_relationship,AN_NSSI)
 
 822                         anNssmfUtils.createRelationShipInAAI(execution, TNFH_relationship,AN_NSSI)
 
 823                         anNssmfUtils.createRelationShipInAAI(execution, TNMH_relationship,AN_NSSI)
 
 825                 } catch (BpmnError e) {
 
 827                 } catch (Exception ex) {
 
 829                         msg = "Exception in DoCreateE2EServiceInstance.createCustomRelationship. " + ex.getMessage()
 
 831                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
 
 836          * update operation status in request db
 
 839         def prepareOperationStatusUpdate = { DelegateExecution execution ->
 
 840                 logger.debug(Prefix + "prepareOperationStatusUpdate Start")
 
 842                 String serviceId = execution.getVariable("dummyServiceId")
 
 843                 String jobId = execution.getVariable("jobId")
 
 844                 String nsiId = execution.getVariable("nsiId")
 
 845                 String nssiId = execution.getVariable("RANServiceInstanceId")
 
 846                 logger.debug("Service Instance serviceId:" + serviceId + " jobId:" + jobId)
 
 848                 ResourceOperationStatus updateStatus = new ResourceOperationStatus()
 
 849                 updateStatus.setServiceId(serviceId)
 
 850                 updateStatus.setOperationId(jobId)
 
 851                 updateStatus.setResourceTemplateUUID(nsiId)
 
 852                 updateStatus.setResourceInstanceID(nssiId)
 
 853                 updateStatus.setOperType("Allocate")
 
 854                 updateStatus.setProgress(100)
 
 855                 updateStatus.setStatus("finished")
 
 856                 requestDBUtil.prepareUpdateResourceOperationStatus(execution, updateStatus)
 
 858                 logger.debug(Prefix + "prepareOperationStatusUpdate Exit")
 
 861         def prepareFailedOperationStatusUpdate = { DelegateExecution execution ->
 
 862                 logger.debug(Prefix + "prepareFailedOperationStatusUpdate Start")
 
 864                 String serviceId = execution.getVariable("dummyServiceId")
 
 865                 String jobId = execution.getVariable("jobId")
 
 866                 String nsiId = execution.getVariable("nsiId")
 
 867                 String nssiId = execution.getVariable("RANServiceInstanceId")
 
 868                 logger.debug("Service Instance serviceId:" + serviceId + " jobId:" + jobId)
 
 870                 ResourceOperationStatus updateStatus = new ResourceOperationStatus()
 
 871                 updateStatus.setServiceId(serviceId)
 
 872                 updateStatus.setOperationId(jobId)
 
 873                 updateStatus.setResourceTemplateUUID(nsiId)
 
 874                 updateStatus.setResourceInstanceID(nssiId)
 
 875                 updateStatus.setOperType("Allocate")
 
 876                 updateStatus.setProgress(0)
 
 877                 updateStatus.setStatus("failed")
 
 878                 requestDBUtil.prepareUpdateResourceOperationStatus(execution, updateStatus)
 
 881         private String buildSdnrAllocateRequest(DelegateExecution execution, String action, String rpcName, String callbackUrl) {
 
 883                 String requestId = execution.getVariable("msoRequestId")
 
 884                 Date date = new Date().getTime()
 
 885                 Timestamp time = new Timestamp(date)
 
 886                 Map<String,Object> sliceProfile = objectMapper.readValue(execution.getVariable("ranNfSliceProfile"), Map.class)
 
 887                 sliceProfile.put("sliceProfileId", execution.getVariable("ANNF_sliceProfileInstanceId"))
 
 888                 sliceProfile.put("maxNumberofConns", sliceProfile.get("maxNumberofPDUSessions"))
 
 889                 sliceProfile.put("uLThptPerSlice", sliceProfile.get("expDataRateUL"))
 
 890                 sliceProfile.put("dLThptPerSlice", sliceProfile.get("expDataRateDL"))
 
 891                 String sliceProfileString = objectMapper.writeValueAsString(sliceProfile)
 
 892                 JsonObject response = new JsonObject()
 
 893                 JsonObject body = new JsonObject()
 
 894                 JsonObject input = new JsonObject()
 
 895                 JsonObject commonHeader = new JsonObject()
 
 896                 JsonObject payload = new JsonObject()
 
 897                 JsonObject payloadInput = new JsonObject()
 
 898                 commonHeader.addProperty("TimeStamp", time.toString())
 
 899                 commonHeader.addProperty("APIver", "1.0")
 
 900                 commonHeader.addProperty("RequestID", requestId)
 
 901                 commonHeader.addProperty("SubRequestID", "1")
 
 902                 commonHeader.add("RequestTrack", new JsonObject())
 
 903                 commonHeader.add("Flags", new JsonObject())
 
 904                 payloadInput.addProperty("sliceProfile", sliceProfileString)
 
 905                 payloadInput.addProperty("RANNSSIId", execution.getVariable("RANServiceInstanceId"))
 
 906                 payloadInput.addProperty("NSIID", execution.getVariable("nsiId"))
 
 907                 payloadInput.addProperty("RANNFNSSIId", execution.getVariable("RANNFServiceInstanceId"))
 
 908                 payloadInput.addProperty("callbackURL", callbackUrl)
 
 909                 payloadInput.add("additionalproperties", new JsonObject())
 
 910                 payload.add("input", payloadInput)
 
 911                 input.add("CommonHeader", commonHeader)
 
 912                 input.addProperty("Action", action)
 
 913                 input.add("Payload", payload)
 
 914                 body.add("input", input)
 
 915                 response.add("body", body)
 
 916                 response.addProperty("version", "1.0")
 
 917                 response.addProperty("rpc-name", rpcName)
 
 918                 response.addProperty("correlation-id", requestId+"-1")
 
 919                 response.addProperty("type", "request")
 
 920                 return response.toString()
 
 923         private void createEndPointsInAai(DelegateExecution execution) {
 
 924                 String type = "endpoint"
 
 925                 String function = "transport_EP"
 
 926                 int prefixLength = 24
 
 927                 String addressFamily = "ipv4"
 
 928                 //BH RAN end point update
 
 929                 String bh_endpoint = execution.getVariable("bh_endpoint")
 
 930                 String bh_routeId = UUID.randomUUID().toString()
 
 931                 execution.setVariable("tranportEp_ID_bh", bh_routeId)
 
 933                 String CU_IpAddress = jsonUtil.getJsonValue(bh_endpoint, "IpAddress")
 
 934                 String LogicalLinkId = jsonUtil.getJsonValue(bh_endpoint, "LogicalLinkId")
 
 935                 String nextHopInfo = jsonUtil.getJsonValue(bh_endpoint, "nextHopInfo")
 
 936                 NetworkRoute bh_ep = new NetworkRoute()
 
 937                 bh_ep.setRouteId(bh_routeId)
 
 938                 bh_ep.setFunction(function)
 
 941                 bh_ep.setIpAddress(CU_IpAddress)
 
 942                 bh_ep.setLogicalInterfaceId(LogicalLinkId)
 
 943                 bh_ep.setNextHop(nextHopInfo)
 
 944                 bh_ep.setPrefixLength(prefixLength)
 
 945                 bh_ep.setAddressFamily(addressFamily)
 
 946                 //FH RAN end points update
 
 948                 String RU_routeId = UUID.randomUUID().toString()
 
 949                 execution.setVariable("tranportEp_ID_RU", RU_routeId)
 
 951                 NetworkRoute RU_ep = new NetworkRoute()
 
 952                 RU_ep.setRouteId(RU_routeId)
 
 953                 RU_ep.setFunction(function)
 
 956                 RU_ep.setIpAddress("192.168.100.4")
 
 957                 RU_ep.setLogicalInterfaceId("1234")
 
 958                 RU_ep.setNextHop("Host1")
 
 959                 RU_ep.setPrefixLength(prefixLength)
 
 960                 RU_ep.setAddressFamily(addressFamily)
 
 962                 String DUIN_routeId = UUID.randomUUID().toString()
 
 963                 execution.setVariable("tranportEp_ID_DUIN", DUIN_routeId)
 
 965                 NetworkRoute DU_ep = new NetworkRoute()
 
 966                 DU_ep.setRouteId(DUIN_routeId)
 
 967                 DU_ep.setFunction(function)
 
 970                 DU_ep.setIpAddress("192.168.100.5")
 
 971                 DU_ep.setLogicalInterfaceId("1234")
 
 972                 DU_ep.setNextHop("Host2")
 
 973                 DU_ep.setPrefixLength(prefixLength)
 
 974                 DU_ep.setAddressFamily(addressFamily)
 
 975                 //MH RAN end point update
 
 977                 String DUEG_routeId = UUID.randomUUID().toString()
 
 978                 execution.setVariable("tranportEp_ID_DUEG", DUEG_routeId)
 
 979                 NetworkRoute DUEG_ep = new NetworkRoute()
 
 980                 DU_ep.setRouteId(DUEG_routeId)
 
 981                 DU_ep.setNextHop("Host3")
 
 983                 String CUIN_routeId = UUID.randomUUID().toString()
 
 984                 execution.setVariable("tranportEp_ID_CUIN", CUIN_routeId)
 
 985                 NetworkRoute CUIN_ep = new NetworkRoute()
 
 986                 CUIN_ep.setRouteId(CUIN_routeId)
 
 987                 CUIN_ep.setFunction(function)
 
 988                 CUIN_ep.setRole(role)
 
 989                 CUIN_ep.setType(type)
 
 990                 CUIN_ep.setIpAddress("192.168.100.6")
 
 991                 CUIN_ep.setLogicalInterfaceId("1234")
 
 992                 CUIN_ep.setNextHop("Host4")
 
 993                 CUIN_ep.setPrefixLength(prefixLength)
 
 994                 CUIN_ep.setAddressFamily(addressFamily)
 
 996                         AAIResourcesClient client = new AAIResourcesClient()
 
 997                         logger.debug("creating bh endpoint . ID : "+bh_routeId+" node details : "+bh_ep.toString())
 
 998                         AAIResourceUri networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), bh_routeId)
 
 999                         client.create(networkRouteUri, bh_ep)
 
1000                         logger.debug("creating RU endpoint . ID : "+RU_routeId+" node details : "+RU_ep.toString())
 
1001                         networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), RU_routeId)
 
1002                         client.create(networkRouteUri, RU_ep)
 
1003                         logger.debug("creating DUIN endpoint . ID : "+DUIN_routeId+" node details : "+DU_ep.toString())
 
1004                         networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), DUIN_routeId)
 
1005                         client.create(networkRouteUri, DU_ep)
 
1006                         logger.debug("creating DUEG endpoint . ID : "+DUEG_routeId+" node details : "+DU_ep.toString())
 
1007                         networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), DUEG_routeId)
 
1008                         client.create(networkRouteUri, DU_ep)
 
1009                         logger.debug("creating CUIN endpoint . ID : "+CUIN_routeId+" node details : "+CUIN_ep.toString())
 
1010                         networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), CUIN_routeId)
 
1011                         client.create(networkRouteUri, CUIN_ep)
 
1012                         //relationship b/w bh_ep and RAN NSSI
 
1013                         def AN_NSSI = execution.getVariable("RANServiceInstanceId")
 
1014                         Relationship relationship = new Relationship()
 
1015                         String relatedLink = "aai/v21/network/network-routes/network-route/${bh_routeId}"               
 
1016                         relationship.setRelatedLink(relatedLink)
 
1017                         relationship.setRelatedTo("network-route")
 
1018                         relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
 
1019                         anNssmfUtils.createRelationShipInAAI(execution, relationship, AN_NSSI)
 
1020                         def ANNF_serviceInstanceId = execution.getVariable("RANNFServiceInstanceId")
 
1021                         relatedLink = "aai/v21/network/network-routes/network-route/${RU_routeId}"
 
1022                         relationship.setRelatedLink(relatedLink)
 
1023                         anNssmfUtils.createRelationShipInAAI(execution, relationship, ANNF_serviceInstanceId)
 
1024                         relatedLink = "aai/v21/network/network-routes/network-route/${DUIN_routeId}"
 
1025                         relationship.setRelatedLink(relatedLink)
 
1026                         anNssmfUtils.createRelationShipInAAI(execution, relationship, ANNF_serviceInstanceId)
 
1027                         relatedLink = "aai/v21/network/network-routes/network-route/${DUEG_routeId}"
 
1028                         relationship.setRelatedLink(relatedLink)
 
1029                         anNssmfUtils.createRelationShipInAAI(execution, relationship, ANNF_serviceInstanceId)
 
1030                         relatedLink = "aai/v21/network/network-routes/network-route/${CUIN_routeId}"
 
1031                         relationship.setRelatedLink(relatedLink)
 
1032                         anNssmfUtils.createRelationShipInAAI(execution, relationship, ANNF_serviceInstanceId)
 
1033                 } catch (BpmnError e) {
 
1035         } catch (Exception ex) {
 
1036                 String msg = "Exception in createEndPointsInAai " + ex.getMessage()
 
1038                 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)