[ONOS-7435] add "ignoreDeviceWhenGet" property to
P4RuntimeGroupProgrammable
Change-Id: I272e9fdd6d97117596c1923640f400955f4b34fe
diff --git a/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/P4RuntimeGroupProgrammable.java b/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/P4RuntimeGroupProgrammable.java
index fb5e892..31ee45b 100644
--- a/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/P4RuntimeGroupProgrammable.java
+++ b/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/P4RuntimeGroupProgrammable.java
@@ -18,6 +18,7 @@
import com.google.common.collect.Maps;
import org.onosproject.drivers.p4runtime.mirror.P4RuntimeGroupMirror;
+import org.onosproject.drivers.p4runtime.mirror.TimedEntry;
import org.onosproject.net.DeviceId;
import org.onosproject.net.group.DefaultGroup;
import org.onosproject.net.group.Group;
@@ -71,6 +72,10 @@
// device mirror.
private boolean checkMirrorBeforeUpdate = true;
+ // If true, we avoid querying the device and return what's already known by
+ // the ONOS store.
+ private boolean ignoreDeviceWhenGet = true;
+
private GroupStore groupStore;
private P4RuntimeGroupMirror groupMirror;
private PiGroupTranslator translator;
@@ -104,10 +109,17 @@
if (!setupBehaviour()) {
return Collections.emptyList();
}
- return pipeconf.pipelineModel().actionProfiles().stream()
- .map(PiActionProfileModel::id)
- .flatMap(this::streamGroupsFromDevice)
- .collect(Collectors.toList());
+ if (!ignoreDeviceWhenGet) {
+ return pipeconf.pipelineModel().actionProfiles().stream()
+ .map(PiActionProfileModel::id)
+ .flatMap(this::streamGroupsFromDevice)
+ .collect(Collectors.toList());
+ } else {
+ return groupMirror.getAll(deviceId).stream()
+ .map(TimedEntry::entry)
+ .map(this::forgeGroupEntry)
+ .collect(Collectors.toList());
+ }
}
private void processGroupOp(DeviceId deviceId, GroupOperation groupOp) {