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 com.fasterxml.jackson.core.type.TypeReference
25 import org.camunda.bpm.engine.delegate.DelegateExecution
26 import org.onap.aai.domain.yang.ServiceInstance
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.QuerySubnetCapability
31 import org.onap.so.beans.nsmf.SliceProfileAdapter
32 import org.onap.so.beans.nsmf.SliceTaskParamsAdapter
33 import org.onap.so.beans.nsmf.oof.SubnetCapability
34 import org.onap.so.beans.nsmf.oof.SubnetType
35 import org.onap.so.beans.nsmf.oof.TemplateInfo
36 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
37 import org.onap.so.bpmn.common.scripts.ExceptionUtil
38 import org.onap.so.bpmn.common.scripts.NssmfAdapterUtils
39 import org.onap.so.bpmn.common.scripts.OofUtils
40 import org.onap.so.bpmn.core.UrnPropertiesReader
41 import org.onap.so.bpmn.core.domain.AllottedResource
42 import org.onap.so.bpmn.core.domain.ModelInfo
43 import org.onap.so.bpmn.core.domain.ServiceDecomposition
44 import org.onap.so.bpmn.core.json.JsonUtils
45 import org.slf4j.Logger
46 import org.slf4j.LoggerFactory
47 import org.springframework.util.StringUtils
50 class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
52 private static final Logger logger = LoggerFactory.getLogger(DoCreateSliceServiceOption.class)
54 ExceptionUtil exceptionUtil = new ExceptionUtil()
56 JsonUtils jsonUtil = new JsonUtils()
58 OofUtils oofUtils = new OofUtils()
60 AAISliceUtil aaiSliceUtil = new AAISliceUtil()
62 private static final ObjectMapper objectMapper = new ObjectMapper()
64 private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil)
66 private static final String QUERY_SUB_NET_CAPABILITY = "/api/rest/provMns/v1/NSS/subnetCapabilityQuery"
68 private static final String QUERY_NSSI_SELECTION_CAPABILITY = "/api/rest/provMns/v1/NSS/NSSISelectionCapability"
70 void preProcessRequest (DelegateExecution execution) {
74 * prepare the params for decompose nst
77 void prepareDecomposeNST(DelegateExecution execution) {
79 SliceTaskParamsAdapter sliceTaskParams =
80 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
82 String modelUuid = sliceTaskParams.getNSTInfo().getUUID()
83 String modelInvariantUuid = sliceTaskParams.getNSTInfo().getInvariantUUID()
85 String serviceModelInfo = """{
86 "modelInvariantUuid":"${modelInvariantUuid}",
87 "modelUuid":"${modelUuid}",
90 execution.setVariable("nstServiceModelInfo", serviceModelInfo)
94 * process the result of NST Decomposition
97 public void processDecompositionNST(DelegateExecution execution) {
99 List<TemplateInfo> nsstInfos = new ArrayList<>()
100 ServiceDecomposition nstServiceDecomposition =
101 execution.getVariable("nstServiceDecomposition") as ServiceDecomposition
103 List<AllottedResource> allottedResources = nstServiceDecomposition.getAllottedResources()
104 for (AllottedResource allottedResource : allottedResources) {
105 TemplateInfo nsstInfo = new TemplateInfo()
106 nsstInfo.setUUID(allottedResource.getProvidingServiceModelUuid())
107 nsstInfo.setInvariantUUID(allottedResource.getProvidingServiceModelInvariantUuid())
108 nsstInfo.setName(allottedResource.getProvidingServiceModelName())
109 nsstInfos.add(nsstInfo)
111 execution.setVariable("nsstInfos", nsstInfos)
113 execution.setVariable("maxNsstIndex", allottedResources.size() - 1)
114 execution.setVariable("currentNsstIndex", 0)
116 List<ServiceDecomposition> nsstServiceDecompositions = new ArrayList<>()
117 execution.setVariable("nsstServiceDecompositions", nsstServiceDecompositions)
121 * prepare the params for decompose nsst
124 public void prepareDecomposeNSST(DelegateExecution execution) {
126 List<TemplateInfo> nsstInfos = execution.getVariable("nsstInfos") as List<TemplateInfo>
127 int index = execution.getVariable("currentNsstIndex") as Integer
129 String modelUuid = nsstInfos.get(index).getUUID()
130 String modelInvariantUuid = nsstInfos.get(index).getInvariantUUID()
132 String serviceModelInfo = """{
133 "modelInvariantUuid":"${modelInvariantUuid}",
134 "modelUuid":"${modelUuid}",
137 execution.setVariable("nsstServiceModelInfo", serviceModelInfo)
141 * process the result of NSST Decomposition
144 public void processDecompositionNSST(DelegateExecution execution) {
145 List<ServiceDecomposition> nsstServiceDecompositions =
146 execution.getVariable("nsstServiceDecompositions") as List<ServiceDecomposition>
148 ServiceDecomposition nsstServiceDecomposition =
149 execution.getVariable("nsstServiceDecomposition") as ServiceDecomposition
151 nsstServiceDecompositions.add(nsstServiceDecomposition)
153 execution.setVariable("nsstServiceDecompositions", nsstServiceDecompositions)
155 int num = execution.getVariable("maxNsstIndex") as Integer
156 int index = execution.getVariable("currentNsstIndex") as Integer
158 List<TemplateInfo> nsstInfos = execution.getVariable("nsstInfos") as List<TemplateInfo>
159 nsstInfos.get(index).name = nsstServiceDecomposition.modelInfo.modelName
160 execution.setVariable("nsstInfos", nsstInfos)
161 execution.setVariable("currentNsstIndex", index + 1)
164 execution.setVariable("nsstHandleContinue", false)
166 execution.setVariable("nsstHandleContinue", true)
171 * set nsst info to sliceTaskParams by type
174 public void handleNsstByType(DelegateExecution execution) {
176 SliceTaskParamsAdapter sliceParams =
177 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
179 List<ServiceDecomposition> nsstServiceDecompositions =
180 execution.getVariable("nsstServiceDecompositions") as List<ServiceDecomposition>
182 List<SubnetCapability> subnetCapabilities = new ArrayList<>()
184 for (ServiceDecomposition serviceDecomposition : nsstServiceDecompositions) {
185 handleByType(execution, serviceDecomposition, sliceParams, subnetCapabilities)
188 execution.setVariable("sliceTaskParams", sliceParams)
189 execution.setVariable("subnetCapabilities", subnetCapabilities)
190 execution.setVariable("queryNsiFirst", true)
191 logger.debug("sliceTaskParams= " + sliceParams.toString())
194 private void handleByType(DelegateExecution execution, ServiceDecomposition serviceDecomposition,
195 SliceTaskParamsAdapter sliceParams, List<SubnetCapability> subnetCapabilities) {
196 ModelInfo modelInfo = serviceDecomposition.getModelInfo()
197 String vendor = serviceDecomposition.getServiceRole()
198 SubnetType subnetType = convertServiceCategory(serviceDecomposition.getServiceCategory())
200 switch (subnetType) {
201 case SubnetType.TN_BH:
202 sliceParams.tnBHSliceTaskInfo.vendor = vendor
203 sliceParams.tnBHSliceTaskInfo.subnetType = subnetType
204 sliceParams.tnBHSliceTaskInfo.networkType = subnetType.networkType
205 sliceParams.tnBHSliceTaskInfo.NSSTInfo.UUID = modelInfo.getModelUuid()
206 sliceParams.tnBHSliceTaskInfo.NSSTInfo.invariantUUID = modelInfo.getModelInvariantUuid()
207 sliceParams.tnBHSliceTaskInfo.NSSTInfo.name = modelInfo.getModelName()
209 case SubnetType.TN_MH:
210 sliceParams.tnMHSliceTaskInfo.vendor = vendor
211 sliceParams.tnMHSliceTaskInfo.subnetType = subnetType
212 sliceParams.tnMHSliceTaskInfo.networkType = subnetType.networkType
213 sliceParams.tnMHSliceTaskInfo.NSSTInfo.UUID = modelInfo.getModelUuid()
214 sliceParams.tnMHSliceTaskInfo.NSSTInfo.invariantUUID = modelInfo.getModelInvariantUuid()
215 sliceParams.tnMHSliceTaskInfo.NSSTInfo.name = modelInfo.getModelName()
217 case SubnetType.TN_FH:
218 sliceParams.tnFHSliceTaskInfo.vendor = vendor
219 sliceParams.tnFHSliceTaskInfo.subnetType = subnetType
220 sliceParams.tnFHSliceTaskInfo.networkType = subnetType.networkType
221 sliceParams.tnFHSliceTaskInfo.NSSTInfo.UUID = modelInfo.getModelUuid()
222 sliceParams.tnFHSliceTaskInfo.NSSTInfo.invariantUUID = modelInfo.getModelInvariantUuid()
223 sliceParams.tnFHSliceTaskInfo.NSSTInfo.name = modelInfo.getModelName()
225 case SubnetType.AN_NF:
226 sliceParams.anNFSliceTaskInfo.vendor = vendor
227 sliceParams.anNFSliceTaskInfo.subnetType = subnetType
228 sliceParams.anNFSliceTaskInfo.networkType = subnetType.networkType
229 sliceParams.anNFSliceTaskInfo.NSSTInfo.UUID = modelInfo.getModelUuid()
230 sliceParams.anNFSliceTaskInfo.NSSTInfo.invariantUUID = modelInfo.getModelInvariantUuid()
231 sliceParams.anNFSliceTaskInfo.NSSTInfo.name = modelInfo.getModelName()
234 sliceParams.anSliceTaskInfo.vendor = vendor
235 sliceParams.anSliceTaskInfo.subnetType = subnetType
236 sliceParams.anSliceTaskInfo.networkType = subnetType.networkType
237 sliceParams.anSliceTaskInfo.NSSTInfo.UUID = modelInfo.getModelUuid()
238 sliceParams.anSliceTaskInfo.NSSTInfo.invariantUUID = modelInfo.getModelInvariantUuid()
239 sliceParams.anSliceTaskInfo.NSSTInfo.name = modelInfo.getModelName()
242 sliceParams.cnSliceTaskInfo.vendor = vendor
243 sliceParams.cnSliceTaskInfo.subnetType = subnetType
244 sliceParams.cnSliceTaskInfo.networkType = subnetType.networkType
245 sliceParams.cnSliceTaskInfo.NSSTInfo.UUID = modelInfo.getModelUuid()
246 sliceParams.cnSliceTaskInfo.NSSTInfo.invariantUUID = modelInfo.getModelInvariantUuid()
247 sliceParams.cnSliceTaskInfo.NSSTInfo.name = modelInfo.getModelName()
253 if (null == subnetType) {
254 def msg = "Get subnetType failed, modelUUId=" + modelInfo.getModelUuid()
256 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
258 String response = querySubnetCapability(execution, vendor, subnetType)
259 if (!StringUtils.isEmpty(response)) {
260 SubnetCapability subnetCapability = new SubnetCapability()
261 Map<String, Object> result = objectMapper.readValue(response, Map.class)
262 for (Map.Entry<String, Object> entry : result.entrySet()) {
263 subnetCapability.setDomainType(entry.getKey())
264 subnetCapability.setCapabilityDetails(entry.getValue())
266 subnetCapabilities.add(subnetCapability)
271 * get subnetType from serviceCategory
274 private SubnetType convertServiceCategory(String serviceCategory){
275 if("CN NSST".equals(serviceCategory)){
278 if ("AN NF NSST".equals(serviceCategory)){
279 return SubnetType.AN_NF
281 if ("AN NSST".equals(serviceCategory)){
284 if ("TN BH NSST".equals(serviceCategory)){
285 return SubnetType.TN_BH
287 if("TN MH NSST".equals(serviceCategory)){
288 return SubnetType.TN_MH
290 if("TN FH NSST".equals(serviceCategory)){
291 return SubnetType.TN_FH
297 * query Subnet Capability of TN AN CN
300 private String querySubnetCapability(DelegateExecution execution, String vendor, SubnetType subnetType) {
302 String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_SUB_NET_CAPABILITY,
303 buildQuerySubnetCapRequest(vendor, subnetType))
308 * build request body for querying Subnet Capability
314 private static NssmfAdapterNBIRequest buildQuerySubnetCapRequest(String vendor, SubnetType subnetType) {
315 NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest()
317 List<String> subnetTypes = new ArrayList<>()
318 subnetTypes.add(subnetType.subnetType)
320 QuerySubnetCapability req = new QuerySubnetCapability()
321 req.setSubnetTypes(subnetTypes)
323 request.setSubnetCapabilityQuery(req)
325 EsrInfo esrInfo = new EsrInfo()
326 esrInfo.setVendor(vendor)
327 esrInfo.setNetworkType(subnetType.networkType)
328 request.setEsrInfo(esrInfo)
335 * prepare select nsi request
338 public void preNSIRequest(DelegateExecution execution) {
339 boolean preferReuse = execution.getVariable("needQuerySliceProfile") ? false : true
341 String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
342 logger.debug( "get NSI option OOF Url: " + urlString)
344 String requestId = execution.getVariable("msoRequestId")
345 String messageType = "NSISelectionResponse"
347 execution.setVariable("nsiSelectionUrl", "/api/oof/selection/nsi/v1")
348 execution.setVariable("nsiSelection_messageType", messageType)
349 execution.setVariable("nsiSelection_correlator", requestId)
350 String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution)
351 execution.setVariable("nsiSelection_timeout", timeout)
353 SliceTaskParamsAdapter sliceParams =
354 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
356 Map<String, Object> profileInfo = sliceParams.getServiceProfile()
357 profileInfo.remove("profileId")
358 TemplateInfo nstInfo = sliceParams.getNSTInfo()
360 List<TemplateInfo> nsstInfos = execution.getVariable("nsstInfos") as List<TemplateInfo>
362 List<SubnetCapability> subnetCapabilities =
363 execution.getVariable("subnetCapabilities") as List<SubnetCapability>
365 String oofRequest = oofUtils.buildSelectNSIRequest(requestId, nstInfo, nsstInfos,
366 messageType, profileInfo, subnetCapabilities, 600, preferReuse)
368 execution.setVariable("nsiSelection_oofRequest", oofRequest)
369 logger.debug("Sending request to OOF: " + oofRequest)
373 * process select nsi response
376 public void processNSIResp(DelegateExecution execution) {
378 SliceTaskParamsAdapter sliceTaskParams =
379 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
381 String oofResponse = execution.getVariable("nsiSelection_oofResponse")
382 logger.debug("NSI oofResponse is: " + oofResponse)
383 execution.setVariable("oofResponse", oofResponse)
384 //This needs to be changed to derive a value when we add policy to decide the solution options.
386 Map<String, Object> resMap = objectMapper.readValue(oofResponse, Map.class)
387 String requestStatus = resMap.get("requestStatus")
388 if (!StringUtils.isEmpty(requestStatus) && requestStatus == "error") {
389 exceptionUtil.buildWorkflowException(execution, 7000, "get nsi from oof error: " + oofResponse)
393 List<Map<String, Object>> nsiSolutions = (List<Map<String, Object>>) resMap.get("solutions")
395 Map<String, Object> solution = nsiSolutions?.get(0)
397 if (solution != null) {
398 if (execution.getVariable("queryNsiFirst")) {
399 if (solution.get("existingNSI")) {
400 processSharedNSI(solution, sliceTaskParams, execution)
401 execution.setVariable("needQuerySliceProfile", true)
403 processNewSliceProfiles(solution, sliceTaskParams)
404 execution.setVariable("needQuerySliceProfile", false)
406 execution.setVariable("queryNsiFirst", false)
408 processNewSliceProfiles(solution, sliceTaskParams)
409 execution.setVariable("needQuerySliceProfile", false)
412 execution.setVariable("sliceTaskParams", sliceTaskParams)
413 logger.debug("after req to oof for nis select, sliceTaskParams = " + sliceTaskParams)
414 logger.debug("*** Completed options Call to OOF ***")
417 private void processSharedNSI(Map<String, Object> solution, SliceTaskParamsAdapter sliceParams, DelegateExecution execution) {
418 Map<String, Object> sharedNSISolution = solution.get("sharedNSISolution") as Map
419 String nsiId = sharedNSISolution.get("NSIId")
420 String nsiName = sharedNSISolution.get("NSIName")
421 sliceParams.setSuggestNsiId(nsiId)
422 sliceParams.setSuggestNsiName(nsiName)
424 List<String> nssiId = aaiSliceUtil.getNSSIIdList(execution,nsiId)
425 List<ServiceInstance> nssiInstances = aaiSliceUtil.getNSSIListFromAAI(execution, nssiId)
427 Map<String, Object> nssiSolution = new HashMap<>()
428 for(ServiceInstance instance: nssiInstances){
429 nssiSolution.put("NSSIId", instance.getServiceInstanceId())
430 nssiSolution.put("NSSIName", instance.getServiceInstanceName())
431 SubnetType subnetType = instance.getWorkloadContext() as SubnetType
432 processNssiResult(sliceParams, subnetType, nssiSolution)
437 private void processNewSliceProfiles(Map<String, Object> solution, SliceTaskParamsAdapter sliceParams) {
438 Map<String, Object> newNSISolution = solution.get("newNSISolution") as Map
439 List<Map> sliceProfiles = newNSISolution.get("sliceProfiles") as List<Map>
440 handleSliceProfiles(sliceProfiles, sliceParams)
443 static def handleSliceProfiles(List<Map> sliceProfiles, SliceTaskParamsAdapter sliceParams) {
444 for (Map sliceProfile : sliceProfiles) {
445 String domainType = sliceProfile.get("domainType")
446 sliceProfile.remove("domainType")
447 SliceProfileAdapter adapter = objectMapper.readValue(objectMapper.writeValueAsString(sliceProfile), SliceProfileAdapter.class)
448 switch (domainType.toLowerCase()) {
450 sliceParams.tnBHSliceTaskInfo.sliceProfile = adapter
453 sliceParams.tnFHSliceTaskInfo.sliceProfile = adapter
456 sliceParams.tnMHSliceTaskInfo.sliceProfile = adapter
459 sliceParams.anNFSliceTaskInfo.sliceProfile = adapter
462 sliceParams.anSliceTaskInfo.sliceProfile = adapter
465 sliceParams.cnSliceTaskInfo.sliceProfile = adapter
474 * get NSSI Selection Capability for AN
477 void getNSSISelectionCap4AN(DelegateExecution execution) {
479 SliceTaskParamsAdapter sliceParams =
480 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
482 def vendor = sliceParams.anSliceTaskInfo.vendor
484 String strRequest = buildNSSISelectionReq(vendor, NetworkType.ACCESS)
486 String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_NSSI_SELECTION_CAPABILITY, strRequest)
488 Map<String, Object> resMap = objectMapper.readValue(response, Map.class)
490 String selection = resMap.get("selection")
493 if ("NSMF".equalsIgnoreCase(selection)) {
494 execution.setVariable("NEED_AN_NSSI_SELECTION", true)
499 * get NSSI Selection Capability for TN
502 void getNSSISelectionCap4TN(DelegateExecution execution) {
504 SliceTaskParamsAdapter sliceParams =
505 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
507 def vendor = sliceParams.tnBHSliceTaskInfo.vendor
509 String strRequest = buildNSSISelectionReq(vendor, NetworkType.TRANSPORT)
511 String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_NSSI_SELECTION_CAPABILITY, strRequest)
513 Map<String, Object> resMap = objectMapper.readValue(response, Map.class)
515 String selection = resMap.get("selection")
517 if ("NSMF".equalsIgnoreCase(selection)) {
518 execution.setVariable("NEED_TN_NSSI_SELECTION", true)
523 * get NSSI Selection Capability for CN
526 void getNSSISelectionCap4CN(DelegateExecution execution) {
528 SliceTaskParamsAdapter sliceParams =
529 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
531 def vendor = sliceParams.cnSliceTaskInfo.vendor
533 String strRequest = buildNSSISelectionReq(vendor, NetworkType.CORE)
535 String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_NSSI_SELECTION_CAPABILITY, strRequest)
537 Map<String, Object> resMap = objectMapper.readValue(response, Map.class)
539 String selection = resMap.get("selection")
541 if ("NSMF".equalsIgnoreCase(selection)) {
542 //execution.setVariable("NEED_CN_NSSI_SELECTION", true)
547 * build NSSI Selection Capability Request body to nssmf adapter
552 private static String buildNSSISelectionReq(String vendor, NetworkType networkType) {
553 NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest()
554 EsrInfo esrInfo = new EsrInfo()
555 esrInfo.setVendor(vendor)
556 esrInfo.setNetworkType(networkType)
557 request.setEsrInfo(esrInfo)
559 return objectMapper.writeValueAsString(request)
563 * if exist nssi need to select
566 public void handleNssiSelect(DelegateExecution execution) {
568 SliceTaskParamsAdapter sliceTaskParams =
569 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
572 boolean needCnNssiSelection = execution.getVariable("NEED_CN_NSSI_SELECTION") as Boolean
573 boolean needAnNssiSelection = execution.getVariable("NEED_AN_NSSI_SELECTION") as Boolean
574 boolean needTnNssiSelection = execution.getVariable("NEED_TN_NSSI_SELECTION") as Boolean
576 List<Map> nssiNeedHandlerInfos = new ArrayList<>()
577 Map<String, Object> nssiNeedHandlerMap = new HashMap()
579 //List<TemplateInfo> nssiNeedHandlers = new ArrayList<>()
580 //List<Object> nssiProfileNeedHandlers = new ArrayList<>()
581 if (needCnNssiSelection) {
582 nssiNeedHandlerMap.put("subnetType", sliceTaskParams.cnSliceTaskInfo.subnetType)
583 nssiNeedHandlerMap.put("nsstInfo", sliceTaskParams.cnSliceTaskInfo.NSSTInfo)
584 nssiNeedHandlerMap.put("sliceProfile", sliceTaskParams.cnSliceTaskInfo.sliceProfile)
585 nssiNeedHandlerInfos.add(nssiNeedHandlerMap)
587 if (needAnNssiSelection) {
588 nssiNeedHandlerMap.clear()
589 nssiNeedHandlerMap.put("subnetType", sliceTaskParams.anSliceTaskInfo.subnetType)
590 nssiNeedHandlerMap.put("nsstInfo", sliceTaskParams.anSliceTaskInfo.NSSTInfo)
591 nssiNeedHandlerMap.put("sliceProfile", sliceTaskParams.anSliceTaskInfo.sliceProfile)
592 nssiNeedHandlerInfos.add(nssiNeedHandlerMap)
594 if (needTnNssiSelection) {
595 nssiNeedHandlerMap.clear()
596 nssiNeedHandlerMap.put("subnetType", sliceTaskParams.tnBHSliceTaskInfo.subnetType)
597 nssiNeedHandlerMap.put("nsstInfo", sliceTaskParams.tnBHSliceTaskInfo.NSSTInfo)
598 nssiNeedHandlerMap.put("sliceProfile", sliceTaskParams.tnBHSliceTaskInfo.sliceProfile)
599 nssiNeedHandlerInfos.add(nssiNeedHandlerMap)
601 nssiNeedHandlerMap.clear()
602 nssiNeedHandlerMap.put("subnetType", sliceTaskParams.tnMHSliceTaskInfo.subnetType)
603 nssiNeedHandlerMap.put("nsstInfo", sliceTaskParams.tnMHSliceTaskInfo.NSSTInfo)
604 nssiNeedHandlerMap.put("sliceProfile", sliceTaskParams.tnMHSliceTaskInfo.sliceProfile)
605 nssiNeedHandlerInfos.add(nssiNeedHandlerMap)
607 nssiNeedHandlerMap.clear()
608 nssiNeedHandlerMap.put("subnetType", sliceTaskParams.tnFHSliceTaskInfo.subnetType)
609 nssiNeedHandlerMap.put("nsstInfo", sliceTaskParams.tnFHSliceTaskInfo.NSSTInfo)
610 nssiNeedHandlerMap.put("sliceProfile", sliceTaskParams.tnFHSliceTaskInfo.sliceProfile)
611 nssiNeedHandlerInfos.add(nssiNeedHandlerMap)
615 if (nssiNeedHandlerInfos.size() > 0) {
616 execution.setVariable("needSelectNssi", true)
617 execution.setVariable("currNssiIndex", 0)
618 execution.setVariable("nssiNeedHandlerInfos", nssiNeedHandlerInfos)
620 execution.setVariable("needSelectNssi", false)
623 execution.setVariable("sliceTaskParams", sliceTaskParams)
627 * prepare select nssi request
630 public void preNSSIRequest(DelegateExecution execution) {
632 List<Map> nssiNeedHandlerInfos =
633 execution.getVariable("nssiNeedHandlerInfos") as List<Map>
635 int currNssiIndex = execution.getVariable("currNssiIndex") as Integer
636 Map nssiNeedHandlerInfo = nssiNeedHandlerInfos.get(currNssiIndex) as Map
638 TemplateInfo nsstInfo = nssiNeedHandlerInfo.get("nsstInfo") as TemplateInfo
639 SliceProfileAdapter sliceProfileInfo = nssiNeedHandlerInfo.get("sliceProfile") as SliceProfileAdapter
641 Map profileInfo = objectMapper.convertValue(sliceProfileInfo, new TypeReference<Map<String, Object>>() {});
642 while (profileInfo.values().remove(null));
644 String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
645 logger.debug( "get NSI option OOF Url: " + urlString)
647 String requestId = execution.getVariable("msoRequestId")
648 String messageType = "NSSISelectionResponse"
650 execution.setVariable("nssiSelectionUrl", "/api/oof/selection/nssi/v1")
651 execution.setVariable("nssiSelection_messageType", messageType)
652 execution.setVariable("nssiSelection_correlator", requestId)
653 String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution)
654 execution.setVariable("nssiSelection_timeout", timeout)
656 String oofRequest = oofUtils.buildSelectNSSIRequest(requestId, messageType, nsstInfo.UUID,
657 nsstInfo.invariantUUID, nsstInfo.name, profileInfo)
659 execution.setVariable("nssiSelection_oofRequest", oofRequest)
660 logger.debug("Sending request to OOF: " + oofRequest)
664 * process select nssi response
667 public void processNSSIResp(DelegateExecution execution) {
669 List<Map> nssiNeedHandlerInfos =
670 execution.getVariable("nssiNeedHandlerInfos") as List<Map>
672 int currNssiIndex = execution.getVariable("currNssiIndex") as Integer
673 Map nssiNeedHandlerInfo = nssiNeedHandlerInfos.get(currNssiIndex) as Map
674 SubnetType subnetType = nssiNeedHandlerInfo.get("subnetType") as SubnetType
676 SliceTaskParamsAdapter sliceTaskParams =
677 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
680 String OOFResponse = execution.getVariable("nssiSelection_oofResponse")
681 logger.debug("NSI OOFResponse is: " + OOFResponse)
682 execution.setVariable("OOFResponse", OOFResponse)
683 //This needs to be changed to derive a value when we add policy to decide the solution options.
685 Map<String, Object> resMap = objectMapper.readValue(OOFResponse, Map.class)
686 List<Map<String, Object>> nsiSolutions = (List<Map<String, Object>>) resMap.get("solutions")
688 if(nsiSolutions.size()>=1) {
689 Map<String,Object> solution = nsiSolutions.get(0) as Map
690 processNssiResult(sliceTaskParams, subnetType, solution)
693 execution.setVariable("sliceTaskParams", sliceTaskParams)
694 //logger.debug("sliceTaskParams: "+ sliceTaskParams.convertToJson())
695 logger.debug("*** Completed options Call to OOF ***")
697 logger.debug("start parseServiceProfile")
698 //parseServiceProfile(execution)
699 logger.debug("end parseServiceProfile")
701 if (currNssiIndex >= nssiNeedHandlerInfos.size() - 1) {
702 execution.setVariable("needSelectNssi", false)
704 execution.setVariable("currNssiIndex", currNssiIndex + 1)
705 execution.setVariable("needSelectNssi", true)
710 private void processNssiResult(SliceTaskParamsAdapter sliceTaskParams, SubnetType subnetType,
711 Map<String, Object> solution) {
712 switch (subnetType) {
714 sliceTaskParams.cnSliceTaskInfo.suggestNssiId = solution.get("NSSIId")
715 sliceTaskParams.cnSliceTaskInfo.suggestNssiName = solution.get("NSSIName")
718 sliceTaskParams.anSliceTaskInfo.suggestNssiId = solution.get("NSSIId")
719 sliceTaskParams.anSliceTaskInfo.suggestNssiName = solution.get("NSSIName")
721 case SubnetType.TN_BH:
722 sliceTaskParams.tnBHSliceTaskInfo.suggestNssiId = solution.get("NSSIId")
723 sliceTaskParams.tnBHSliceTaskInfo.suggestNssiName = solution.get("NSSIName")
725 case SubnetType.TN_FH:
726 sliceTaskParams.tnFHSliceTaskInfo.suggestNssiId = solution.get("NSSIId")
727 sliceTaskParams.tnFHSliceTaskInfo.suggestNssiName = solution.get("NSSIName")
729 case SubnetType.TN_MH:
730 sliceTaskParams.tnMHSliceTaskInfo.suggestNssiId = solution.get("NSSIId")
731 sliceTaskParams.tnMHSliceTaskInfo.suggestNssiName = solution.get("NSSIName")