[ONOS-4115] Support flow table pipeline for REST API
This commit adds capability to handle Table type in
InstructionCodec.
Change-Id: I82f1abf9f7ed17df3885746e8c24223190dd216f
diff --git a/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java b/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java
index aef755f..e1a71fc 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java
@@ -103,6 +103,12 @@
return new SetQueueInstruction(queueId, port);
}
+ /**
+ * Creates a meter instruction.
+ *
+ * @param meterId Meter Id
+ * @return meter instruction
+ */
public static MeterInstruction meterTraffic(final MeterId meterId) {
checkNotNull(meterId, "meter id cannot be null");
return new MeterInstruction(meterId);
diff --git a/core/common/src/main/java/org/onosproject/codec/impl/DecodeInstructionCodecHelper.java b/core/common/src/main/java/org/onosproject/codec/impl/DecodeInstructionCodecHelper.java
index fbb8c57..105924e 100644
--- a/core/common/src/main/java/org/onosproject/codec/impl/DecodeInstructionCodecHelper.java
+++ b/core/common/src/main/java/org/onosproject/codec/impl/DecodeInstructionCodecHelper.java
@@ -15,8 +15,7 @@
*/
package org.onosproject.codec.impl;
-import static org.onlab.util.Tools.nullIsIllegal;
-
+import com.fasterxml.jackson.databind.node.ObjectNode;
import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
import org.onlab.packet.MplsLabel;
@@ -37,7 +36,7 @@
import org.onosproject.net.flow.instructions.L3ModificationInstruction;
import org.onosproject.net.flow.instructions.L4ModificationInstruction;
-import com.fasterxml.jackson.databind.node.ObjectNode;
+import static org.onlab.util.Tools.nullIsIllegal;
/**
* Decoding portion of the instruction codec.
@@ -259,6 +258,9 @@
return Instructions.createOutput(portNumber);
} else if (type.equals(Instruction.Type.NOACTION.name())) {
return Instructions.createNoAction();
+ } else if (type.equals(Instruction.Type.TABLE.name())) {
+ return Instructions.transition(nullIsIllegal(json.get(InstructionCodec.TABLE_ID)
+ .asInt(), InstructionCodec.TABLE_ID + InstructionCodec.MISSING_MEMBER_MESSAGE));
} else if (type.equals(Instruction.Type.L0MODIFICATION.name())) {
return decodeL0();
} else if (type.equals(Instruction.Type.L1MODIFICATION.name())) {
@@ -273,5 +275,4 @@
throw new IllegalArgumentException("Instruction type "
+ type + " is not supported");
}
-
}
diff --git a/core/common/src/main/java/org/onosproject/codec/impl/InstructionCodec.java b/core/common/src/main/java/org/onosproject/codec/impl/InstructionCodec.java
index d7307ad..0b5e8ad 100644
--- a/core/common/src/main/java/org/onosproject/codec/impl/InstructionCodec.java
+++ b/core/common/src/main/java/org/onosproject/codec/impl/InstructionCodec.java
@@ -15,14 +15,13 @@
*/
package org.onosproject.codec.impl;
+import com.fasterxml.jackson.databind.node.ObjectNode;
import org.onosproject.codec.CodecContext;
import org.onosproject.codec.JsonCodec;
import org.onosproject.net.flow.instructions.Instruction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
import static com.google.common.base.Preconditions.checkNotNull;
/**
@@ -50,6 +49,7 @@
protected static final String TUNNEL_ID = "tunnelId";
protected static final String TCP_PORT = "tcpPort";
protected static final String UDP_PORT = "udpPort";
+ protected static final String TABLE_ID = "tableId";
protected static final String TRIBUTARY_PORT_NUMBER = "tributaryPortNumber";
protected static final String TRIBUTARY_SLOT_LEN = "tributarySlotLength";
protected static final String TRIBUTARY_SLOT_BITMAP = "tributarySlotBitmap";