Jian Li
Committed by Gerrit Code Review

[ONOS-4115] Support flow table pipeline for REST API

This commit adds capability to handle Table type in
InstructionCodec.

Change-Id: I82f1abf9f7ed17df3885746e8c24223190dd216f
......@@ -103,6 +103,12 @@ public final class Instructions {
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);
......
......@@ -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.L2ModificationInstruction;
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 @@ public final class DecodeInstructionCodecHelper {
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 @@ public final class DecodeInstructionCodecHelper {
throw new IllegalArgumentException("Instruction type "
+ type + " is not supported");
}
}
......
......@@ -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 @@ public final class InstructionCodec extends JsonCodec<Instruction> {
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";
......