From 8ea7b39efe67d3af3236948782f3046d2a858a3a Mon Sep 17 00:00:00 2001 From: Niranjana Date: Wed, 25 Aug 2021 14:29:52 +0000 Subject: Fix bug in intelligent-slicing part Issue-ID: INT-1961 Signed-off-by: Niranjana Change-Id: Ibef2149b8bc36a929adbd8eb6406600c9f1f6810 --- .../onap/ransim/rest/api/models/PLMNInfoModel.java | 8 +- .../api/services/RansimControllerServices.java | 102 ++++++++++----------- 2 files changed, 52 insertions(+), 58 deletions(-) diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/PLMNInfoModel.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/PLMNInfoModel.java index cab1c47..1151ef9 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/PLMNInfoModel.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/PLMNInfoModel.java @@ -30,7 +30,7 @@ public class PLMNInfoModel { private String status; private String gnbType; private String gnbId; - private int nrCellId; + private Integer nrCellId; private String nearrtricid; private List configData; @@ -38,7 +38,7 @@ public class PLMNInfoModel { } - public PLMNInfoModel(String pLMNId, String snssai, String status, String gnbType, String gnbId, int nrCellId, + public PLMNInfoModel(String pLMNId, String snssai, String status, String gnbType, String gnbId, Integer nrCellId, String nearrtricid, List configData) { super(); this.pLMNId = pLMNId; @@ -91,11 +91,11 @@ public class PLMNInfoModel { this.gnbId = gnbId; } - public int getNrCellId() { + public Integer getNrCellId() { return nrCellId; } - public void setNrCellId(int nrCellId) { + public void setNrCellId(Integer nrCellId) { this.nrCellId = nrCellId; } diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/RansimControllerServices.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/RansimControllerServices.java index 235bc80..514666f 100644 --- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/RansimControllerServices.java +++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/RansimControllerServices.java @@ -1379,66 +1379,60 @@ public class RansimControllerServices { log.info("handle Intelligent Slicing data From Sdnr : " + message); org.onap.ransim.rest.api.models.PLMNInfoModel plmnInfoModel = new Gson().fromJson(message, org.onap.ransim.rest.api.models.PLMNInfoModel.class); - String[] ipPortlist = ipPort.split(":"); - List netconfServers = (List) netconfServersRepo.findAll(); - for (NetconfServers server : netconfServers) { - if (!(Objects.isNull(server.getNetconfPort()))) { - if (server.getNetconfPort().equalsIgnoreCase(ipPortlist[1].trim())) { - String netconfServerId = server.getServerId(); - log.info("netconfServerId: " + netconfServerId); - List gNBCUCPModelList = new ArrayList<>(); - HttpHeaders headers = new HttpHeaders(); - headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); - HttpEntity requestEntity = new HttpEntity<>(headers); - try { - RestTemplate restTemplate = new RestTemplate(); - - ResponseEntity> response = restTemplate.exchange( - "http://" + "localhost" + ":" + "8081" + "/ransim/api/ransim-db/v4/cucp-list/", - HttpMethod.GET, requestEntity, new ParameterizedTypeReference>() {}); - gNBCUCPModelList = response.getBody(); - gNBCUCPModelList.forEach(gnb -> { - GNBCUCPModel gNBCUCPModel = gnb; - log.info("gNBCUCPModel: " + gNBCUCPModel.toString()); - List nRCellCUModelList = gnb.getCellCUList(); - for (NRCellCUModel nrcell : nRCellCUModelList) { - if ((int) nrcell.getCellLocalId() == Integer - .parseInt(plmnInfoModel.getConfigData().get(0).getConfigParameter())) { - plmnInfoModel.setGnbId(Integer.toString(gnb.getgNBId())); - List pLMNInfoModelList = nrcell.getpLMNInfoList(); - pLMNInfoModelList.forEach(plmn -> { - if (plmn.getpLMNId().equalsIgnoreCase(plmnInfoModel.getpLMNId())) { - if (plmn.getsNSSAI().getsNSSAI() - .equalsIgnoreCase(plmnInfoModel.getSnssai())) { - plmnInfoModel.setStatus(plmn.getsNSSAI().getStatus()); - log.info("plmn status set"); - } - } - }); - NetconfClient netconfClient = new NetconfClient("ransim", "admin", "admin", - netconfServerId, server.getIp(), Integer.parseInt(server.getNetconfPort())); - - netconfClient.editConfig(netconfClient - .sendUpdatedPLMNInfoForIntelligentSlicing(plmnInfoModel, netconfServerId)); - log.info("Intelligent Slicing Data sent successfully : "); - plmnInfoModel.getConfigData().get(0).setConfigParameter("maxNumberOfConns"); - try { - ObjectMapper obj = new ObjectMapper(); - String plmnString = obj.writeValueAsString(plmnInfoModel); - handlePLMNInfoUpdateFromSdnr(plmnString, session, ipPort); - } catch (Exception e) { - log.info("Exception while parsing:", e); + plmnInfoModel.getConfigData().get(0).setConfigParameter("maxNumberOfConns"); + log.info("plmnInfoModel: " + plmnInfoModel.toString()); + List gNBCUCPModelList = new ArrayList<>(); + HttpHeaders headers = new HttpHeaders(); + headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); + HttpEntity requestEntity = new HttpEntity<>(headers); + try { + RestTemplate restTemplate = new RestTemplate(); + + ResponseEntity> response = restTemplate.exchange( + "http://" + "localhost" + ":" + "8081" + "/ransim/api/ransim-db/v4/cucp-list/", HttpMethod.GET, + requestEntity, new ParameterizedTypeReference>() {}); + gNBCUCPModelList = response.getBody(); + gNBCUCPModelList.forEach(gnb -> { + GNBCUCPModel gNBCUCPModel = gnb; + log.info("gNBCUCPModel: " + gNBCUCPModel.toString()); + List nRCellCUModelList = gnb.getCellCUList(); + for (NRCellCUModel nrcell : nRCellCUModelList) { + if (nrcell.getCellLocalId().equals(plmnInfoModel.getNrCellId())) { + plmnInfoModel.setGnbId(gnb.getgNBCUName()); + List pLMNInfoModelList = nrcell.getpLMNInfoList(); + pLMNInfoModelList.forEach(plmn -> { + if (plmn.getpLMNId().equalsIgnoreCase(plmnInfoModel.getpLMNId())) { + if (plmn.getsNSSAI().getsNSSAI().equalsIgnoreCase(plmnInfoModel.getSnssai())) { + if (Objects.isNull(plmnInfoModel.getStatus())) { + plmnInfoModel.setStatus(plmn.getsNSSAI().getStatus()); + log.info("plmn status set"); } - - break; } } }); - } catch (Exception e) { - log.info("Exception:", e); + String serverId = plmnInfoModel.getGnbId(); + String ipPortKey = serverIdIpPortMapping.get(serverId); + String[] ipPortlist = ipPortKey.split(":"); + NetconfClient netconfClient = new NetconfClient("ransim", "admin", "admin", serverId, + ipPortlist[0], Integer.parseInt(ipPortlist[1])); + + netconfClient.editConfig( + netconfClient.sendUpdatedPLMNInfoForIntelligentSlicing(plmnInfoModel, serverId)); + log.info("Intelligent Slicing Data sent successfully : "); + try { + ObjectMapper obj = new ObjectMapper(); + String plmnString = obj.writeValueAsString(plmnInfoModel); + handlePLMNInfoUpdateFromSdnr(plmnString, session, ipPort); + } catch (Exception e) { + log.info("Exception while parsing:", e); + } + + break; } } - } + }); + } catch (Exception e) { + log.info("Exception:", e); } } -- cgit 1.2.3-korg