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 if(execution.getVariable("needQuerySliceProfile")){
375 execution.setVariable("needQuerySliceProfile", false)
377 processNewNSI(solution, sliceTaskParams)
380 execution.setVariable("sliceTaskParams", sliceTaskParams)
381 //logger.debug("sliceTaskParams: " + sliceTaskParams.convertToJson())
382 logger.debug("*** Completed options Call to OOF ***")
385 private void processSharedNSI(Map<String, Object> solution, SliceTaskParamsAdapter sliceParams) {
386 Map<String, Object> sharedNSISolution = solution.get("sharedNSISolution") as Map
388 String nsiId = sharedNSISolution.get("NSIId")
389 String nsiName = sharedNSISolution.get("NSIName")
390 sliceParams.setSuggestNsiId(nsiId)
391 sliceParams.setSuggestNsiName(nsiName)
395 private void processNewNSI(Map<String, Object> solution, SliceTaskParamsAdapter sliceParams) {
396 Map<String, Object> newNSISolution = solution.get("newNSISolution") as Map
397 List<Map> sliceProfiles = newNSISolution.get("sliceProfiles") as List<Map>
398 for (Map sliceProfile : sliceProfiles) {
399 String domainType = sliceProfile.get("domainType")
400 switch (domainType.toLowerCase()) {
402 sliceParams.tnBHSliceTaskInfo.sliceProfile = sliceProfile as TnSliceProfile
405 sliceParams.anSliceTaskInfo.sliceProfile = sliceProfile as AnSliceProfile
408 sliceParams.cnSliceTaskInfo.sliceProfile = sliceProfile as CnSliceProfile
420 * get NSSI Selection Capability for AN
423 public void getNSSISelectionCap4AN(DelegateExecution execution) {
425 def vendor = execution.getVariable("vendor") as String
427 String strRequest = buildNSSISelectionReq(vendor, NetworkType.ACCESS)
429 String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_NSSI_SELECTION_CAPABILITY, strRequest)
431 Map<String, Object> resMap = objectMapper.readValue(response, Map.class)
433 String selection = resMap.get("selection")
436 if ("NSMF".equalsIgnoreCase(selection)) {
437 execution.setVariable("NEED_AN_NSSI_SELECTION", true)
442 * get NSSI Selection Capability for TN
445 public void getNSSISelectionCap4TN(DelegateExecution execution) {
447 def vendor = execution.getVariable("vendor") as String
449 String strRequest = buildNSSISelectionReq(vendor, NetworkType.TRANSPORT)
451 String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_NSSI_SELECTION_CAPABILITY, strRequest)
453 Map<String, Object> resMap = objectMapper.readValue(response, Map.class)
455 String selection = resMap.get("selection")
457 if ("NSMF".equalsIgnoreCase(selection)) {
458 execution.setVariable("NEED_TN_NSSI_SELECTION", true)
463 * get NSSI Selection Capability for CN
466 public void getNSSISelectionCap4CN(DelegateExecution execution) {
468 def vendor = execution.getVariable("vendor") as String
470 String strRequest = buildNSSISelectionReq(vendor, NetworkType.CORE)
472 String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_NSSI_SELECTION_CAPABILITY, strRequest)
474 Map<String, Object> resMap = objectMapper.readValue(response, Map.class)
476 String selection = resMap.get("selection")
478 if ("NSMF".equalsIgnoreCase(selection)) {
479 execution.setVariable("NEED_CN_NSSI_SELECTION", true)
484 * build NSSI Selection Capability Request body to nssmf adapter
489 private static String buildNSSISelectionReq(String vendor, NetworkType networkType) {
490 NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest()
491 EsrInfo esrInfo = new EsrInfo()
492 esrInfo.setVendor(vendor)
493 esrInfo.setNetworkType(networkType)
494 request.setEsrInfo(esrInfo)
496 return objectMapper.writeValueAsString(request)
500 * if exist nssi need to select?
503 public void handleNssiSelect(DelegateExecution execution) {
505 SliceTaskParamsAdapter sliceTaskParams =
506 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
509 boolean needCnNssiSelection = execution.getVariable("NEED_CN_NSSI_SELECTION") as Boolean
510 boolean needAnNssiSelection = execution.getVariable("NEED_AN_NSSI_SELECTION") as Boolean
511 boolean needTnNssiSelection = execution.getVariable("NEED_TN_NSSI_SELECTION") as Boolean
516 * "subType": subtype,
517 * "nsstInfo": object,
518 * "sliceProfile": object
521 * "subType": subtype,
522 * "nsstInfo": object,
523 * "sliceProfile": object
527 List<Map> nssiNeedHandlerInfos = new ArrayList<>()
528 Map<String, Object> nssiNeedHandlerMap = new HashMap()
530 //List<TemplateInfo> nssiNeedHandlers = new ArrayList<>()
531 //List<Object> nssiProfileNeedHandlers = new ArrayList<>()
532 if (needCnNssiSelection) {
533 nssiNeedHandlerMap.put("subnetType", sliceTaskParams.cnSliceTaskInfo.subnetType)
534 nssiNeedHandlerMap.put("nsstInfo", sliceTaskParams.cnSliceTaskInfo.NSSTInfo)
535 nssiNeedHandlerMap.put("sliceProfile", sliceTaskParams.cnSliceTaskInfo.sliceProfile)
536 nssiNeedHandlerInfos.add(nssiNeedHandlerMap)
538 if (needAnNssiSelection) {
539 nssiNeedHandlerMap.clear()
540 nssiNeedHandlerMap.put("subnetType", sliceTaskParams.anSliceTaskInfo.subnetType)
541 nssiNeedHandlerMap.put("nsstInfo", sliceTaskParams.anSliceTaskInfo.NSSTInfo)
542 nssiNeedHandlerMap.put("sliceProfile", sliceTaskParams.anSliceTaskInfo.sliceProfile)
543 nssiNeedHandlerInfos.add(nssiNeedHandlerMap)
545 if (needTnNssiSelection) {
546 nssiNeedHandlerMap.clear()
547 nssiNeedHandlerMap.put("subnetType", sliceTaskParams.tnBHSliceTaskInfo.subnetType)
548 nssiNeedHandlerMap.put("nsstInfo", sliceTaskParams.tnBHSliceTaskInfo.NSSTInfo)
549 nssiNeedHandlerMap.put("sliceProfile", sliceTaskParams.tnBHSliceTaskInfo.sliceProfile)
550 nssiNeedHandlerInfos.add(nssiNeedHandlerMap)
552 nssiNeedHandlerMap.clear()
553 nssiNeedHandlerMap.put("subnetType", sliceTaskParams.tnMHSliceTaskInfo.subnetType)
554 nssiNeedHandlerMap.put("nsstInfo", sliceTaskParams.tnMHSliceTaskInfo.NSSTInfo)
555 nssiNeedHandlerMap.put("sliceProfile", sliceTaskParams.tnMHSliceTaskInfo.sliceProfile)
556 nssiNeedHandlerInfos.add(nssiNeedHandlerMap)
558 nssiNeedHandlerMap.clear()
559 nssiNeedHandlerMap.put("subnetType", sliceTaskParams.tnFHSliceTaskInfo.subnetType)
560 nssiNeedHandlerMap.put("nsstInfo", sliceTaskParams.tnFHSliceTaskInfo.NSSTInfo)
561 nssiNeedHandlerMap.put("sliceProfile", sliceTaskParams.tnFHSliceTaskInfo.sliceProfile)
562 nssiNeedHandlerInfos.add(nssiNeedHandlerMap)
566 if (nssiNeedHandlerInfos.size() > 0) {
567 execution.setVariable("needSelectNssi", true)
568 execution.setVariable("currNssiIndex", 0)
569 execution.setVariable("nssiNeedHandlerInfos", nssiNeedHandlerInfos)
571 execution.setVariable("needSelectNssi", false)
574 execution.setVariable("sliceTaskParams", sliceTaskParams)
578 * prepare select nssi request
581 public void preNSSIRequest(DelegateExecution execution) {
583 List<Map> nssiNeedHandlerInfos =
584 execution.getVariable("nssiNeedHandlerInfos") as List<Map>
586 int currNssiIndex = execution.getVariable("currNssiIndex") as Integer
587 Map nssiNeedHandlerInfo = nssiNeedHandlerInfos.get(currNssiIndex) as Map
589 TemplateInfo nsstInfo = nssiNeedHandlerInfo.get("nsstInfo") as TemplateInfo
590 Object profileInfo = nssiNeedHandlerInfo.get("sliceProfile")
592 String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
593 logger.debug( "get NSI option OOF Url: " + urlString)
595 String requestId = execution.getVariable("msoRequestId")
596 String messageType = "NSSISelectionResponse"
598 execution.setVariable("nssiSelectionUrl", "/api/oof/selection/nssi/v1")
599 execution.setVariable("nssiSelection_messageType", messageType)
600 execution.setVariable("nssiSelection_correlator", requestId)
601 String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution)
602 execution.setVariable("nssiSelection_timeout", timeout)
604 String oofRequest = oofUtils.buildSelectNSSIRequest(requestId, nsstInfo, messageType,
605 profileInfo, timeout as Integer)
607 execution.setVariable("nssiSelection_oofRequest", oofRequest)
608 logger.debug("Sending request to OOF: " + oofRequest)
612 * process select nssi response
615 public void processNSSIResp(DelegateExecution execution) {
617 List<Map> nssiNeedHandlerInfos =
618 execution.getVariable("nssiNeedHandlerInfos") as List<Map>
620 int currNssiIndex = execution.getVariable("currNssiIndex") as Integer
621 Map nssiNeedHandlerInfo = nssiNeedHandlerInfos.get(currNssiIndex) as Map
622 SubnetType subnetType = nssiNeedHandlerInfo.get("subnetType") as SubnetType
624 SliceTaskParamsAdapter sliceTaskParams =
625 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
628 String OOFResponse = execution.getVariable("nssiSelection_oofResponse")
629 logger.debug("NSI OOFResponse is: " + OOFResponse)
630 execution.setVariable("OOFResponse", OOFResponse)
631 //This needs to be changed to derive a value when we add policy to decide the solution options.
633 Map<String, Object> resMap = objectMapper.readValue(OOFResponse, Map.class)
634 List<Map<String, Object>> nsiSolutions = (List<Map<String, Object>>) resMap.get("solutions")
635 Map<String, Object> solution = nsiSolutions.get(0)
637 String resourceSharingLevel = execution.getVariable("resourceSharingLevel")
638 Boolean isSharable = resourceSharingLevel == "shared" //todo
640 if (isSharable && solution != null) {
641 processNssiResult(sliceTaskParams, subnetType, solution)
644 execution.setVariable("sliceTaskParams", sliceTaskParams)
645 //logger.debug("sliceTaskParams: "+ sliceTaskParams.convertToJson())
646 logger.debug("*** Completed options Call to OOF ***")
648 logger.debug("start parseServiceProfile")
649 //parseServiceProfile(execution)
650 logger.debug("end parseServiceProfile")
652 if (currNssiIndex >= nssiNeedHandlerInfos.size() - 1) {
653 execution.setVariable("needSelectNssi", false)
655 execution.setVariable("currNssiIndex", currNssiIndex + 1)
656 execution.setVariable("needSelectNssi", true)
661 private void processNssiResult(SliceTaskParamsAdapter sliceTaskParams, SubnetType subnetType,
662 Map<String, Object> solution) {
663 switch (subnetType) {
665 sliceTaskParams.cnSliceTaskInfo.suggestNssiId = solution.get("NSSIId")
666 sliceTaskParams.cnSliceTaskInfo.suggestNssiName = solution.get("NSSIName")
668 case SubnetType.AN_NF:
669 sliceTaskParams.anSliceTaskInfo.suggestNssiId = solution.get("NSSIId")
670 sliceTaskParams.anSliceTaskInfo.suggestNssiName = solution.get("NSSIName")
672 case SubnetType.TN_BH:
673 sliceTaskParams.tnBHSliceTaskInfo.suggestNssiId = solution.get("NSSIId")
674 sliceTaskParams.tnBHSliceTaskInfo.suggestNssiName = solution.get("NSSIName")
676 case SubnetType.TN_FH:
677 sliceTaskParams.tnFHSliceTaskInfo.suggestNssiId = solution.get("NSSIId")
678 sliceTaskParams.tnFHSliceTaskInfo.suggestNssiName = solution.get("NSSIName")
680 case SubnetType.TN_MH:
681 sliceTaskParams.tnMHSliceTaskInfo.suggestNssiId = solution.get("NSSIId")
682 sliceTaskParams.tnMHSliceTaskInfo.suggestNssiName = solution.get("NSSIName")