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 { ...@@ -103,6 +103,12 @@ public final class Instructions {
103 return new SetQueueInstruction(queueId, port); 103 return new SetQueueInstruction(queueId, port);
104 } 104 }
105 105
106 + /**
107 + * Creates a meter instruction.
108 + *
109 + * @param meterId Meter Id
110 + * @return meter instruction
111 + */
106 public static MeterInstruction meterTraffic(final MeterId meterId) { 112 public static MeterInstruction meterTraffic(final MeterId meterId) {
107 checkNotNull(meterId, "meter id cannot be null"); 113 checkNotNull(meterId, "meter id cannot be null");
108 return new MeterInstruction(meterId); 114 return new MeterInstruction(meterId);
......
...@@ -15,8 +15,7 @@ ...@@ -15,8 +15,7 @@
15 */ 15 */
16 package org.onosproject.codec.impl; 16 package org.onosproject.codec.impl;
17 17
18 -import static org.onlab.util.Tools.nullIsIllegal; 18 +import com.fasterxml.jackson.databind.node.ObjectNode;
19 -
20 import org.onlab.packet.IpAddress; 19 import org.onlab.packet.IpAddress;
21 import org.onlab.packet.MacAddress; 20 import org.onlab.packet.MacAddress;
22 import org.onlab.packet.MplsLabel; 21 import org.onlab.packet.MplsLabel;
...@@ -37,7 +36,7 @@ import org.onosproject.net.flow.instructions.L2ModificationInstruction; ...@@ -37,7 +36,7 @@ import org.onosproject.net.flow.instructions.L2ModificationInstruction;
37 import org.onosproject.net.flow.instructions.L3ModificationInstruction; 36 import org.onosproject.net.flow.instructions.L3ModificationInstruction;
38 import org.onosproject.net.flow.instructions.L4ModificationInstruction; 37 import org.onosproject.net.flow.instructions.L4ModificationInstruction;
39 38
40 -import com.fasterxml.jackson.databind.node.ObjectNode; 39 +import static org.onlab.util.Tools.nullIsIllegal;
41 40
42 /** 41 /**
43 * Decoding portion of the instruction codec. 42 * Decoding portion of the instruction codec.
...@@ -259,6 +258,9 @@ public final class DecodeInstructionCodecHelper { ...@@ -259,6 +258,9 @@ public final class DecodeInstructionCodecHelper {
259 return Instructions.createOutput(portNumber); 258 return Instructions.createOutput(portNumber);
260 } else if (type.equals(Instruction.Type.NOACTION.name())) { 259 } else if (type.equals(Instruction.Type.NOACTION.name())) {
261 return Instructions.createNoAction(); 260 return Instructions.createNoAction();
261 + } else if (type.equals(Instruction.Type.TABLE.name())) {
262 + return Instructions.transition(nullIsIllegal(json.get(InstructionCodec.TABLE_ID)
263 + .asInt(), InstructionCodec.TABLE_ID + InstructionCodec.MISSING_MEMBER_MESSAGE));
262 } else if (type.equals(Instruction.Type.L0MODIFICATION.name())) { 264 } else if (type.equals(Instruction.Type.L0MODIFICATION.name())) {
263 return decodeL0(); 265 return decodeL0();
264 } else if (type.equals(Instruction.Type.L1MODIFICATION.name())) { 266 } else if (type.equals(Instruction.Type.L1MODIFICATION.name())) {
...@@ -273,5 +275,4 @@ public final class DecodeInstructionCodecHelper { ...@@ -273,5 +275,4 @@ public final class DecodeInstructionCodecHelper {
273 throw new IllegalArgumentException("Instruction type " 275 throw new IllegalArgumentException("Instruction type "
274 + type + " is not supported"); 276 + type + " is not supported");
275 } 277 }
276 -
277 } 278 }
......
...@@ -15,14 +15,13 @@ ...@@ -15,14 +15,13 @@
15 */ 15 */
16 package org.onosproject.codec.impl; 16 package org.onosproject.codec.impl;
17 17
18 +import com.fasterxml.jackson.databind.node.ObjectNode;
18 import org.onosproject.codec.CodecContext; 19 import org.onosproject.codec.CodecContext;
19 import org.onosproject.codec.JsonCodec; 20 import org.onosproject.codec.JsonCodec;
20 import org.onosproject.net.flow.instructions.Instruction; 21 import org.onosproject.net.flow.instructions.Instruction;
21 import org.slf4j.Logger; 22 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory; 23 import org.slf4j.LoggerFactory;
23 24
24 -import com.fasterxml.jackson.databind.node.ObjectNode;
25 -
26 import static com.google.common.base.Preconditions.checkNotNull; 25 import static com.google.common.base.Preconditions.checkNotNull;
27 26
28 /** 27 /**
...@@ -50,6 +49,7 @@ public final class InstructionCodec extends JsonCodec<Instruction> { ...@@ -50,6 +49,7 @@ public final class InstructionCodec extends JsonCodec<Instruction> {
50 protected static final String TUNNEL_ID = "tunnelId"; 49 protected static final String TUNNEL_ID = "tunnelId";
51 protected static final String TCP_PORT = "tcpPort"; 50 protected static final String TCP_PORT = "tcpPort";
52 protected static final String UDP_PORT = "udpPort"; 51 protected static final String UDP_PORT = "udpPort";
52 + protected static final String TABLE_ID = "tableId";
53 protected static final String TRIBUTARY_PORT_NUMBER = "tributaryPortNumber"; 53 protected static final String TRIBUTARY_PORT_NUMBER = "tributaryPortNumber";
54 protected static final String TRIBUTARY_SLOT_LEN = "tributarySlotLength"; 54 protected static final String TRIBUTARY_SLOT_LEN = "tributarySlotLength";
55 protected static final String TRIBUTARY_SLOT_BITMAP = "tributarySlotBitmap"; 55 protected static final String TRIBUTARY_SLOT_BITMAP = "tributarySlotBitmap";
......