diff options
author | 2022-04-28 14:14:44 +0000 | |
---|---|---|
committer | 2022-04-29 15:25:44 +0000 | |
commit | 111f6428fea584ce6342c84e6c623945b900addd (patch) | |
tree | e2ba1f23a0cec033ec08be6ca98a163bd2d40876 | |
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
12 files changed, 119 insertions, 26 deletions
diff --git a/components/slice-analysis-ms/ChangeLog.md b/components/slice-analysis-ms/ChangeLog.md index d8ef6273..b58a17dd 100644 --- a/components/slice-analysis-ms/ChangeLog.md +++ b/components/slice-analysis-ms/ChangeLog.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [1.1.2] - 2022/04/28 + - [DCAEGEN2-3145](https://jira.onap.org/browse/DCAEGEN2-3145) - Filter RAN related service instances in AAI + + - [DCAEGEN2-3146](https://jira.onap.org/browse/DCAEGEN2-3146) - Fetch CU Cells instead of DU cells data for ML message processing + ## [1.1.1] - 2022/04/12 - [DCAEGEN2-3142](https://jira.onap.org/browse/DCAEGEN2-3142) - Filter data from AAI to avoid possible exceptions, remove null parameters in policy payload and add logs diff --git a/components/slice-analysis-ms/pom.xml b/components/slice-analysis-ms/pom.xml index 1f68fe51..afcc6f60 100644 --- a/components/slice-analysis-ms/pom.xml +++ b/components/slice-analysis-ms/pom.xml @@ -34,7 +34,7 @@ </parent> <groupId>org.onap.dcaegen2.services.components</groupId> <artifactId>slice-analysis-ms</artifactId> - <version>1.1.1-SNAPSHOT</version> + <version>1.1.2-SNAPSHOT</version> <name>dcaegen2-services-slice-analysis-ms</name> <description>Network slice PM analyser</description> <packaging>jar</packaging> 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); } diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/configdb/ConfigDbInterfaceServiceTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/configdb/ConfigDbInterfaceServiceTest.java index 885a9171..28e157c8 100644 --- a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/configdb/ConfigDbInterfaceServiceTest.java +++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/configdb/ConfigDbInterfaceServiceTest.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. @@ -126,6 +126,7 @@ public class ConfigDbInterfaceServiceTest { } + @Test public void fetchServiceProfile() { Map<String,String> responseMap=new HashMap<String, String>(); responseMap.put("sNSSAI", "001-010"); @@ -136,5 +137,34 @@ public class ConfigDbInterfaceServiceTest { .thenReturn(new ResponseEntity<Object>(responseMap, HttpStatus.OK)); assertEquals(responseMap, configdbservice.fetchServiceDetails("snssai")); } + + @Test + public void fetchCUCPCellsOfSnssaiTest() { + Map<String, List<CellsModel>> response = new HashMap<>(); + List<CellsModel> cellslist = new ArrayList<>(); + List<CellsModel> cellslist1 = new ArrayList<>(); + CellsModel cellsmodel1 = new CellsModel(); + cellsmodel1.setCellLocalId("1111"); + CellsModel cellsmodel2 = new CellsModel(); + cellsmodel2.setCellLocalId("2222"); + cellslist.add(cellsmodel1); + cellslist.add(cellsmodel2); + response.put("1", cellslist); + CellsModel cellsmodel3 = new CellsModel(); + cellsmodel3.setCellLocalId("3333"); + CellsModel cellsmodel4 = new CellsModel(); + cellsmodel4.setCellLocalId("4444"); + cellslist1.add(cellsmodel3); + cellslist1.add(cellsmodel4); + response.put("2", cellslist1); + Mockito.when(restclient.sendGetRequest(Mockito.anyString(), Mockito.any())) + .thenReturn(new ResponseEntity<Object>(response, HttpStatus.OK)); + List<String> outputlist = new ArrayList<>(); + outputlist.add("1111"); + outputlist.add("2222"); + Map<String, List<String>> output = configdbservice.fetchCUCPCellsOfSnssai("snssai"); + assertEquals(outputlist, output.get("1")); + + } } diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/MLMessageProcessorTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/MLMessageProcessorTest.java index 387b5fd0..708ba7e4 100644 --- a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/MLMessageProcessorTest.java +++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/MLMessageProcessorTest.java @@ -97,7 +97,7 @@ public class MLMessageProcessorTest { } catch (IOException e) { e.printStackTrace(); } - when(configDbService.fetchRICsOfSnssai("0001-0111")).thenReturn(ricToCellMapping); + when(configDbService.fetchCUCPCellsOfSnssai("0001-0111")).thenReturn(ricToCellMapping); AdditionalProperties<MLOutputModel> addProps = new AdditionalProperties<>(); addProps.setResourceConfig(mloutputExp); doNothing().when(policyService).sendOnsetMessageToPolicy(anyString(), any(AdditionalProperties.class), diff --git a/components/slice-analysis-ms/src/test/resources/aaiDetailsList.json b/components/slice-analysis-ms/src/test/resources/aaiDetailsList.json index e538e220..4f306f34 100644 --- a/components/slice-analysis-ms/src/test/resources/aaiDetailsList.json +++ b/components/slice-analysis-ms/src/test/resources/aaiDetailsList.json @@ -44,9 +44,9 @@ "service-instance-id":"ab9af40f13f7219099333", "service-instance-name":"an_sp_1", "service-type":"00-000", - "service-role":"slice-profile-instance", + "service-role":"slice-profile", "environment-context":"001-00110", - "workload-context":"ÁN-NF", + "workload-context":"AN-NF", "service-instance-location-id":"[\"460-00\",\"460-01\"]", "resource-version":"1613715676282", "orchestration-status":"deactivated" diff --git a/components/slice-analysis-ms/version.properties b/components/slice-analysis-ms/version.properties index 612bdf05..299692b9 100644 --- a/components/slice-analysis-ms/version.properties +++ b/components/slice-analysis-ms/version.properties @@ -21,7 +21,7 @@ ############################################################################### major=1 minor=1 -patch=1 +patch=2 base_version=${major}.${minor}.${patch} release_version=${base_version} snapshot_version=${base_version}-SNAPSHOT |