From d629f558e1fafd8130f265ec3876fa85f5646ae4 Mon Sep 17 00:00:00 2001 From: malar Date: Wed, 19 Jan 2022 14:23:36 +0000 Subject: Fix bug in triggering control loop for PCI collision/confusion - by replacing Config DB with CPS Issue-ID: DCAEGEN2-3057 Signed-off-by: Malarvizhi Paramasivam Change-Id: I122022c1ad7e4dc007e8565bac694813d4a35bef --- Changelog.md | 4 ++ dpo/spec/sonhandler-componentspec.json | 8 ++-- pom.xml | 4 +- .../dcaegen2/services/sonhms/Configuration.java | 51 +++++++++++----------- .../services/sonhms/restclient/CpsClient.java | 23 +++++++--- .../services/sonhms/restclient/SdnrRestClient.java | 16 ++++--- .../services/sonhms/restclient/CpsClientTest.java | 19 ++++---- version.properties | 4 +- 8 files changed, 75 insertions(+), 54 deletions(-) diff --git a/Changelog.md b/Changelog.md index 5a0864b..caaf6b4 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,6 +4,10 @@ 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/). + +## [2.1.6] - 2022/02/07 + - [DCAEGEN2-3057](https://jira.onap.org/browse/DCAEGEN2-3057) - Fix bug in triggering control loop for PCI collision/confusion - by replacing Config DB with CPS + ## [2.1.5] - 2021/10/14 - [DCAEGEN2-2943](https://jira.onap.org/browse/DCAEGEN2-2943) - Fix bug in filtering new FM notification diff --git a/dpo/spec/sonhandler-componentspec.json b/dpo/spec/sonhandler-componentspec.json index 4133c73..6805f0c 100644 --- a/dpo/spec/sonhandler-componentspec.json +++ b/dpo/spec/sonhandler-componentspec.json @@ -273,7 +273,7 @@ "designer_editable": false }, { - "name": "sonhandler.get.cell.data.url", + "name": "cps.get.celldata", "value": "execute/cps-ran-schemaset/get-cell-list", "description": "Cps get cell data url", "sourced_at_deployment": false, @@ -281,7 +281,7 @@ "designer_editable": false }, { - "name": "sonhandler.get.nbr.list.url", + "name": "cps.get.nbr.list.url", "value": "execute/cps-ran-schemaset/get-nbr-list", "description": "Cps get nbr list url", "sourced_at_deployment": false, @@ -289,7 +289,7 @@ "designer_editable": false }, { - "name": "sonhandler.get.pci.url", + "name": "cps.get.pci.url", "value": "execute/ran-network-schemaset/get-pci", "description": "Cps get pci url", "sourced_at_deployment": false, @@ -297,7 +297,7 @@ "designer_editable": false }, { - "name": "sonhandler.get.pnf.url", + "name": "cps.get.pnf.url", "value": "execute/ran-network-schemaset/get-pnf", "description": "Cps get pnf url", "sourced_at_deployment": false, diff --git a/pom.xml b/pom.xml index 1102bfb..625e693 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ * ============LICENSE_START======================================================= * son-handler * ================================================================================ - * Copyright (C) 2019-2021 Wipro Limited. + * Copyright (C) 2019-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. @@ -27,7 +27,7 @@ org.onap.dcaegen2.services.son-handler son-handler dcaegen2-services-son-handler - 2.1.5-SNAPSHOT + 2.1.6-SNAPSHOT diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java b/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java index 2ddeaa6..1824e92 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * son-handler * ================================================================================ - * Copyright (C) 2019-2021 Wipro Limited. + * Copyright (C) 2019-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. @@ -390,28 +390,28 @@ public class Configuration { } public int getPolicyNegativeAckThreshold() { - return policyNegativeAckThreshold; - } + return policyNegativeAckThreshold; + } - public void setPolicyNegativeAckThreshold(int policyNegativeAckThreshold) { - this.policyNegativeAckThreshold = policyNegativeAckThreshold; - } + public void setPolicyNegativeAckThreshold(int policyNegativeAckThreshold) { + this.policyNegativeAckThreshold = policyNegativeAckThreshold; + } - public long getPolicyFixedPciTimeInterval() { - return policyFixedPciTimeInterval; - } + public long getPolicyFixedPciTimeInterval() { + return policyFixedPciTimeInterval; + } - public void setPolicyFixedPciTimeInterval(long policyFixedPciTimeInterval) { - this.policyFixedPciTimeInterval = policyFixedPciTimeInterval; - } + public void setPolicyFixedPciTimeInterval(long policyFixedPciTimeInterval) { + this.policyFixedPciTimeInterval = policyFixedPciTimeInterval; + } - public String getNfNamingCode() { - return nfNamingCode; - } + public String getNfNamingCode() { + return nfNamingCode; + } - public void setNfNamingCode(String nfNamingCode) { - this.nfNamingCode = nfNamingCode; - } + public void setNfNamingCode(String nfNamingCode) { + this.nfNamingCode = nfNamingCode; + } public static Logger getLog() { return log; @@ -465,13 +465,6 @@ public class Configuration { Configuration.instance = instance; } - public ConfigInterface getConfigurationClient() - { - ConfigInterface conf = ConfigurationClient.configClient(Configuration.getInstance().getConfigClientType()); - log.info("ConfigurationClient obj is : " + conf); - return conf; - } - @Override public String toString() { return "Configuration [pgHost=" + pgHost + ", pgPort=" + pgPort + ", pgUsername=" + pgUsername + ", pgPassword=" @@ -554,12 +547,18 @@ public class Configuration { getCellDataUrl = jsonObject.get("cps.get.celldata").getAsString(); getPnfUrl = jsonObject.get("cps.get.pnf.url").getAsString(); getPciUrl = jsonObject.get("cps.get.pci.url").getAsString(); + getNbrListUrl = jsonObject.get("cps.get.nbr.list.url").getAsString(); ConfigClientType = jsonObject.get("sonhandler.clientType").getAsString(); log.info("configuration from CBS {}", this); } - + public ConfigInterface getConfigurationClient() + { + ConfigInterface conf = ConfigurationClient.configClient(Configuration.getInstance().getConfigClientType()); + log.info("ConfigurationClient obj is : " + conf); + return conf; + } } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/CpsClient.java b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/CpsClient.java index f19c9e8..282fe91 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/CpsClient.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/CpsClient.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * son-handler * ================================================================================ - * Copyright (C) 2021 Wipro Limited. + * Copyright (C) 2021-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. @@ -65,9 +65,10 @@ public class CpsClient extends ConfigInterface { reqbody.put("inputParameters", inputparam); log.debug("request url: {}", requestUrl); String response = sendRequest(requestUrl, reqbody); + log.info("Response from CPS is : " + response); List nbrList = new ArrayList<>(); - - JSONArray nbrListObj = new JSONArray(response); + JSONObject responseJson = new JSONObject(response); + JSONArray nbrListObj = responseJson.getJSONArray("NRCellRelation"); for (int i = 0; i < nbrListObj.length(); i++) { JSONObject cellObj = nbrListObj.getJSONObject(i); JSONObject obj = cellObj.getJSONObject("attributes"); @@ -95,8 +96,11 @@ public class CpsClient extends ConfigInterface { inputparam.put("cellId", cellId); reqbody.put("inputParameters", inputparam); String response = sendRequest(requestUrl, reqbody); + log.info("Response from CPS is : " + response); JSONObject respObj = new JSONObject(response); - return respObj.getInt("value"); + int obj = respObj.getInt("nRPCI"); + log.info("The nRPCI value is " + obj ); + return respObj.getInt("nRPCI"); } /** @@ -107,14 +111,20 @@ public class CpsClient extends ConfigInterface { @Override public String getPnfName(String cellId) throws CpsNotFoundException { Configuration configuration = Configuration.getInstance(); + String responseObject = ""; String requestUrl = configuration.getCpsServiceUrl() + "/" + configuration.getGetPnfUrl(); JSONObject inputparam = new JSONObject(); JSONObject reqbody = new JSONObject(); inputparam.put("cellId", cellId); reqbody.put("inputParameters", inputparam); String response = sendRequest(requestUrl, reqbody); - JSONObject responseObject = new JSONObject(response); - return responseObject.getString("value"); + log.info("Response from CPS is : " + response); + JSONArray requestArray = new JSONArray(response); + for (int i=0;i nbrList = new ArrayList<>(); JSONObject responseJson = new JSONObject(response); JSONArray nbrListObj = responseJson.getJSONArray("nbrList"); @@ -94,6 +95,7 @@ public class SdnrRestClient extends ConfigInterface { String requestUrl = configuration.getConfigDbService() + "/api/sdnc-config-db/v3/getPCI" + "/" + cellId + "/" + ts; String response = sendRequest(requestUrl); + log.info("Response from configdb getPci is : " + response); JSONObject respObj = new JSONObject(response); return respObj.getInt("value"); } @@ -112,6 +114,7 @@ public class SdnrRestClient extends ConfigInterface { String requestUrl = configuration.getConfigDbService() + "/api/sdnc-config-db/v3/getPnfId" + "/" + cellId + "/" + ts; String response = sendRequest(requestUrl); + log.info("Response from configdb getPnfName is : " + response); JSONObject responseObject = new JSONObject(response); return responseObject.getString("value"); } @@ -125,11 +128,12 @@ public class SdnrRestClient extends ConfigInterface { @Override public JSONObject getCellData(String cellId) throws ConfigDbNotFoundException { - Configuration configuration = Configuration.getInstance(); - String requestUrl = configuration.getConfigDbService() + "/api/sdnc-config-db/v3/getCell" + "/" + cellId; - String response = sendRequest(requestUrl); - JSONObject responseObject = new JSONObject(response); - return responseObject; + Configuration configuration = Configuration.getInstance(); + String requestUrl = configuration.getConfigDbService() + "/api/sdnc-config-db/v3/getCell" + "/" + cellId; + String response = sendRequest(requestUrl); + log.info("Response from configdb getCellData is : " + response); + JSONObject responseObject = new JSONObject(response); + return responseObject; } diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/CpsClientTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/CpsClientTest.java index a531b4d..e43a635 100644 --- a/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/CpsClientTest.java +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/CpsClientTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * son-handler * ================================================================================ - * Copyright (C) 2021 Wipro Limited. + * Copyright (C) 2021-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. @@ -103,7 +103,7 @@ public class CpsClientTest { @Test public void getPciTest() { - String responseBody = "{\n" + " \"attribute-name\": \"string\",\n" + " \"value\": 0\n" + "}"; + String responseBody = "{\n" + " \"nRPCI\": \"11\",\n" + " \"value\": 0\n" + "}"; PowerMockito.mockStatic(SonHandlerRestTemplate.class); PowerMockito.mockStatic(Configuration.class); PowerMockito.when(Configuration.getInstance()).thenReturn(configuration); @@ -116,7 +116,7 @@ public class CpsClientTest { int result = cps.getPci("1"); String response = ResponseEntity.ok(responseBody).getBody(); JSONObject respObj = new JSONObject(response); - assertEquals(respObj.getInt("value"), result); + assertEquals(respObj.getInt("nRPCI"), result); } catch (CpsNotFoundException e) { log.debug("CpsNotFoundException {}", e.toString()); ; @@ -127,7 +127,7 @@ public class CpsClientTest { @Test public void getPnfNameTest() { - String responseBody = "{\n" + " \"attribute-name\": \"string\",\n" + " \"value\": \"string\"\n" + "}"; + String responseBody = "[{\n" + " \"idGNBCUCPFunction\": \"cucpserver1\",\n" + " \"value\": \"string\"\n" + "}]"; PowerMockito.mockStatic(SonHandlerRestTemplate.class); PowerMockito.mockStatic(Configuration.class); PowerMockito.when(Configuration.getInstance()).thenReturn(configuration); @@ -136,10 +136,13 @@ public class CpsClientTest { Matchers.>any())) .thenReturn(ResponseEntity.ok(responseBody)); try { - String result = cps.getPnfName("1"); + String result = cps.getPnfName("cucpserver1"); String response = ResponseEntity.ok(responseBody).getBody(); - JSONObject respObj = new JSONObject(response); - assertEquals(respObj.getString("value"), result); + + JSONArray requestArray = new JSONArray(response); + for (int i=0;i