ONOS-7916 address a NPE and add some more debugging logs
Change-Id: I1debef2d108177ea8d000496ff3de78349433cc5
diff --git a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfControllerImpl.java b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfControllerImpl.java
index 10eabd9..19197e7 100644
--- a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfControllerImpl.java
+++ b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfControllerImpl.java
@@ -238,6 +238,7 @@
if (device != null) {
ip = device.annotations().value("ipaddress");
port = Integer.parseInt(device.annotations().value("port"));
+ path = device.annotations().value("path");
} else {
Triple<String, Integer, Optional<String>> info = extractIpPortPath(deviceId);
ip = info.getLeft();
@@ -289,8 +290,10 @@
}
private void stopDevice(DeviceId deviceId, boolean remove) {
- netconfDeviceMap.get(deviceId).disconnect();
- netconfDeviceMap.remove(deviceId);
+ NetconfDevice nc = netconfDeviceMap.remove(deviceId);
+ if (nc != null) {
+ nc.disconnect();
+ }
if (remove) {
for (NetconfDeviceListener l : netconfDeviceListeners) {
l.deviceRemoved(deviceId);
diff --git a/providers/netconf/device/src/main/java/org/onosproject/provider/netconf/device/impl/NetconfDeviceProvider.java b/providers/netconf/device/src/main/java/org/onosproject/provider/netconf/device/impl/NetconfDeviceProvider.java
index fe5cda9..12325c3 100644
--- a/providers/netconf/device/src/main/java/org/onosproject/provider/netconf/device/impl/NetconfDeviceProvider.java
+++ b/providers/netconf/device/src/main/java/org/onosproject/provider/netconf/device/impl/NetconfDeviceProvider.java
@@ -418,12 +418,13 @@
private void connectDevice(NetconfDeviceConfig config) {
if (config == null) {
+ log.warn("connect device invoked with null config");
return;
}
DeviceId deviceId = config.subject();
if (!deviceId.uri().getScheme().equals(SCHEME_NAME)) {
// not under my scheme, skipping
- log.trace("{} not my scheme, skipping", deviceId);
+ log.debug("{} not of schema {}, skipping", deviceId, SCHEME_NAME);
return;
}
if (!isReachable(deviceId)) {
@@ -438,6 +439,7 @@
storeDeviceKey(config.sshKey(), config.username(), config.password(), deviceId);
retriedPortDiscoveryMap.put(deviceId, new AtomicInteger(0));
if (deviceService.getDevice(deviceId) == null) {
+ log.debug("device connected {}", deviceId);
providerService.deviceConnected(deviceId, deviceDescription);
}
}
@@ -529,6 +531,7 @@
cfgService.getConfig(deviceId, NetconfDeviceConfig.class);
DeviceDescription deviceDescription = createDeviceRepresentation(deviceId, config);
storeDeviceKey(config.sshKey(), config.username(), config.password(), deviceId);
+ log.debug("check and update {}", deviceId);
checkAndUpdateDevice(deviceId, deviceDescription, false);
});
}
@@ -683,6 +686,7 @@
device.manufacturer(), device.hwVersion(), device.swVersion(),
device.serialNumber(), device.chassisId(),
(SparseAnnotations) device.annotations());
+ log.debug("check and update {}", deviceId);
checkAndUpdateDevice(deviceId, description, true);
} catch (Exception e) {
log.error("Unhandled exception checking {}", deviceId, e);