[SLICEANALYSIS] Filter RAN related service instances in AAI and Fetch CU Cells data... 59/128959/4
authorNiranjana <niranjana.y60@wipro.com>
Thu, 28 Apr 2022 14:14:44 +0000 (14:14 +0000)
committerNiranjana <niranjana.y60@wipro.com>
Fri, 29 Apr 2022 15:25:44 +0000 (15:25 +0000)
Issue-ID: DCAEGEN2-3145
Issue-ID: DCAEGEN2-3146
Signed-off-by: Niranjana <niranjana.y60@wipro.com>
Change-Id: I5c53bc05f43de09554b02a763d7f5c22435c9962

12 files changed:
components/slice-analysis-ms/ChangeLog.md
components/slice-analysis-ms/pom.xml
components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/aai/AaiService.java
components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/configdb/ConfigDbInterfaceService.java
components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/configdb/IConfigDbService.java
components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/cps/CpsInterface.java
components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/cps/CpsService.java
components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/MLMessageProcessor.java
components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/configdb/ConfigDbInterfaceServiceTest.java
components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/MLMessageProcessorTest.java
components/slice-analysis-ms/src/test/resources/aaiDetailsList.json
components/slice-analysis-ms/version.properties

index d8ef627..b58a17d 100644 (file)
@@ -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
 
index 1f68fe5..afcc6f6 100644 (file)
@@ -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>
index ab67c03..9459b64 100644 (file)
@@ -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");
                 }
             }
index 50a60ac..3e41fbe 100644 (file)
@@ -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;
+        }
+
 }
 
index 2b92b09..f34fcc9 100644 (file)
@@ -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);
 }
 
index 95e7340..d6a187c 100644 (file)
@@ -37,4 +37,6 @@ public interface CpsInterface {
 
     public Map<String, Map<String, Object>> fetchCurrentConfigurationOfRIC(String snssai);
 
+    public Map<String, List<String>> fetchnrCellCUsOfSnssai(String snssai);
+
 }
index 27f37ab..a9562e5 100644 (file)
@@ -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;
     }
 }
index f692efc..d1d2a15 100644 (file)
@@ -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);
     }
 
index 885a917..28e157c 100644 (file)
@@ -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"));
+
+        }
 }
 
index 387b5fd..708ba7e 100644 (file)
@@ -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),
index e538e22..4f306f3 100644 (file)
@@ -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"
index 612bdf0..299692b 100644 (file)
@@ -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