diff options
author | 2021-05-18 09:47:00 +0530 | |
---|---|---|
committer | 2021-05-18 09:52:24 +0530 | |
commit | caaf7cf0edd7c605c9d57c0470806d2a13ebe773 (patch) | |
tree | c9c5ac7474aa5b19243b9f57d54172f06d5cb0aa /sdnr/wt/mountpoint-state-provider/provider/src | |
parent | c8b3f59b0bc308e9b715ce88ac83d67959dc112d (diff) |
Fix nullPointerException
IPv4/IPv6 addresses can be used as mountpoint addresses for reporting state changes
Issue-ID: CCSDK-3308
Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
Change-Id: I8fda8297a15998a293dbd13da084e4ef2c369705
Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/mountpoint-state-provider/provider/src')
2 files changed, 13 insertions, 5 deletions
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()); |