updated to handle OF1.0 flow test (tableId as argument and new test 96/3696/2
authorEd Warnicke <eaw@cisco.com>
Fri, 13 Dec 2013 11:39:11 +0000 (17:09 +0530)
committerEd Warnicke <eaw@cisco.com>
Sat, 14 Dec 2013 20:11:05 +0000 (12:11 -0800)
cases)

Change-Id: I7591db48857904544031e7174e8045d0157ff25b
Signed-off-by: AnilGujele <angujele@in.ibm.com>
Signed-off-by: Ed Warnicke <eaw@cisco.com>
test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestCommandProvider.java

index 57a97801d45c9dbd2af2040501ce0da6f369486a..f3df112db3da4431b4d28f8561e2fd7104c8208a 100644 (file)
@@ -187,7 +187,7 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         pc = session;
         dataBrokerService = session.getSALService(DataBrokerService.class);
         ctx.registerService(CommandProvider.class.getName(), this, null);
-        createTestFlow(createTestNode(null), null);
+        createTestFlow(createTestNode(null), null, null);
     }
 
     private NodeBuilder createTestNode(String nodeId) {
@@ -206,7 +206,7 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         return InstanceIdentifier.builder(Nodes.class).child(Node.class, node.getKey()).toInstance();
     }
 
-    private FlowBuilder createTestFlow(NodeBuilder nodeBuilder, String flowTypeArg) {
+    private FlowBuilder createTestFlow(NodeBuilder nodeBuilder, String flowTypeArg, String tableId) {
 
         FlowBuilder flow = new FlowBuilder();
         long id = 123;
@@ -462,11 +462,31 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
             flow.setMatch(createVlanMatch().build());
             flow.setInstructions(createMeterInstructions().build());
             break;
+
         case "f50":
             id += 50;
             flow.setMatch(createPbbMatch().build());
             flow.setInstructions(createMeterInstructions().build());
             break;
+
+        case "51":
+            id += 51;
+            flow.setMatch(createIPMatch().build());
+            flow.setInstructions(createDropInstructions().build());
+            break;
+    
+        case "52":
+            id += 52;
+            flow.setMatch(createL4TCPMatch().build());
+            flow.setInstructions(createDropInstructions().build());
+            break;    
+            
+        case "53":
+            id += 53;
+            flow.setMatch(createL4UDPMatch().build());
+            flow.setInstructions(createDropInstructions().build());
+            break;
+
         default:
             LOG.warn("flow type not understood: {}", flowType);
         }
@@ -484,7 +504,7 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         flow.setContainerName(null);
         flow.setFlags(new FlowModFlags(false, false, false, false, false));
         flow.setId(new FlowId(new Long(12)));
-        flow.setTableId((short) 2);
+        flow.setTableId(getTableId(tableId));
         flow.setOutGroup(new Long(2));
         flow.setOutPort(value);
 
@@ -494,6 +514,23 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
         testFlow = flow;
         return flow;
     }
+    
+    
+    private short getTableId(String tableId)
+    {
+         short table = 2;
+          try
+          {
+            table = Short.parseShort(tableId);
+          }
+          catch(Exception ex)
+          {
+             // ignore exception and continue with default value
+          }
+          
+          return table;
+        
+    }
 
     /**
      * @return
@@ -1936,7 +1973,7 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
     public void _removeMDFlow(CommandInterpreter ci) {
         DataModification<InstanceIdentifier<?>, DataObject> modification = dataBrokerService.beginTransaction();
         NodeBuilder tn = createTestNode(ci.nextArgument());
-        FlowBuilder tf = createTestFlow(tn, ci.nextArgument());
+        FlowBuilder tf = createTestFlow(tn, ci.nextArgument(), ci.nextArgument());
         InstanceIdentifier<Flow> path1 = InstanceIdentifier.builder(Nodes.class)
                 .child(Node.class, tn.getKey()).augmentation(FlowCapableNode.class)
                 .child(Table.class, new TableKey(tf.getTableId())).child(Flow.class, tf.getKey())
@@ -1962,7 +1999,7 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     public void _addMDFlow(CommandInterpreter ci) {
         NodeBuilder tn = createTestNode(ci.nextArgument());
-        FlowBuilder tf = createTestFlow(tn, ci.nextArgument());
+        FlowBuilder tf = createTestFlow(tn, ci.nextArgument(), ci.nextArgument());
         writeFlow(ci, tf, tn);
     }
 
@@ -1993,7 +2030,7 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
     public void _modifyMDFlow(CommandInterpreter ci) {
         NodeBuilder tn = createTestNode(ci.nextArgument());
-        FlowBuilder tf = createTestFlow(tn, ci.nextArgument());
+        FlowBuilder tf = createTestFlow(tn, ci.nextArgument(), ci.nextArgument());
         tf.setFlowName(updatedFlowName);
         writeFlow(ci, tf, tn);
         tf.setFlowName(originalFlowName);