aboutsummaryrefslogtreecommitdiffstats
path: root/ransim
diff options
context:
space:
mode:
authorNiranjana <niranjana.y60@wipro.com>2021-04-28 05:33:51 +0000
committerNiranjana <niranjana.y60@wipro.com>2021-05-05 11:03:26 +0000
commitf627071458fd90ad2d35f2e7bc027f3831cb4df3 (patch)
treee489e844f49ac994fbd9260758f0786ef417cb66 /ransim
parent959c9cf80775c4b1e5d78f299a441ce9fe9bd9d3 (diff)
Add Intelligent slicing data code changes
Issue-ID: INT-1917 Signed-off-by: Niranjana <niranjana.y60@wipro.com> Change-Id: I7c56ac4db09cca3bf242ce2dc3e1e78e02d20b9b
Diffstat (limited to 'ransim')
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/netconf/NetconfClient.java81
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/models/PLMNInfoModel.java31
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/rest/api/services/RansimControllerServices.java172
-rw-r--r--ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/server/RansimWebSocketServer.java1
4 files changed, 231 insertions, 54 deletions
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/netconf/NetconfClient.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/netconf/NetconfClient.java
index f4dc174..e3a4261 100644
--- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/netconf/NetconfClient.java
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/netconf/NetconfClient.java
@@ -30,6 +30,7 @@ import java.io.IOException;
import java.net.ConnectException;
import org.apache.log4j.Logger;
+import org.onap.ransim.rest.api.models.PLMNInfoModel;
import org.onap.ransim.rest.web.mapper.GNBCUCPModel;
import org.onap.ransim.rest.web.mapper.GNBCUUPModel;
import org.onap.ransim.rest.web.mapper.GNBDUModel;
@@ -211,6 +212,86 @@ public class NetconfClient {
}
+ public Element sendIntelligentSlicingData(PLMNInfoModel pLMNInfoModel, String serverId) {
+ try {
+ log.info("sending Intelligent Slicing netconf data");
+ Element ranNetworkElement =
+ Element.create("org:onap:ccsdk:features:sdnr:northbound:ran-network", "/ran-network");
+ Element nearRTRICElement =
+ Element.create("org:onap:ccsdk:features:sdnr:northbound:ran-network", "/NearRTRIC");
+ Element idNearRTRICElement =
+ Element.create("org:onap:ccsdk:features:sdnr:northbound:ran-network", "/idNearRTRIC");
+ idNearRTRICElement.setValue(pLMNInfoModel.getNearrtricid());
+
+ Element gNBCUCPFunctionElement =
+ Element.create("org:onap:ccsdk:features:sdnr:northbound:ran-network", "/GNBCUCPFunction");
+ Element idGNBCUCPFunctionElement =
+ Element.create("org:onap:ccsdk:features:sdnr:northbound:ran-network", "/idGNBCUCPFunction");
+ idGNBCUCPFunctionElement.setValue(pLMNInfoModel.getGnbId());
+
+ Element nRCellCUElement =
+ Element.create("org:onap:ccsdk:features:sdnr:northbound:ran-network", "/NRCellCU");
+ Element idNRCellCUElement =
+ Element.create("org:onap:ccsdk:features:sdnr:northbound:ran-network", "/idNRCellCU");
+ idNRCellCUElement.setValue(pLMNInfoModel.getConfigParameter());
+ Element nRCellattributesElement =
+ Element.create("org:onap:ccsdk:features:sdnr:northbound:ran-network", "/attributes");
+ Element pLMNInfoListElement =
+ Element.create("org:onap:ccsdk:features:sdnr:northbound:ran-network", "/pLMNInfoList");
+ Element mccElement = Element.create("org:onap:ccsdk:features:sdnr:northbound:ran-network", "/mcc");
+ Element mncElement = Element.create("org:onap:ccsdk:features:sdnr:northbound:ran-network", "/mnc");
+ String[] plmn = pLMNInfoModel.getpLMNId().split("-");
+ log.info("plmn list" + plmn);
+ mccElement.setValue(plmn[0]);
+ mncElement.setValue(plmn[1]);
+ Element sNSSAIListElement =
+ Element.create("org:onap:ccsdk:features:sdnr:northbound:ran-network", "/sNSSAIList");
+ Element sNssaiElement = Element.create("org:onap:ccsdk:features:sdnr:northbound:ran-network", "/sNssai");
+ sNssaiElement.setValue(pLMNInfoModel.getSnssai());
+ Element statusElement = Element.create("org:onap:ccsdk:features:sdnr:northbound:ran-network", "/status");
+ statusElement.setValue(pLMNInfoModel.getStatus());
+ Element configDataElement =
+ Element.create("org:onap:ccsdk:features:sdnr:northbound:ran-network", "/configData");
+ Element configParameterElement =
+ Element.create("org:onap:ccsdk:features:sdnr:northbound:ran-network", "/configParameter");
+ configParameterElement.setValue("maxNumberOfConns");
+ Element configValueElement =
+ Element.create("org:onap:ccsdk:features:sdnr:northbound:ran-network", "/configValue");
+ configValueElement.setValue(pLMNInfoModel.getConfigValue());
+
+ configDataElement.addChild(configParameterElement);
+ configDataElement.addChild(configValueElement);
+
+ sNSSAIListElement.markReplace();
+ sNSSAIListElement.addChild(sNssaiElement);
+ sNSSAIListElement.addChild(statusElement);
+ sNSSAIListElement.addChild(configDataElement);
+
+ pLMNInfoListElement.addChild(mccElement);
+ pLMNInfoListElement.addChild(mncElement);
+ pLMNInfoListElement.addChild(sNSSAIListElement);
+
+ nRCellattributesElement.addChild(pLMNInfoListElement);
+ nRCellCUElement.addChild(idNRCellCUElement);
+ nRCellCUElement.addChild(nRCellattributesElement);
+
+ gNBCUCPFunctionElement.addChild(idGNBCUCPFunctionElement);
+ gNBCUCPFunctionElement.addChild(nRCellCUElement);
+
+ nearRTRICElement.addChild(idNearRTRICElement);
+ nearRTRICElement.addChild(gNBCUCPFunctionElement);
+
+ ranNetworkElement.addChild(nearRTRICElement);
+ ranNetworkElement.markMerge();
+ return ranNetworkElement;
+
+ } catch (JNCException e) {
+ log.error("Exception occured during NodeSet creation {}", e);
+ return null;
+ }
+
+ }
+
public void editConfig(Element initialConfig) {
try {
Boolean connected = false;
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 fd674bc..bdeb9b2 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
@@ -28,14 +28,15 @@ public class PLMNInfoModel {
private int gnbId;
private int nrCellId;
private String nearrtricid;
- private long maxNumberOfConns;
+ private String configParameter;
+ private Integer configValue;
public PLMNInfoModel() {
}
public PLMNInfoModel(String pLMNId, String snssai, String status, String gnbType, int gnbId, int nrCellId,
- String nearrtricid, long maxNumberOfConns) {
+ String nearrtricid, String configParameter, Integer configValue) {
super();
this.pLMNId = pLMNId;
this.snssai = snssai;
@@ -44,7 +45,8 @@ public class PLMNInfoModel {
this.gnbId = gnbId;
this.nrCellId = nrCellId;
this.nearrtricid = nearrtricid;
- this.maxNumberOfConns = maxNumberOfConns;
+ this.configParameter = configParameter;
+ this.configValue = configValue;
}
public String getpLMNId() {
@@ -103,11 +105,26 @@ public class PLMNInfoModel {
this.nearrtricid = nearrtricid;
}
- public long getMaxNumberOfConns() {
- return maxNumberOfConns;
+ public String getConfigParameter() {
+ return configParameter;
}
- public void setMaxNumberOfConns(long maxNumberOfConns) {
- this.maxNumberOfConns = maxNumberOfConns;
+ public void setConfigParameter(String configParameter) {
+ this.configParameter = configParameter;
+ }
+
+ public Integer getConfigValue() {
+ return configValue;
+ }
+
+ public void setConfigValue(Integer configValue) {
+ this.configValue = configValue;
+ }
+
+ @Override
+ public String toString() {
+ return "PLMNInfoModel [pLMNId=" + pLMNId + ", snssai=" + snssai + ", status=" + status + ", gnbType=" + gnbType
+ + ", gnbId=" + gnbId + ", nrCellId=" + nrCellId + ", nearrtricid=" + nearrtricid + ", configParameter="
+ + configParameter + ", configValue=" + configValue + "]";
}
}
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 6197751..571994c 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
@@ -20,6 +20,7 @@
package org.onap.ransim.rest.api.services;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import java.io.BufferedReader;
@@ -64,6 +65,7 @@ import org.onap.ransim.rest.api.models.TopologyDump;
import org.onap.ransim.rest.api.repository.GNBCUUPRepository;
import org.onap.ransim.rest.api.repository.NRCellCURepository;
import org.onap.ransim.rest.api.repository.NRCellDURepository;
+import org.onap.ransim.rest.api.repository.NetconfServersRepo;
import org.onap.ransim.rest.api.repository.RRMPolicyRepository;
import org.onap.ransim.rest.api.repository.SliceProfileRepository;
import org.onap.ransim.rest.client.RestClient;
@@ -151,6 +153,9 @@ public class RansimControllerServices {
@Autowired
GNBCUUPRepository gNBCUUPRepository;
+
+ @Autowired
+ NetconfServersRepo netconfServersRepo;
/*
* @Autowired
* PLMNInfoRepo pLMNInfoRepo;
@@ -1220,54 +1225,59 @@ public class RansimControllerServices {
List<PLMNInfo> pLMNInfoList = null;
org.onap.ransim.rest.api.models.PLMNInfoModel plmnInfoModel =
new Gson().fromJson(message, org.onap.ransim.rest.api.models.PLMNInfoModel.class);
- PLMNInfo plmnInfo = new PLMNInfo();
- NSSAIConfig nSSAIConfig = new NSSAIConfig();
- nSSAIConfig.setMaxNumberOfConns((int) (plmnInfoModel.getMaxNumberOfConns()));
- org.onap.ransim.rest.api.models.SNSSAI sNSSAI = new org.onap.ransim.rest.api.models.SNSSAI();
- sNSSAI.setsNSSAI(plmnInfoModel.getSnssai());
- sNSSAI.setStatus(plmnInfoModel.getStatus());
- sNSSAI.setConfigData(nSSAIConfig);
- plmnInfo.setpLMNId(plmnInfoModel.getpLMNId());
- plmnInfo.setsNSSAI(sNSSAI);
- try {
- if (plmnInfoModel.getGnbType().equalsIgnoreCase("gnbdu")) {
- org.onap.ransim.rest.api.models.NRCellDU nrCellDu =
- nRCellDURepository.findById(plmnInfoModel.getNrCellId()).get();
- if (!(Objects.isNull(nrCellDu.getpLMNInfoList()))) {
- pLMNInfoList = nrCellDu.getpLMNInfoList();
- } else {
- pLMNInfoList = new ArrayList<PLMNInfo>();
- }
- pLMNInfoList.add(plmnInfo);
- nrCellDu.setpLMNInfoList(pLMNInfoList);
- nRCellDURepository.save(nrCellDu);
- } else if (plmnInfoModel.getGnbType().equalsIgnoreCase("gnbcucp")) {
- org.onap.ransim.rest.api.models.NRCellCU nrCellCu =
- nRCellCURepository.findById(plmnInfoModel.getNrCellId()).get();
- if (!(Objects.isNull(nrCellCu.getpLMNInfoList()))) {
- pLMNInfoList = nrCellCu.getpLMNInfoList();
- } else {
- pLMNInfoList = new ArrayList<PLMNInfo>();
- }
- pLMNInfoList.add(plmnInfo);
- nrCellCu.setpLMNInfoList(pLMNInfoList);
- nRCellCURepository.save(nrCellCu);
- } else {
- org.onap.ransim.rest.api.models.GNBCUUPFunction gNBCUUPFunction =
- gNBCUUPRepository.findById(plmnInfoModel.getGnbId()).get();
- if (!(Objects.isNull(gNBCUUPFunction.getpLMNInfoList()))) {
- pLMNInfoList = gNBCUUPFunction.getpLMNInfoList();
+ if (!(plmnInfoModel.getConfigParameter().equalsIgnoreCase("maxNumberOfConns"))
+ && plmnInfoModel.getGnbType().equalsIgnoreCase("gnbcucp")) {
+ handleIntelligentSlicingDataFromSdnr(message, session, ipPort);
+ } else {
+ PLMNInfo plmnInfo = new PLMNInfo();
+ NSSAIConfig nSSAIConfig = new NSSAIConfig();
+ nSSAIConfig.setMaxNumberOfConns(plmnInfoModel.getConfigValue());
+ org.onap.ransim.rest.api.models.SNSSAI sNSSAI = new org.onap.ransim.rest.api.models.SNSSAI();
+ sNSSAI.setsNSSAI(plmnInfoModel.getSnssai());
+ sNSSAI.setStatus(plmnInfoModel.getStatus());
+ sNSSAI.setConfigData(nSSAIConfig);
+ plmnInfo.setpLMNId(plmnInfoModel.getpLMNId());
+ plmnInfo.setsNSSAI(sNSSAI);
+ try {
+ if (plmnInfoModel.getGnbType().equalsIgnoreCase("gnbdu")) {
+ org.onap.ransim.rest.api.models.NRCellDU nrCellDu =
+ nRCellDURepository.findById(plmnInfoModel.getNrCellId()).get();
+ if (!(Objects.isNull(nrCellDu.getpLMNInfoList()))) {
+ pLMNInfoList = nrCellDu.getpLMNInfoList();
+ } else {
+ pLMNInfoList = new ArrayList<PLMNInfo>();
+ }
+ pLMNInfoList.add(plmnInfo);
+ nrCellDu.setpLMNInfoList(pLMNInfoList);
+ nRCellDURepository.save(nrCellDu);
+ } else if (plmnInfoModel.getGnbType().equalsIgnoreCase("gnbcucp")) {
+ org.onap.ransim.rest.api.models.NRCellCU nrCellCu =
+ nRCellCURepository.findById(plmnInfoModel.getNrCellId()).get();
+ if (!(Objects.isNull(nrCellCu.getpLMNInfoList()))) {
+ pLMNInfoList = nrCellCu.getpLMNInfoList();
+ } else {
+ pLMNInfoList = new ArrayList<PLMNInfo>();
+ }
+ pLMNInfoList.add(plmnInfo);
+ nrCellCu.setpLMNInfoList(pLMNInfoList);
+ nRCellCURepository.save(nrCellCu);
} else {
- pLMNInfoList = new ArrayList<PLMNInfo>();
+ org.onap.ransim.rest.api.models.GNBCUUPFunction gNBCUUPFunction =
+ gNBCUUPRepository.findById(plmnInfoModel.getGnbId()).get();
+ if (!(Objects.isNull(gNBCUUPFunction.getpLMNInfoList()))) {
+ pLMNInfoList = gNBCUUPFunction.getpLMNInfoList();
+ } else {
+ pLMNInfoList = new ArrayList<PLMNInfo>();
+ }
+ pLMNInfoList.add(plmnInfo);
+ gNBCUUPFunction.setpLMNInfoList(pLMNInfoList);
+ gNBCUUPRepository.save(gNBCUUPFunction);
}
- pLMNInfoList.add(plmnInfo);
- gNBCUUPFunction.setpLMNInfoList(pLMNInfoList);
- gNBCUUPRepository.save(gNBCUUPFunction);
+ } catch (NullPointerException nullPointerException) {
+ log.error("Record does not exist");
+ } catch (Exception e) {
+ log.error("Unexpected error while fetching data from database: " + e);
}
- } catch (NullPointerException nullPointerException) {
- log.error("Record does not exist");
- } catch (Exception e) {
- log.error("Unexpected error while fetching data from database: " + e);
}
}
@@ -1277,7 +1287,7 @@ public class RansimControllerServices {
new Gson().fromJson(message, org.onap.ransim.rest.api.models.PLMNInfoModel.class);
PLMNInfo plmnInfo = new PLMNInfo();
NSSAIConfig nSSAIConfig = new NSSAIConfig();
- nSSAIConfig.setMaxNumberOfConns((int) (plmnInfoModel.getMaxNumberOfConns()));
+ nSSAIConfig.setMaxNumberOfConns(plmnInfoModel.getConfigValue());
org.onap.ransim.rest.api.models.SNSSAI sNSSAI = new org.onap.ransim.rest.api.models.SNSSAI();
sNSSAI.setsNSSAI(plmnInfoModel.getSnssai());
sNSSAI.setStatus(plmnInfoModel.getStatus());
@@ -1299,6 +1309,76 @@ public class RansimControllerServices {
sliceProfileRepository.delete(sliceProfile);
}
+ public void handleIntelligentSlicingDataFromSdnr(String message, Session session, String ipPort) {
+
+ 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(":");
+ log.info("ip: " + ipPortlist[0]);
+ log.info("Port: " + ipPortlist[1]);
+ List<NetconfServers> netconfServers = (List<NetconfServers>) 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<GNBCUCPModel> gNBCUCPModelList = new ArrayList<>();
+ HttpHeaders headers = new HttpHeaders();
+ headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
+ HttpEntity<Void> requestEntity = new HttpEntity<>(headers);
+ try {
+ RestTemplate restTemplate = new RestTemplate();
+
+ ResponseEntity<List<GNBCUCPModel>> response = restTemplate.exchange(
+ "http://" + "localhost" + ":" + "8081" + "/ransim/api/ransim-db/v4/cucp-list/",
+ HttpMethod.GET, requestEntity, new ParameterizedTypeReference<List<GNBCUCPModel>>() {});
+ gNBCUCPModelList = response.getBody();
+ gNBCUCPModelList.forEach(gnb -> {
+ GNBCUCPModel gNBCUCPModel = gnb;
+ log.info("gNBCUCPModel: " + gNBCUCPModel.toString());
+ List<NRCellCUModel> nRCellCUModelList = gnb.getCellCUList();
+ for (NRCellCUModel nrcell : nRCellCUModelList) {
+ if ((int) nrcell.getCellLocalId() == Integer
+ .parseInt(plmnInfoModel.getConfigParameter())) {
+ plmnInfoModel.setGnbId(gnb.getgNBId());
+ List<PLMNInfoModel> 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.sendIntelligentSlicingData(plmnInfoModel, netconfServerId));
+ log.info("Intelligent Slicing Data sent successfully : ");
+ plmnInfoModel.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);
+ }
+
+ break;
+ }
+ }
+ });
+ } catch (Exception e) {
+ log.info("Exception:", e);
+ }
+ }
+ }
+ }
+ }
+
/**
* The function alters the database information based on the modifications made
* in the SDNR.
diff --git a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/server/RansimWebSocketServer.java b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/server/RansimWebSocketServer.java
index 3061fad..bbcf2ce 100644
--- a/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/server/RansimWebSocketServer.java
+++ b/ransim/ransimctrlr/RANSIM-CTRLR/src/main/java/org/onap/ransim/websocket/server/RansimWebSocketServer.java
@@ -146,7 +146,6 @@ public class RansimWebSocketServer {
log.info("Delete SliceProfile message received");
rscServices.handleSliceProfileDeleteFromSdnr(message.getMessage(), session, ipPort);
}
-
}
}
} catch (Exception e) {