From caaf7cf0edd7c605c9d57c0470806d2a13ebe773 Mon Sep 17 00:00:00 2001 From: Ravi Pendurty Date: Tue, 18 May 2021 09:47:00 +0530 Subject: Fix nullPointerException IPv4/IPv6 addresses can be used as mountpoint addresses for reporting state changes Issue-ID: CCSDK-3308 Signed-off-by: Ravi Pendurty Change-Id: I8fda8297a15998a293dbd13da084e4ef2c369705 Signed-off-by: Ravi Pendurty --- sdnr/wt/mountpoint-state-provider/provider/pom.xml | 8 ++++---- .../impl/MountpointNodeConnectListenerImpl.java | 6 +++++- .../impl/MountpointNodeStateListenerImpl.java | 12 ++++++++---- 3 files changed, 17 insertions(+), 9 deletions(-) (limited to 'sdnr/wt/mountpoint-state-provider/provider') diff --git a/sdnr/wt/mountpoint-state-provider/provider/pom.xml b/sdnr/wt/mountpoint-state-provider/provider/pom.xml index fc6d7e07e..6323b85c1 100644 --- a/sdnr/wt/mountpoint-state-provider/provider/pom.xml +++ b/sdnr/wt/mountpoint-state-provider/provider/pom.xml @@ -61,19 +61,19 @@ - org.onap.ccsdk.features.sdnr.wt + ${project.groupId} sdnr-wt-common ${project.version} provided - org.onap.ccsdk.features.sdnr.wt - sdnr-wt-devicemanager-model + ${project.groupId} + sdnr-wt-devicemanager-core-model ${project.version} provided - org.onap.ccsdk.features.sdnr.wt + ${project.groupId} sdnr-wt-netconfnode-state-service-model ${project.version} diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointNodeConnectListenerImpl.java b/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointNodeConnectListenerImpl.java index 466d4f4ef..20487a300 100644 --- a/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointNodeConnectListenerImpl.java +++ b/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointNodeConnectListenerImpl.java @@ -25,6 +25,8 @@ import org.json.JSONObject; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNodeConnectListener; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNodeStateService; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address; import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; import org.opendaylight.yangtools.concepts.ListenerRegistration; @@ -51,8 +53,10 @@ public class MountpointNodeConnectListenerImpl implements NetconfNodeConnectList NodeId nNodeId = accessor.getNodeId(); NetconfNode netconfNode = accessor.getNetconfNode(); + Ipv4Address ipv4Address = netconfNode.getHost().getIpAddress().getIpv4Address(); + Ipv6Address ipv6Address = netconfNode.getHost().getIpAddress().getIpv6Address(); LOG.debug("In onEnterConnected of MountpointNodeConnectListenerImpl - nNodeId = {}, IP Address = {}",nNodeId.getValue() - ,netconfNode.getHost().getIpAddress().getIpv4Address().getValue()); + ,ipv4Address != null?ipv4Address.getValue():ipv6Address.getValue()); JSONObject obj = new JSONObject(); obj.put(Constants.NODEID, nNodeId.getValue()); diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointNodeStateListenerImpl.java b/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointNodeStateListenerImpl.java index 46b17eb15..ea5232d59 100644 --- a/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointNodeStateListenerImpl.java +++ b/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointNodeStateListenerImpl.java @@ -21,6 +21,8 @@ package org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.impl; import org.json.JSONObject; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNodeStateListener; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNodeStateService; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address; import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; import org.opendaylight.yangtools.concepts.ListenerRegistration; @@ -45,9 +47,10 @@ public class MountpointNodeStateListenerImpl implements NetconfNodeStateListener @Override public void onCreated(NodeId nNodeId, NetconfNode netconfNode) { - + Ipv4Address ipv4Address = netconfNode.getHost().getIpAddress().getIpv4Address(); + Ipv6Address ipv6Address = netconfNode.getHost().getIpAddress().getIpv6Address(); LOG.info("In onCreated of MountpointNodeStateListenerImpl - nNodeId = {}, IP Address = {}",nNodeId.getValue(), - netconfNode.getHost().getIpAddress().getIpv4Address().toString()); + ipv4Address != null?ipv4Address.getValue():ipv6Address.getValue()); JSONObject obj = new JSONObject(); obj.put(Constants.NODEID, nNodeId.getValue()); obj.put(Constants.NETCONFNODESTATE, netconfNode.getConnectionStatus().toString()); @@ -58,9 +61,10 @@ public class MountpointNodeStateListenerImpl implements NetconfNodeStateListener @Override public void onStateChange(NodeId nNodeId, NetconfNode netconfNode) { - + Ipv4Address ipv4Address = netconfNode.getHost().getIpAddress().getIpv4Address(); + Ipv6Address ipv6Address = netconfNode.getHost().getIpAddress().getIpv6Address(); LOG.info("In onStateChange of MountpointNodeStateListenerImpl - nNodeId = {}, IP Address = {}",nNodeId.getValue(), - netconfNode.getHost().getIpAddress().getIpv4Address().getValue()); + ipv4Address != null?ipv4Address.getValue():ipv6Address.getValue()); JSONObject obj = new JSONObject(); obj.put(Constants.NODEID, nNodeId.getValue()); obj.put(Constants.NETCONFNODESTATE, netconfNode.getConnectionStatus().toString()); -- cgit 1.2.3-korg