Fixed device subsystem behaviour where auxiliary provider prevented emitting device availability change events.
Change-Id: Iaed6359598ff87d5706e10eb9d905ed0883617d9
diff --git a/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStore.java b/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStore.java
index 83c96e1..873a273 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStore.java
@@ -383,7 +383,8 @@
// We allow only certain attributes to trigger update
boolean propertiesChanged =
!Objects.equals(oldDevice.hwVersion(), newDevice.hwVersion()) ||
- !Objects.equals(oldDevice.swVersion(), newDevice.swVersion());
+ !Objects.equals(oldDevice.swVersion(), newDevice.swVersion()) ||
+ !Objects.equals(oldDevice.providerId(), newDevice.providerId());
boolean annotationsChanged =
!AnnotationsUtil.isEqual(oldDevice.annotations(), newDevice.annotations());
@@ -399,16 +400,14 @@
, newDevice);
}
if (!providerId.isAncillary()) {
+ boolean wasOnline = availableDevices.contains(newDevice.id());
markOnline(newDevice.id(), newTimestamp);
+ if (!wasOnline) {
+ notifyDelegateIfNotNull(new DeviceEvent(DEVICE_AVAILABILITY_CHANGED, newDevice, null));
+ }
}
- return new DeviceEvent(DeviceEvent.Type.DEVICE_UPDATED, newDevice, null);
- }
- // Otherwise merely attempt to change availability if primary provider
- if (!providerId.isAncillary()) {
- boolean added = markOnline(newDevice.id(), newTimestamp);
- return !added ? null :
- new DeviceEvent(DEVICE_AVAILABILITY_CHANGED, newDevice, null);
+ return new DeviceEvent(DeviceEvent.Type.DEVICE_UPDATED, newDevice, null);
}
return null;
}
diff --git a/tools/test/topos/linear-2.json b/tools/test/topos/linear-2.json
new file mode 100644
index 0000000..c248a23
--- /dev/null
+++ b/tools/test/topos/linear-2.json
@@ -0,0 +1,6 @@
+{
+ "devices": [
+ { "alias": "s1", "uri": "of:0000000000000001", "annotations": { "driver": "ovs-corsa" } },
+ { "alias": "s2", "uri": "of:0000000000000002", "annotations": { "driver": "ovs-corsa" } }
+ ]
+}