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)
156 int num = execution.getVariable("maxNsstIndex") as Integer
157 int index = execution.getVariable("currentNsstIndex") as Integer
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<>()
185 for (ServiceDecomposition serviceDecomposition : nsstServiceDecompositions) {
186 SubnetCapability subnetCapability = new SubnetCapability()
187 handleByType(execution, serviceDecomposition, sliceParams, subnetCapability)
188 subnetCapabilities.add(subnetCapability)
191 execution.setVariable("sliceTaskParams", sliceParams)
192 execution.setVariable("subnetCapabilities", subnetCapabilities)
195 private void handleByType(DelegateExecution execution, ServiceDecomposition serviceDecomposition,
196 SliceTaskParamsAdapter sliceParams, SubnetCapability subnetCapability) {
197 ModelInfo modelInfo = serviceDecomposition.getModelInfo()
198 String vendor = serviceDecomposition.getServiceRole()
199 SubnetType subnetType = convertServiceCategory(serviceDecomposition.getServiceCategory())
201 switch (subnetType) {
202 case SubnetType.TN_BH:
203 sliceParams.tnBHSliceTaskInfo.vendor = vendor
204 sliceParams.tnBHSliceTaskInfo.subnetType = subnetType
205 sliceParams.tnBHSliceTaskInfo.networkType = subnetType.networkType
206 sliceParams.tnBHSliceTaskInfo.NSSTInfo.UUID = modelInfo.getModelUuid()
207 sliceParams.tnBHSliceTaskInfo.NSSTInfo.invariantUUID = modelInfo.getModelInvariantUuid()
208 sliceParams.tnBHSliceTaskInfo.NSSTInfo.name = modelInfo.getModelName()
211 case SubnetType.TN_MH:
212 sliceParams.tnMHSliceTaskInfo.vendor = vendor
213 sliceParams.tnMHSliceTaskInfo.subnetType = subnetType
214 sliceParams.tnMHSliceTaskInfo.networkType = subnetType.networkType
215 sliceParams.tnMHSliceTaskInfo.NSSTInfo.UUID = modelInfo.getModelUuid()
216 sliceParams.tnMHSliceTaskInfo.NSSTInfo.invariantUUID = modelInfo.getModelInvariantUuid()
217 sliceParams.tnMHSliceTaskInfo.NSSTInfo.name = modelInfo.getModelName()
220 case SubnetType.AN_NF:
221 sliceParams.anSliceTaskInfo.vendor = vendor
222 sliceParams.anSliceTaskInfo.subnetType = subnetType
223 sliceParams.anSliceTaskInfo.networkType = subnetType.networkType
224 sliceParams.anSliceTaskInfo.NSSTInfo.UUID = modelInfo.getModelUuid()
225 sliceParams.anSliceTaskInfo.NSSTInfo.invariantUUID = modelInfo.getModelInvariantUuid()
226 sliceParams.anSliceTaskInfo.NSSTInfo.name = modelInfo.getModelName()
229 sliceParams.cnSliceTaskInfo.vendor = vendor
230 sliceParams.cnSliceTaskInfo.subnetType = subnetType
231 sliceParams.cnSliceTaskInfo.networkType = subnetType.networkType
232 sliceParams.cnSliceTaskInfo.NSSTInfo.UUID = modelInfo.getModelUuid()
233 sliceParams.cnSliceTaskInfo.NSSTInfo.invariantUUID = modelInfo.getModelInvariantUuid()
234 sliceParams.cnSliceTaskInfo.NSSTInfo.name = modelInfo.getModelName()
243 if (null == subnetType) {
244 def msg = "Get subnetType failed, modelUUId=" + modelInfo.getModelUuid()
246 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
248 String response = querySubnetCapability(execution, vendor, subnetType)
249 ResponseEntity responseEntity = objectMapper.readValue(response, ResponseEntity.class)
251 Map<String, Object> result = responseEntity.getBody() as Map
252 for (Map.Entry<String, Object> entry : result.entrySet()) {
253 subnetCapability.setDomainType(entry.getKey())
254 subnetCapability.setCapabilityDetails(entry.getValue())
259 * get subnetType from serviceCategory
262 private SubnetType convertServiceCategory(String serviceCategory){
263 if(serviceCategory ==~ /CN.*/){
266 if (serviceCategory ==~ /AN.*NF.*/){
267 return SubnetType.AN_NF
269 if (serviceCategory ==~ /TN.*BH.*/){
270 return SubnetType.TN_BH
272 if(serviceCategory ==~ /TN.*MH.*/){
273 return SubnetType.TN_MH
279 * query Subnet Capability of TN AN CN
282 private String querySubnetCapability(DelegateExecution execution, String vendor, SubnetType subnetType) {
284 String strRequest = objectMapper.writeValueAsString(buildQuerySubnetCapRequest(vendor, subnetType))
286 String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_SUB_NET_CAPABILITY, strRequest)
291 * build request body for querying Subnet Capability
297 private static String buildQuerySubnetCapRequest(String vendor, SubnetType subnetType) {
298 NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest()
300 List<String> subnetTypes = new ArrayList<>()
301 subnetTypes.add(subnetType.subnetType)
302 Map<String, Object> paramMap = new HashMap()
303 paramMap.put("subnetTypes", subnetTypes)
305 request.setSubnetCapabilityQuery(objectMapper.writeValueAsString(paramMap))
307 EsrInfo esrInfo = new EsrInfo()
308 esrInfo.setVendor(vendor)
309 esrInfo.setNetworkType(subnetType.networkType)
311 request.setEsrInfo(esrInfo)
313 String strRequest = objectMapper.writeValueAsString(request)
320 * prepare select nsi request
323 public void preNSIRequest(DelegateExecution execution, boolean preferReuse) {
325 String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
326 logger.debug( "get NSI option OOF Url: " + urlString)
328 String requestId = execution.getVariable("msoRequestId")
329 String messageType = "NSISelectionResponse"
331 execution.setVariable("nsiSelectionUrl", "/api/oof/selection/nsi/v1")
332 execution.setVariable("nsiSelection_messageType", messageType)
333 execution.setVariable("nsiSelection_correlator", requestId)
334 String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution)
335 execution.setVariable("nsiSelection_timeout", timeout)
337 SliceTaskParamsAdapter sliceParams =
338 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
340 Map<String, Object> profileInfo = sliceParams.getServiceProfile()
341 TemplateInfo nstInfo = sliceParams.getNSTInfo()
343 List<TemplateInfo> nsstInfos = execution.getVariable("nsstInfos") as List<TemplateInfo>
345 List<SubnetCapability> subnetCapabilities =
346 execution.getVariable("subnetCapabilities") as List<SubnetCapability>
348 String oofRequest = oofUtils.buildSelectNSIRequest(requestId, nstInfo, nsstInfos,
349 messageType, profileInfo, subnetCapabilities, timeout as Integer, preferReuse)
351 execution.setVariable("nsiSelection_oofRequest", oofRequest)
352 logger.debug("Sending request to OOF: " + oofRequest)
357 * process select nsi response
360 public void processNSIResp(DelegateExecution execution) {
362 SliceTaskParamsAdapter sliceTaskParams =
363 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
365 String oofResponse = execution.getVariable("nsiSelection_oofResponse")
366 logger.debug("NSI oofResponse is: " + oofResponse)
367 execution.setVariable("oofResponse", oofResponse)
368 //This needs to be changed to derive a value when we add policy to decide the solution options.
370 Map<String, Object> resMap = objectMapper.readValue(oofResponse, Map.class)
371 List<Map<String, Object>> nsiSolutions = (List<Map<String, Object>>) resMap.get("solutions")
372 Map<String, Object> solution = nsiSolutions.get(0)
374 String resourceSharingLevel = execution.getVariable("resourceSharingLevel")
375 Boolean isSharable = resourceSharingLevel == "shared"
377 if (solution != null) {
378 if (isSharable && solution.get("existingNSI")) {
380 processSharedNSI(solution, sliceTaskParams)
382 else if(solution.containsKey("newNSISolution")) {
383 processNewNSI(solution, sliceTaskParams)
386 execution.setVariable("sliceTaskParams", sliceTaskParams)
387 //logger.debug("sliceTaskParams: " + sliceTaskParams.convertToJson())
388 logger.debug("*** Completed options Call to OOF ***")
391 private void processSharedNSI(Map<String, Object> solution, SliceTaskParamsAdapter sliceParams) {
392 Map<String, Object> sharedNSISolution = solution.get("sharedNSISolution") as Map
394 String nsiId = sharedNSISolution.get("NSIId")
395 String nsiName = sharedNSISolution.get("NSIName")
396 sliceParams.setSuggestNsiId(nsiId)
397 sliceParams.setSuggestNsiName(nsiName)
400 private void processNewNSI(Map<String, Object> solution, SliceTaskParamsAdapter sliceParams) {
401 Map<String, Object> newNSISolution = solution.get("newNSISolution") as Map
402 List<Map> sliceProfiles = newNSISolution.get("sliceProfiles") as List<Map>
403 for (Map sliceProfile : sliceProfiles) {
404 String domainType = sliceProfile.get("domainType")
405 switch (domainType.toLowerCase()) {
407 sliceParams.tnBHSliceTaskInfo.sliceProfile = sliceProfile as TnSliceProfile
410 sliceParams.anSliceTaskInfo.sliceProfile = sliceProfile as AnSliceProfile
413 sliceParams.cnSliceTaskInfo.sliceProfile = sliceProfile as CnSliceProfile
425 * get NSSI Selection Capability for AN
428 public void getNSSISelectionCap4AN(DelegateExecution execution) {
430 def vendor = execution.getVariable("vendor") as String
432 String strRequest = buildNSSISelectionReq(vendor, NetworkType.ACCESS)
434 String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_NSSI_SELECTION_CAPABILITY, strRequest)
436 Map<String, Object> resMap = objectMapper.readValue(response, Map.class)
438 String selection = resMap.get("selection")
441 if ("NSMF".equalsIgnoreCase(selection)) {
442 execution.setVariable("NEED_AN_NSSI_SELECTION", true)
447 * get NSSI Selection Capability for TN
450 public void getNSSISelectionCap4TN(DelegateExecution execution) {
452 def vendor = execution.getVariable("vendor") as String
454 String strRequest = buildNSSISelectionReq(vendor, NetworkType.TRANSPORT)
456 String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_NSSI_SELECTION_CAPABILITY, strRequest)
458 Map<String, Object> resMap = objectMapper.readValue(response, Map.class)
460 String selection = resMap.get("selection")
462 if ("NSMF".equalsIgnoreCase(selection)) {
463 execution.setVariable("NEED_TN_NSSI_SELECTION", true)
468 * get NSSI Selection Capability for CN
471 public void getNSSISelectionCap4CN(DelegateExecution execution) {
473 def vendor = execution.getVariable("vendor") as String
475 String strRequest = buildNSSISelectionReq(vendor, NetworkType.CORE)
477 String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_NSSI_SELECTION_CAPABILITY, strRequest)
479 Map<String, Object> resMap = objectMapper.readValue(response, Map.class)
481 String selection = resMap.get("selection")
483 if ("NSMF".equalsIgnoreCase(selection)) {
484 execution.setVariable("NEED_CN_NSSI_SELECTION", true)
489 * build NSSI Selection Capability Request body to nssmf adapter
494 private static String buildNSSISelectionReq(String vendor, NetworkType networkType) {
495 NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest()
496 EsrInfo esrInfo = new EsrInfo()
497 esrInfo.setVendor(vendor)
498 esrInfo.setNetworkType(networkType)
499 request.setEsrInfo(esrInfo)
501 return objectMapper.writeValueAsString(request)
505 * if exist nssi need to select?
508 public void handleNssiSelect(DelegateExecution execution) {
510 SliceTaskParamsAdapter sliceTaskParams =
511 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
514 boolean needCnNssiSelection = execution.getVariable("NEED_CN_NSSI_SELECTION") as Boolean
515 boolean needAnNssiSelection = execution.getVariable("NEED_AN_NSSI_SELECTION") as Boolean
516 boolean needTnNssiSelection = execution.getVariable("NEED_TN_NSSI_SELECTION") as Boolean
521 * "subType": subtype,
522 * "nsstInfo": object,
523 * "sliceProfile": object
526 * "subType": subtype,
527 * "nsstInfo": object,
528 * "sliceProfile": object
532 List<Map> nssiNeedHandlerInfos = new ArrayList<>()
533 Map<String, Object> nssiNeedHandlerMap = new HashMap()
535 //List<TemplateInfo> nssiNeedHandlers = new ArrayList<>()
536 //List<Object> nssiProfileNeedHandlers = new ArrayList<>()
537 if (needCnNssiSelection) {
538 nssiNeedHandlerMap.put("subnetType", sliceTaskParams.cnSliceTaskInfo.subnetType)
539 nssiNeedHandlerMap.put("nsstInfo", sliceTaskParams.cnSliceTaskInfo.NSSTInfo)
540 nssiNeedHandlerMap.put("sliceProfile", sliceTaskParams.cnSliceTaskInfo.sliceProfile)
541 nssiNeedHandlerInfos.add(nssiNeedHandlerMap)
543 if (needAnNssiSelection) {
544 nssiNeedHandlerMap.clear()
545 nssiNeedHandlerMap.put("subnetType", sliceTaskParams.anSliceTaskInfo.subnetType)
546 nssiNeedHandlerMap.put("nsstInfo", sliceTaskParams.anSliceTaskInfo.NSSTInfo)
547 nssiNeedHandlerMap.put("sliceProfile", sliceTaskParams.anSliceTaskInfo.sliceProfile)
548 nssiNeedHandlerInfos.add(nssiNeedHandlerMap)
550 if (needTnNssiSelection) {
551 nssiNeedHandlerMap.clear()
552 nssiNeedHandlerMap.put("subnetType", sliceTaskParams.tnBHSliceTaskInfo.subnetType)
553 nssiNeedHandlerMap.put("nsstInfo", sliceTaskParams.tnBHSliceTaskInfo.NSSTInfo)
554 nssiNeedHandlerMap.put("sliceProfile", sliceTaskParams.tnBHSliceTaskInfo.sliceProfile)
555 nssiNeedHandlerInfos.add(nssiNeedHandlerMap)
557 nssiNeedHandlerMap.clear()
558 nssiNeedHandlerMap.put("subnetType", sliceTaskParams.tnMHSliceTaskInfo.subnetType)
559 nssiNeedHandlerMap.put("nsstInfo", sliceTaskParams.tnMHSliceTaskInfo.NSSTInfo)
560 nssiNeedHandlerMap.put("sliceProfile", sliceTaskParams.tnMHSliceTaskInfo.sliceProfile)
561 nssiNeedHandlerInfos.add(nssiNeedHandlerMap)
563 nssiNeedHandlerMap.clear()
564 nssiNeedHandlerMap.put("subnetType", sliceTaskParams.tnFHSliceTaskInfo.subnetType)
565 nssiNeedHandlerMap.put("nsstInfo", sliceTaskParams.tnFHSliceTaskInfo.NSSTInfo)
566 nssiNeedHandlerMap.put("sliceProfile", sliceTaskParams.tnFHSliceTaskInfo.sliceProfile)
567 nssiNeedHandlerInfos.add(nssiNeedHandlerMap)
571 if (nssiNeedHandlerInfos.size() > 0) {
572 execution.setVariable("needSelectNssi", true)
573 execution.setVariable("currNssiIndex", 0)
574 execution.setVariable("nssiNeedHandlerInfos", nssiNeedHandlerInfos)
576 execution.setVariable("needSelectNssi", false)
579 execution.setVariable("sliceTaskParams", sliceTaskParams)
583 * prepare select nssi request
586 public void preNSSIRequest(DelegateExecution execution) {
588 List<Map> nssiNeedHandlerInfos =
589 execution.getVariable("nssiNeedHandlerInfos") as List<Map>
591 int currNssiIndex = execution.getVariable("currNssiIndex") as Integer
592 Map nssiNeedHandlerInfo = nssiNeedHandlerInfos.get(currNssiIndex) as Map
594 TemplateInfo nsstInfo = nssiNeedHandlerInfo.get("nsstInfo") as TemplateInfo
595 Object profileInfo = nssiNeedHandlerInfo.get("sliceProfile")
597 String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
598 logger.debug( "get NSI option OOF Url: " + urlString)
600 String requestId = execution.getVariable("msoRequestId")
601 String messageType = "NSSISelectionResponse"
603 execution.setVariable("nssiSelectionUrl", "/api/oof/selection/nssi/v1")
604 execution.setVariable("nssiSelection_messageType", messageType)
605 execution.setVariable("nssiSelection_correlator", requestId)
606 String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution)
607 execution.setVariable("nssiSelection_timeout", timeout)
609 String oofRequest = oofUtils.buildSelectNSSIRequest(requestId, nsstInfo, messageType,
610 profileInfo, timeout as Integer)
612 execution.setVariable("nssiSelection_oofRequest", oofRequest)
613 logger.debug("Sending request to OOF: " + oofRequest)
617 * process select nssi response
620 public void processNSSIResp(DelegateExecution execution) {
622 List<Map> nssiNeedHandlerInfos =
623 execution.getVariable("nssiNeedHandlerInfos") as List<Map>
625 int currNssiIndex = execution.getVariable("currNssiIndex") as Integer
626 Map nssiNeedHandlerInfo = nssiNeedHandlerInfos.get(currNssiIndex) as Map
627 SubnetType subnetType = nssiNeedHandlerInfo.get("subnetType") as SubnetType
629 SliceTaskParamsAdapter sliceTaskParams =
630 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
633 String OOFResponse = execution.getVariable("nssiSelection_oofResponse")
634 logger.debug("NSI OOFResponse is: " + OOFResponse)
635 execution.setVariable("OOFResponse", OOFResponse)
636 //This needs to be changed to derive a value when we add policy to decide the solution options.
638 Map<String, Object> resMap = objectMapper.readValue(OOFResponse, Map.class)
639 List<Map<String, Object>> nsiSolutions = (List<Map<String, Object>>) resMap.get("solutions")
640 Map<String, Object> solution = nsiSolutions.get(0)
642 String resourceSharingLevel = execution.getVariable("resourceSharingLevel")
643 Boolean isSharable = resourceSharingLevel == "shared" //todo
645 if (isSharable && solution != null) {
646 processNssiResult(sliceTaskParams, subnetType, solution)
649 execution.setVariable("sliceTaskParams", sliceTaskParams)
650 //logger.debug("sliceTaskParams: "+ sliceTaskParams.convertToJson())
651 logger.debug("*** Completed options Call to OOF ***")
653 logger.debug("start parseServiceProfile")
654 //parseServiceProfile(execution)
655 logger.debug("end parseServiceProfile")
657 if (currNssiIndex >= nssiNeedHandlerInfos.size() - 1) {
658 execution.setVariable("needSelectNssi", false)
660 execution.setVariable("currNssiIndex", currNssiIndex + 1)
661 execution.setVariable("needSelectNssi", true)
666 private void processNssiResult(SliceTaskParamsAdapter sliceTaskParams, SubnetType subnetType,
667 Map<String, Object> solution) {
668 switch (subnetType) {
670 sliceTaskParams.cnSliceTaskInfo.suggestNssiId = solution.get("NSSIId")
671 sliceTaskParams.cnSliceTaskInfo.suggestNssiName = solution.get("NSSIName")
673 case SubnetType.AN_NF:
674 sliceTaskParams.anSliceTaskInfo.suggestNssiId = solution.get("NSSIId")
675 sliceTaskParams.anSliceTaskInfo.suggestNssiName = solution.get("NSSIName")
677 case SubnetType.TN_BH:
678 sliceTaskParams.tnBHSliceTaskInfo.suggestNssiId = solution.get("NSSIId")
679 sliceTaskParams.tnBHSliceTaskInfo.suggestNssiName = solution.get("NSSIName")
681 case SubnetType.TN_FH:
682 sliceTaskParams.tnFHSliceTaskInfo.suggestNssiId = solution.get("NSSIId")
683 sliceTaskParams.tnFHSliceTaskInfo.suggestNssiName = solution.get("NSSIName")
685 case SubnetType.TN_MH:
686 sliceTaskParams.tnMHSliceTaskInfo.suggestNssiId = solution.get("NSSIId")
687 sliceTaskParams.tnMHSliceTaskInfo.suggestNssiName = solution.get("NSSIName")