Konstantinos Kanonakis
Committed by Gerrit Code Review

Making NetconfDeviceProvider try to get actual device description from device in…

… checkAndUpdateDevice()

- Getting device description only if controller is currently Master for device

Change-Id: I870b2f19fd5e09e198e2c73bcabf9869504f2c94
...@@ -347,9 +347,23 @@ public class NetconfDeviceProvider extends AbstractProvider ...@@ -347,9 +347,23 @@ public class NetconfDeviceProvider extends AbstractProvider
347 } else { 347 } else {
348 boolean isReachable = isReachable(deviceId); 348 boolean isReachable = isReachable(deviceId);
349 if (isReachable && !deviceService.isAvailable(deviceId)) { 349 if (isReachable && !deviceService.isAvailable(deviceId)) {
350 + Device device = deviceService.getDevice(deviceId);
351 + DeviceDescription updatedDeviceDescription = null;
352 + if (device.is(DeviceDescriptionDiscovery.class)) {
353 + if (mastershipService.isLocalMaster(deviceId)) {
354 + DeviceDescriptionDiscovery deviceDescriptionDiscovery =
355 + device.as(DeviceDescriptionDiscovery.class);
356 + updatedDeviceDescription = deviceDescriptionDiscovery.discoverDeviceDetails();
357 + }
358 + } else {
359 + log.warn("No DeviceDescriptionDiscovery behaviour for device {}", deviceId);
360 + }
361 + if (updatedDeviceDescription == null) {
362 + updatedDeviceDescription = deviceDescription;
363 + }
350 providerService.deviceConnected( 364 providerService.deviceConnected(
351 deviceId, new DefaultDeviceDescription( 365 deviceId, new DefaultDeviceDescription(
352 - deviceDescription, true, deviceDescription.annotations())); 366 + updatedDeviceDescription, true, updatedDeviceDescription.annotations()));
353 } else if (!isReachable && deviceService.isAvailable(deviceId)) { 367 } else if (!isReachable && deviceService.isAvailable(deviceId)) {
354 providerService.deviceDisconnected(deviceId); 368 providerService.deviceDisconnected(deviceId);
355 } 369 }
...@@ -422,7 +436,6 @@ public class NetconfDeviceProvider extends AbstractProvider ...@@ -422,7 +436,6 @@ public class NetconfDeviceProvider extends AbstractProvider
422 device.as(DeviceDescriptionDiscovery.class); 436 device.as(DeviceDescriptionDiscovery.class);
423 providerService.updatePorts(deviceId, 437 providerService.updatePorts(deviceId,
424 deviceDescriptionDiscovery.discoverPortDetails()); 438 deviceDescriptionDiscovery.discoverPortDetails());
425 -
426 } else { 439 } else {
427 log.warn("No portGetter behaviour for device {}", deviceId); 440 log.warn("No portGetter behaviour for device {}", deviceId);
428 } 441 }
......