Fix for ONOS-3750
Change-Id: Ib4c870ea050d0c3a0f9a95c1327621bda93b40f6
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/FlowViewMessageHandler.java b/web/gui/src/main/java/org/onosproject/ui/impl/FlowViewMessageHandler.java
index 46f9f9e..a5c7a60 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/FlowViewMessageHandler.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/FlowViewMessageHandler.java
@@ -25,6 +25,7 @@
import org.onosproject.net.flow.FlowEntry;
import org.onosproject.net.flow.FlowRule;
import org.onosproject.net.flow.FlowRuleService;
+import org.onosproject.net.flow.TrafficTreatment;
import org.onosproject.net.flow.criteria.Criterion;
import org.onosproject.net.flow.instructions.Instruction;
import org.onosproject.ui.RequestHandler;
@@ -41,6 +42,7 @@
import java.util.List;
import java.util.Set;
+
/**
* Message handler for flow view related messages.
*/
@@ -86,6 +88,12 @@
);
}
+ private StringBuilder removeTrailingComma(StringBuilder sb) {
+ int pos = sb.lastIndexOf(COMMA);
+ sb.delete(pos, sb.length());
+ return sb;
+ }
+
// handler for flow table requests
private final class FlowDataRequest extends TableRequestHandler {
@@ -168,33 +176,53 @@
@Override
public String format(Object value) {
FlowEntry flow = (FlowEntry) value;
- List<Instruction> instructions = flow.treatment().allInstructions();
-
- if (instructions.isEmpty()
- && flow.treatment().metered() == null
- && flow.treatment().tableTransition() == null) {
+ TrafficTreatment treatment = flow.treatment();
+ List<Instruction> imm = treatment.immediate();
+ List<Instruction> def = treatment.deferred();
+ if (imm.isEmpty() &&
+ def.isEmpty() &&
+ treatment.metered() == null &&
+ treatment.tableTransition() == null) {
return "(No traffic treatment instructions for this flow)";
}
+
StringBuilder sb = new StringBuilder("Treatment Instructions: ");
- for (Instruction i : instructions) {
- sb.append(i).append(COMMA);
+ formatInstructs(sb, imm, "immediate:");
+ formatInstructs(sb, def, "deferred:");
+
+ if (treatment.metered() != null) {
+ sb.append("metered:")
+ .append(treatment.metered())
+ .append(COMMA);
}
- if (flow.treatment().metered() != null) {
- sb.append(flow.treatment().metered().toString()).append(COMMA);
+
+ if (treatment.tableTransition() != null) {
+ sb.append("transition:")
+ .append(treatment.tableTransition())
+ .append(COMMA);
}
- if (flow.treatment().tableTransition() != null) {
- sb.append(flow.treatment().tableTransition().toString()).append(COMMA);
+
+ if (treatment.writeMetadata() != null) {
+ sb.append("metadata:")
+ .append(treatment.writeMetadata())
+ .append(COMMA);
}
- removeTrailingComma(sb);
+
+ sb.append("cleared:").append(treatment.clearedDeferred());
return sb.toString();
}
}
- private StringBuilder removeTrailingComma(StringBuilder sb) {
- int pos = sb.lastIndexOf(COMMA);
- sb.delete(pos, sb.length());
- return sb;
+ private void formatInstructs(StringBuilder sb,
+ List<Instruction> instructs,
+ String type) {
+ if (!instructs.isEmpty()) {
+ sb.append(type);
+ for (Instruction i : instructs) {
+ sb.append(i).append(COMMA);
+ }
+ }
}
}
@@ -233,9 +261,7 @@
for (Criterion c : criteria) {
sb.append(c).append(COMMA);
}
- int pos = sb.lastIndexOf(COMMA);
- sb.delete(pos, sb.length());
-
+ removeTrailingComma(sb);
return sb.toString();
}
@@ -246,14 +272,13 @@
sb.append(inst).append(COMMA);
}
if (flow.treatment().metered() != null) {
- sb.append(flow.treatment().metered().toString()).append(COMMA);
+ sb.append(flow.treatment().metered()).append(COMMA);
}
if (flow.treatment().tableTransition() != null) {
- sb.append(flow.treatment().tableTransition().toString()).append(COMMA);
+ sb.append(flow.treatment().tableTransition()).append(COMMA);
}
- int pos = sb.lastIndexOf(COMMA);
- sb.delete(pos, sb.length());
+ removeTrailingComma(sb);
return sb.toString();
}