Simplified string representation of PI flow rules
For easier consumption in UI or CLI
Change-Id: I01c5119194b44581a45b7ec78b1b58ce2a8a01f0
diff --git a/core/api/src/main/java/org/onosproject/net/flow/criteria/PiCriterion.java b/core/api/src/main/java/org/onosproject/net/flow/criteria/PiCriterion.java
index 2ba0bc8..23102dd 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/criteria/PiCriterion.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/criteria/PiCriterion.java
@@ -94,7 +94,7 @@
@Override
public String toString() {
- StringJoiner stringParams = new StringJoiner(", ", "{", "}");
+ StringJoiner stringParams = new StringJoiner(", ");
fieldMatchMap.forEach((key, value) -> stringParams.add(value.toString()));
return stringParams.toString();
}
diff --git a/core/api/src/main/java/org/onosproject/net/flow/instructions/PiInstruction.java b/core/api/src/main/java/org/onosproject/net/flow/instructions/PiInstruction.java
index 5db8a84..3558bd5 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/instructions/PiInstruction.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/instructions/PiInstruction.java
@@ -19,10 +19,10 @@
import com.google.common.annotations.Beta;
import com.google.common.base.Objects;
+import org.onosproject.net.pi.runtime.PiActionGroupId;
+import org.onosproject.net.pi.runtime.PiActionGroupMemberId;
import org.onosproject.net.pi.runtime.PiTableAction;
-import static java.lang.String.format;
-
/**
* Representation of a protocol-independent instruction.
*/
@@ -75,9 +75,9 @@
public String toString() {
switch (tableAction.type()) {
case ACTION_GROUP_ID:
+ return "GROUP:" + ((PiActionGroupId) tableAction).id().toString();
case GROUP_MEMBER_ID:
- // e.g. PiActionGroupId(1)
- return format("%s{%s}", tableAction.getClass().getSimpleName(), tableAction.toString());
+ return "GROUP_MEMBER:" + ((PiActionGroupMemberId) tableAction).id().toString();
default:
return tableAction.toString();
}
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiAction.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiAction.java
index bba3338..24655b6 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiAction.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiAction.java
@@ -17,7 +17,6 @@
package org.onosproject.net.pi.runtime;
import com.google.common.annotations.Beta;
-import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
@@ -96,9 +95,7 @@
public String toString() {
StringJoiner stringParams = new StringJoiner(", ", "(", ")");
this.parameters().forEach(p -> stringParams.add(p.toString()));
- return MoreObjects.toStringHelper(this)
- .addValue(this.id().toString() + stringParams.toString())
- .toString();
+ return this.id().toString() + stringParams.toString();
}
/**