From 07e649d885ffb210b5c76cf8b17421dbd8439696 Mon Sep 17 00:00:00 2001 From: zm330 Date: Thu, 14 May 2020 11:45:08 +0800 Subject: update oof option and slice profile Issue-ID: SO-2919 Signed-off-by: zm330 Change-Id: I6b8877d518887f0e56b2f125c8f9f58ab95aee9f --- .../scripts/DoCreateSliceServiceOption.groovy | 136 +++++++++++++-------- 1 file changed, 87 insertions(+), 49 deletions(-) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy index 303b8c892e..a4b360276d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy @@ -66,11 +66,6 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ void getNSIOptionfromOOF(DelegateExecution execution) { - //解析sliceProfile - logger.debug("start parseServiceProfile") - parseServiceProfile(execution) - logger.debug("end parseServiceProfile") - String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution) logger.debug( "get NSI option OOF Url: " + urlString) @@ -120,6 +115,11 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ Response httpResponse = httpClient.post(oofRequest) processOOFResponse(httpResponse, execution) + + //解析sliceProfile + logger.debug("start parseServiceProfile") + parseServiceProfile(execution) + logger.debug("end parseServiceProfile") } private void processOOFResponse(Response httpResponse, DelegateExecution execution) { @@ -141,17 +141,15 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ Map OOFResponseObject = new JsonSlurper().parseText(OOFResponse) Map solutions = OOFResponseObject.get("solutions") - Boolean isSharable = false String resourceSharingLevel = execution.getVariable("resourceSharingLevel") - if (resourceSharingLevel.equals("shared")) - isSharable = true + Boolean isSharable = resourceSharingLevel.equals("shared") if (solutions != null) { if (isSharable) { //sharedNSISolution processSharedNSISolutions(solutions, execution) } else { - //TODO test OOF don't implement in Frankfurt release + //TODO test OOF if (solutions.containsKey("newNSISolutions")) { List newNSISolutions = solutions.get("newNSISolutions") List NSSImap = new ArrayList<>() @@ -185,7 +183,7 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ } } execution.setVariable("sliceTaskParams", sliceTaskParams) - logger.debug("Info: No NSI suggested by OOF") + logger.debug("sliceTaskParams: "+sliceTaskParams.convertToJson()) } logger.debug("*** Completed options Call to OOF ***") } @@ -203,7 +201,7 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ Map sharedNSIsolution = ((List) solutions.get("sharedNSISolutions")).get(0) nsiInstanceId = sharedNSIsolution.getOrDefault("NSIId", "") nsiName = sharedNSIsolution.getOrDefault("NSIName", "") - sliceTaskParams.setNstId(nsiInstanceId) + sliceTaskParams.setSuggestNsiId(nsiInstanceId) sliceTaskParams.setSuggestNsiName(nsiName) //Temporary modification @@ -213,8 +211,9 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ nssiId = nssi.getOrDefault("NSSIId","") nssiName = nssi.getOrDefault("NSSIName","") sliceTaskParams.setCnSuggestNssiId(nssiId) - sliceTaskParams.setCnSuggestNssiName(nssiName) + //TODO Need update after OOF return camel key and domainType sliceProfile = ((List)nssi.get("sliceProfile"))?.get(0) + sliceTaskParams.setCnSuggestNssiName(nssiName) // execution.setVariable("sliceProfileCn", sliceProfile) // sliceTaskParams.setSliceProfileCn(sliceProfile) } @@ -226,51 +225,90 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ logger.debug("Start parseServiceProfile") String serviceType = execution.getVariable("serviceType") Map serviceProfile = execution.getVariable("serviceProfile") - + SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") // set sliceProfile for three domains - Map sliceProfileTn = getSliceProfile(serviceType, "TN", serviceProfile) - Map sliceProfileCn = getSliceProfile(serviceType, "CN", serviceProfile) - Map sliceProfileAn = getSliceProfile(serviceType, "AN", serviceProfile) + if(!sliceTaskParams.getSliceProfileAn()){ + Map sliceProfileAn = getSliceProfile(serviceType, "AN", serviceProfile) + execution.setVariable("sliceProfileAn", sliceProfileAn) + sliceTaskParams.setSliceProfileAn(sliceProfileAn) + logger.debug("sliceProfileAn: " + sliceProfileAn) + } - execution.setVariable("sliceProfileTn", sliceProfileTn) - execution.setVariable("sliceProfileCn", sliceProfileCn) - execution.setVariable("sliceProfileAn", sliceProfileAn) - logger.debug("sliceProfileTn: " + sliceProfileTn) - logger.debug("sliceProfileCn: " + sliceProfileCn) - logger.debug("sliceProfileAn: " + sliceProfileAn) + if(!sliceTaskParams.getSliceProfileTn()){ + Map sliceProfileTn = getSliceProfile(serviceType, "TN", serviceProfile) + execution.setVariable("sliceProfileTn", sliceProfileTn) + sliceTaskParams.setSliceProfileTn(sliceProfileTn) + logger.debug("sliceProfileTn: " + sliceProfileTn) + } + + if(!sliceTaskParams.getSliceProfileCn()){ + Map sliceProfileCn = getSliceProfile(serviceType, "CN", serviceProfile) + execution.setVariable("sliceProfileCn", sliceProfileCn) + sliceTaskParams.setSliceProfileCn(sliceProfileCn) + logger.debug("sliceProfileCn: " + sliceProfileCn) + } logger.debug("Finish parseServiceProfile") } - Map getSliceProfile(String serviceType, String domain, Map serviceProfile) { - //String variablePath = "nsmf." + serviceType + ".profileMap" + domain - //String profileMapStr = UrnPropertiesReader.getVariable(variablePath) - String profileMapStr = """ { - "skip_post_instantiation_configuration":"skip_post_instantiation_configuration", - "controller_actor":"controller_actor", - "areaTrafficCapDL":"areaTrafficCapDL", - "maxNumberofUEs":"maxNumberofUEs", - "latency":"latency", - "expDataRateUL":"expDataRateUL", - "sNSSAI":"sNSSAI", - "plmnIdList":"plmnIdList", - "sST":"sST", - "areaTrafficCapUL":"areaTrafficCapUL", - "uEMobilityLevel":"uEMobilityLevel", - "expDataRateDL":"expDataRateDL", - "coverageAreaTAList":"coverageAreaTAList", - "activityFactor":"activityFactor", - "resourceSharingLevel":"resourceSharingLevel" - } - """.trim().replaceAll(" ", "") - logger.debug("Profile map for " + domain + " : " + profileMapStr) - Map profileMaps = objectMapper.readValue(profileMapStr, new TypeReference>(){}) - Map sliceProfileTn = [:] + Map getSliceProfile(String serviceType, String domain, Map serviceProfile) { + String profileMapStr + Integer domainLatency = (Integer) serviceProfile.get("latency")/3 + + switch (domain) { + case "AN": + profileMapStr = """ { + "latency": ${domainLatency}, + "sNSSAI": "sNSSAI", + "uEMobilityLevel": "uEMobilityLevel", + "coverageAreaTAList": "coverageAreaTAList", + "5QI": 100 + } + """.trim().replaceAll(" ", "") + break + case "TN": + profileMapStr =""" { + "latency":${domainLatency}, + "sNSSAI":"sNSSAI", + "e2eLatency":"latency", + "bandwidth": 100 + } + """.trim().replaceAll(" ", "") + break + case "CN": + profileMapStr = """ { + "areaTrafficCapDL":"areaTrafficCapDL", + "maxNumberofUEs":"maxNumberofUEs", + "latency":${domainLatency}, + "expDataRateUL":"expDataRateUL", + "sNSSAI":"sNSSAI", + "areaTrafficCapUL":"areaTrafficCapUL", + "uEMobilityLevel":"uEMobilityLevel", + "expDataRateDL":"expDataRateDL", + "activityFactor":"activityFactor", + "resourceSharingLevel":"resourceSharingLevel" + } + """.trim().replaceAll(" ", "") + break + default: + break + } + + logger.debug("Profile map for " + domain + " : " + profileMapStr) + Map profileMaps = objectMapper.readValue(profileMapStr, new TypeReference>(){}) + Map sliceProfile = [:] for (Map.Entry profileMap : profileMaps) { - sliceProfileTn.put(profileMap.key, serviceProfile.get(profileMap.value)) + String key = profileMap.key + String value = profileMaps.get(key) + if(serviceProfile.keySet().contains(value)){ + sliceProfile.put(key, serviceProfile.get(value)) + } + else{ + sliceProfile.put(key, profileMaps.get(key)) + } } - return sliceProfileTn + return sliceProfile } void processDecomposition(DelegateExecution execution){ @@ -279,8 +317,8 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ ServiceDecomposition serviceDecomposition= execution.getVariable("serviceDecomposition") SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") String nstName = serviceDecomposition.getModelInfo().getModelName() - sliceTaskParams.setNstName(nstName) String nstId = serviceDecomposition.getModelInfo().getModelUuid() + sliceTaskParams.setNstName(nstName) sliceTaskParams.setNstId(nstId) logger.debug("End processDecomposition") -- cgit 1.2.3-korg