summaryrefslogtreecommitdiffstats
path: root/sdnr
diff options
context:
space:
mode:
authorRavi Pendurty <ravi.pendurty@highstreet-technologies.com>2021-04-27 10:12:46 +0200
committerRavi Pendurty <ravi.pendurty@highstreet-technologies.com>2021-04-29 15:03:21 +0200
commit3cb21ac46f62e5c03afef0584af8472a3bb6b13b (patch)
tree2a4f24d31c1dbf888642afa7d588c0f2efd6a5dc /sdnr
parent05fe114a5969727c32cd9f1051cd7b9fde0344d5 (diff)
Support IPv6 address
Mountpoints can be created with IPv6 address from VES PNFRegistration messages Issue-ID: CCSDK-3257 Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com> Change-Id: Ia9cde6db1d76599cfd24d95e987728fc7c39106c Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
Diffstat (limited to 'sdnr')
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPPNFRegVESMsgConsumer.java41
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/PNFMountPointClient.java35
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestDMaaPPNFRegVESMsgConsumer.java3
3 files changed, 59 insertions, 20 deletions
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPPNFRegVESMsgConsumer.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPPNFRegVESMsgConsumer.java
index b64f6c689..1d70077b9 100644
--- a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPPNFRegVESMsgConsumer.java
+++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPPNFRegVESMsgConsumer.java
@@ -21,6 +21,7 @@ package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
+import org.eclipse.jdt.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -43,19 +44,25 @@ public class DMaaPPNFRegVESMsgConsumer extends DMaaPVESMsgConsumerImpl {
@Override
public void processMsg(String msg) {
LOG.debug("Message from DMaaP topic is - {} ", msg);
+ @Nullable
String pnfId;
- String pnfIPv4Address;
+ String pnfIPAddress;
+ @Nullable
String pnfCommProtocol;
+ @Nullable
String pnfCommPort;
+ @Nullable
String pnfKeyId = null;
+ @Nullable
String pnfUsername;
+ @Nullable
String pnfPasswd = null;
ObjectMapper oMapper = new ObjectMapper();
JsonNode dmaapMessageRootNode;
try {
dmaapMessageRootNode = oMapper.readTree(msg);
pnfId = dmaapMessageRootNode.at("/event/commonEventHeader/sourceName").textValue();
- pnfIPv4Address = dmaapMessageRootNode.at("/event/pnfRegistrationFields/oamV4IpAddress").textValue();
+ pnfIPAddress = getPNFIPAddress(dmaapMessageRootNode);
pnfCommProtocol =
dmaapMessageRootNode.at("/event/pnfRegistrationFields/additionalFields/protocol").textValue();
pnfCommPort = dmaapMessageRootNode.at("/event/pnfRegistrationFields/additionalFields/oamPort").textValue();
@@ -89,8 +96,9 @@ public class DMaaPPNFRegVESMsgConsumer extends DMaaPVESMsgConsumerImpl {
pnfPasswd = DEFAULT_PASSWORD;
}
- LOG.debug("PNF Fields - {} : {} : {} : {} : {} : {} : {}", pnfId, pnfIPv4Address, pnfCommProtocol, pnfKeyId,
- pnfUsername, pnfPasswd, pnfCommPort);
+ LOG.debug(
+ "PNF Fields - ID - {} : IP Address - {} : Protocol - {} : TLS Key ID - {} : User - {} : Port - {}",
+ pnfId, pnfIPAddress, pnfCommProtocol, pnfKeyId, pnfUsername, pnfCommPort);
String baseUrl = getBaseUrl();
String sdnrUser = getSDNRUser();
@@ -100,13 +108,16 @@ public class DMaaPPNFRegVESMsgConsumer extends DMaaPVESMsgConsumerImpl {
LOG.debug("Setting RESTConf Authorization values - {} : {}", sdnrUser, sdnrPasswd);
mountpointClient.setAuthorization(sdnrUser, sdnrPasswd);
- if ((null != pnfId) && (null != pnfIPv4Address) && (null != pnfCommProtocol) && (null != pnfUsername)
+ if ((null != pnfId) && null != pnfIPAddress && (null != pnfCommProtocol) && (null != pnfUsername)
&& (null != pnfCommPort)) {
- mountpointClient.pnfMountPointCreate(pnfId, pnfIPv4Address, pnfCommProtocol, pnfKeyId, pnfUsername,
+ mountpointClient.pnfMountPointCreate(pnfId, pnfIPAddress, pnfCommProtocol, pnfKeyId, pnfUsername,
pnfPasswd, pnfCommPort);
} else {
- LOG.warn("One of the mandatory fields has a null value - pnfId = {} : pnfIPv4Address = {} : pnfCommProtocol = {} : pnfUsername {} : "
- + "pnfCommPort {}", pnfId, pnfIPv4Address, pnfCommProtocol, pnfUsername, pnfCommPort, "- not invoking mountpoint creation");
+ LOG.warn(
+ "One of the mandatory fields has a null value - pnfId = {} : pnfIPAddress = {} : pnfCommProtocol = {} : pnfUsername {} : "
+ + "pnfCommPort {}",
+ pnfId, pnfIPAddress, pnfCommProtocol, pnfUsername, pnfCommPort,
+ "- not invoking mountpoint creation");
}
} catch (IOException e) {
LOG.info("Cannot parse json object, ignoring the received PNF Registration VES Message. Reason: {}",
@@ -114,6 +125,18 @@ public class DMaaPPNFRegVESMsgConsumer extends DMaaPVESMsgConsumerImpl {
}
}
+ private String getPNFIPAddress(JsonNode dmaapMessageRootNode) {
+ String ipAddress = dmaapMessageRootNode.at("/event/pnfRegistrationFields/oamV6IpAddress").textValue();
+ if (ipAddress != null && ipAddress != "")
+ return ipAddress;
+
+ ipAddress = dmaapMessageRootNode.at("/event/pnfRegistrationFields/oamV4IpAddress").textValue();
+ if (ipAddress != null && ipAddress != "")
+ return ipAddress;
+
+ return null;
+ }
+
public String getBaseUrl() {
return generalConfig.getBaseUrl();
}
@@ -126,7 +149,7 @@ public class DMaaPPNFRegVESMsgConsumer extends DMaaPVESMsgConsumerImpl {
return generalConfig.getSDNRPasswd() != null ? generalConfig.getSDNRPasswd() : DEFAULT_SDNRPASSWD;
}
- public PNFMountPointClient getPNFMountPointClient(String baseUrl) {
+ private PNFMountPointClient getPNFMountPointClient(String baseUrl) {
return new PNFMountPointClient(baseUrl);
}
}
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/PNFMountPointClient.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/PNFMountPointClient.java
index 029ae4c55..b271e8a6d 100644
--- a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/PNFMountPointClient.java
+++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/PNFMountPointClient.java
@@ -22,6 +22,9 @@ import java.io.IOException;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.eclipse.jdt.annotation.NonNull;
import org.onap.ccsdk.features.sdnr.wt.common.database.requests.BaseRequest;
import org.onap.ccsdk.features.sdnr.wt.common.http.BaseHTTPClient;
import org.onap.ccsdk.features.sdnr.wt.common.http.BaseHTTPResponse;
@@ -90,35 +93,35 @@ public class PNFMountPointClient extends BaseHTTPClient {
}
- public boolean pnfMountPointCreate(String pnfName, String ipv4Address, String protocol, String keyId,
- String username, String password, String commPort) {
+ public boolean pnfMountPointCreate(@NonNull String pnfName, @NonNull String ipAddress, @NonNull String protocol, String keyId,
+ String username, String password, @NonNull String commPort) {
String message = "";
if (protocol.equals("TLS")) {
- message = updateTLSPayload(pnfName, ipv4Address, username, keyId, commPort);
+ message = updateTLSPayload(pnfName, ipAddress, username, keyId, commPort);
} else { //SSH
- message = updatePayload(pnfName, ipv4Address, username, password, commPort);
- LOG.debug("Payload after updating values is: {}", message);
+ message = updatePayload(pnfName, ipAddress, username, password, commPort);
}
+ LOG.debug("Payload after updating values is: {}", redactMessage(message, protocol));
return pnfRequest(pnfName, "PUT", message) == 200;
}
- private static String updatePayload(String pnfName, String ipv4Address, String username, String password,
+ private static String updatePayload(String pnfName, String ipAddress, String username, String password,
String portNo) {
// @formatter:off
return SSH_PAYLOAD.replace("@device-name@", pnfName)
- .replace("@device-ip@", ipv4Address)
+ .replace("@device-ip@", ipAddress)
.replace("@device-port@", portNo)
.replace("@username@", username)
.replace("@password@", password);
// @formatter:on
}
- private static String updateTLSPayload(String pnfName, String ipv4Address, String username, String keyId,
+ private static String updateTLSPayload(String pnfName, String ipAddress, String username, String keyId,
String portNo) {
// @formatter:off
return TLS_PAYLOAD.replace("@device-name@", pnfName)
- .replace("@device-ip@", ipv4Address)
+ .replace("@device-ip@", ipAddress)
.replace("@username@", username)
.replace("@key-id@", keyId)
.replace("@device-port@", portNo);
@@ -126,7 +129,7 @@ public class PNFMountPointClient extends BaseHTTPClient {
}
private int pnfRequest(String pnfName, String method, String message) {
- LOG.info("In pnfRequest - {} : {} : {}", pnfName, method, message);
+ LOG.info("In pnfRequest - {} : {} ", pnfName, method);
BaseHTTPResponse response;
try {
String uri = MOUNTPOINT_URI + BaseRequest.urlEncodeValue(pnfName);
@@ -139,4 +142,16 @@ public class PNFMountPointClient extends BaseHTTPClient {
}
}
+ private String redactMessage(String message, String protocol) {
+ String REGEX = "";
+ if (("TLS").equals(protocol)) {
+ REGEX = "(<key-id.*>)(.*)(<\\/key-id>)";
+ } else {
+ REGEX = "(<password.*>)(.*)(<\\/password>)";
+ }
+ Pattern p = Pattern.compile(REGEX, Pattern.MULTILINE);
+ Matcher matcher = p.matcher(message);
+ return matcher.replaceAll("$1*********$3");
+ }
+
}
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestDMaaPPNFRegVESMsgConsumer.java b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestDMaaPPNFRegVESMsgConsumer.java
index fb38879a5..2c07caa1c 100644
--- a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestDMaaPPNFRegVESMsgConsumer.java
+++ b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestDMaaPPNFRegVESMsgConsumer.java
@@ -220,7 +220,7 @@ public class TestDMaaPPNFRegVESMsgConsumer {
+ " \"modelNumbsdnrer\": \"1234 BestInClass\",\n"
+ " \"oamV4IpAddress\": \"10.10.10.11\",\n"
+ " \"oamPort\":\"17380\",\n"
- + " \"oamV6IpAddress\": \"0:0:0:0:0:ffff:a0a:011\",\n"
+ //+ " \"oamV6IpAddress\": \"\",\n"
+ " \"serialNumber\": \"VENDORA-1234-10.10.10.11-1234 BestInClass\",\n"
+ " \"softwareVersion\": \"2.3.5\",\n"
+ " \"unitFamily\": \"VENDORA-1234\",\n"
@@ -266,4 +266,5 @@ public class TestDMaaPPNFRegVESMsgConsumer {
System.out.println(pnfConsumer.getSDNRUser());
System.out.println(pnfConsumer.getSDNRPasswd());
}
+
}