diff options
author | 2022-04-28 14:14:44 +0000 | |
---|---|---|
committer | 2022-04-29 15:25:44 +0000 | |
commit | 111f6428fea584ce6342c84e6c623945b900addd (patch) | |
tree | e2ba1f23a0cec033ec08be6ca98a163bd2d40876 /components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms | |
parent | 96bb3070750e59e028ae9d06c368f9a6b2e014a2 (diff) |
[SLICEANALYSIS] Filter RAN related service instances in AAI and Fetch CU Cells data for intelligent slicing
Issue-ID: DCAEGEN2-3145
Issue-ID: DCAEGEN2-3146
Signed-off-by: Niranjana <niranjana.y60@wipro.com>
Change-Id: I5c53bc05f43de09554b02a763d7f5c22435c9962
Diffstat (limited to 'components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms')
6 files changed, 78 insertions, 20 deletions
diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/aai/AaiService.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/aai/AaiService.java index ab67c031..9459b64f 100644 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/aai/AaiService.java +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/aai/AaiService.java @@ -79,7 +79,10 @@ public class AaiService implements AaiInterface { JSONArray serviceInstanceList = serviceInstanceJson.getJSONArray("service-instance"); for (int i = 0; i < serviceInstanceList.length(); i++) { JSONObject serviceObj = serviceInstanceList.getJSONObject(i); - if (serviceObj.has("environment-context") && serviceObj.getString("environment-context").equalsIgnoreCase(snssai)) { + if (serviceObj.has("environment-context") && serviceObj.getString("environment-context").equalsIgnoreCase(snssai) + && serviceObj.has("workload-context") && serviceObj.getString("workload-context").contains("AN") + && serviceObj.has("service-role") + && serviceObj.getString("service-role").contains("slice-profile")) { responseMap.put("sliceProfileId", serviceObj.getString("service-instance-id")); } } @@ -128,7 +131,10 @@ public class AaiService implements AaiInterface { JSONArray serviceInstanceList = serviceInstanceJson.getJSONArray("service-instance"); for (int i = 0; i < serviceInstanceList.length(); i++) { JSONObject serviceObj = serviceInstanceList.getJSONObject(i); - if (serviceObj.has("environment-context") && serviceObj.getString("environment-context").equalsIgnoreCase(snssai)) { + if (serviceObj.has("environment-context") && serviceObj.getString("environment-context").equalsIgnoreCase(snssai) + && serviceObj.has("workload-context") && serviceObj.getString("workload-context").contains("AN") + && serviceObj.has("service-role") + && serviceObj.getString("service-role").contains("slice-profile-instance")) { serviceInstaneId = serviceObj.getString("service-instance-id"); } } diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/configdb/ConfigDbInterfaceService.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/configdb/ConfigDbInterfaceService.java index 50a60ac3..3e41fbee 100644 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/configdb/ConfigDbInterfaceService.java +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/configdb/ConfigDbInterfaceService.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * slice-analysis-ms * ================================================================================ - * Copyright (C) 2020-2021 Wipro Limited. + * Copyright (C) 2020-2022 Wipro Limited. * ============================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -128,5 +128,24 @@ public class ConfigDbInterfaceService implements IConfigDbService { return response.getBody(); } + /** + * Fetches the CUCP Cells of an S-NSSAI from config DB + */ + public Map<String, List<String>> fetchCUCPCellsOfSnssai(String snssai){ + Map<String,List<String>> responseMap=new HashMap<>(); + String reqUrl=configDbBaseUrl+"/api/sdnc-config-db/v4/cucp-cell-list/"+snssai; + ResponseEntity<Map<String,List<CellsModel>>> response = restclient.sendGetRequest(reqUrl, new ParameterizedTypeReference<Map<String,List<CellsModel>>>() { + }); + + for (Map.Entry<String, List<CellsModel>> entry : response.getBody().entrySet()) { + List<String> cellslist=new ArrayList<>(); + for(CellsModel cellmodel:entry.getValue()) { + cellslist.add(cellmodel.getCellLocalId()); + } + responseMap.put(entry.getKey(), cellslist); + } + return responseMap; + } + } diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/configdb/IConfigDbService.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/configdb/IConfigDbService.java index 2b92b091..f34fcc9a 100644 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/configdb/IConfigDbService.java +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/configdb/IConfigDbService.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * slice-analysis-ms * ================================================================================ - * Copyright (C) 2020 Wipro Limited. + * Copyright (C) 2020-2022 Wipro Limited. * ============================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,16 +25,17 @@ import java.util.List; import java.util.Map; /** - * + * * Interface for config db service * */ public interface IConfigDbService { - public Map<String, List<String>> fetchRICsOfSnssai(String snssai); - public List<String> fetchNetworkFunctionsOfSnssai(String snssai); - public Map<String, Integer> fetchCurrentConfigurationOfSlice(String snssai); - public Map<String, Map<String,Object>> fetchCurrentConfigurationOfRIC(String snssai); - public Map<String ,String> fetchServiceDetails(String snssai); + public Map<String, List<String>> fetchRICsOfSnssai(String snssai); + public List<String> fetchNetworkFunctionsOfSnssai(String snssai); + public Map<String, Integer> fetchCurrentConfigurationOfSlice(String snssai); + public Map<String, Map<String,Object>> fetchCurrentConfigurationOfRIC(String snssai); + public Map<String ,String> fetchServiceDetails(String snssai); + public Map<String, List<String>> fetchCUCPCellsOfSnssai(String snssai); } diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/cps/CpsInterface.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/cps/CpsInterface.java index 95e7340f..d6a187cb 100644 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/cps/CpsInterface.java +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/cps/CpsInterface.java @@ -37,4 +37,6 @@ public interface CpsInterface { public Map<String, Map<String, Object>> fetchCurrentConfigurationOfRIC(String snssai); + public Map<String, List<String>> fetchnrCellCUsOfSnssai(String snssai); + } diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/cps/CpsService.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/cps/CpsService.java index 27f37aba..a9562e58 100644 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/cps/CpsService.java +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/cps/CpsService.java @@ -142,6 +142,41 @@ public class CpsService implements CpsInterface { } catch (Exception e) { log.info("Fetch RICS of S-NSSAI from CPS" + e); } + log.info("responseMap: {}", responseMap); + return responseMap; + } + + /** + * Fetches the NRCellCUs of an S-NSSAI from CPS + */ + public Map<String, List<String>> fetchnrCellCUsOfSnssai(String snssai) { + Map<String, List<String>> responseMap = new HashMap<>(); + String reqUrl = cpsBaseUrl + "/get-nearrtric-config"; + log.info("fetching NrCellCUs of s-NSSAI from Cps: {s-NSSAI: " + snssai + "}"); + log.info("reqUrl {}", reqUrl); + String requestBody = "{\"inputParameters\": {\"sNssai\":" + JSONObject.quote(snssai) + "}}"; + log.info("requestBody {}", requestBody); + try { + String response = restclient + .sendPostRequest(reqUrl, requestBody, new ParameterizedTypeReference<String>() {}).getBody(); + JSONArray sliceArray = new JSONArray(response); + for (int i = 0; i < sliceArray.length(); i++) { + String nearRTTICid = sliceArray.getJSONObject(i).optString("idNearRTRIC"); + JSONArray GNBCUCPFunctionArray = sliceArray.getJSONObject(i).getJSONArray("GNBCUCPFunction"); + for (int j = 0; j < GNBCUCPFunctionArray.length(); j++) { + JSONArray NRCellCUArray = GNBCUCPFunctionArray.getJSONObject(j).getJSONArray("NRCellCU"); + List<String> cellslist = new ArrayList<>(); + for (int k = 0; k < NRCellCUArray.length(); k++) { + cellslist.add( + NRCellCUArray.getJSONObject(k).getJSONObject("attributes").optString("cellLocalId")); + } + responseMap.put(nearRTTICid, cellslist); + } + } + } catch (Exception e) { + log.info("Exception: {}", e); + } + log.info("responseMap: {}", responseMap); return responseMap; } } diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/MLMessageProcessor.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/MLMessageProcessor.java index f692efcc..d1d2a152 100644 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/MLMessageProcessor.java +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/MLMessageProcessor.java @@ -69,11 +69,13 @@ public class MLMessageProcessor { String snssai = mlOutputMsg.getSnssai(); List<CUModel> cuData = mlOutputMsg.getData(); if (isConfigDbEnabled) { - ricToCellMapping = configDbService.fetchRICsOfSnssai(snssai); + serviceDetails = configDbService.fetchServiceDetails(snssai); + ricToCellMapping = configDbService.fetchCUCPCellsOfSnssai(snssai); } else { - ricToCellMapping = cpsInterface.fetchRICsOfSnssai(snssai); + ricToCellMapping = cpsInterface.fetchnrCellCUsOfSnssai(snssai); + serviceDetails = aaiInterface.fetchServiceDetails(snssai); } - log.debug("RIC to cell mapping of S-NSSAI {} is {}", snssai, ricToCellMapping); + log.info("RIC to cell mapping of S-NSSAI {} is {}", snssai, ricToCellMapping); for (CUModel cuModel : cuData) { String cellId = String.valueOf(cuModel.getCellCUList().get(0).getCellLocalId()); ricToCellMapping.forEach((ricId, cells) -> { @@ -84,13 +86,6 @@ public class MLMessageProcessor { } AdditionalProperties<MLOutputModel> addProps = new AdditionalProperties<>(); addProps.setResourceConfig(mlOutputMsg); - - if (isConfigDbEnabled) { - serviceDetails = configDbService.fetchServiceDetails(snssai); - } else { - serviceDetails = aaiInterface.fetchServiceDetails(snssai); - - } policyService.sendOnsetMessageToPolicy(snssai, addProps, serviceDetails); } |