make sure only one instance pushes default rules
Change-Id: I0953c4db36ab48d7aeec88b940712c2cbe35e415
diff --git a/app/src/main/java/org/onosproject/olt/impl/Olt.java b/app/src/main/java/org/onosproject/olt/impl/Olt.java
index 96573f2..976fcaa 100644
--- a/app/src/main/java/org/onosproject/olt/impl/Olt.java
+++ b/app/src/main/java/org/onosproject/olt/impl/Olt.java
@@ -30,6 +30,7 @@
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
import org.onosproject.event.AbstractListenerManager;
+import org.onosproject.mastership.MastershipService;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
import org.onosproject.net.Port;
@@ -99,6 +100,9 @@
protected FlowObjectiveService flowObjectiveService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected MastershipService mastershipService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected DeviceService deviceService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
@@ -420,6 +424,9 @@
}
private void processFilteringObjectives(DeviceId devId, PortNumber port, boolean install) {
+ if (!mastershipService.isLocalMaster(devId)) {
+ return;
+ }
DefaultFilteringObjective.Builder builder = DefaultFilteringObjective.builder();
FilteringObjective eapol = (install ? builder.permit() : builder.deny())
@@ -550,6 +557,9 @@
}
private void provisionDefaultFlows(DeviceId deviceId) {
+ if (!mastershipService.isLocalMaster(deviceId)) {
+ return;
+ }
List<Port> ports = deviceService.getPorts(deviceId);
ports.stream()