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
47 import org.springframework.util.StringUtils
49 class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
51 private static final Logger logger = LoggerFactory.getLogger(DoCreateSliceServiceOption.class)
53 ExceptionUtil exceptionUtil = new ExceptionUtil()
55 JsonUtils jsonUtil = new JsonUtils()
57 OofUtils oofUtils = new OofUtils()
59 private static final ObjectMapper objectMapper = new ObjectMapper()
61 private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil)
63 private static final String QUERY_SUB_NET_CAPABILITY = "/api/rest/provMns/v1/NSS/subnetCapabilityQuery"
65 private static final String QUERY_NSSI_SELECTION_CAPABILITY = "/api/rest/provMns/v1/NSS/NSSISelectionCapability"
67 void preProcessRequest (DelegateExecution execution) {
71 * prepare the params for decompose nst
74 public void prepareDecomposeNST(DelegateExecution execution) {
76 SliceTaskParamsAdapter sliceTaskParams =
77 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
79 String modelUuid = sliceTaskParams.getNSTInfo().getUUID()
80 String modelInvariantUuid = sliceTaskParams.getNSTInfo().getInvariantUUID()
82 String serviceModelInfo = """{
83 "modelInvariantUuid":"${modelInvariantUuid}",
84 "modelUuid":"${modelUuid}",
87 execution.setVariable("nstServiceModelInfo", serviceModelInfo)
91 * process the result of NST Decomposition
94 public void processDecompositionNST(DelegateExecution execution) {
96 List<TemplateInfo> nsstInfos = new ArrayList<>()
97 ServiceDecomposition nstServiceDecomposition =
98 execution.getVariable("nstServiceDecomposition") as ServiceDecomposition
100 List<AllottedResource> allottedResources = nstServiceDecomposition.getAllottedResources()
101 for (AllottedResource allottedResource : allottedResources) {
102 TemplateInfo nsstInfo = new TemplateInfo()
103 nsstInfo.setUUID(allottedResource.getProvidingServiceModelUuid())
104 nsstInfo.setInvariantUUID(allottedResource.getProvidingServiceModelInvariantUuid())
105 nsstInfo.setName(allottedResource.getProvidingServiceModelName())
106 nsstInfos.add(nsstInfo)
108 execution.setVariable("nsstInfos", nsstInfos)
110 execution.setVariable("maxNsstIndex", allottedResources.size() - 1)
111 execution.setVariable("currentNsstIndex", 0)
113 List<ServiceDecomposition> nsstServiceDecompositions = new ArrayList<>()
114 execution.setVariable("nsstServiceDecompositions", nsstServiceDecompositions)
118 * prepare the params for decompose nsst
121 public void prepareDecomposeNSST(DelegateExecution execution) {
123 List<TemplateInfo> nsstInfos = execution.getVariable("nsstInfos") as List<TemplateInfo>
124 int index = execution.getVariable("currentNsstIndex") as Integer
126 String modelUuid = nsstInfos.get(index).getUUID()
127 String modelInvariantUuid = nsstInfos.get(index).getInvariantUUID()
129 String serviceModelInfo = """{
130 "modelInvariantUuid":"${modelInvariantUuid}",
131 "modelUuid":"${modelUuid}",
134 execution.setVariable("nsstServiceModelInfo", serviceModelInfo)
139 * process the result of NSST Decomposition
142 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 List<TemplateInfo> nsstInfos = execution.getVariable("nsstInfos") as List<TemplateInfo>
157 nsstInfos.get(index).name = nsstServiceDecomposition.modelInfo.modelName
158 execution.setVariable("nsstInfos", nsstInfos)
159 execution.setVariable("currentNsstIndex", index + 1)
162 execution.setVariable("nsstHandleContinue", false)
164 execution.setVariable("nsstHandleContinue", true)
170 * set nsst info to sliceTaskParams by type
173 public void handleNsstByType(DelegateExecution execution) {
175 SliceTaskParamsAdapter sliceParams =
176 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
178 List<ServiceDecomposition> nsstServiceDecompositions =
179 execution.getVariable("nsstServiceDecompositions") as List<ServiceDecomposition>
181 List<SubnetCapability> subnetCapabilities = new ArrayList<>()
183 for (ServiceDecomposition serviceDecomposition : nsstServiceDecompositions) {
184 handleByType(execution, serviceDecomposition, sliceParams, subnetCapabilities)
187 execution.setVariable("sliceTaskParams", sliceParams)
188 execution.setVariable("subnetCapabilities", subnetCapabilities)
189 logger.debug("sliceTaskParams= " + sliceParams.toString())
192 private void handleByType(DelegateExecution execution, ServiceDecomposition serviceDecomposition,
193 SliceTaskParamsAdapter sliceParams, List<SubnetCapability> subnetCapabilities) {
194 ModelInfo modelInfo = serviceDecomposition.getModelInfo()
195 String vendor = serviceDecomposition.getServiceRole()
196 SubnetType subnetType = convertServiceCategory(serviceDecomposition.getServiceCategory())
198 switch (subnetType) {
199 case SubnetType.TN_BH:
200 sliceParams.tnBHSliceTaskInfo.vendor = vendor
201 sliceParams.tnBHSliceTaskInfo.subnetType = subnetType
202 sliceParams.tnBHSliceTaskInfo.networkType = subnetType.networkType
203 sliceParams.tnBHSliceTaskInfo.NSSTInfo.UUID = modelInfo.getModelUuid()
204 sliceParams.tnBHSliceTaskInfo.NSSTInfo.invariantUUID = modelInfo.getModelInvariantUuid()
205 sliceParams.tnBHSliceTaskInfo.NSSTInfo.name = modelInfo.getModelName()
207 case SubnetType.TN_MH:
208 sliceParams.tnMHSliceTaskInfo.vendor = vendor
209 sliceParams.tnMHSliceTaskInfo.subnetType = subnetType
210 sliceParams.tnMHSliceTaskInfo.networkType = subnetType.networkType
211 sliceParams.tnMHSliceTaskInfo.NSSTInfo.UUID = modelInfo.getModelUuid()
212 sliceParams.tnMHSliceTaskInfo.NSSTInfo.invariantUUID = modelInfo.getModelInvariantUuid()
213 sliceParams.tnMHSliceTaskInfo.NSSTInfo.name = modelInfo.getModelName()
216 sliceParams.anSliceTaskInfo.vendor = vendor
217 sliceParams.anSliceTaskInfo.subnetType = subnetType
218 sliceParams.anSliceTaskInfo.networkType = subnetType.networkType
219 sliceParams.anSliceTaskInfo.NSSTInfo.UUID = modelInfo.getModelUuid()
220 sliceParams.anSliceTaskInfo.NSSTInfo.invariantUUID = modelInfo.getModelInvariantUuid()
221 sliceParams.anSliceTaskInfo.NSSTInfo.name = modelInfo.getModelName()
224 sliceParams.cnSliceTaskInfo.vendor = vendor
225 sliceParams.cnSliceTaskInfo.subnetType = subnetType
226 sliceParams.cnSliceTaskInfo.networkType = subnetType.networkType
227 sliceParams.cnSliceTaskInfo.NSSTInfo.UUID = modelInfo.getModelUuid()
228 sliceParams.cnSliceTaskInfo.NSSTInfo.invariantUUID = modelInfo.getModelInvariantUuid()
229 sliceParams.cnSliceTaskInfo.NSSTInfo.name = modelInfo.getModelName()
235 if (null == subnetType) {
236 def msg = "Get subnetType failed, modelUUId=" + modelInfo.getModelUuid()
238 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
240 String response = querySubnetCapability(execution, vendor, subnetType)
241 if (!StringUtils.isEmpty(response)) {
242 SubnetCapability subnetCapability = new SubnetCapability()
243 Map<String, Object> result = objectMapper.readValue(response, Map.class)
244 for (Map.Entry<String, Object> entry : result.entrySet()) {
245 subnetCapability.setDomainType(entry.getKey())
246 subnetCapability.setCapabilityDetails(entry.getValue())
248 subnetCapabilities.add(subnetCapability)
253 * get subnetType from serviceCategory
256 private SubnetType convertServiceCategory(String serviceCategory){
257 if(serviceCategory ==~ /CN.*/){
260 if (serviceCategory ==~ /AN.*NF.*/){
263 if (serviceCategory ==~ /TN.*BH.*/){
264 return SubnetType.TN_BH
266 if(serviceCategory ==~ /TN.*MH.*/){
267 return SubnetType.TN_MH
273 * query Subnet Capability of TN AN CN
276 private String querySubnetCapability(DelegateExecution execution, String vendor, SubnetType subnetType) {
278 String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_SUB_NET_CAPABILITY,
279 buildQuerySubnetCapRequest(vendor, subnetType))
284 * build request body for querying Subnet Capability
290 private static NssmfAdapterNBIRequest buildQuerySubnetCapRequest(String vendor, SubnetType subnetType) {
291 NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest()
293 List<String> subnetTypes = new ArrayList<>()
295 subnetTypes.add(subnetType.subnetType)
297 Map<String, Object> paramMap = new HashMap<>()
298 paramMap.put("subnetTypes", subnetTypes)
300 request.setSubnetCapabilityQuery(paramMap)
302 EsrInfo esrInfo = new EsrInfo()
303 esrInfo.setVendor(vendor)
304 esrInfo.setNetworkType(subnetType.networkType)
305 request.setEsrInfo(esrInfo)
312 * prepare select nsi request
315 public void preNSIRequest(DelegateExecution execution) {
316 boolean preferReuse = execution.getVariable("needQuerySliceProfile") ? false : true
318 String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
319 logger.debug( "get NSI option OOF Url: " + urlString)
321 String requestId = execution.getVariable("msoRequestId")
322 String messageType = "NSISelectionResponse"
324 execution.setVariable("nsiSelectionUrl", "/api/oof/selection/nsi/v1")
325 execution.setVariable("nsiSelection_messageType", messageType)
326 execution.setVariable("nsiSelection_correlator", requestId)
327 String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution)
328 execution.setVariable("nsiSelection_timeout", timeout)
330 SliceTaskParamsAdapter sliceParams =
331 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
333 Map<String, Object> profileInfo = sliceParams.getServiceProfile()
334 TemplateInfo nstInfo = sliceParams.getNSTInfo()
336 List<TemplateInfo> nsstInfos = execution.getVariable("nsstInfos") as List<TemplateInfo>
338 List<SubnetCapability> subnetCapabilities =
339 execution.getVariable("subnetCapabilities") as List<SubnetCapability>
341 String oofRequest = oofUtils.buildSelectNSIRequest(requestId, nstInfo, nsstInfos,
342 messageType, profileInfo, subnetCapabilities, 600, preferReuse)
344 execution.setVariable("nsiSelection_oofRequest", oofRequest)
345 logger.debug("Sending request to OOF: " + oofRequest)
350 * process select nsi response
353 public void processNSIResp(DelegateExecution execution) {
355 SliceTaskParamsAdapter sliceTaskParams =
356 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
358 String oofResponse = execution.getVariable("nsiSelection_oofResponse")
359 logger.debug("NSI oofResponse is: " + oofResponse)
360 execution.setVariable("oofResponse", oofResponse)
361 //This needs to be changed to derive a value when we add policy to decide the solution options.
363 Map<String, Object> resMap = objectMapper.readValue(oofResponse, Map.class)
364 String requestStatus = resMap.get("requestStatus")
365 if (StringUtils.isEmpty(requestStatus)) {
366 exceptionUtil.buildWorkflowException(execution, 7000, "get nsi from oof error: " + oofResponse)
369 List<Map<String, Object>> nsiSolutions = (List<Map<String, Object>>) resMap.get("solutions")
371 Map<String, Object> solution = nsiSolutions.get(0)
373 String resourceSharingLevel = execution.getVariable("resourceSharingLevel")
374 Boolean isSharable = resourceSharingLevel == "shared"
376 if (solution != null) {
377 if (isSharable && solution.get("existingNSI")) {
379 processSharedNSI(solution, sliceTaskParams)
380 execution.setVariable("needQuerySliceProfile", true)
383 if(execution.getVariable("needQuerySliceProfile")){
384 execution.setVariable("needQuerySliceProfile", false)
386 processNewNSI(solution, sliceTaskParams)
389 execution.setVariable("sliceTaskParams", sliceTaskParams)
390 logger.debug("*** Completed options Call to OOF ***")
393 private void processSharedNSI(Map<String, Object> solution, SliceTaskParamsAdapter sliceParams) {
394 Map<String, Object> sharedNSISolution = solution.get("sharedNSISolution") as Map
396 String nsiId = sharedNSISolution.get("NSIId")
397 String nsiName = sharedNSISolution.get("NSIName")
398 sliceParams.setSuggestNsiId(nsiId)
399 sliceParams.setSuggestNsiName(nsiName)
403 private void processNewNSI(Map<String, Object> solution, SliceTaskParamsAdapter sliceParams) {
404 Map<String, Object> newNSISolution = solution.get("newNSISolution") as Map
405 List<Map> sliceProfiles = newNSISolution.get("sliceProfiles") as List<Map>
406 for (Map sliceProfile : sliceProfiles) {
407 String domainType = sliceProfile.get("domainType")
408 switch (domainType.toLowerCase()) {
410 sliceParams.tnBHSliceTaskInfo.sliceProfile = sliceProfile as TnSliceProfile
414 sliceParams.anSliceTaskInfo.sliceProfile = sliceProfile as AnSliceProfile
417 sliceParams.cnSliceTaskInfo.sliceProfile = sliceProfile as CnSliceProfile
429 * get NSSI Selection Capability for AN
432 public void getNSSISelectionCap4AN(DelegateExecution execution) {
434 def vendor = execution.getVariable("vendor") as String
436 String strRequest = buildNSSISelectionReq(vendor, NetworkType.ACCESS)
438 String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_NSSI_SELECTION_CAPABILITY, strRequest)
440 Map<String, Object> resMap = objectMapper.readValue(response, Map.class)
442 String selection = resMap.get("selection")
445 if ("NSMF".equalsIgnoreCase(selection)) {
446 execution.setVariable("NEED_AN_NSSI_SELECTION", true)
451 * get NSSI Selection Capability for TN
454 public void getNSSISelectionCap4TN(DelegateExecution execution) {
456 def vendor = execution.getVariable("vendor") as String
458 String strRequest = buildNSSISelectionReq(vendor, NetworkType.TRANSPORT)
460 String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_NSSI_SELECTION_CAPABILITY, strRequest)
462 Map<String, Object> resMap = objectMapper.readValue(response, Map.class)
464 String selection = resMap.get("selection")
466 if ("NSMF".equalsIgnoreCase(selection)) {
467 execution.setVariable("NEED_TN_NSSI_SELECTION", true)
472 * get NSSI Selection Capability for CN
475 public void getNSSISelectionCap4CN(DelegateExecution execution) {
477 def vendor = execution.getVariable("vendor") as String
479 String strRequest = buildNSSISelectionReq(vendor, NetworkType.CORE)
481 String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_NSSI_SELECTION_CAPABILITY, strRequest)
483 Map<String, Object> resMap = objectMapper.readValue(response, Map.class)
485 String selection = resMap.get("selection")
487 if ("NSMF".equalsIgnoreCase(selection)) {
488 execution.setVariable("NEED_CN_NSSI_SELECTION", true)
493 * build NSSI Selection Capability Request body to nssmf adapter
498 private static String buildNSSISelectionReq(String vendor, NetworkType networkType) {
499 NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest()
500 EsrInfo esrInfo = new EsrInfo()
501 esrInfo.setVendor(vendor)
502 esrInfo.setNetworkType(networkType)
503 request.setEsrInfo(esrInfo)
505 return objectMapper.writeValueAsString(request)
509 * if exist nssi need to select?
512 public void handleNssiSelect(DelegateExecution execution) {
514 SliceTaskParamsAdapter sliceTaskParams =
515 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
518 boolean needCnNssiSelection = execution.getVariable("NEED_CN_NSSI_SELECTION") as Boolean
519 boolean needAnNssiSelection = execution.getVariable("NEED_AN_NSSI_SELECTION") as Boolean
520 boolean needTnNssiSelection = execution.getVariable("NEED_TN_NSSI_SELECTION") as Boolean
525 * "subType": subtype,
526 * "nsstInfo": object,
527 * "sliceProfile": object
530 * "subType": subtype,
531 * "nsstInfo": object,
532 * "sliceProfile": object
536 List<Map> nssiNeedHandlerInfos = new ArrayList<>()
537 Map<String, Object> nssiNeedHandlerMap = new HashMap()
539 //List<TemplateInfo> nssiNeedHandlers = new ArrayList<>()
540 //List<Object> nssiProfileNeedHandlers = new ArrayList<>()
541 if (needCnNssiSelection) {
542 nssiNeedHandlerMap.put("subnetType", sliceTaskParams.cnSliceTaskInfo.subnetType)
543 nssiNeedHandlerMap.put("nsstInfo", sliceTaskParams.cnSliceTaskInfo.NSSTInfo)
544 nssiNeedHandlerMap.put("sliceProfile", sliceTaskParams.cnSliceTaskInfo.sliceProfile)
545 nssiNeedHandlerInfos.add(nssiNeedHandlerMap)
547 if (needAnNssiSelection) {
548 nssiNeedHandlerMap.clear()
549 nssiNeedHandlerMap.put("subnetType", sliceTaskParams.anSliceTaskInfo.subnetType)
550 nssiNeedHandlerMap.put("nsstInfo", sliceTaskParams.anSliceTaskInfo.NSSTInfo)
551 nssiNeedHandlerMap.put("sliceProfile", sliceTaskParams.anSliceTaskInfo.sliceProfile)
552 nssiNeedHandlerInfos.add(nssiNeedHandlerMap)
554 if (needTnNssiSelection) {
555 nssiNeedHandlerMap.clear()
556 nssiNeedHandlerMap.put("subnetType", sliceTaskParams.tnBHSliceTaskInfo.subnetType)
557 nssiNeedHandlerMap.put("nsstInfo", sliceTaskParams.tnBHSliceTaskInfo.NSSTInfo)
558 nssiNeedHandlerMap.put("sliceProfile", sliceTaskParams.tnBHSliceTaskInfo.sliceProfile)
559 nssiNeedHandlerInfos.add(nssiNeedHandlerMap)
561 nssiNeedHandlerMap.clear()
562 nssiNeedHandlerMap.put("subnetType", sliceTaskParams.tnMHSliceTaskInfo.subnetType)
563 nssiNeedHandlerMap.put("nsstInfo", sliceTaskParams.tnMHSliceTaskInfo.NSSTInfo)
564 nssiNeedHandlerMap.put("sliceProfile", sliceTaskParams.tnMHSliceTaskInfo.sliceProfile)
565 nssiNeedHandlerInfos.add(nssiNeedHandlerMap)
567 nssiNeedHandlerMap.clear()
568 nssiNeedHandlerMap.put("subnetType", sliceTaskParams.tnFHSliceTaskInfo.subnetType)
569 nssiNeedHandlerMap.put("nsstInfo", sliceTaskParams.tnFHSliceTaskInfo.NSSTInfo)
570 nssiNeedHandlerMap.put("sliceProfile", sliceTaskParams.tnFHSliceTaskInfo.sliceProfile)
571 nssiNeedHandlerInfos.add(nssiNeedHandlerMap)
575 if (nssiNeedHandlerInfos.size() > 0) {
576 execution.setVariable("needSelectNssi", true)
577 execution.setVariable("currNssiIndex", 0)
578 execution.setVariable("nssiNeedHandlerInfos", nssiNeedHandlerInfos)
580 execution.setVariable("needSelectNssi", false)
583 execution.setVariable("sliceTaskParams", sliceTaskParams)
587 * prepare select nssi request
590 public void preNSSIRequest(DelegateExecution execution) {
592 List<Map> nssiNeedHandlerInfos =
593 execution.getVariable("nssiNeedHandlerInfos") as List<Map>
595 int currNssiIndex = execution.getVariable("currNssiIndex") as Integer
596 Map nssiNeedHandlerInfo = nssiNeedHandlerInfos.get(currNssiIndex) as Map
598 TemplateInfo nsstInfo = nssiNeedHandlerInfo.get("nsstInfo") as TemplateInfo
599 Object profileInfo = nssiNeedHandlerInfo.get("sliceProfile")
601 String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
602 logger.debug( "get NSI option OOF Url: " + urlString)
604 String requestId = execution.getVariable("msoRequestId")
605 String messageType = "NSSISelectionResponse"
607 execution.setVariable("nssiSelectionUrl", "/api/oof/selection/nssi/v1")
608 execution.setVariable("nssiSelection_messageType", messageType)
609 execution.setVariable("nssiSelection_correlator", requestId)
610 String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution)
611 execution.setVariable("nssiSelection_timeout", timeout)
613 String oofRequest = oofUtils.buildSelectNSSIRequest(requestId, nsstInfo, messageType,
616 execution.setVariable("nssiSelection_oofRequest", oofRequest)
617 logger.debug("Sending request to OOF: " + oofRequest)
621 * process select nssi response
624 public void processNSSIResp(DelegateExecution execution) {
626 List<Map> nssiNeedHandlerInfos =
627 execution.getVariable("nssiNeedHandlerInfos") as List<Map>
629 int currNssiIndex = execution.getVariable("currNssiIndex") as Integer
630 Map nssiNeedHandlerInfo = nssiNeedHandlerInfos.get(currNssiIndex) as Map
631 SubnetType subnetType = nssiNeedHandlerInfo.get("subnetType") as SubnetType
633 SliceTaskParamsAdapter sliceTaskParams =
634 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
637 String OOFResponse = execution.getVariable("nssiSelection_oofResponse")
638 logger.debug("NSI OOFResponse is: " + OOFResponse)
639 execution.setVariable("OOFResponse", OOFResponse)
640 //This needs to be changed to derive a value when we add policy to decide the solution options.
642 Map<String, Object> resMap = objectMapper.readValue(OOFResponse, Map.class)
643 List<Map<String, Object>> nsiSolutions = (List<Map<String, Object>>) resMap.get("solutions")
644 Map<String, Object> solution = nsiSolutions.get(0)
646 String resourceSharingLevel = execution.getVariable("resourceSharingLevel")
647 Boolean isSharable = resourceSharingLevel == "shared" //todo
649 if (isSharable && solution != null) {
650 processNssiResult(sliceTaskParams, subnetType, solution)
653 execution.setVariable("sliceTaskParams", sliceTaskParams)
654 //logger.debug("sliceTaskParams: "+ sliceTaskParams.convertToJson())
655 logger.debug("*** Completed options Call to OOF ***")
657 logger.debug("start parseServiceProfile")
658 //parseServiceProfile(execution)
659 logger.debug("end parseServiceProfile")
661 if (currNssiIndex >= nssiNeedHandlerInfos.size() - 1) {
662 execution.setVariable("needSelectNssi", false)
664 execution.setVariable("currNssiIndex", currNssiIndex + 1)
665 execution.setVariable("needSelectNssi", true)
670 private void processNssiResult(SliceTaskParamsAdapter sliceTaskParams, SubnetType subnetType,
671 Map<String, Object> solution) {
672 switch (subnetType) {
674 sliceTaskParams.cnSliceTaskInfo.suggestNssiId = solution.get("NSSIId")
675 sliceTaskParams.cnSliceTaskInfo.suggestNssiName = solution.get("NSSIName")
678 sliceTaskParams.anSliceTaskInfo.suggestNssiId = solution.get("NSSIId")
679 sliceTaskParams.anSliceTaskInfo.suggestNssiName = solution.get("NSSIName")
681 case SubnetType.TN_BH:
682 sliceTaskParams.tnBHSliceTaskInfo.suggestNssiId = solution.get("NSSIId")
683 sliceTaskParams.tnBHSliceTaskInfo.suggestNssiName = solution.get("NSSIName")
685 case SubnetType.TN_FH:
686 sliceTaskParams.tnFHSliceTaskInfo.suggestNssiId = solution.get("NSSIId")
687 sliceTaskParams.tnFHSliceTaskInfo.suggestNssiName = solution.get("NSSIName")
689 case SubnetType.TN_MH:
690 sliceTaskParams.tnMHSliceTaskInfo.suggestNssiId = solution.get("NSSIId")
691 sliceTaskParams.tnMHSliceTaskInfo.suggestNssiName = solution.get("NSSIName")