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(serviceCategory ==~ /CN.*/){
277 if (serviceCategory ==~ /AN.*/){
280 if (serviceCategory ==~ /TN.*BH.*/){
281 return SubnetType.TN_BH
283 if(serviceCategory ==~ /TN.*MH.*/){
284 return SubnetType.TN_MH
286 if(serviceCategory ==~ /TN.*FH.*/){
287 return SubnetType.TN_FH
294 * query Subnet Capability of TN AN CN
297 private String querySubnetCapability(DelegateExecution execution, String vendor, SubnetType subnetType) {
299 String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_SUB_NET_CAPABILITY,
300 buildQuerySubnetCapRequest(vendor, subnetType))
305 * build request body for querying Subnet Capability
311 private static NssmfAdapterNBIRequest buildQuerySubnetCapRequest(String vendor, SubnetType subnetType) {
312 NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest()
314 List<String> subnetTypes = new ArrayList<>()
315 subnetTypes.add(subnetType.subnetType)
317 QuerySubnetCapability req = new QuerySubnetCapability()
318 req.setSubnetTypes(subnetTypes)
320 request.setSubnetCapabilityQuery(req)
322 EsrInfo esrInfo = new EsrInfo()
323 esrInfo.setVendor(vendor)
324 esrInfo.setNetworkType(subnetType.networkType)
325 request.setEsrInfo(esrInfo)
332 * prepare select nsi request
335 public void preNSIRequest(DelegateExecution execution) {
336 boolean preferReuse = execution.getVariable("needQuerySliceProfile") ? false : true
338 String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
339 logger.debug( "get NSI option OOF Url: " + urlString)
341 String requestId = execution.getVariable("msoRequestId")
342 String messageType = "NSISelectionResponse"
344 execution.setVariable("nsiSelectionUrl", "/api/oof/selection/nsi/v1")
345 execution.setVariable("nsiSelection_messageType", messageType)
346 execution.setVariable("nsiSelection_correlator", requestId)
347 String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution)
348 execution.setVariable("nsiSelection_timeout", timeout)
350 SliceTaskParamsAdapter sliceParams =
351 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
353 Map<String, Object> profileInfo = sliceParams.getServiceProfile()
354 profileInfo.remove("profileId")
355 TemplateInfo nstInfo = sliceParams.getNSTInfo()
357 List<TemplateInfo> nsstInfos = execution.getVariable("nsstInfos") as List<TemplateInfo>
359 List<SubnetCapability> subnetCapabilities =
360 execution.getVariable("subnetCapabilities") as List<SubnetCapability>
362 String oofRequest = oofUtils.buildSelectNSIRequest(requestId, nstInfo, nsstInfos,
363 messageType, profileInfo, subnetCapabilities, 600, preferReuse)
365 execution.setVariable("nsiSelection_oofRequest", oofRequest)
366 logger.debug("Sending request to OOF: " + oofRequest)
370 * process select nsi response
373 public void processNSIResp(DelegateExecution execution) {
375 SliceTaskParamsAdapter sliceTaskParams =
376 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
378 String oofResponse = execution.getVariable("nsiSelection_oofResponse")
379 logger.debug("NSI oofResponse is: " + oofResponse)
380 execution.setVariable("oofResponse", oofResponse)
381 //This needs to be changed to derive a value when we add policy to decide the solution options.
383 Map<String, Object> resMap = objectMapper.readValue(oofResponse, Map.class)
384 String requestStatus = resMap.get("requestStatus")
385 if (!StringUtils.isEmpty(requestStatus) && requestStatus == "error") {
386 exceptionUtil.buildWorkflowException(execution, 7000, "get nsi from oof error: " + oofResponse)
390 List<Map<String, Object>> nsiSolutions = (List<Map<String, Object>>) resMap.get("solutions")
392 Map<String, Object> solution = nsiSolutions?.get(0)
394 if (solution != null) {
395 if (execution.getVariable("queryNsiFirst")) {
396 if (solution.get("existingNSI")) {
397 processSharedNSI(solution, sliceTaskParams, execution)
398 execution.setVariable("needQuerySliceProfile", true)
400 processNewSliceProfiles(solution, sliceTaskParams)
401 execution.setVariable("needQuerySliceProfile", false)
403 execution.setVariable("queryNsiFirst", false)
405 processNewSliceProfiles(solution, sliceTaskParams)
406 execution.setVariable("needQuerySliceProfile", false)
409 execution.setVariable("sliceTaskParams", sliceTaskParams)
410 logger.debug("after req to oof for nis select, sliceTaskParams = " + sliceTaskParams)
411 logger.debug("*** Completed options Call to OOF ***")
414 private void processSharedNSI(Map<String, Object> solution, SliceTaskParamsAdapter sliceParams, DelegateExecution execution) {
415 Map<String, Object> sharedNSISolution = solution.get("sharedNSISolution") as Map
416 String nsiId = sharedNSISolution.get("NSIId")
417 String nsiName = sharedNSISolution.get("NSIName")
418 sliceParams.setSuggestNsiId(nsiId)
419 sliceParams.setSuggestNsiName(nsiName)
421 List<String> nssiId = aaiSliceUtil.getNSSIIdList(execution,nsiId)
422 List<ServiceInstance> nssiInstances = aaiSliceUtil.getNSSIListFromAAI(execution, nssiId)
424 Map<String, Object> nssiSolution = new HashMap<>()
425 for(ServiceInstance instance: nssiInstances){
426 nssiSolution.put("NSSIId", instance.getServiceInstanceId())
427 nssiSolution.put("NSSIName", instance.getServiceInstanceName())
428 SubnetType subnetType = instance.getWorkloadContext() as SubnetType
429 processNssiResult(sliceParams, subnetType, nssiSolution)
434 private void processNewSliceProfiles(Map<String, Object> solution, SliceTaskParamsAdapter sliceParams) {
435 Map<String, Object> newNSISolution = solution.get("newNSISolution") as Map
436 List<Map> sliceProfiles = newNSISolution.get("sliceProfiles") as List<Map>
437 handleSliceProfiles(sliceProfiles, sliceParams)
440 static def handleSliceProfiles(List<Map> sliceProfiles, SliceTaskParamsAdapter sliceParams) {
441 for (Map sliceProfile : sliceProfiles) {
442 String domainType = sliceProfile.get("domainType")
443 sliceProfile.remove("domainType")
444 SliceProfileAdapter adapter = objectMapper.readValue(objectMapper.writeValueAsString(sliceProfile), SliceProfileAdapter.class)
445 switch (domainType.toLowerCase()) {
447 sliceParams.tnBHSliceTaskInfo.sliceProfile = adapter
450 sliceParams.tnFHSliceTaskInfo.sliceProfile = adapter
453 sliceParams.tnMHSliceTaskInfo.sliceProfile = adapter
456 sliceParams.anNFSliceTaskInfo.sliceProfile = adapter
459 sliceParams.anSliceTaskInfo.sliceProfile = adapter
462 sliceParams.cnSliceTaskInfo.sliceProfile = adapter
471 * get NSSI Selection Capability for AN
474 void getNSSISelectionCap4AN(DelegateExecution execution) {
476 def vendor = execution.getVariable("vendor") as String
478 String strRequest = buildNSSISelectionReq(vendor, NetworkType.ACCESS)
480 String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_NSSI_SELECTION_CAPABILITY, strRequest)
482 Map<String, Object> resMap = objectMapper.readValue(response, Map.class)
484 String selection = resMap.get("selection")
487 if ("NSMF".equalsIgnoreCase(selection)) {
488 execution.setVariable("NEED_AN_NSSI_SELECTION", true)
493 * get NSSI Selection Capability for TN
496 void getNSSISelectionCap4TN(DelegateExecution execution) {
498 def vendor = execution.getVariable("vendor") as String
500 String strRequest = buildNSSISelectionReq(vendor, NetworkType.TRANSPORT)
502 String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_NSSI_SELECTION_CAPABILITY, strRequest)
504 Map<String, Object> resMap = objectMapper.readValue(response, Map.class)
506 String selection = resMap.get("selection")
508 if ("NSMF".equalsIgnoreCase(selection)) {
509 execution.setVariable("NEED_TN_NSSI_SELECTION", true)
514 * get NSSI Selection Capability for CN
517 void getNSSISelectionCap4CN(DelegateExecution execution) {
519 def vendor = execution.getVariable("vendor") as String
521 String strRequest = buildNSSISelectionReq(vendor, NetworkType.CORE)
523 String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_NSSI_SELECTION_CAPABILITY, strRequest)
525 Map<String, Object> resMap = objectMapper.readValue(response, Map.class)
527 String selection = resMap.get("selection")
529 if ("NSMF".equalsIgnoreCase(selection)) {
530 //execution.setVariable("NEED_CN_NSSI_SELECTION", true)
535 * build NSSI Selection Capability Request body to nssmf adapter
540 private static String buildNSSISelectionReq(String vendor, NetworkType networkType) {
541 NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest()
542 EsrInfo esrInfo = new EsrInfo()
543 esrInfo.setVendor(vendor)
544 esrInfo.setNetworkType(networkType)
545 request.setEsrInfo(esrInfo)
547 return objectMapper.writeValueAsString(request)
551 * if exist nssi need to select
554 public void handleNssiSelect(DelegateExecution execution) {
556 SliceTaskParamsAdapter sliceTaskParams =
557 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
560 boolean needCnNssiSelection = execution.getVariable("NEED_CN_NSSI_SELECTION") as Boolean
561 boolean needAnNssiSelection = execution.getVariable("NEED_AN_NSSI_SELECTION") as Boolean
562 boolean needTnNssiSelection = execution.getVariable("NEED_TN_NSSI_SELECTION") as Boolean
564 List<Map> nssiNeedHandlerInfos = new ArrayList<>()
565 Map<String, Object> nssiNeedHandlerMap = new HashMap()
567 //List<TemplateInfo> nssiNeedHandlers = new ArrayList<>()
568 //List<Object> nssiProfileNeedHandlers = new ArrayList<>()
569 if (needCnNssiSelection) {
570 nssiNeedHandlerMap.put("subnetType", sliceTaskParams.cnSliceTaskInfo.subnetType)
571 nssiNeedHandlerMap.put("nsstInfo", sliceTaskParams.cnSliceTaskInfo.NSSTInfo)
572 nssiNeedHandlerMap.put("sliceProfile", sliceTaskParams.cnSliceTaskInfo.sliceProfile)
573 nssiNeedHandlerInfos.add(nssiNeedHandlerMap)
575 if (needAnNssiSelection) {
576 nssiNeedHandlerMap.clear()
577 nssiNeedHandlerMap.put("subnetType", sliceTaskParams.anSliceTaskInfo.subnetType)
578 nssiNeedHandlerMap.put("nsstInfo", sliceTaskParams.anSliceTaskInfo.NSSTInfo)
579 nssiNeedHandlerMap.put("sliceProfile", sliceTaskParams.anSliceTaskInfo.sliceProfile)
580 nssiNeedHandlerInfos.add(nssiNeedHandlerMap)
582 if (needTnNssiSelection) {
583 nssiNeedHandlerMap.clear()
584 nssiNeedHandlerMap.put("subnetType", sliceTaskParams.tnBHSliceTaskInfo.subnetType)
585 nssiNeedHandlerMap.put("nsstInfo", sliceTaskParams.tnBHSliceTaskInfo.NSSTInfo)
586 nssiNeedHandlerMap.put("sliceProfile", sliceTaskParams.tnBHSliceTaskInfo.sliceProfile)
587 nssiNeedHandlerInfos.add(nssiNeedHandlerMap)
589 nssiNeedHandlerMap.clear()
590 nssiNeedHandlerMap.put("subnetType", sliceTaskParams.tnMHSliceTaskInfo.subnetType)
591 nssiNeedHandlerMap.put("nsstInfo", sliceTaskParams.tnMHSliceTaskInfo.NSSTInfo)
592 nssiNeedHandlerMap.put("sliceProfile", sliceTaskParams.tnMHSliceTaskInfo.sliceProfile)
593 nssiNeedHandlerInfos.add(nssiNeedHandlerMap)
595 nssiNeedHandlerMap.clear()
596 nssiNeedHandlerMap.put("subnetType", sliceTaskParams.tnFHSliceTaskInfo.subnetType)
597 nssiNeedHandlerMap.put("nsstInfo", sliceTaskParams.tnFHSliceTaskInfo.NSSTInfo)
598 nssiNeedHandlerMap.put("sliceProfile", sliceTaskParams.tnFHSliceTaskInfo.sliceProfile)
599 nssiNeedHandlerInfos.add(nssiNeedHandlerMap)
603 if (nssiNeedHandlerInfos.size() > 0) {
604 execution.setVariable("needSelectNssi", true)
605 execution.setVariable("currNssiIndex", 0)
606 execution.setVariable("nssiNeedHandlerInfos", nssiNeedHandlerInfos)
608 execution.setVariable("needSelectNssi", false)
611 execution.setVariable("sliceTaskParams", sliceTaskParams)
615 * prepare select nssi request
618 public void preNSSIRequest(DelegateExecution execution) {
620 List<Map> nssiNeedHandlerInfos =
621 execution.getVariable("nssiNeedHandlerInfos") as List<Map>
623 int currNssiIndex = execution.getVariable("currNssiIndex") as Integer
624 Map nssiNeedHandlerInfo = nssiNeedHandlerInfos.get(currNssiIndex) as Map
626 TemplateInfo nsstInfo = nssiNeedHandlerInfo.get("nsstInfo") as TemplateInfo
627 Map<String, Object> profileInfo = nssiNeedHandlerInfo.get("sliceProfile") as Map
628 //profileInfo.remove("profileId")
630 String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
631 logger.debug( "get NSI option OOF Url: " + urlString)
633 String requestId = execution.getVariable("msoRequestId")
634 String messageType = "NSSISelectionResponse"
636 execution.setVariable("nssiSelectionUrl", "/api/oof/selection/nssi/v1")
637 execution.setVariable("nssiSelection_messageType", messageType)
638 execution.setVariable("nssiSelection_correlator", requestId)
639 String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution)
640 execution.setVariable("nssiSelection_timeout", timeout)
642 String oofRequest = oofUtils.buildSelectNSSIRequest(requestId, nsstInfo, messageType,
645 execution.setVariable("nssiSelection_oofRequest", oofRequest)
646 logger.debug("Sending request to OOF: " + oofRequest)
650 * process select nssi response
653 public void processNSSIResp(DelegateExecution execution) {
655 List<Map> nssiNeedHandlerInfos =
656 execution.getVariable("nssiNeedHandlerInfos") as List<Map>
658 int currNssiIndex = execution.getVariable("currNssiIndex") as Integer
659 Map nssiNeedHandlerInfo = nssiNeedHandlerInfos.get(currNssiIndex) as Map
660 SubnetType subnetType = nssiNeedHandlerInfo.get("subnetType") as SubnetType
662 SliceTaskParamsAdapter sliceTaskParams =
663 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
666 String OOFResponse = execution.getVariable("nssiSelection_oofResponse")
667 logger.debug("NSI OOFResponse is: " + OOFResponse)
668 execution.setVariable("OOFResponse", OOFResponse)
669 //This needs to be changed to derive a value when we add policy to decide the solution options.
671 Map<String, Object> resMap = objectMapper.readValue(OOFResponse, Map.class)
672 List<Map<String, Object>> nsiSolutions = (List<Map<String, Object>>) resMap.get("solutions")
673 Map<String, Object> solution = nsiSolutions.get(0)
675 String resourceSharingLevel = execution.getVariable("resourceSharingLevel")
676 Boolean isSharable = resourceSharingLevel == "shared" //todo
678 if (isSharable && solution != null) {
679 processNssiResult(sliceTaskParams, subnetType, solution)
682 execution.setVariable("sliceTaskParams", sliceTaskParams)
683 //logger.debug("sliceTaskParams: "+ sliceTaskParams.convertToJson())
684 logger.debug("*** Completed options Call to OOF ***")
686 logger.debug("start parseServiceProfile")
687 //parseServiceProfile(execution)
688 logger.debug("end parseServiceProfile")
690 if (currNssiIndex >= nssiNeedHandlerInfos.size() - 1) {
691 execution.setVariable("needSelectNssi", false)
693 execution.setVariable("currNssiIndex", currNssiIndex + 1)
694 execution.setVariable("needSelectNssi", true)
699 private void processNssiResult(SliceTaskParamsAdapter sliceTaskParams, SubnetType subnetType,
700 Map<String, Object> solution) {
701 switch (subnetType) {
703 sliceTaskParams.cnSliceTaskInfo.suggestNssiId = solution.get("NSSIId")
704 sliceTaskParams.cnSliceTaskInfo.suggestNssiName = solution.get("NSSIName")
707 sliceTaskParams.anSliceTaskInfo.suggestNssiId = solution.get("NSSIId")
708 sliceTaskParams.anSliceTaskInfo.suggestNssiName = solution.get("NSSIName")
710 case SubnetType.TN_BH:
711 sliceTaskParams.tnBHSliceTaskInfo.suggestNssiId = solution.get("NSSIId")
712 sliceTaskParams.tnBHSliceTaskInfo.suggestNssiName = solution.get("NSSIName")
714 case SubnetType.TN_FH:
715 sliceTaskParams.tnFHSliceTaskInfo.suggestNssiId = solution.get("NSSIId")
716 sliceTaskParams.tnFHSliceTaskInfo.suggestNssiName = solution.get("NSSIName")
718 case SubnetType.TN_MH:
719 sliceTaskParams.tnMHSliceTaskInfo.suggestNssiId = solution.get("NSSIId")
720 sliceTaskParams.tnMHSliceTaskInfo.suggestNssiName = solution.get("NSSIName")