NullHostProvider does not report hosts for device the local instance is not master for
Change-Id: I41fbeb1d9fa9be48792a7f223481e42c27e02d72
diff --git a/providers/null/host/src/main/java/org/onosproject/provider/nil/host/impl/NullHostProvider.java b/providers/null/host/src/main/java/org/onosproject/provider/nil/host/impl/NullHostProvider.java
index d3ece62..8f59bcb 100644
--- a/providers/null/host/src/main/java/org/onosproject/provider/nil/host/impl/NullHostProvider.java
+++ b/providers/null/host/src/main/java/org/onosproject/provider/nil/host/impl/NullHostProvider.java
@@ -26,6 +26,7 @@
import org.onosproject.net.Host;
import org.onosproject.net.HostId;
import org.onosproject.net.HostLocation;
+import org.onosproject.net.MastershipRole;
import org.onosproject.net.PortNumber;
import org.onosproject.net.device.DeviceEvent;
import org.onosproject.net.device.DeviceListener;
@@ -129,6 +130,11 @@
private class InternalHostProvider implements DeviceListener {
@Override
public void event(DeviceEvent event) {
+ if (!deviceService.getRole(event.subject().id())
+ .equals(MastershipRole.MASTER)) {
+ log.info("Local node is not master for device", event.subject().id());
+ return;
+ }
switch (event.type()) {
case DEVICE_ADDED: