2  * ============LICENSE_START=======================================================
 
   4  * ================================================================================
 
   5  # Copyright (c) 2020, CMCC Technologies Co., Ltd.
 
   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 com.fasterxml.jackson.databind.ObjectMapper
 
  24 import org.camunda.bpm.engine.delegate.DelegateExecution
 
  25 import org.onap.so.beans.nsmf.AnSliceProfile
 
  26 import org.onap.so.beans.nsmf.CnSliceProfile
 
  27 import org.onap.so.beans.nsmf.EsrInfo
 
  28 import org.onap.so.beans.nsmf.NetworkType
 
  29 import org.onap.so.beans.nsmf.NssmfAdapterNBIRequest
 
  30 import org.onap.so.beans.nsmf.SliceTaskParamsAdapter
 
  31 import org.onap.so.beans.nsmf.TnSliceProfile
 
  32 import org.onap.so.beans.nsmf.oof.SubnetCapability
 
  33 import org.onap.so.beans.nsmf.oof.SubnetType
 
  34 import org.onap.so.beans.nsmf.oof.TemplateInfo
 
  35 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
 
  36 import org.onap.so.bpmn.common.scripts.ExceptionUtil
 
  37 import org.onap.so.bpmn.common.scripts.NssmfAdapterUtils
 
  38 import org.onap.so.bpmn.common.scripts.OofUtils
 
  39 import org.onap.so.bpmn.core.UrnPropertiesReader
 
  40 import org.onap.so.bpmn.core.domain.AllottedResource
 
  41 import org.onap.so.bpmn.core.domain.ModelInfo
 
  42 import org.onap.so.bpmn.core.domain.ServiceDecomposition
 
  43 import org.onap.so.bpmn.core.json.JsonUtils
 
  44 import org.slf4j.Logger
 
  45 import org.slf4j.LoggerFactory
 
  46 import org.springframework.http.ResponseEntity
 
  48 class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
 
  50     private static final Logger logger = LoggerFactory.getLogger(DoCreateSliceServiceOption.class)
 
  52     ExceptionUtil exceptionUtil = new ExceptionUtil()
 
  54     JsonUtils jsonUtil = new JsonUtils()
 
  56     OofUtils oofUtils = new OofUtils()
 
  58     private static final ObjectMapper objectMapper = new ObjectMapper()
 
  60     private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil)
 
  62     private static final String QUERY_SUB_NET_CAPABILITY = "/api/rest/provMns/v1/NSS/subnetCapabilityQuery"
 
  64     private static final String QUERY_NSSI_SELECTION_CAPABILITY = "/api/rest/provMns/v1/NSS/NSSISelectionCapability"
 
  66     void preProcessRequest (DelegateExecution execution) {
 
  70      * prepare the params for decompose nst
 
  73     public void prepareDecomposeNST(DelegateExecution execution) {
 
  75         SliceTaskParamsAdapter sliceTaskParams =
 
  76                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
 
  78         String modelUuid = sliceTaskParams.getNSTInfo().getUUID()
 
  79         String modelInvariantUuid = sliceTaskParams.getNSTInfo().getInvariantUUID()
 
  81         String serviceModelInfo = """{
 
  82             "modelInvariantUuid":"${modelInvariantUuid}",
 
  83             "modelUuid":"${modelUuid}",
 
  86         execution.setVariable("nstServiceModelInfo", serviceModelInfo)
 
  90      * process the result of NST Decomposition
 
  93     public void processDecompositionNST(DelegateExecution execution) {
 
  95         List<TemplateInfo> nsstInfos = new ArrayList<>()
 
  96         ServiceDecomposition nstServiceDecomposition =
 
  97                 execution.getVariable("nstServiceDecomposition") as ServiceDecomposition
 
  99         List<AllottedResource> allottedResources = nstServiceDecomposition.getAllottedResources()
 
 100         for (AllottedResource allottedResource : allottedResources) {
 
 101             TemplateInfo nsstInfo = new TemplateInfo()
 
 102             nsstInfo.setUUID(allottedResource.getProvidingServiceModelUuid())
 
 103             nsstInfo.setInvariantUUID(allottedResource.getProvidingServiceModelInvariantUuid())
 
 104             nsstInfo.setName(allottedResource.getProvidingServiceModelName())
 
 105             nsstInfos.add(nsstInfo)
 
 107         execution.setVariable("nsstInfos", nsstInfos)
 
 109         execution.setVariable("maxNsstIndex", allottedResources.size() - 1)
 
 110         execution.setVariable("currentNsstIndex", 0)
 
 112         List<ServiceDecomposition> nsstServiceDecompositions = new ArrayList<>()
 
 113         execution.setVariable("nsstServiceDecompositions", nsstServiceDecompositions)
 
 117      * prepare the params for decompose nsst
 
 120     public void prepareDecomposeNSST(DelegateExecution execution) {
 
 122         List<TemplateInfo> nsstInfos = execution.getVariable("nsstInfos") as List<TemplateInfo>
 
 123         int index = execution.getVariable("currentNsstIndex") as Integer
 
 125         String modelUuid = nsstInfos.get(index).getUUID()
 
 126         String modelInvariantUuid = nsstInfos.get(index).getInvariantUUID()
 
 128         String serviceModelInfo = """{
 
 129             "modelInvariantUuid":"${modelInvariantUuid}",
 
 130             "modelUuid":"${modelUuid}",
 
 133         execution.setVariable("nsstServiceModelInfo", serviceModelInfo)
 
 138      * process the result of NSST Decomposition
 
 141     public void processDecompositionNSST(DelegateExecution execution) {
 
 143         List<ServiceDecomposition> nsstServiceDecompositions =
 
 144                 execution.getVariable("nsstServiceDecompositions") as List<ServiceDecomposition>
 
 146         ServiceDecomposition nsstServiceDecomposition =
 
 147                 execution.getVariable("nsstServiceDecomposition") as ServiceDecomposition
 
 149         nsstServiceDecompositions.add(nsstServiceDecomposition)
 
 151         execution.setVariable("nsstServiceDecompositions", nsstServiceDecompositions)
 
 153         int num = execution.getVariable("maxNsstIndex") as Integer
 
 154         int index = execution.getVariable("currentNsstIndex") as Integer
 
 156         execution.setVariable("currentNsstIndex", index + 1)
 
 159             execution.setVariable("nsstHandleContinue", false)
 
 161             execution.setVariable("nsstHandleContinue", true)
 
 167      * set nsst info to sliceTaskParams by type
 
 170     public void handleNsstByType(DelegateExecution execution) {
 
 172         SliceTaskParamsAdapter sliceParams =
 
 173                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
 
 175         List<ServiceDecomposition> nsstServiceDecompositions =
 
 176                 execution.getVariable("nsstServiceDecompositions") as List<ServiceDecomposition>
 
 178         List<SubnetCapability> subnetCapabilities = new ArrayList<>()
 
 180         for (ServiceDecomposition serviceDecomposition : nsstServiceDecompositions) {
 
 181             SubnetCapability subnetCapability = new SubnetCapability()
 
 182             handleByType(execution, serviceDecomposition, sliceParams, subnetCapability)
 
 183             subnetCapabilities.add(subnetCapability)
 
 186         execution.setVariable("sliceTaskParams", sliceParams)
 
 187         execution.setVariable("subnetCapabilities", subnetCapabilities)
 
 190     private void handleByType(DelegateExecution execution, ServiceDecomposition serviceDecomposition,
 
 191                               SliceTaskParamsAdapter sliceParams, SubnetCapability subnetCapability) {
 
 192         ModelInfo modelInfo = serviceDecomposition.getModelInfo()
 
 193         String vendor = serviceDecomposition.getServiceRole()
 
 194         SubnetType subnetType = convertServiceCategory(serviceDecomposition.getServiceCategory())
 
 196         switch (subnetType) {
 
 197             case SubnetType.TN_BH:
 
 198                 sliceParams.tnBHSliceTaskInfo.vendor = vendor
 
 199                 sliceParams.tnBHSliceTaskInfo.subnetType = subnetType
 
 200                 sliceParams.tnBHSliceTaskInfo.networkType = subnetType.networkType
 
 201                 sliceParams.tnBHSliceTaskInfo.NSSTInfo.UUID = modelInfo.getModelUuid()
 
 202                 sliceParams.tnBHSliceTaskInfo.NSSTInfo.invariantUUID = modelInfo.getModelInvariantUuid()
 
 203                 sliceParams.tnBHSliceTaskInfo.NSSTInfo.name = modelInfo.getModelName()
 
 205             case SubnetType.TN_MH:
 
 206                 sliceParams.tnMHSliceTaskInfo.vendor = vendor
 
 207                 sliceParams.tnMHSliceTaskInfo.subnetType = subnetType
 
 208                 sliceParams.tnMHSliceTaskInfo.networkType = subnetType.networkType
 
 209                 sliceParams.tnMHSliceTaskInfo.NSSTInfo.UUID = modelInfo.getModelUuid()
 
 210                 sliceParams.tnMHSliceTaskInfo.NSSTInfo.invariantUUID = modelInfo.getModelInvariantUuid()
 
 211                 sliceParams.tnMHSliceTaskInfo.NSSTInfo.name = modelInfo.getModelName()
 
 213             case SubnetType.AN_NF:
 
 214                 sliceParams.anSliceTaskInfo.vendor = vendor
 
 215                 sliceParams.anSliceTaskInfo.subnetType = subnetType
 
 216                 sliceParams.anSliceTaskInfo.networkType = subnetType.networkType
 
 217                 sliceParams.anSliceTaskInfo.NSSTInfo.UUID = modelInfo.getModelUuid()
 
 218                 sliceParams.anSliceTaskInfo.NSSTInfo.invariantUUID = modelInfo.getModelInvariantUuid()
 
 219                 sliceParams.anSliceTaskInfo.NSSTInfo.name = modelInfo.getModelName()
 
 222                 sliceParams.cnSliceTaskInfo.vendor = vendor
 
 223                 sliceParams.cnSliceTaskInfo.subnetType = subnetType
 
 224                 sliceParams.cnSliceTaskInfo.networkType = subnetType.networkType
 
 225                 sliceParams.cnSliceTaskInfo.NSSTInfo.UUID = modelInfo.getModelUuid()
 
 226                 sliceParams.cnSliceTaskInfo.NSSTInfo.invariantUUID = modelInfo.getModelInvariantUuid()
 
 227                 sliceParams.cnSliceTaskInfo.NSSTInfo.name = modelInfo.getModelName()
 
 233         if (null == subnetType) {
 
 234             def msg = "Get subnetType failed, modelUUId=" + modelInfo.getModelUuid()
 
 236             exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
 
 238         String response = querySubnetCapability(execution, vendor, subnetType)
 
 239         ResponseEntity responseEntity = objectMapper.readValue(response, ResponseEntity.class)
 
 241         Map<String, Object> result = responseEntity.getBody() as Map
 
 242         for (Map.Entry<String, Object> entry : result.entrySet()) {
 
 243             subnetCapability.setDomainType(entry.getKey())
 
 244             subnetCapability.setCapabilityDetails(entry.getValue())
 
 249      * get subnetType from serviceCategory
 
 252     private SubnetType convertServiceCategory(String serviceCategory){
 
 253         if(serviceCategory ==~ /CN.*/){
 
 256         if (serviceCategory ==~ /AN.*NF.*/){
 
 257             return SubnetType.AN_NF
 
 259         if (serviceCategory ==~ /TN.*BH.*/){
 
 260             return SubnetType.TN_BH
 
 262         if(serviceCategory ==~ /TN.*MH.*/){
 
 263             return SubnetType.TN_MH
 
 269      * query Subnet Capability of TN AN CN
 
 272     private String querySubnetCapability(DelegateExecution execution, String vendor, SubnetType subnetType) {
 
 274         String strRequest = objectMapper.writeValueAsString(buildQuerySubnetCapRequest(vendor, subnetType))
 
 276         String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_SUB_NET_CAPABILITY, strRequest)
 
 281      * build request body for querying Subnet Capability
 
 287     private static String buildQuerySubnetCapRequest(String vendor, SubnetType subnetType) {
 
 288         NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest()
 
 290 //        List<String> subnetTypes =  new ArrayList<>()
 
 291 //        subnetTypes.add(subnetType.subnetType)
 
 292         Map<String, Object> paramMap = new HashMap()
 
 293         paramMap.put("subnetType", subnetType.subnetType)
 
 295         request.setSubnetCapabilityQuery(objectMapper.writeValueAsString(paramMap))
 
 297         EsrInfo esrInfo = new EsrInfo()
 
 298         esrInfo.setVendor(vendor)
 
 299         esrInfo.setNetworkType(subnetType.networkType)
 
 300         request.setEsrInfo(esrInfo)
 
 302         String strRequest = objectMapper.writeValueAsString(request)
 
 309      * prepare select nsi request
 
 312     public void preNSIRequest(DelegateExecution execution) {
 
 313         boolean preferReuse = execution.getVariable("needQuerySliceProfile") ? false : true
 
 315         String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
 
 316         logger.debug( "get NSI option OOF Url: " + urlString)
 
 318         String requestId = execution.getVariable("msoRequestId")
 
 319         String messageType = "NSISelectionResponse"
 
 321         execution.setVariable("nsiSelectionUrl", "/api/oof/selection/nsi/v1")
 
 322         execution.setVariable("nsiSelection_messageType", messageType)
 
 323         execution.setVariable("nsiSelection_correlator", requestId)
 
 324         String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution)
 
 325         execution.setVariable("nsiSelection_timeout", timeout)
 
 327         SliceTaskParamsAdapter sliceParams =
 
 328                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
 
 330         Map<String, Object> profileInfo = sliceParams.getServiceProfile()
 
 331         TemplateInfo nstInfo = sliceParams.getNSTInfo()
 
 333         List<TemplateInfo> nsstInfos = execution.getVariable("nsstInfos") as List<TemplateInfo>
 
 335         List<SubnetCapability> subnetCapabilities =
 
 336                 execution.getVariable("subnetCapabilities") as List<SubnetCapability>
 
 338         String oofRequest = oofUtils.buildSelectNSIRequest(requestId, nstInfo, nsstInfos,
 
 339                 messageType, profileInfo, subnetCapabilities, timeout as Integer, preferReuse)
 
 341         execution.setVariable("nsiSelection_oofRequest", oofRequest)
 
 342         logger.debug("Sending request to OOF: " + oofRequest)
 
 347      * process select nsi response
 
 350     public void processNSIResp(DelegateExecution execution) {
 
 352         SliceTaskParamsAdapter sliceTaskParams =
 
 353                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
 
 355         String oofResponse = execution.getVariable("nsiSelection_oofResponse")
 
 356         logger.debug("NSI oofResponse is: " + oofResponse)
 
 357         execution.setVariable("oofResponse", oofResponse)
 
 358         //This needs to be changed to derive a value when we add policy to decide the solution options.
 
 360         Map<String, Object> resMap = objectMapper.readValue(oofResponse, Map.class)
 
 361         List<Map<String, Object>> nsiSolutions = (List<Map<String, Object>>) resMap.get("solutions")
 
 362         Map<String, Object> solution = nsiSolutions.get(0)
 
 364         String resourceSharingLevel = execution.getVariable("resourceSharingLevel")
 
 365         Boolean isSharable = resourceSharingLevel == "shared"
 
 367         if (solution != null) {
 
 368             if (isSharable && solution.get("existingNSI")) {
 
 370                 processSharedNSI(solution, sliceTaskParams)
 
 371                 execution.setVariable("needQuerySliceProfile", true)
 
 374                 processNewNSI(solution, sliceTaskParams)
 
 377         execution.setVariable("sliceTaskParams", sliceTaskParams)
 
 378         //logger.debug("sliceTaskParams: " + sliceTaskParams.convertToJson())
 
 379         logger.debug("*** Completed options Call to OOF ***")
 
 382     private void processSharedNSI(Map<String, Object> solution, SliceTaskParamsAdapter sliceParams) {
 
 383         Map<String, Object> sharedNSISolution = solution.get("sharedNSISolution") as Map
 
 385         String nsiId = sharedNSISolution.get("NSIId")
 
 386         String nsiName = sharedNSISolution.get("NSIName")
 
 387         sliceParams.setSuggestNsiId(nsiId)
 
 388         sliceParams.setSuggestNsiName(nsiName)
 
 392     private void processNewNSI(Map<String, Object> solution, SliceTaskParamsAdapter sliceParams) {
 
 393         Map<String, Object> newNSISolution = solution.get("newNSISolution") as Map
 
 394         List<Map> sliceProfiles = newNSISolution.get("sliceProfiles") as List<Map>
 
 395         for (Map sliceProfile : sliceProfiles) {
 
 396             String domainType = sliceProfile.get("domainType")
 
 397             switch (domainType.toLowerCase()) {
 
 399                     sliceParams.tnBHSliceTaskInfo.sliceProfile = sliceProfile as TnSliceProfile
 
 402                     sliceParams.anSliceTaskInfo.sliceProfile = sliceProfile as AnSliceProfile
 
 405                     sliceParams.cnSliceTaskInfo.sliceProfile = sliceProfile as CnSliceProfile
 
 417      * get NSSI Selection Capability for AN
 
 420     public void getNSSISelectionCap4AN(DelegateExecution execution) {
 
 422         def vendor = execution.getVariable("vendor") as String
 
 424         String strRequest = buildNSSISelectionReq(vendor, NetworkType.ACCESS)
 
 426         String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_NSSI_SELECTION_CAPABILITY, strRequest)
 
 428         Map<String, Object> resMap = objectMapper.readValue(response, Map.class)
 
 430         String selection = resMap.get("selection")
 
 433         if ("NSMF".equalsIgnoreCase(selection)) {
 
 434             execution.setVariable("NEED_AN_NSSI_SELECTION", true)
 
 439      * get NSSI Selection Capability for TN
 
 442     public void getNSSISelectionCap4TN(DelegateExecution execution) {
 
 444         def vendor = execution.getVariable("vendor") as String
 
 446         String strRequest = buildNSSISelectionReq(vendor, NetworkType.TRANSPORT)
 
 448         String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_NSSI_SELECTION_CAPABILITY, strRequest)
 
 450         Map<String, Object> resMap = objectMapper.readValue(response, Map.class)
 
 452         String selection = resMap.get("selection")
 
 454         if ("NSMF".equalsIgnoreCase(selection)) {
 
 455             execution.setVariable("NEED_TN_NSSI_SELECTION", true)
 
 460      * get NSSI Selection Capability for CN
 
 463     public void getNSSISelectionCap4CN(DelegateExecution execution) {
 
 465         def vendor = execution.getVariable("vendor") as String
 
 467         String strRequest = buildNSSISelectionReq(vendor, NetworkType.CORE)
 
 469         String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_NSSI_SELECTION_CAPABILITY, strRequest)
 
 471         Map<String, Object> resMap = objectMapper.readValue(response, Map.class)
 
 473         String selection = resMap.get("selection")
 
 475         if ("NSMF".equalsIgnoreCase(selection)) {
 
 476             execution.setVariable("NEED_CN_NSSI_SELECTION", true)
 
 481      * build NSSI Selection Capability Request body to nssmf adapter
 
 486     private static String buildNSSISelectionReq(String vendor, NetworkType networkType) {
 
 487         NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest()
 
 488         EsrInfo esrInfo = new EsrInfo()
 
 489         esrInfo.setVendor(vendor)
 
 490         esrInfo.setNetworkType(networkType)
 
 491         request.setEsrInfo(esrInfo)
 
 493         return objectMapper.writeValueAsString(request)
 
 497      * if exist nssi need to select?
 
 500     public void handleNssiSelect(DelegateExecution execution) {
 
 502         SliceTaskParamsAdapter sliceTaskParams =
 
 503                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
 
 506         boolean needCnNssiSelection = execution.getVariable("NEED_CN_NSSI_SELECTION") as Boolean
 
 507         boolean needAnNssiSelection = execution.getVariable("NEED_AN_NSSI_SELECTION") as Boolean
 
 508         boolean needTnNssiSelection = execution.getVariable("NEED_TN_NSSI_SELECTION") as Boolean
 
 513          *           "subType":  subtype,
 
 514          *           "nsstInfo": object,
 
 515          *           "sliceProfile": object
 
 518          *          "subType":  subtype,
 
 519          *          "nsstInfo": object,
 
 520          *          "sliceProfile": object
 
 524         List<Map> nssiNeedHandlerInfos = new ArrayList<>()
 
 525         Map<String, Object> nssiNeedHandlerMap = new HashMap()
 
 527         //List<TemplateInfo> nssiNeedHandlers = new ArrayList<>()
 
 528         //List<Object> nssiProfileNeedHandlers = new ArrayList<>()
 
 529         if (needCnNssiSelection) {
 
 530             nssiNeedHandlerMap.put("subnetType", sliceTaskParams.cnSliceTaskInfo.subnetType)
 
 531             nssiNeedHandlerMap.put("nsstInfo", sliceTaskParams.cnSliceTaskInfo.NSSTInfo)
 
 532             nssiNeedHandlerMap.put("sliceProfile", sliceTaskParams.cnSliceTaskInfo.sliceProfile)
 
 533             nssiNeedHandlerInfos.add(nssiNeedHandlerMap)
 
 535         if (needAnNssiSelection) {
 
 536             nssiNeedHandlerMap.clear()
 
 537             nssiNeedHandlerMap.put("subnetType", sliceTaskParams.anSliceTaskInfo.subnetType)
 
 538             nssiNeedHandlerMap.put("nsstInfo", sliceTaskParams.anSliceTaskInfo.NSSTInfo)
 
 539             nssiNeedHandlerMap.put("sliceProfile", sliceTaskParams.anSliceTaskInfo.sliceProfile)
 
 540             nssiNeedHandlerInfos.add(nssiNeedHandlerMap)
 
 542         if (needTnNssiSelection) {
 
 543             nssiNeedHandlerMap.clear()
 
 544             nssiNeedHandlerMap.put("subnetType", sliceTaskParams.tnBHSliceTaskInfo.subnetType)
 
 545             nssiNeedHandlerMap.put("nsstInfo", sliceTaskParams.tnBHSliceTaskInfo.NSSTInfo)
 
 546             nssiNeedHandlerMap.put("sliceProfile", sliceTaskParams.tnBHSliceTaskInfo.sliceProfile)
 
 547             nssiNeedHandlerInfos.add(nssiNeedHandlerMap)
 
 549             nssiNeedHandlerMap.clear()
 
 550             nssiNeedHandlerMap.put("subnetType", sliceTaskParams.tnMHSliceTaskInfo.subnetType)
 
 551             nssiNeedHandlerMap.put("nsstInfo", sliceTaskParams.tnMHSliceTaskInfo.NSSTInfo)
 
 552             nssiNeedHandlerMap.put("sliceProfile", sliceTaskParams.tnMHSliceTaskInfo.sliceProfile)
 
 553             nssiNeedHandlerInfos.add(nssiNeedHandlerMap)
 
 555             nssiNeedHandlerMap.clear()
 
 556             nssiNeedHandlerMap.put("subnetType", sliceTaskParams.tnFHSliceTaskInfo.subnetType)
 
 557             nssiNeedHandlerMap.put("nsstInfo", sliceTaskParams.tnFHSliceTaskInfo.NSSTInfo)
 
 558             nssiNeedHandlerMap.put("sliceProfile", sliceTaskParams.tnFHSliceTaskInfo.sliceProfile)
 
 559             nssiNeedHandlerInfos.add(nssiNeedHandlerMap)
 
 563         if (nssiNeedHandlerInfos.size() > 0) {
 
 564             execution.setVariable("needSelectNssi", true)
 
 565             execution.setVariable("currNssiIndex", 0)
 
 566             execution.setVariable("nssiNeedHandlerInfos", nssiNeedHandlerInfos)
 
 568             execution.setVariable("needSelectNssi", false)
 
 571         execution.setVariable("sliceTaskParams", sliceTaskParams)
 
 575      * prepare select nssi request
 
 578     public void preNSSIRequest(DelegateExecution execution) {
 
 580         List<Map> nssiNeedHandlerInfos =
 
 581                 execution.getVariable("nssiNeedHandlerInfos") as List<Map>
 
 583         int currNssiIndex = execution.getVariable("currNssiIndex") as Integer
 
 584         Map nssiNeedHandlerInfo = nssiNeedHandlerInfos.get(currNssiIndex) as Map
 
 586         TemplateInfo nsstInfo = nssiNeedHandlerInfo.get("nsstInfo") as TemplateInfo
 
 587         Object profileInfo = nssiNeedHandlerInfo.get("sliceProfile")
 
 589         String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
 
 590         logger.debug( "get NSI option OOF Url: " + urlString)
 
 592         String requestId = execution.getVariable("msoRequestId")
 
 593         String messageType = "NSSISelectionResponse"
 
 595         execution.setVariable("nssiSelectionUrl", "/api/oof/selection/nssi/v1")
 
 596         execution.setVariable("nssiSelection_messageType", messageType)
 
 597         execution.setVariable("nssiSelection_correlator", requestId)
 
 598         String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution)
 
 599         execution.setVariable("nssiSelection_timeout", timeout)
 
 601         String oofRequest = oofUtils.buildSelectNSSIRequest(requestId, nsstInfo, messageType,
 
 602                 profileInfo, timeout as Integer)
 
 604         execution.setVariable("nssiSelection_oofRequest", oofRequest)
 
 605         logger.debug("Sending request to OOF: " + oofRequest)
 
 609      * process select nssi response
 
 612     public void processNSSIResp(DelegateExecution execution) {
 
 614         List<Map> nssiNeedHandlerInfos =
 
 615                 execution.getVariable("nssiNeedHandlerInfos") as List<Map>
 
 617         int currNssiIndex = execution.getVariable("currNssiIndex") as Integer
 
 618         Map nssiNeedHandlerInfo = nssiNeedHandlerInfos.get(currNssiIndex) as Map
 
 619         SubnetType subnetType = nssiNeedHandlerInfo.get("subnetType") as SubnetType
 
 621         SliceTaskParamsAdapter sliceTaskParams =
 
 622                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
 
 625         String OOFResponse = execution.getVariable("nssiSelection_oofResponse")
 
 626         logger.debug("NSI OOFResponse is: " + OOFResponse)
 
 627         execution.setVariable("OOFResponse", OOFResponse)
 
 628         //This needs to be changed to derive a value when we add policy to decide the solution options.
 
 630         Map<String, Object> resMap = objectMapper.readValue(OOFResponse, Map.class)
 
 631         List<Map<String, Object>> nsiSolutions = (List<Map<String, Object>>) resMap.get("solutions")
 
 632         Map<String, Object> solution = nsiSolutions.get(0)
 
 634         String resourceSharingLevel = execution.getVariable("resourceSharingLevel")
 
 635         Boolean isSharable = resourceSharingLevel == "shared"   //todo
 
 637         if (isSharable && solution != null) {
 
 638             processNssiResult(sliceTaskParams, subnetType, solution)
 
 641         execution.setVariable("sliceTaskParams", sliceTaskParams)
 
 642         //logger.debug("sliceTaskParams: "+ sliceTaskParams.convertToJson())
 
 643         logger.debug("*** Completed options Call to OOF ***")
 
 645         logger.debug("start parseServiceProfile")
 
 646         //parseServiceProfile(execution)
 
 647         logger.debug("end parseServiceProfile")
 
 649         if (currNssiIndex >= nssiNeedHandlerInfos.size() - 1) {
 
 650             execution.setVariable("needSelectNssi", false)
 
 652             execution.setVariable("currNssiIndex", currNssiIndex + 1)
 
 653             execution.setVariable("needSelectNssi", true)
 
 658     private void processNssiResult(SliceTaskParamsAdapter sliceTaskParams, SubnetType subnetType,
 
 659                                    Map<String, Object> solution) {
 
 660         switch (subnetType) {
 
 662                 sliceTaskParams.cnSliceTaskInfo.suggestNssiId = solution.get("NSSIId")
 
 663                 sliceTaskParams.cnSliceTaskInfo.suggestNssiName = solution.get("NSSIName")
 
 665             case SubnetType.AN_NF:
 
 666                 sliceTaskParams.anSliceTaskInfo.suggestNssiId = solution.get("NSSIId")
 
 667                 sliceTaskParams.anSliceTaskInfo.suggestNssiName = solution.get("NSSIName")
 
 669             case SubnetType.TN_BH:
 
 670                 sliceTaskParams.tnBHSliceTaskInfo.suggestNssiId = solution.get("NSSIId")
 
 671                 sliceTaskParams.tnBHSliceTaskInfo.suggestNssiName = solution.get("NSSIName")
 
 673             case SubnetType.TN_FH:
 
 674                 sliceTaskParams.tnFHSliceTaskInfo.suggestNssiId = solution.get("NSSIId")
 
 675                 sliceTaskParams.tnFHSliceTaskInfo.suggestNssiName = solution.get("NSSIName")
 
 677             case SubnetType.TN_MH:
 
 678                 sliceTaskParams.tnMHSliceTaskInfo.suggestNssiId = solution.get("NSSIId")
 
 679                 sliceTaskParams.tnMHSliceTaskInfo.suggestNssiName = solution.get("NSSIName")