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.aai.domain.yang.ServiceInstance
26 import org.onap.so.beans.nsmf.EsrInfo
27 import org.onap.so.beans.nsmf.NetworkType
28 import org.onap.so.beans.nsmf.NssmfAdapterNBIRequest
29 import org.onap.so.beans.nsmf.QuerySubnetCapability
30 import org.onap.so.beans.nsmf.SliceProfileAdapter
31 import org.onap.so.beans.nsmf.SliceTaskParamsAdapter
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.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 AAISliceUtil aaiSliceUtil = new AAISliceUtil()
61 private static final ObjectMapper objectMapper = new ObjectMapper()
63 private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil)
65 private static final String QUERY_SUB_NET_CAPABILITY = "/api/rest/provMns/v1/NSS/subnetCapabilityQuery"
67 private static final String QUERY_NSSI_SELECTION_CAPABILITY = "/api/rest/provMns/v1/NSS/NSSISelectionCapability"
69 void preProcessRequest (DelegateExecution execution) {
73 * prepare the params for decompose nst
76 void prepareDecomposeNST(DelegateExecution execution) {
78 SliceTaskParamsAdapter sliceTaskParams =
79 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
81 String modelUuid = sliceTaskParams.getNSTInfo().getUUID()
82 String modelInvariantUuid = sliceTaskParams.getNSTInfo().getInvariantUUID()
84 String serviceModelInfo = """{
85 "modelInvariantUuid":"${modelInvariantUuid}",
86 "modelUuid":"${modelUuid}",
89 execution.setVariable("nstServiceModelInfo", serviceModelInfo)
93 * process the result of NST Decomposition
96 public void processDecompositionNST(DelegateExecution execution) {
98 List<TemplateInfo> nsstInfos = new ArrayList<>()
99 ServiceDecomposition nstServiceDecomposition =
100 execution.getVariable("nstServiceDecomposition") as ServiceDecomposition
102 List<AllottedResource> allottedResources = nstServiceDecomposition.getAllottedResources()
103 for (AllottedResource allottedResource : allottedResources) {
104 TemplateInfo nsstInfo = new TemplateInfo()
105 nsstInfo.setUUID(allottedResource.getProvidingServiceModelUuid())
106 nsstInfo.setInvariantUUID(allottedResource.getProvidingServiceModelInvariantUuid())
107 nsstInfo.setName(allottedResource.getProvidingServiceModelName())
108 nsstInfos.add(nsstInfo)
110 execution.setVariable("nsstInfos", nsstInfos)
112 execution.setVariable("maxNsstIndex", allottedResources.size() - 1)
113 execution.setVariable("currentNsstIndex", 0)
115 List<ServiceDecomposition> nsstServiceDecompositions = new ArrayList<>()
116 execution.setVariable("nsstServiceDecompositions", nsstServiceDecompositions)
120 * prepare the params for decompose nsst
123 public void prepareDecomposeNSST(DelegateExecution execution) {
125 List<TemplateInfo> nsstInfos = execution.getVariable("nsstInfos") as List<TemplateInfo>
126 int index = execution.getVariable("currentNsstIndex") as Integer
128 String modelUuid = nsstInfos.get(index).getUUID()
129 String modelInvariantUuid = nsstInfos.get(index).getInvariantUUID()
131 String serviceModelInfo = """{
132 "modelInvariantUuid":"${modelInvariantUuid}",
133 "modelUuid":"${modelUuid}",
136 execution.setVariable("nsstServiceModelInfo", serviceModelInfo)
140 * process the result of NSST Decomposition
143 public void processDecompositionNSST(DelegateExecution execution) {
144 List<ServiceDecomposition> nsstServiceDecompositions =
145 execution.getVariable("nsstServiceDecompositions") as List<ServiceDecomposition>
147 ServiceDecomposition nsstServiceDecomposition =
148 execution.getVariable("nsstServiceDecomposition") as ServiceDecomposition
150 nsstServiceDecompositions.add(nsstServiceDecomposition)
152 execution.setVariable("nsstServiceDecompositions", nsstServiceDecompositions)
154 int num = execution.getVariable("maxNsstIndex") as Integer
155 int index = execution.getVariable("currentNsstIndex") as Integer
157 List<TemplateInfo> nsstInfos = execution.getVariable("nsstInfos") as List<TemplateInfo>
158 nsstInfos.get(index).name = nsstServiceDecomposition.modelInfo.modelName
159 execution.setVariable("nsstInfos", nsstInfos)
160 execution.setVariable("currentNsstIndex", index + 1)
163 execution.setVariable("nsstHandleContinue", false)
165 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 execution.setVariable("queryNsiFirst", true)
190 logger.debug("sliceTaskParams= " + sliceParams.toString())
193 private void handleByType(DelegateExecution execution, ServiceDecomposition serviceDecomposition,
194 SliceTaskParamsAdapter sliceParams, List<SubnetCapability> subnetCapabilities) {
195 ModelInfo modelInfo = serviceDecomposition.getModelInfo()
196 String vendor = serviceDecomposition.getServiceRole()
197 SubnetType subnetType = convertServiceCategory(serviceDecomposition.getServiceCategory())
199 switch (subnetType) {
200 case SubnetType.TN_BH:
201 sliceParams.tnBHSliceTaskInfo.vendor = vendor
202 sliceParams.tnBHSliceTaskInfo.subnetType = subnetType
203 sliceParams.tnBHSliceTaskInfo.networkType = subnetType.networkType
204 sliceParams.tnBHSliceTaskInfo.NSSTInfo.UUID = modelInfo.getModelUuid()
205 sliceParams.tnBHSliceTaskInfo.NSSTInfo.invariantUUID = modelInfo.getModelInvariantUuid()
206 sliceParams.tnBHSliceTaskInfo.NSSTInfo.name = modelInfo.getModelName()
208 case SubnetType.TN_MH:
209 sliceParams.tnMHSliceTaskInfo.vendor = vendor
210 sliceParams.tnMHSliceTaskInfo.subnetType = subnetType
211 sliceParams.tnMHSliceTaskInfo.networkType = subnetType.networkType
212 sliceParams.tnMHSliceTaskInfo.NSSTInfo.UUID = modelInfo.getModelUuid()
213 sliceParams.tnMHSliceTaskInfo.NSSTInfo.invariantUUID = modelInfo.getModelInvariantUuid()
214 sliceParams.tnMHSliceTaskInfo.NSSTInfo.name = modelInfo.getModelName()
216 case SubnetType.TN_FH:
217 sliceParams.tnFHSliceTaskInfo.vendor = vendor
218 sliceParams.tnFHSliceTaskInfo.subnetType = subnetType
219 sliceParams.tnFHSliceTaskInfo.networkType = subnetType.networkType
220 sliceParams.tnFHSliceTaskInfo.NSSTInfo.UUID = modelInfo.getModelUuid()
221 sliceParams.tnFHSliceTaskInfo.NSSTInfo.invariantUUID = modelInfo.getModelInvariantUuid()
222 sliceParams.tnFHSliceTaskInfo.NSSTInfo.name = modelInfo.getModelName()
224 case SubnetType.AN_NF:
225 sliceParams.anNFSliceTaskInfo.vendor = vendor
226 sliceParams.anNFSliceTaskInfo.subnetType = subnetType
227 sliceParams.anNFSliceTaskInfo.networkType = subnetType.networkType
228 sliceParams.anNFSliceTaskInfo.NSSTInfo.UUID = modelInfo.getModelUuid()
229 sliceParams.anNFSliceTaskInfo.NSSTInfo.invariantUUID = modelInfo.getModelInvariantUuid()
230 sliceParams.anNFSliceTaskInfo.NSSTInfo.name = modelInfo.getModelName()
233 sliceParams.anSliceTaskInfo.vendor = vendor
234 sliceParams.anSliceTaskInfo.subnetType = subnetType
235 sliceParams.anSliceTaskInfo.networkType = subnetType.networkType
236 sliceParams.anSliceTaskInfo.NSSTInfo.UUID = modelInfo.getModelUuid()
237 sliceParams.anSliceTaskInfo.NSSTInfo.invariantUUID = modelInfo.getModelInvariantUuid()
238 sliceParams.anSliceTaskInfo.NSSTInfo.name = modelInfo.getModelName()
241 sliceParams.cnSliceTaskInfo.vendor = vendor
242 sliceParams.cnSliceTaskInfo.subnetType = subnetType
243 sliceParams.cnSliceTaskInfo.networkType = subnetType.networkType
244 sliceParams.cnSliceTaskInfo.NSSTInfo.UUID = modelInfo.getModelUuid()
245 sliceParams.cnSliceTaskInfo.NSSTInfo.invariantUUID = modelInfo.getModelInvariantUuid()
246 sliceParams.cnSliceTaskInfo.NSSTInfo.name = modelInfo.getModelName()
252 if (null == subnetType) {
253 def msg = "Get subnetType failed, modelUUId=" + modelInfo.getModelUuid()
255 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
257 String response = querySubnetCapability(execution, vendor, subnetType)
258 if (!StringUtils.isEmpty(response)) {
259 SubnetCapability subnetCapability = new SubnetCapability()
260 Map<String, Object> result = objectMapper.readValue(response, Map.class)
261 for (Map.Entry<String, Object> entry : result.entrySet()) {
262 subnetCapability.setDomainType(entry.getKey())
263 subnetCapability.setCapabilityDetails(entry.getValue())
265 subnetCapabilities.add(subnetCapability)
270 * get subnetType from serviceCategory
273 private SubnetType convertServiceCategory(String serviceCategory){
274 if("CN NSST".equals(serviceCategory)){
277 if ("AN NF NSST".equals(serviceCategory)){
278 return SubnetType.AN_NF
280 if ("AN NSST".equals(serviceCategory)){
283 if ("TN BH NSST".equals(serviceCategory)){
284 return SubnetType.TN_BH
286 if("TN MH NSST".equals(serviceCategory)){
287 return SubnetType.TN_MH
289 if("TN FH NSST".equals(serviceCategory)){
290 return SubnetType.TN_FH
296 * query Subnet Capability of TN AN CN
299 private String querySubnetCapability(DelegateExecution execution, String vendor, SubnetType subnetType) {
301 String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_SUB_NET_CAPABILITY,
302 buildQuerySubnetCapRequest(vendor, subnetType))
307 * build request body for querying Subnet Capability
313 private static NssmfAdapterNBIRequest buildQuerySubnetCapRequest(String vendor, SubnetType subnetType) {
314 NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest()
316 List<String> subnetTypes = new ArrayList<>()
317 subnetTypes.add(subnetType.subnetType)
319 QuerySubnetCapability req = new QuerySubnetCapability()
320 req.setSubnetTypes(subnetTypes)
322 request.setSubnetCapabilityQuery(req)
324 EsrInfo esrInfo = new EsrInfo()
325 esrInfo.setVendor(vendor)
326 esrInfo.setNetworkType(subnetType.networkType)
327 request.setEsrInfo(esrInfo)
334 * prepare select nsi request
337 public void preNSIRequest(DelegateExecution execution) {
338 boolean preferReuse = execution.getVariable("needQuerySliceProfile") ? false : true
340 String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
341 logger.debug( "get NSI option OOF Url: " + urlString)
343 String requestId = execution.getVariable("msoRequestId")
344 String messageType = "NSISelectionResponse"
346 execution.setVariable("nsiSelectionUrl", "/api/oof/selection/nsi/v1")
347 execution.setVariable("nsiSelection_messageType", messageType)
348 execution.setVariable("nsiSelection_correlator", requestId)
349 String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution)
350 execution.setVariable("nsiSelection_timeout", timeout)
352 SliceTaskParamsAdapter sliceParams =
353 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
355 Map<String, Object> profileInfo = sliceParams.getServiceProfile()
356 profileInfo.remove("profileId")
357 TemplateInfo nstInfo = sliceParams.getNSTInfo()
359 List<TemplateInfo> nsstInfos = execution.getVariable("nsstInfos") as List<TemplateInfo>
361 List<SubnetCapability> subnetCapabilities =
362 execution.getVariable("subnetCapabilities") as List<SubnetCapability>
364 String oofRequest = oofUtils.buildSelectNSIRequest(requestId, nstInfo, nsstInfos,
365 messageType, profileInfo, subnetCapabilities, 600, preferReuse)
367 execution.setVariable("nsiSelection_oofRequest", oofRequest)
368 logger.debug("Sending request to OOF: " + oofRequest)
372 * process select nsi response
375 public void processNSIResp(DelegateExecution execution) {
377 SliceTaskParamsAdapter sliceTaskParams =
378 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
380 String oofResponse = execution.getVariable("nsiSelection_oofResponse")
381 logger.debug("NSI oofResponse is: " + oofResponse)
382 execution.setVariable("oofResponse", oofResponse)
383 //This needs to be changed to derive a value when we add policy to decide the solution options.
385 Map<String, Object> resMap = objectMapper.readValue(oofResponse, Map.class)
386 String requestStatus = resMap.get("requestStatus")
387 if (!StringUtils.isEmpty(requestStatus) && requestStatus == "error") {
388 exceptionUtil.buildWorkflowException(execution, 7000, "get nsi from oof error: " + oofResponse)
392 List<Map<String, Object>> nsiSolutions = (List<Map<String, Object>>) resMap.get("solutions")
394 Map<String, Object> solution = nsiSolutions?.get(0)
396 if (solution != null) {
397 if (execution.getVariable("queryNsiFirst")) {
398 if (solution.get("existingNSI")) {
399 processSharedNSI(solution, sliceTaskParams, execution)
400 execution.setVariable("needQuerySliceProfile", true)
402 processNewSliceProfiles(solution, sliceTaskParams)
403 execution.setVariable("needQuerySliceProfile", false)
405 execution.setVariable("queryNsiFirst", false)
407 processNewSliceProfiles(solution, sliceTaskParams)
408 execution.setVariable("needQuerySliceProfile", false)
411 execution.setVariable("sliceTaskParams", sliceTaskParams)
412 logger.debug("after req to oof for nis select, sliceTaskParams = " + sliceTaskParams)
413 logger.debug("*** Completed options Call to OOF ***")
416 private void processSharedNSI(Map<String, Object> solution, SliceTaskParamsAdapter sliceParams, DelegateExecution execution) {
417 Map<String, Object> sharedNSISolution = solution.get("sharedNSISolution") as Map
418 String nsiId = sharedNSISolution.get("NSIId")
419 String nsiName = sharedNSISolution.get("NSIName")
420 sliceParams.setSuggestNsiId(nsiId)
421 sliceParams.setSuggestNsiName(nsiName)
423 List<String> nssiId = aaiSliceUtil.getNSSIIdList(execution,nsiId)
424 List<ServiceInstance> nssiInstances = aaiSliceUtil.getNSSIListFromAAI(execution, nssiId)
426 Map<String, Object> nssiSolution = new HashMap<>()
427 for(ServiceInstance instance: nssiInstances){
428 nssiSolution.put("NSSIId", instance.getServiceInstanceId())
429 nssiSolution.put("NSSIName", instance.getServiceInstanceName())
430 SubnetType subnetType = instance.getWorkloadContext() as SubnetType
431 processNssiResult(sliceParams, subnetType, nssiSolution)
436 private void processNewSliceProfiles(Map<String, Object> solution, SliceTaskParamsAdapter sliceParams) {
437 Map<String, Object> newNSISolution = solution.get("newNSISolution") as Map
438 List<Map> sliceProfiles = newNSISolution.get("sliceProfiles") as List<Map>
439 handleSliceProfiles(sliceProfiles, sliceParams)
442 static def handleSliceProfiles(List<Map> sliceProfiles, SliceTaskParamsAdapter sliceParams) {
443 for (Map sliceProfile : sliceProfiles) {
444 String domainType = sliceProfile.get("domainType")
445 sliceProfile.remove("domainType")
446 SliceProfileAdapter adapter = objectMapper.readValue(objectMapper.writeValueAsString(sliceProfile), SliceProfileAdapter.class)
447 switch (domainType.toLowerCase()) {
449 sliceParams.tnBHSliceTaskInfo.sliceProfile = adapter
452 sliceParams.tnFHSliceTaskInfo.sliceProfile = adapter
455 sliceParams.tnMHSliceTaskInfo.sliceProfile = adapter
458 sliceParams.anNFSliceTaskInfo.sliceProfile = adapter
461 sliceParams.anSliceTaskInfo.sliceProfile = adapter
464 sliceParams.cnSliceTaskInfo.sliceProfile = adapter
473 * get NSSI Selection Capability for AN
476 void getNSSISelectionCap4AN(DelegateExecution execution) {
478 def vendor = execution.getVariable("vendor") as String
480 String strRequest = buildNSSISelectionReq(vendor, NetworkType.ACCESS)
482 String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_NSSI_SELECTION_CAPABILITY, strRequest)
484 Map<String, Object> resMap = objectMapper.readValue(response, Map.class)
486 String selection = resMap.get("selection")
489 if ("NSMF".equalsIgnoreCase(selection)) {
490 execution.setVariable("NEED_AN_NSSI_SELECTION", true)
495 * get NSSI Selection Capability for TN
498 void getNSSISelectionCap4TN(DelegateExecution execution) {
500 def vendor = execution.getVariable("vendor") as String
502 String strRequest = buildNSSISelectionReq(vendor, NetworkType.TRANSPORT)
504 String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_NSSI_SELECTION_CAPABILITY, strRequest)
506 Map<String, Object> resMap = objectMapper.readValue(response, Map.class)
508 String selection = resMap.get("selection")
510 if ("NSMF".equalsIgnoreCase(selection)) {
511 execution.setVariable("NEED_TN_NSSI_SELECTION", true)
516 * get NSSI Selection Capability for CN
519 void getNSSISelectionCap4CN(DelegateExecution execution) {
521 def vendor = execution.getVariable("vendor") as String
523 String strRequest = buildNSSISelectionReq(vendor, NetworkType.CORE)
525 String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_NSSI_SELECTION_CAPABILITY, strRequest)
527 Map<String, Object> resMap = objectMapper.readValue(response, Map.class)
529 String selection = resMap.get("selection")
531 if ("NSMF".equalsIgnoreCase(selection)) {
532 //execution.setVariable("NEED_CN_NSSI_SELECTION", true)
537 * build NSSI Selection Capability Request body to nssmf adapter
542 private static String buildNSSISelectionReq(String vendor, NetworkType networkType) {
543 NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest()
544 EsrInfo esrInfo = new EsrInfo()
545 esrInfo.setVendor(vendor)
546 esrInfo.setNetworkType(networkType)
547 request.setEsrInfo(esrInfo)
549 return objectMapper.writeValueAsString(request)
553 * if exist nssi need to select
556 public void handleNssiSelect(DelegateExecution execution) {
558 SliceTaskParamsAdapter sliceTaskParams =
559 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
562 boolean needCnNssiSelection = execution.getVariable("NEED_CN_NSSI_SELECTION") as Boolean
563 boolean needAnNssiSelection = execution.getVariable("NEED_AN_NSSI_SELECTION") as Boolean
564 boolean needTnNssiSelection = execution.getVariable("NEED_TN_NSSI_SELECTION") as Boolean
566 List<Map> nssiNeedHandlerInfos = new ArrayList<>()
567 Map<String, Object> nssiNeedHandlerMap = new HashMap()
569 //List<TemplateInfo> nssiNeedHandlers = new ArrayList<>()
570 //List<Object> nssiProfileNeedHandlers = new ArrayList<>()
571 if (needCnNssiSelection) {
572 nssiNeedHandlerMap.put("subnetType", sliceTaskParams.cnSliceTaskInfo.subnetType)
573 nssiNeedHandlerMap.put("nsstInfo", sliceTaskParams.cnSliceTaskInfo.NSSTInfo)
574 nssiNeedHandlerMap.put("sliceProfile", sliceTaskParams.cnSliceTaskInfo.sliceProfile)
575 nssiNeedHandlerInfos.add(nssiNeedHandlerMap)
577 if (needAnNssiSelection) {
578 nssiNeedHandlerMap.clear()
579 nssiNeedHandlerMap.put("subnetType", sliceTaskParams.anSliceTaskInfo.subnetType)
580 nssiNeedHandlerMap.put("nsstInfo", sliceTaskParams.anSliceTaskInfo.NSSTInfo)
581 nssiNeedHandlerMap.put("sliceProfile", sliceTaskParams.anSliceTaskInfo.sliceProfile)
582 nssiNeedHandlerInfos.add(nssiNeedHandlerMap)
584 if (needTnNssiSelection) {
585 nssiNeedHandlerMap.clear()
586 nssiNeedHandlerMap.put("subnetType", sliceTaskParams.tnBHSliceTaskInfo.subnetType)
587 nssiNeedHandlerMap.put("nsstInfo", sliceTaskParams.tnBHSliceTaskInfo.NSSTInfo)
588 nssiNeedHandlerMap.put("sliceProfile", sliceTaskParams.tnBHSliceTaskInfo.sliceProfile)
589 nssiNeedHandlerInfos.add(nssiNeedHandlerMap)
591 nssiNeedHandlerMap.clear()
592 nssiNeedHandlerMap.put("subnetType", sliceTaskParams.tnMHSliceTaskInfo.subnetType)
593 nssiNeedHandlerMap.put("nsstInfo", sliceTaskParams.tnMHSliceTaskInfo.NSSTInfo)
594 nssiNeedHandlerMap.put("sliceProfile", sliceTaskParams.tnMHSliceTaskInfo.sliceProfile)
595 nssiNeedHandlerInfos.add(nssiNeedHandlerMap)
597 nssiNeedHandlerMap.clear()
598 nssiNeedHandlerMap.put("subnetType", sliceTaskParams.tnFHSliceTaskInfo.subnetType)
599 nssiNeedHandlerMap.put("nsstInfo", sliceTaskParams.tnFHSliceTaskInfo.NSSTInfo)
600 nssiNeedHandlerMap.put("sliceProfile", sliceTaskParams.tnFHSliceTaskInfo.sliceProfile)
601 nssiNeedHandlerInfos.add(nssiNeedHandlerMap)
605 if (nssiNeedHandlerInfos.size() > 0) {
606 execution.setVariable("needSelectNssi", true)
607 execution.setVariable("currNssiIndex", 0)
608 execution.setVariable("nssiNeedHandlerInfos", nssiNeedHandlerInfos)
610 execution.setVariable("needSelectNssi", false)
613 execution.setVariable("sliceTaskParams", sliceTaskParams)
617 * prepare select nssi request
620 public void preNSSIRequest(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
628 TemplateInfo nsstInfo = nssiNeedHandlerInfo.get("nsstInfo") as TemplateInfo
629 Map<String, Object> profileInfo = nssiNeedHandlerInfo.get("sliceProfile") as Map
630 //profileInfo.remove("profileId")
632 String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
633 logger.debug( "get NSI option OOF Url: " + urlString)
635 String requestId = execution.getVariable("msoRequestId")
636 String messageType = "NSSISelectionResponse"
638 execution.setVariable("nssiSelectionUrl", "/api/oof/selection/nssi/v1")
639 execution.setVariable("nssiSelection_messageType", messageType)
640 execution.setVariable("nssiSelection_correlator", requestId)
641 String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution)
642 execution.setVariable("nssiSelection_timeout", timeout)
644 String oofRequest = oofUtils.buildSelectNSSIRequest(requestId, nsstInfo, messageType,
647 execution.setVariable("nssiSelection_oofRequest", oofRequest)
648 logger.debug("Sending request to OOF: " + oofRequest)
652 * process select nssi response
655 public void processNSSIResp(DelegateExecution execution) {
657 List<Map> nssiNeedHandlerInfos =
658 execution.getVariable("nssiNeedHandlerInfos") as List<Map>
660 int currNssiIndex = execution.getVariable("currNssiIndex") as Integer
661 Map nssiNeedHandlerInfo = nssiNeedHandlerInfos.get(currNssiIndex) as Map
662 SubnetType subnetType = nssiNeedHandlerInfo.get("subnetType") as SubnetType
664 SliceTaskParamsAdapter sliceTaskParams =
665 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
668 String OOFResponse = execution.getVariable("nssiSelection_oofResponse")
669 logger.debug("NSI OOFResponse is: " + OOFResponse)
670 execution.setVariable("OOFResponse", OOFResponse)
671 //This needs to be changed to derive a value when we add policy to decide the solution options.
673 Map<String, Object> resMap = objectMapper.readValue(OOFResponse, Map.class)
674 List<Map<String, Object>> nsiSolutions = (List<Map<String, Object>>) resMap.get("solutions")
675 Map<String, Object> solution = nsiSolutions.get(0)
677 String resourceSharingLevel = execution.getVariable("resourceSharingLevel")
678 Boolean isSharable = resourceSharingLevel == "shared" //todo
680 if (isSharable && solution != null) {
681 processNssiResult(sliceTaskParams, subnetType, solution)
684 execution.setVariable("sliceTaskParams", sliceTaskParams)
685 //logger.debug("sliceTaskParams: "+ sliceTaskParams.convertToJson())
686 logger.debug("*** Completed options Call to OOF ***")
688 logger.debug("start parseServiceProfile")
689 //parseServiceProfile(execution)
690 logger.debug("end parseServiceProfile")
692 if (currNssiIndex >= nssiNeedHandlerInfos.size() - 1) {
693 execution.setVariable("needSelectNssi", false)
695 execution.setVariable("currNssiIndex", currNssiIndex + 1)
696 execution.setVariable("needSelectNssi", true)
701 private void processNssiResult(SliceTaskParamsAdapter sliceTaskParams, SubnetType subnetType,
702 Map<String, Object> solution) {
703 switch (subnetType) {
705 sliceTaskParams.cnSliceTaskInfo.suggestNssiId = solution.get("NSSIId")
706 sliceTaskParams.cnSliceTaskInfo.suggestNssiName = solution.get("NSSIName")
709 sliceTaskParams.anSliceTaskInfo.suggestNssiId = solution.get("NSSIId")
710 sliceTaskParams.anSliceTaskInfo.suggestNssiName = solution.get("NSSIName")
712 case SubnetType.TN_BH:
713 sliceTaskParams.tnBHSliceTaskInfo.suggestNssiId = solution.get("NSSIId")
714 sliceTaskParams.tnBHSliceTaskInfo.suggestNssiName = solution.get("NSSIName")
716 case SubnetType.TN_FH:
717 sliceTaskParams.tnFHSliceTaskInfo.suggestNssiId = solution.get("NSSIId")
718 sliceTaskParams.tnFHSliceTaskInfo.suggestNssiName = solution.get("NSSIName")
720 case SubnetType.TN_MH:
721 sliceTaskParams.tnMHSliceTaskInfo.suggestNssiId = solution.get("NSSIId")
722 sliceTaskParams.tnMHSliceTaskInfo.suggestNssiName = solution.get("NSSIName")