refactoring ovsdb of13 neutron 74/9474/5
authorBrent Salisbury <brent.salisbury@gmail.com>
Tue, 29 Jul 2014 16:21:05 +0000 (12:21 -0400)
committerBrent Salisbury <brent.salisbury@gmail.com>
Sun, 10 Aug 2014 04:17:17 +0000 (00:17 -0400)
patch#5:
renamed openflow constant

patch#4:
rebase

Patch#3:
-rebased, added a couple of constants and deleted old
commented out code from Hydrogen.

-I am getting so many node errors on the current
master that it is hard to tell if I am introducing
any new ones. We should probably verify the existing base
isnt broken for all of us before we merge this until md_sal
starts behaving like it did prior to all of the
normalization/node work by that team captured in Bug #1490.

Patch#2:
Changed a couple assessors in the match and comments
in instructions

-First of a few, was wanting  to put a builder wrapper around
all of the ofplug java API boiler plate sounded good in
theory but maintenance and tshooting mdsal RPCs,
threading etc from a loosely coupled wrapper may eventually
make us sad pandas.

-Pulled the ofplugin match/action APIs out of OF13Provider
and into a seperate package. Will work with Dave/Madhu
(or anyone else up to speed on karaf strategy) to package
it into Karaf or something if we are still aiming for
seperate bundles.
-Want to break it up into a progressive set of patches rather
then one biggy since we dont have IT yet to avoid any
impact.
-I have tests done just no PaxExam to run them against.
Can push them as a stub/example if someone wants.
-Added TCP_Flag and IPv4 Tunnel_Src/Dst.
-Modified and added a couple of constants.
-Later today will be adding a few methods to remove some
boiler plate jsut not as much as initially desired but
instantiating the MDSAL builders outside of of13provider
was getting mixed results with lots of rpc errors. Will
push it with a bug tomorrow anyways as a talking point for
out consumer APIs moving forward.

Change-Id: I05d7cccf3d7d0ae481070d8410e2328588faa348
Signed-off-by: Brent Salisbury <brent.salisbury@gmail.com>
openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/OF13Provider.java
openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/mdsalopenflow13/OF13MdSalInstruction.java [new file with mode: 0644]
openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/mdsalopenflow13/OF13MdSalMatch.java [new file with mode: 0644]

index 2e43b49ad8af8e0cec76c78c30a371d95a18bc32..1369f0c2d6ea0e8c3be6bc159a732ffd2da9b92b 100644 (file)
@@ -31,43 +31,24 @@ import org.opendaylight.ovsdb.openstack.netvirt.api.NetworkingProvider;
 import org.opendaylight.ovsdb.openstack.netvirt.api.TenantNetworkManager;
 import org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService;
 import org.opendaylight.ovsdb.plugin.api.OvsdbConnectionService;
+import org.opendaylight.ovsdb.openstack.netvirt.providers.mdsalopenflow13.OF13MdSalInstruction;
+import org.opendaylight.ovsdb.openstack.netvirt.providers.mdsalopenflow13.OF13MdSalMatch;
 import org.opendaylight.ovsdb.plugin.api.StatusWithUuid;
 import org.opendaylight.ovsdb.schema.openvswitch.Bridge;
 import org.opendaylight.ovsdb.schema.openvswitch.Interface;
 import org.opendaylight.ovsdb.schema.openvswitch.Port;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtl;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtlBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropActionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
@@ -80,9 +61,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.I
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.go.to.table._case.GoToTableBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
@@ -104,21 +83,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddressBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddressBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TunnelBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 import com.google.common.base.Preconditions;
@@ -143,6 +107,7 @@ public class OF13Provider implements NetworkingProvider {
     private static final short TABLE_0_DEFAULT_INGRESS = 0;
     private static final short TABLE_1_ISOLATE_TENANT = 10;
     private static final short TABLE_2_LOCAL_FORWARD = 20;
+    private static final String OPENFLOW = "openflow:";
     private static Long groupId = 1L;
 
     private volatile org.opendaylight.ovsdb.openstack.netvirt.api.ConfigurationService configurationService;
@@ -1257,10 +1222,10 @@ public class OF13Provider implements NetworkingProvider {
                 for (Node dstNode : nodes) {
                     InetAddress src = configurationService.getTunnelEndPoint(srcNode);
                     InetAddress dst = configurationService.getTunnelEndPoint(dstNode);
-                    logger.info("Remove tunnel rules for interface " + intf.getName() + " on srcNode" + srcNode.getNodeIDString());
+                    logger.info("Remove tunnel rules for interface " + intf.getName() + " on srcNode " + srcNode.getNodeIDString());
                     this.removeTunnelRules(tunnelType, network.getProviderSegmentationID(),
                                            dst, srcNode, intf, true, isLastInstanceOnNode);
-                    logger.info("Remove tunnel rules for interface " + intf.getName() + " on dstNode" + dstNode.getNodeIDString());
+                    logger.info("Remove tunnel rules for interface " + intf.getName() + " on dstNode " + dstNode.getNodeIDString());
                     this.removeTunnelRules(tunnelType, network.getProviderSegmentationID(),
                                            src, dstNode, intf, false, isLastInstanceOnNode);
                 }
@@ -1312,7 +1277,7 @@ public class OF13Provider implements NetworkingProvider {
 
     private void writeLLDPRule(Long dpidLong) {
 
-        String nodeName = "openflow:" + dpidLong;
+        String nodeName = OPENFLOW + dpidLong;
         EtherType etherType = new EtherType(0x88CCL);
 
         MatchBuilder matchBuilder = new MatchBuilder();
@@ -1320,7 +1285,7 @@ public class OF13Provider implements NetworkingProvider {
         FlowBuilder flowBuilder = new FlowBuilder();
 
         // Create Match(es) and Set them in the FlowBuilder Object
-        flowBuilder.setMatch(createEtherTypeMatch(matchBuilder, etherType).build());
+        flowBuilder.setMatch(OF13MdSalMatch.createEtherTypeMatch(matchBuilder, etherType).build());
 
         // Create the OF Actions and Instructions
         InstructionBuilder ib = new InstructionBuilder();
@@ -1330,7 +1295,7 @@ public class OF13Provider implements NetworkingProvider {
         List<Instruction> instructions = Lists.newArrayList();
 
         // Call the InstructionBuilder Methods Containing Actions
-        createSendToControllerInstructions(ib);
+        OF13MdSalInstruction.createSendToControllerInstructions(ib);
         ib.setOrder(0);
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
@@ -1361,7 +1326,7 @@ public class OF13Provider implements NetworkingProvider {
 
     private void writeNormalRule(Long dpidLong) {
 
-        String nodeName = "openflow:" + dpidLong;
+        String nodeName = OPENFLOW + dpidLong;
 
         MatchBuilder matchBuilder = new MatchBuilder();
         NodeBuilder nodeBuilder = createNodeBuilder(nodeName);
@@ -1375,7 +1340,7 @@ public class OF13Provider implements NetworkingProvider {
         List<Instruction> instructions = Lists.newArrayList();
 
         // Call the InstructionBuilder Methods Containing Actions
-        createNormalInstructions(ib);
+        OF13MdSalInstruction.createNormalInstructions(ib);
         ib.setOrder(0);
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
@@ -1411,7 +1376,7 @@ public class OF13Provider implements NetworkingProvider {
                                 Short goToTableId, String segmentationId,
                                 Long ofPort, boolean write) {
 
-        String nodeName = "openflow:" + dpidLong;
+        String nodeName = OPENFLOW + dpidLong;
 
         BigInteger tunnelId = new BigInteger(segmentationId);
         MatchBuilder matchBuilder = new MatchBuilder();
@@ -1419,8 +1384,8 @@ public class OF13Provider implements NetworkingProvider {
         FlowBuilder flowBuilder = new FlowBuilder();
 
         // Create Match(es) and Set them in the FlowBuilder Object
-        flowBuilder.setMatch(createTunnelIDMatch(matchBuilder, tunnelId).build());
-        flowBuilder.setMatch(createInPortMatch(matchBuilder, dpidLong, ofPort).build());
+        flowBuilder.setMatch(OF13MdSalMatch.createTunnelIDMatch(matchBuilder, tunnelId).build());
+        flowBuilder.setMatch(OF13MdSalMatch.createInPortMatch(matchBuilder, dpidLong, ofPort).build());
 
         if (write) {
             // Create the OF Actions and Instructions
@@ -1431,7 +1396,7 @@ public class OF13Provider implements NetworkingProvider {
             List<Instruction> instructions = Lists.newArrayList();
 
             // Call the InstructionBuilder Methods Containing Actions
-            createGotoTableInstructions(ib, goToTableId);
+            OF13MdSalInstruction.createGotoTableInstructions(ib, goToTableId);
             ib.setOrder(0);
             ib.setKey(new InstructionKey(0));
             instructions.add(ib.build());
@@ -1472,15 +1437,18 @@ public class OF13Provider implements NetworkingProvider {
     private void handleVlanIn(Long dpidLong, Short writeTable, Short goToTableId,
                       String segmentationId,  Long ethPort, boolean write) {
 
-        String nodeName = "openflow:" + dpidLong;
+        String nodeName = OPENFLOW + dpidLong;
 
         MatchBuilder matchBuilder = new MatchBuilder();
         NodeBuilder nodeBuilder = createNodeBuilder(nodeName);
         FlowBuilder flowBuilder = new FlowBuilder();
 
         // Create Match(es) and Set them in the FlowBuilder Object
-        flowBuilder.setMatch(createVlanIdMatch(matchBuilder, new VlanId(Integer.valueOf(segmentationId))).build());
-        flowBuilder.setMatch(createInPortMatch(matchBuilder, dpidLong, ethPort).build());
+        flowBuilder.setMatch(
+                OF13MdSalMatch.createVlanIdMatch(matchBuilder, new VlanId(Integer.valueOf(segmentationId)))
+                        .build())
+                .setMatch(OF13MdSalMatch.createInPortMatch(matchBuilder, dpidLong, ethPort)
+                        .build());
 
         if (write) {
             // Create the OF Actions and Instructions
@@ -1491,7 +1459,7 @@ public class OF13Provider implements NetworkingProvider {
             List<Instruction> instructions = Lists.newArrayList();
 
             // Call the InstructionBuilder Methods Containing Actions
-            createGotoTableInstructions(ib, goToTableId);
+            OF13MdSalInstruction.createGotoTableInstructions(ib, goToTableId);
             ib.setOrder(0);
             ib.setKey(new InstructionKey(0));
             instructions.add(ib.build());
@@ -1533,16 +1501,16 @@ public class OF13Provider implements NetworkingProvider {
                            String segmentationId, Long inPort, String attachedMac,
                            boolean write) {
 
-        String nodeName = "openflow:" + dpidLong;
+        String nodeName = OPENFLOW + dpidLong;
 
         MatchBuilder matchBuilder = new MatchBuilder();
         NodeBuilder nodeBuilder = createNodeBuilder(nodeName);
         FlowBuilder flowBuilder = new FlowBuilder();
 
         // Create the OF Match using MatchBuilder
-        flowBuilder.setMatch(createEthSrcMatch(matchBuilder, new MacAddress(attachedMac)).build());
+        flowBuilder.setMatch(OF13MdSalMatch.createEthSrcMatch(matchBuilder, new MacAddress(attachedMac)).build());
         // TODO Broken In_Port Match
-        flowBuilder.setMatch(createInPortMatch(matchBuilder, dpidLong, inPort).build());
+        flowBuilder.setMatch(OF13MdSalMatch.createInPortMatch(matchBuilder, dpidLong, inPort).build());
 
         String flowId = "LocalMac_"+segmentationId+"_"+inPort+"_"+attachedMac;
         // Add Flow Attributes
@@ -1564,13 +1532,13 @@ public class OF13Provider implements NetworkingProvider {
             // Instructions List Stores Individual Instructions
             List<Instruction> instructions = Lists.newArrayList();
 
-            // GOTO Instuctions Need to be added first to the List
-            createGotoTableInstructions(ib, goToTableId);
+            // GOTO Instructions Need to be added first to the List
+            OF13MdSalInstruction.createGotoTableInstructions(ib, goToTableId);
             ib.setOrder(0);
             ib.setKey(new InstructionKey(0));
             instructions.add(ib.build());
             // TODO Broken SetTunID
-            createSetTunnelIdInstructions(ib, new BigInteger(segmentationId));
+            OF13MdSalInstruction.createSetTunnelIdInstructions(ib, new BigInteger(segmentationId));
             ib.setOrder(1);
             ib.setKey(new InstructionKey(1));
             instructions.add(ib.build());
@@ -1600,16 +1568,15 @@ public class OF13Provider implements NetworkingProvider {
                                   Long inPort, String attachedMac,
                                   boolean write) {
 
-         String nodeName = "openflow:" + dpidLong;
+         String nodeName = OPENFLOW + dpidLong;
 
          MatchBuilder matchBuilder = new MatchBuilder();
          NodeBuilder nodeBuilder = createNodeBuilder(nodeName);
          FlowBuilder flowBuilder = new FlowBuilder();
 
          // Create the OF Match using MatchBuilder
-         flowBuilder.setMatch(createEthSrcMatch(matchBuilder, new MacAddress(attachedMac)).build());
-         // TODO Broken In_Port Match
-         flowBuilder.setMatch(createInPortMatch(matchBuilder, dpidLong, inPort).build());
+         flowBuilder.setMatch(OF13MdSalMatch.createEthSrcMatch(matchBuilder, new MacAddress(attachedMac)).build());
+         flowBuilder.setMatch(OF13MdSalMatch.createInPortMatch(matchBuilder, dpidLong, inPort).build());
 
          String flowId = "LocalMac_"+segmentationId+"_"+inPort+"_"+attachedMac;
          // Add Flow Attributes
@@ -1632,12 +1599,12 @@ public class OF13Provider implements NetworkingProvider {
              List<Instruction> instructions = Lists.newArrayList();
 
              // GOTO Instructions Need to be added first to the List
-             createGotoTableInstructions(ib, goToTableId);
+             OF13MdSalInstruction.createGotoTableInstructions(ib, goToTableId);
              ib.setOrder(0);
              ib.setKey(new InstructionKey(0));
              instructions.add(ib.build());
              // Set VLAN ID Instruction
-             createSetVlanInstructions(ib, new VlanId(Integer.valueOf(segmentationId)));
+             OF13MdSalInstruction.createSetVlanInstructions(ib, new VlanId(Integer.valueOf(segmentationId)));
              ib.setOrder(1);
              ib.setKey(new InstructionKey(1));
              instructions.add(ib.build());
@@ -1664,14 +1631,14 @@ public class OF13Provider implements NetworkingProvider {
 
     private void handleDropSrcIface(Long dpidLong, Long inPort, boolean write) {
 
-        String nodeName = "openflow:" + dpidLong;
+        String nodeName = OPENFLOW + dpidLong;
 
         MatchBuilder matchBuilder = new MatchBuilder();
         NodeBuilder nodeBuilder = createNodeBuilder(nodeName);
         FlowBuilder flowBuilder = new FlowBuilder();
 
         // Create the OF Match using MatchBuilder
-        flowBuilder.setMatch(createInPortMatch(matchBuilder, dpidLong, inPort).build());
+        flowBuilder.setMatch(OF13MdSalMatch.createInPortMatch(matchBuilder, dpidLong, inPort).build());
 
         if (write) {
             // Instantiate the Builders for the OF Actions and Instructions
@@ -1682,7 +1649,7 @@ public class OF13Provider implements NetworkingProvider {
             List<Instruction> instructions = Lists.newArrayList();
 
             // Call the InstructionBuilder Methods Containing Actions
-            createDropInstructions(ib);
+            OF13MdSalInstruction.createDropInstructions(ib);
             ib.setOrder(0);
             ib.setKey(new InstructionKey(0));
             instructions.add(ib.build());
@@ -1700,7 +1667,7 @@ public class OF13Provider implements NetworkingProvider {
         FlowKey key = new FlowKey(new FlowId(flowId));
         flowBuilder.setStrict(true);
         flowBuilder.setBarrier(false);
-        flowBuilder.setTableId((short) 0);
+        flowBuilder.setTableId(TABLE_0_DEFAULT_INGRESS);
         flowBuilder.setKey(key);
         flowBuilder.setFlowName(flowId);
         flowBuilder.setPriority(8192);
@@ -1725,15 +1692,15 @@ public class OF13Provider implements NetworkingProvider {
                          Long OFPortOut, String attachedMac,
                          boolean write) {
 
-        String nodeName = "openflow:" + dpidLong;
+        String nodeName = OPENFLOW + dpidLong;
 
         MatchBuilder matchBuilder = new MatchBuilder();
         NodeBuilder nodeBuilder = createNodeBuilder(nodeName);
         FlowBuilder flowBuilder = new FlowBuilder();
 
         // Create the OF Match using MatchBuilder
-        flowBuilder.setMatch(createTunnelIDMatch(matchBuilder, new BigInteger(segmentationId)).build());
-        flowBuilder.setMatch(createDestEthMatch(matchBuilder, new MacAddress(attachedMac), null).build());
+        flowBuilder.setMatch(OF13MdSalMatch.createTunnelIDMatch(matchBuilder, new BigInteger(segmentationId)).build());
+        flowBuilder.setMatch(OF13MdSalMatch.createDestEthMatch(matchBuilder, new MacAddress(attachedMac), null).build());
 
         String flowId = "TunnelOut_"+segmentationId+"_"+OFPortOut+"_"+attachedMac;
         // Add Flow Attributes
@@ -1755,13 +1722,13 @@ public class OF13Provider implements NetworkingProvider {
             // Instructions List Stores Individual Instructions
             List<Instruction> instructions = Lists.newArrayList();
 
-            // GOTO Instuctions
-            createGotoTableInstructions(ib, goToTableId);
+            // GOTO Instructions
+            OF13MdSalInstruction.createGotoTableInstructions(ib, goToTableId);
             ib.setOrder(0);
             ib.setKey(new InstructionKey(0));
             instructions.add(ib.build());
             // Set the Output Port/Iface
-            createOutputPortInstructions(ib, dpidLong, OFPortOut);
+            OF13MdSalInstruction.createOutputPortInstructions(ib, dpidLong, OFPortOut);
             ib.setOrder(1);
             ib.setKey(new InstructionKey(1));
             instructions.add(ib.build());
@@ -1790,15 +1757,16 @@ public class OF13Provider implements NetworkingProvider {
                         Short goToTableId, String segmentationId,
                         Long ethPort, String attachedMac, boolean write) {
 
-         String nodeName = "openflow:" + dpidLong;
+         String nodeName = OPENFLOW + dpidLong;
 
          MatchBuilder matchBuilder = new MatchBuilder();
          NodeBuilder nodeBuilder = createNodeBuilder(nodeName);
          FlowBuilder flowBuilder = new FlowBuilder();
 
          // Create the OF Match using MatchBuilder
-         flowBuilder.setMatch(createVlanIdMatch(matchBuilder, new VlanId(Integer.valueOf(segmentationId))).build());
-         flowBuilder.setMatch(createDestEthMatch(matchBuilder, new MacAddress(attachedMac), null).build());
+         flowBuilder.setMatch(
+                 OF13MdSalMatch.createVlanIdMatch(matchBuilder, new VlanId(Integer.valueOf(segmentationId))).build());
+         flowBuilder.setMatch(OF13MdSalMatch.createDestEthMatch(matchBuilder, new MacAddress(attachedMac), null).build());
 
          String flowId = "VlanOut_"+segmentationId+"_"+ethPort+"_"+attachedMac;
          // Add Flow Attributes
@@ -1820,8 +1788,8 @@ public class OF13Provider implements NetworkingProvider {
              // Instructions List Stores Individual Instructions
              List<Instruction> instructions = Lists.newArrayList();
 
-             // GOTO Instuctions
-             createGotoTableInstructions(ib, goToTableId);
+             // GOTO Instructions
+             OF13MdSalInstruction.createGotoTableInstructions(ib, goToTableId);
              ib.setOrder(0);
              ib.setKey(new InstructionKey(0));
              instructions.add(ib.build());
@@ -1850,7 +1818,7 @@ public class OF13Provider implements NetworkingProvider {
                              Short localTable, String segmentationId,
                              Long OFPortOut, boolean write) {
 
-        String nodeName = "openflow:" + dpidLong;
+        String nodeName = OPENFLOW + dpidLong;
 
         MatchBuilder matchBuilder = new MatchBuilder();
         NodeBuilder nodeBuilder = createNodeBuilder(nodeName);
@@ -1858,10 +1826,11 @@ public class OF13Provider implements NetworkingProvider {
 
         // Create the OF Match using MatchBuilder
         // Match TunnelID
-        flowBuilder.setMatch(createTunnelIDMatch(matchBuilder, new BigInteger(segmentationId)).build());
+        flowBuilder.setMatch(OF13MdSalMatch.createTunnelIDMatch(matchBuilder, new BigInteger(segmentationId)).build());
         // Match DMAC
 
-        flowBuilder.setMatch(createDestEthMatch(matchBuilder, new MacAddress("01:00:00:00:00:00"), new MacAddress("01:00:00:00:00:00")).build());
+        flowBuilder.setMatch(OF13MdSalMatch.createDestEthMatch(matchBuilder, new MacAddress("01:00:00:00:00:00"),
+                new MacAddress("01:00:00:00:00:00")).build());
 
         String flowId = "TunnelFloodOut_"+segmentationId;
         // Add Flow Attributes
@@ -1890,7 +1859,7 @@ public class OF13Provider implements NetworkingProvider {
 
         if (write) {
             // GOTO Instruction
-            createGotoTableInstructions(ib, localTable);
+            OF13MdSalInstruction.createGotoTableInstructions(ib, localTable);
             ib.setOrder(0);
             ib.setKey(new InstructionKey(0));
             instructions.add(ib.build());
@@ -1910,8 +1879,8 @@ public class OF13Provider implements NetworkingProvider {
             writeFlow(flowBuilder, nodeBuilder);
         } else {
             /* remove port from action list */
-            boolean flowRemove = removeOutputPortFromInstructions(ib, dpidLong,
-                                   OFPortOut, existingInstructions);
+            boolean flowRemove = OF13MdSalInstruction.removeOutputPortFromInstructions(ib, dpidLong,
+                    OFPortOut, existingInstructions);
             if (flowRemove) {
                 /* if all port are removed, remove the flow too. */
                 removeFlow(flowBuilder, nodeBuilder);
@@ -1942,7 +1911,7 @@ public class OF13Provider implements NetworkingProvider {
                            Short localTable, String segmentationId,
                            Long ethPort, boolean write) {
 
-         String nodeName = "openflow:" + dpidLong;
+         String nodeName = OPENFLOW + dpidLong;
 
          MatchBuilder matchBuilder = new MatchBuilder();
          NodeBuilder nodeBuilder = createNodeBuilder(nodeName);
@@ -1950,9 +1919,11 @@ public class OF13Provider implements NetworkingProvider {
 
          // Create the OF Match using MatchBuilder
          // Match Vlan ID
-         flowBuilder.setMatch(createVlanIdMatch(matchBuilder, new VlanId(Integer.valueOf(segmentationId))).build());
+         flowBuilder.setMatch(
+                 OF13MdSalMatch.createVlanIdMatch(matchBuilder, new VlanId(Integer.valueOf(segmentationId))).build());
          // Match DMAC
-         flowBuilder.setMatch(createDestEthMatch(matchBuilder, new MacAddress("01:00:00:00:00:00"), new MacAddress("01:00:00:00:00:00")).build());
+         flowBuilder.setMatch(OF13MdSalMatch.createDestEthMatch(matchBuilder, new MacAddress("01:00:00:00:00:00"),
+                 new MacAddress("01:00:00:00:00:00")).build());
 
          String flowId = "VlanFloodOut_"+segmentationId;
          // Add Flow Attributes
@@ -1975,13 +1946,13 @@ public class OF13Provider implements NetworkingProvider {
          List<Instruction> instructions = Lists.newArrayList();
 
          if (write) {
-             // GOTO Instuction
-             createGotoTableInstructions(ib, localTable);
+             // GOTO Instruction
+             OF13MdSalInstruction.createGotoTableInstructions(ib, localTable);
              ib.setOrder(0);
              ib.setKey(new InstructionKey(0));
              instructions.add(ib.build());
              // Set the Output Port/Iface
-             createOutputPortInstructions(ib, dpidLong, ethPort);
+             OF13MdSalInstruction.createOutputPortInstructions(ib, dpidLong, ethPort);
              ib.setOrder(1);
              ib.setKey(new InstructionKey(1));
              instructions.add(ib.build());
@@ -2009,14 +1980,14 @@ public class OF13Provider implements NetworkingProvider {
                           Short goToTableId, String segmentationId,
                           boolean write) {
 
-        String nodeName = "openflow:" + dpidLong;
+        String nodeName = OPENFLOW + dpidLong;
 
         MatchBuilder matchBuilder = new MatchBuilder();
         NodeBuilder nodeBuilder = createNodeBuilder(nodeName);
         FlowBuilder flowBuilder = new FlowBuilder();
 
         // Create Match(es) and Set them in the FlowBuilder Object
-        flowBuilder.setMatch(createTunnelIDMatch(matchBuilder, new BigInteger(segmentationId)).build());
+        flowBuilder.setMatch(OF13MdSalMatch.createTunnelIDMatch(matchBuilder, new BigInteger(segmentationId)).build());
 
         if (write) {
             // Create the OF Actions and Instructions
@@ -2027,7 +1998,7 @@ public class OF13Provider implements NetworkingProvider {
             List<Instruction> instructions = Lists.newArrayList();
 
             // Call the InstructionBuilder Methods Containing Actions
-            createGotoTableInstructions(ib, goToTableId);
+            OF13MdSalInstruction.createGotoTableInstructions(ib, goToTableId);
             ib.setOrder(0);
             ib.setKey(new InstructionKey(0));
             instructions.add(ib.build());
@@ -2070,14 +2041,15 @@ public class OF13Provider implements NetworkingProvider {
                          Short goToTableId, String segmentationId,
                          Long ethPort, boolean write) {
 
-         String nodeName = "openflow:" + dpidLong;
+         String nodeName = OPENFLOW + dpidLong;
 
          MatchBuilder matchBuilder = new MatchBuilder();
          NodeBuilder nodeBuilder = createNodeBuilder(nodeName);
          FlowBuilder flowBuilder = new FlowBuilder();
 
          // Create Match(es) and Set them in the FlowBuilder Object
-         flowBuilder.setMatch(createVlanIdMatch(matchBuilder, new VlanId(Integer.valueOf(segmentationId))).build());
+         flowBuilder.setMatch(
+                 OF13MdSalMatch.createVlanIdMatch(matchBuilder, new VlanId(Integer.valueOf(segmentationId))).build());
 
          if (write) {
              // Create the OF Actions and Instructions
@@ -2093,7 +2065,7 @@ public class OF13Provider implements NetworkingProvider {
              //ib.setKey(new InstructionKey(0));
              //instructions.add(ib.build());
              // Set the Output Port/Iface
-             createOutputPortInstructions(ib, dpidLong, ethPort);
+             OF13MdSalInstruction.createOutputPortInstructions(ib, dpidLong, ethPort);
              ib.setOrder(0);
              ib.setKey(new InstructionKey(1));
              instructions.add(ib.build());
@@ -2135,15 +2107,15 @@ public class OF13Provider implements NetworkingProvider {
                              String segmentationId, Long localPort,
                              String attachedMac, boolean write) {
 
-        String nodeName = "openflow:" + dpidLong;
+        String nodeName = OPENFLOW + dpidLong;
 
         MatchBuilder matchBuilder = new MatchBuilder();
         NodeBuilder nodeBuilder = createNodeBuilder(nodeName);
         FlowBuilder flowBuilder = new FlowBuilder();
 
         // Create the OF Match using MatchBuilder
-        flowBuilder.setMatch(createTunnelIDMatch(matchBuilder, new BigInteger(segmentationId)).build());
-        flowBuilder.setMatch(createDestEthMatch(matchBuilder, new MacAddress(attachedMac), null).build());
+        flowBuilder.setMatch(OF13MdSalMatch.createTunnelIDMatch(matchBuilder, new BigInteger(segmentationId)).build());
+        flowBuilder.setMatch(OF13MdSalMatch.createDestEthMatch(matchBuilder, new MacAddress(attachedMac), null).build());
 
         String flowId = "UcastOut_"+segmentationId+"_"+localPort+"_"+attachedMac;
         // Add Flow Attributes
@@ -2166,7 +2138,7 @@ public class OF13Provider implements NetworkingProvider {
             List<Instruction> instructions = Lists.newArrayList();
 
             // Set the Output Port/Iface
-            createOutputPortInstructions(ib, dpidLong, localPort);
+            OF13MdSalInstruction.createOutputPortInstructions(ib, dpidLong, localPort);
             ib.setOrder(0);
             ib.setKey(new InstructionKey(0));
             instructions.add(ib.build());
@@ -2193,15 +2165,16 @@ public class OF13Provider implements NetworkingProvider {
                                  String segmentationId, Long localPort,
                                  String attachedMac, boolean write) {
 
-        String nodeName = "openflow:" + dpidLong;
+        String nodeName = OPENFLOW + dpidLong;
 
         MatchBuilder matchBuilder = new MatchBuilder();
         NodeBuilder nodeBuilder = createNodeBuilder(nodeName);
         FlowBuilder flowBuilder = new FlowBuilder();
 
         // Create the OF Match using MatchBuilder
-        flowBuilder.setMatch(createVlanIdMatch(matchBuilder, new VlanId(Integer.valueOf(segmentationId))).build());
-        flowBuilder.setMatch(createDestEthMatch(matchBuilder, new MacAddress(attachedMac), null).build());
+        flowBuilder.setMatch(
+                OF13MdSalMatch.createVlanIdMatch(matchBuilder, new VlanId(Integer.valueOf(segmentationId))).build());
+        flowBuilder.setMatch(OF13MdSalMatch.createDestEthMatch(matchBuilder, new MacAddress(attachedMac), null).build());
 
         String flowId = "VlanUcastOut_"+segmentationId+"_"+localPort+"_"+attachedMac;
         // Add Flow Attributes
@@ -2225,14 +2198,14 @@ public class OF13Provider implements NetworkingProvider {
             List<Instruction> instructions_tmp = Lists.newArrayList();
 
             /* Strip vlan and store to tmp instruction space*/
-            createPopVlanInstructions(ib);
+            OF13MdSalInstruction.createPopVlanInstructions(ib);
             ib.setOrder(0);
             ib.setKey(new InstructionKey(0));
             instructions_tmp.add(ib.build());
 
             // Set the Output Port/Iface
             ib = new InstructionBuilder();
-            addOutputPortInstructions(ib, dpidLong, localPort, instructions_tmp);
+            OF13MdSalInstruction.addOutputPortInstructions(ib, dpidLong, localPort, instructions_tmp);
             ib.setOrder(0);
             ib.setKey(new InstructionKey(0));
             instructions.add(ib.build());
@@ -2259,15 +2232,16 @@ public class OF13Provider implements NetworkingProvider {
                              String segmentationId, Long localPort,
                              boolean write) {
 
-        String nodeName = "openflow:" + dpidLong;
+        String nodeName = OPENFLOW + dpidLong;
 
         MatchBuilder matchBuilder = new MatchBuilder();
         NodeBuilder nodeBuilder = createNodeBuilder(nodeName);
         FlowBuilder flowBuilder = new FlowBuilder();
 
         // Create the OF Match using MatchBuilder
-        flowBuilder.setMatch(createTunnelIDMatch(matchBuilder, new BigInteger(segmentationId)).build());
-        flowBuilder.setMatch(createDestEthMatch(matchBuilder, new MacAddress("01:00:00:00:00:00"), new MacAddress("01:00:00:00:00:00")).build());
+        flowBuilder.setMatch(OF13MdSalMatch.createTunnelIDMatch(matchBuilder, new BigInteger(segmentationId)).build());
+        flowBuilder.setMatch(OF13MdSalMatch.createDestEthMatch(matchBuilder, new MacAddress("01:00:00:00:00:00"),
+                new MacAddress("01:00:00:00:00:00")).build());
 
         String flowId = "BcastOut_"+segmentationId;
         // Add Flow Attributes
@@ -2309,8 +2283,8 @@ public class OF13Provider implements NetworkingProvider {
 
             writeFlow(flowBuilder, nodeBuilder);
         } else {
-            boolean flowRemove = removeOutputPortFromInstructions(ib, dpidLong, localPort,
-                                                                  existingInstructions);
+            boolean flowRemove = OF13MdSalInstruction.removeOutputPortFromInstructions(ib, dpidLong, localPort,
+                    existingInstructions);
             if (flowRemove) {
                 /* if all ports are removed, remove flow */
                 removeFlow(flowBuilder, nodeBuilder);
@@ -2342,15 +2316,17 @@ public class OF13Provider implements NetworkingProvider {
                                  String segmentationId, Long localPort,
                                  boolean write) {
 
-        String nodeName = "openflow:" + dpidLong;
+        String nodeName = OPENFLOW + dpidLong;
 
         MatchBuilder matchBuilder = new MatchBuilder();
         NodeBuilder nodeBuilder = createNodeBuilder(nodeName);
         FlowBuilder flowBuilder = new FlowBuilder();
 
         // Create the OF Match using MatchBuilder
-        flowBuilder.setMatch(createVlanIdMatch(matchBuilder, new VlanId(Integer.valueOf(segmentationId))).build());
-        flowBuilder.setMatch(createDestEthMatch(matchBuilder, new MacAddress("01:00:00:00:00:00"), new MacAddress("01:00:00:00:00:00")).build());
+        flowBuilder.setMatch(
+                OF13MdSalMatch.createVlanIdMatch(matchBuilder, new VlanId(Integer.valueOf(segmentationId))).build());
+        flowBuilder.setMatch(OF13MdSalMatch.createDestEthMatch(matchBuilder, new MacAddress("01:00:00:00:00:00"),
+                new MacAddress("01:00:00:00:00:00")).build());
 
         String flowId = "VlanBcastOut_"+segmentationId;
         // Add Flow Attributes
@@ -2398,7 +2374,7 @@ public class OF13Provider implements NetworkingProvider {
 
             if (add_pop_vlan) {
                 /* pop vlan */
-                createPopVlanInstructions(ib);
+                OF13MdSalInstruction.createPopVlanInstructions(ib);
                 ib.setOrder(0);
                 ib.setKey(new InstructionKey(0));
                 existingInstructions.add(ib.build());
@@ -2422,8 +2398,8 @@ public class OF13Provider implements NetworkingProvider {
         } else {
             //boolean flowRemove = removeOutputPortFromGroup(nodeBuilder, ib, dpidLong,
             //                     localPort, existingInstructions);
-            boolean flowRemove = removeOutputPortFromInstructions(ib, dpidLong,
-                                                    localPort, existingInstructions);
+            boolean flowRemove = OF13MdSalInstruction.removeOutputPortFromInstructions(ib, dpidLong,
+                    localPort, existingInstructions);
             if (flowRemove) {
                 /* if all ports are removed, remove flow */
                 removeFlow(flowBuilder, nodeBuilder);
@@ -2453,14 +2429,14 @@ public class OF13Provider implements NetworkingProvider {
     private void handleLocalTableMiss(Long dpidLong, Short writeTable,
                              String segmentationId, boolean write) {
 
-        String nodeName = "openflow:" + dpidLong;
+        String nodeName = OPENFLOW + dpidLong;
 
         MatchBuilder matchBuilder = new MatchBuilder();
         NodeBuilder nodeBuilder = createNodeBuilder(nodeName);
         FlowBuilder flowBuilder = new FlowBuilder();
 
         // Create Match(es) and Set them in the FlowBuilder Object
-        flowBuilder.setMatch(createTunnelIDMatch(matchBuilder, new BigInteger(segmentationId)).build());
+        flowBuilder.setMatch(OF13MdSalMatch.createTunnelIDMatch(matchBuilder, new BigInteger(segmentationId)).build());
 
         if (write) {
             // Create the OF Actions and Instructions
@@ -2471,7 +2447,7 @@ public class OF13Provider implements NetworkingProvider {
             List<Instruction> instructions = Lists.newArrayList();
 
             // Call the InstructionBuilder Methods Containing Actions
-            createDropInstructions(ib);
+            OF13MdSalInstruction.createDropInstructions(ib);
             ib.setOrder(0);
             ib.setKey(new InstructionKey(0));
             instructions.add(ib.build());
@@ -2512,14 +2488,15 @@ public class OF13Provider implements NetworkingProvider {
     private void handleLocalVlanTableMiss(Long dpidLong, Short writeTable,
                                   String segmentationId, boolean write) {
 
-        String nodeName = "openflow:" + dpidLong;
+        String nodeName = OPENFLOW + dpidLong;
 
         MatchBuilder matchBuilder = new MatchBuilder();
         NodeBuilder nodeBuilder = createNodeBuilder(nodeName);
         FlowBuilder flowBuilder = new FlowBuilder();
 
         // Create Match(es) and Set them in the FlowBuilder Object
-        flowBuilder.setMatch(createVlanIdMatch(matchBuilder, new VlanId(Integer.valueOf(segmentationId))).build());
+        flowBuilder.setMatch(
+                OF13MdSalMatch.createVlanIdMatch(matchBuilder, new VlanId(Integer.valueOf(segmentationId))).build());
 
         if (write) {
             // Create the OF Actions and Instructions
@@ -2530,7 +2507,7 @@ public class OF13Provider implements NetworkingProvider {
             List<Instruction> instructions = Lists.newArrayList();
 
             // Call the InstructionBuilder Methods Containing Actions
-            createDropInstructions(ib);
+            OF13MdSalInstruction.createDropInstructions(ib);
             ib.setOrder(0);
             ib.setKey(new InstructionKey(0));
             instructions.add(ib.build());
@@ -2771,338 +2748,6 @@ public class OF13Provider implements NetworkingProvider {
         }
     }
 
-    /**
-     * Create Ingress Port Match dpidLong, inPort
-     *
-     * @param matchBuilder  Map matchBuilder MatchBuilder Object without a match
-     * @param dpidLong      Long the datapath ID of a switch/node
-     * @param inPort        Long ingress port on a switch
-     * @return matchBuilder Map MatchBuilder Object with a match
-     */
-    protected static MatchBuilder createInPortMatch(MatchBuilder matchBuilder, Long dpidLong, Long inPort) {
-
-        NodeConnectorId ncid = new NodeConnectorId("openflow:" + dpidLong + ":" + inPort);
-        logger.debug("createInPortMatch() Node Connector ID is - Type=openflow: DPID={} inPort={} ", dpidLong, inPort);
-        matchBuilder.setInPort(NodeConnectorId.getDefaultInstance(ncid.getValue()));
-        matchBuilder.setInPort(ncid);
-
-        return matchBuilder;
-    }
-
-    /**
-     * Create EtherType Match
-     *
-     * @param matchBuilder  Map matchBuilder MatchBuilder Object without a match
-     * @param etherType     Long EtherType
-     * @return matchBuilder Map MatchBuilder Object with a match
-     */
-    protected static MatchBuilder createEtherTypeMatch(MatchBuilder matchBuilder, EtherType etherType) {
-
-        EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
-        EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
-        ethTypeBuilder.setType(new EtherType(etherType));
-        ethernetMatch.setEthernetType(ethTypeBuilder.build());
-        matchBuilder.setEthernetMatch(ethernetMatch.build());
-
-        return matchBuilder;
-    }
-
-    /**
-     * Create Ethernet Source Match
-     *
-     * @param matchBuilder  MatchBuilder Object without a match yet
-     * @param sMacAddr      String representing a source MAC
-     * @return matchBuilder Map MatchBuilder Object with a match
-     */
-    protected static MatchBuilder createEthSrcMatch(MatchBuilder matchBuilder, MacAddress sMacAddr) {
-
-        EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
-        EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
-        ethSourceBuilder.setAddress(new MacAddress(sMacAddr));
-        ethernetMatch.setEthernetSource(ethSourceBuilder.build());
-        matchBuilder.setEthernetMatch(ethernetMatch.build());
-
-        return matchBuilder;
-    }
-
-    /**
-     * Create Ethernet Destination Match
-     *
-     * @param matchBuilder MatchBuilder Object without a match yet
-     * @param vlanId       Integer representing a VLAN ID Integer representing a VLAN ID
-     * @return matchBuilder Map MatchBuilder Object with a match
-     */
-
-    protected static MatchBuilder createVlanIdMatch(MatchBuilder matchBuilder, VlanId vlanId) {
-        VlanMatchBuilder vlanMatchBuilder = new VlanMatchBuilder();
-        VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
-        vlanIdBuilder.setVlanId(new VlanId(vlanId));
-        vlanIdBuilder.setVlanIdPresent(true);
-        vlanMatchBuilder.setVlanId(vlanIdBuilder.build());
-        matchBuilder.setVlanMatch(vlanMatchBuilder.build());
-
-        return matchBuilder;
-    }
-
-    /**
-     * Create Ethernet Destination Match
-     *
-     * @param matchBuilder  MatchBuilder Object without a match yet
-     * @param dMacAddr      String representing a destination MAC
-     * @return matchBuilder Map MatchBuilder Object with a match
-     */
-
-    protected static MatchBuilder createDestEthMatch(MatchBuilder matchBuilder, MacAddress dMacAddr, MacAddress mask) {
-
-        EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
-        EthernetDestinationBuilder ethDestinationBuilder = new EthernetDestinationBuilder();
-        ethDestinationBuilder.setAddress(new MacAddress(dMacAddr));
-        if (mask != null) {
-            ethDestinationBuilder.setMask(mask);
-        }
-        ethernetMatch.setEthernetDestination(ethDestinationBuilder.build());
-        matchBuilder.setEthernetMatch(ethernetMatch.build());
-
-        return matchBuilder;
-    }
-
-    /**
-     * Tunnel ID Match Builder
-     *
-     * @param matchBuilder  MatchBuilder Object without a match yet
-     * @param tunnelId      BigInteger representing a tunnel ID
-     * @return matchBuilder Map MatchBuilder Object with a match
-     */
-    protected static MatchBuilder createTunnelIDMatch(MatchBuilder matchBuilder, BigInteger tunnelId) {
-
-        TunnelBuilder tunnelBuilder = new TunnelBuilder();
-        tunnelBuilder.setTunnelId(tunnelId);
-        matchBuilder.setTunnel(tunnelBuilder.build());
-
-        return matchBuilder;
-    }
-
-    /**
-     * Match ICMP code and type
-     *
-     * @param matchBuilder  MatchBuilder Object without a match yet
-     * @param type          short representing an ICMP type
-     * @param code          short representing an ICMP code
-     * @return matchBuilder Map MatchBuilder Object with a match
-     */
-    protected static MatchBuilder createICMPv4Match(MatchBuilder matchBuilder, short type, short code) {
-
-        EthernetMatchBuilder eth = new EthernetMatchBuilder();
-        EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
-        ethTypeBuilder.setType(new EtherType(0x0800L));
-        eth.setEthernetType(ethTypeBuilder.build());
-        matchBuilder.setEthernetMatch(eth.build());
-
-        // Build the IPv4 Match requied per OVS Syntax
-        IpMatchBuilder ipmatch = new IpMatchBuilder();
-        ipmatch.setIpProtocol((short) 1);
-        matchBuilder.setIpMatch(ipmatch.build());
-
-        // Build the ICMPv4 Match
-        Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder();
-        icmpv4match.setIcmpv4Type(type);
-        icmpv4match.setIcmpv4Code(code);
-        matchBuilder.setIcmpv4Match(icmpv4match.build());
-
-        return matchBuilder;
-    }
-
-    /**
-     * @param matchBuilder MatchBuilder Object without a match yet
-     * @param dstip        String containing an IPv4 prefix
-     * @return matchBuilder Map Object with a match
-     */
-    private static MatchBuilder createDstL3IPv4Match(MatchBuilder matchBuilder, Ipv4Prefix dstip) {
-
-        EthernetMatchBuilder eth = new EthernetMatchBuilder();
-        EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
-        ethTypeBuilder.setType(new EtherType(0x0800L));
-        eth.setEthernetType(ethTypeBuilder.build());
-        matchBuilder.setEthernetMatch(eth.build());
-
-        Ipv4MatchBuilder ipv4match = new Ipv4MatchBuilder();
-        ipv4match.setIpv4Destination(dstip);
-
-        matchBuilder.setLayer3Match(ipv4match.build());
-
-        return matchBuilder;
-
-    }
-
-    /**
-     * @param matchBuilder MatchBuilder Object without a match yet
-     * @param srcip        String containing an IPv4 prefix
-     * @return             matchBuilder Map Object with a match
-     */
-    private static MatchBuilder createSrcL3IPv4Match(MatchBuilder matchBuilder, Ipv4Prefix srcip) {
-
-        EthernetMatchBuilder eth = new EthernetMatchBuilder();
-        EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
-        ethTypeBuilder.setType(new EtherType(0x0800L));
-        eth.setEthernetType(ethTypeBuilder.build());
-        matchBuilder.setEthernetMatch(eth.build());
-
-        Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
-        Ipv4MatchBuilder ipv4match = new Ipv4MatchBuilder();
-        ipv4match.setIpv4Source(srcip);
-        matchBuilder.setLayer3Match(ipv4match.build());
-
-        return matchBuilder;
-
-    }
-
-    /**
-     * Create Source TCP Port Match
-     *
-     * @param matchBuilder @param matchbuilder MatchBuilder Object without a match yet
-     * @param tcpport      Integer representing a source TCP port
-     * @return             matchBuilder Map MatchBuilder Object with a match
-     */
-    protected static MatchBuilder createSetSrcTcpMatch(MatchBuilder matchBuilder, PortNumber tcpport) {
-
-        EthernetMatchBuilder ethType = new EthernetMatchBuilder();
-        EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
-        ethTypeBuilder.setType(new EtherType(0x0800L));
-        ethType.setEthernetType(ethTypeBuilder.build());
-        matchBuilder.setEthernetMatch(ethType.build());
-
-        IpMatchBuilder ipmatch = new IpMatchBuilder();
-        ipmatch.setIpProtocol((short) 6);
-        matchBuilder.setIpMatch(ipmatch.build());
-
-        TcpMatchBuilder tcpmatch = new TcpMatchBuilder();
-        tcpmatch.setTcpSourcePort(tcpport);
-        matchBuilder.setLayer4Match(tcpmatch.build());
-
-        return matchBuilder;
-
-    }
-
-    /**
-     * Create Destination TCP Port Match
-     *
-     * @param matchBuilder MatchBuilder Object without a match yet
-     * @param tcpport      Integer representing a destination TCP port
-     * @return             matchBuilder Map MatchBuilder Object with a match
-     */
-    protected static MatchBuilder createSetDstTcpMatch(MatchBuilder matchBuilder, PortNumber tcpport) {
-
-        EthernetMatchBuilder ethType = new EthernetMatchBuilder();
-        EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
-        ethTypeBuilder.setType(new EtherType(0x0800L));
-        ethType.setEthernetType(ethTypeBuilder.build());
-        matchBuilder.setEthernetMatch(ethType.build());
-
-        IpMatchBuilder ipmatch = new IpMatchBuilder();
-        ipmatch.setIpProtocol((short) 6);
-        matchBuilder.setIpMatch(ipmatch.build());
-
-        PortNumber dstport = new PortNumber(tcpport);
-        TcpMatchBuilder tcpmatch = new TcpMatchBuilder();
-
-        tcpmatch.setTcpDestinationPort(tcpport);
-        matchBuilder.setLayer4Match(tcpmatch.build());
-
-        return matchBuilder;
-    }
-
-    /**
-     * Create Send to Controller Reserved Port Instruction (packet_in)
-     *
-     * @param ib Map InstructionBuilder without any instructions
-     * @return ib Map InstructionBuilder with instructions
-     */
-
-    protected static InstructionBuilder createSendToControllerInstructions(InstructionBuilder ib) {
-
-        List<Action> actionList = Lists.newArrayList();
-        ActionBuilder ab = new ActionBuilder();
-
-        OutputActionBuilder output = new OutputActionBuilder();
-        output.setMaxLength(0xffff);
-        Uri value = new Uri("CONTROLLER");
-        output.setOutputNodeConnector(value);
-        ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
-        ab.setOrder(0);
-        ab.setKey(new ActionKey(0));
-        actionList.add(ab.build());
-
-        // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
-        aab.setAction(actionList);
-
-        // Wrap our Apply Action in an Instruction
-        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
-
-        return ib;
-    }
-
-    /**
-     * Create NORMAL Reserved Port Instruction (packet_in)
-     *
-     * @param ib Map InstructionBuilder without any instructions
-     * @return ib Map InstructionBuilder with instructions
-     */
-
-    protected static InstructionBuilder createNormalInstructions(InstructionBuilder ib) {
-
-        List<Action> actionList = Lists.newArrayList();
-        ActionBuilder ab = new ActionBuilder();
-
-        OutputActionBuilder output = new OutputActionBuilder();
-        Uri value = new Uri("NORMAL");
-        output.setOutputNodeConnector(value);
-        ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
-        ab.setOrder(0);
-        ab.setKey(new ActionKey(0));
-        actionList.add(ab.build());
-
-        // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
-        aab.setAction(actionList);
-
-        // Wrap our Apply Action in an Instruction
-        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
-
-        return ib;
-    }
-
-    /**
-     * Create Output Port Instruction
-     *
-     * @param ib       Map InstructionBuilder without any instructions
-     * @param dpidLong Long the datapath ID of a switch/node
-     * @param port     Long representing a port on a switch/node
-     * @return ib InstructionBuilder Map with instructions
-     */
-    protected static InstructionBuilder createOutputPortInstructions(InstructionBuilder ib, Long dpidLong, Long port) {
-
-        NodeConnectorId ncid = new NodeConnectorId("openflow:" + dpidLong + ":" + port);
-        logger.debug("createOutputPortInstructions() Node Connector ID is - Type=openflow: DPID={} inPort={} ", dpidLong, port);
-
-        List<Action> actionList = Lists.newArrayList();
-        ActionBuilder ab = new ActionBuilder();
-        OutputActionBuilder oab = new OutputActionBuilder();
-        oab.setOutputNodeConnector(ncid);
-
-        ab.setAction(new OutputActionCaseBuilder().setOutputAction(oab.build()).build());
-        ab.setOrder(0);
-        ab.setKey(new ActionKey(0));
-        actionList.add(ab.build());
-
-        // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
-        aab.setAction(actionList);
-        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
-
-        return ib;
-    }
-
     /**
      * Create Output Port Group Instruction
      *
@@ -3114,7 +2759,7 @@ public class OF13Provider implements NetworkingProvider {
     protected InstructionBuilder createOutputPortInstructions(InstructionBuilder ib,
                                                               Long dpidLong, Long port ,
                                                               List<Instruction> instructions) {
-        NodeConnectorId ncid = new NodeConnectorId("openflow:" + dpidLong + ":" + port);
+        NodeConnectorId ncid = new NodeConnectorId(OPENFLOW + dpidLong + ":" + port);
         logger.debug("createOutputPortInstructions() Node Connector ID is - Type=openflow: DPID={} port={} existingInstructions={}", dpidLong, port, instructions);
 
         List<Action> actionList = Lists.newArrayList();
@@ -3171,7 +2816,7 @@ public class OF13Provider implements NetworkingProvider {
                                                                InstructionBuilder ib,
                                                                Long dpidLong, Long port ,
                                                                List<Instruction> instructions) {
-        NodeConnectorId ncid = new NodeConnectorId("openflow:" + dpidLong + ":" + port);
+        NodeConnectorId ncid = new NodeConnectorId(OPENFLOW + dpidLong + ":" + port);
         logger.debug("createOutputGroupInstructions() Node Connector ID is - Type=openflow: DPID={} port={} existingInstructions={}", dpidLong, port, instructions);
 
         List<Action> actionList = Lists.newArrayList();
@@ -3267,7 +2912,7 @@ public class OF13Provider implements NetworkingProvider {
             groupBuilder.setGroupType(GroupTypes.GroupAll);
             groupBuilder.setGroupId(new GroupId(groupId));
             groupBuilder.setKey(new GroupKey(new GroupId(groupId)));
-            groupBuilder.setGroupName("Output port group" + groupId);
+            groupBuilder.setGroupName("Output port group " + groupId);
             groupBuilder.setBarrier(false);
 
             BucketsBuilder bucketBuilder = new BucketsBuilder();
@@ -3291,7 +2936,7 @@ public class OF13Provider implements NetworkingProvider {
             /* Add new group action */
             GroupActionBuilder groupActionB = new GroupActionBuilder();
             groupActionB.setGroupId(groupId);
-            groupActionB.setGroup("Output port group" + groupId);
+            groupActionB.setGroup("Output port group " + groupId);
             ab = new ActionBuilder();
             ab.setAction(new GroupActionCaseBuilder().setGroupAction(groupActionB.build()).build());
             ab.setOrder(actionList.size());
@@ -3316,51 +2961,6 @@ public class OF13Provider implements NetworkingProvider {
         return ib;
     }
 
-    /**
-     * add Output Port action to Instruction action list.
-     * This is use for flow with single output port actions.
-     * Flow with mutiple output port actions should use createOutputPortInstructions() method.
-     *
-     * @param ib       Map InstructionBuilder without any instructions
-     * @param dpidLong Long the datapath ID of a switch/node
-     * @param port     Long representing a port on a switch/node
-     * @return ib InstructionBuilder Map with instructions
-     */
-    protected static InstructionBuilder addOutputPortInstructions(InstructionBuilder ib,
-                                                                     Long dpidLong, Long port ,
-                                                                     List<Instruction> instructions) {
-        NodeConnectorId ncid = new NodeConnectorId("openflow:" + dpidLong + ":" + port);
-        logger.debug("addOutputPortInstructions() Node Connector ID is - Type=openflow: DPID={} port={} existingInstructions={}", dpidLong, port, instructions);
-
-        List<Action> actionList = Lists.newArrayList();
-        ActionBuilder ab = new ActionBuilder();
-
-        List<Action> existingActions;
-        if (instructions != null) {
-            for (Instruction in : instructions) {
-                if (in.getInstruction() instanceof ApplyActionsCase) {
-                    existingActions = (((ApplyActionsCase) in.getInstruction()).getApplyActions().getAction());
-                    actionList.addAll(existingActions);
-                }
-            }
-        }
-
-        /* Create output action for this port*/
-        OutputActionBuilder oab = new OutputActionBuilder();
-        oab.setOutputNodeConnector(ncid);
-        ab.setAction(new OutputActionCaseBuilder().setOutputAction(oab.build()).build());
-        ab.setOrder(actionList.size());
-        ab.setKey(new ActionKey(actionList.size()));
-        actionList.add(ab.build());
-
-        // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
-        aab.setAction(actionList);
-        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
-
-        return ib;
-    }
-
     /**
      * Remove Output Port from action list in group bucket
      *
@@ -3372,7 +2972,7 @@ public class OF13Provider implements NetworkingProvider {
     protected boolean removeOutputPortFromGroup(NodeBuilder nodeBuilder, InstructionBuilder ib,
                                 Long dpidLong, Long port , List<Instruction> instructions) {
 
-        NodeConnectorId ncid = new NodeConnectorId("openflow:" + dpidLong + ":" + port);
+        NodeConnectorId ncid = new NodeConnectorId(OPENFLOW + dpidLong + ":" + port);
         logger.debug("removeOutputPortFromGroup() Node Connector ID is - Type=openflow: DPID={} port={} existingInstructions={}", dpidLong, port, instructions);
 
         List<Action> actionList = Lists.newArrayList();
@@ -3482,576 +3082,6 @@ public class OF13Provider implements NetworkingProvider {
         }
     }
 
-    /**
-     * Remove Output Port from Instruction
-     *
-     * @param ib       Map InstructionBuilder without any instructions
-     * @param dpidLong Long the datapath ID of a switch/node
-     * @param port     Long representing a port on a switch/node
-     * @return ib InstructionBuilder Map with instructions
-     */
-    protected static boolean removeOutputPortFromInstructions(InstructionBuilder ib,
-                                Long dpidLong, Long port , List<Instruction> instructions) {
-
-        NodeConnectorId ncid = new NodeConnectorId("openflow:" + dpidLong + ":" + port);
-        logger.debug("removeOutputPortFromInstructions() Node Connector ID is - Type=openflow: DPID={} port={} existingInstructions={}", dpidLong, port, instructions);
-
-        List<Action> actionList = Lists.newArrayList();
-        ActionBuilder ab;
-
-        List<Action> existingActions;
-        if (instructions != null) {
-            for (Instruction in : instructions) {
-                if (in.getInstruction() instanceof ApplyActionsCase) {
-                    existingActions = (((ApplyActionsCase) in.getInstruction()).getApplyActions().getAction());
-                    actionList.addAll(existingActions);
-                    break;
-                }
-            }
-        }
-
-        int index = 0;
-        boolean isPortDeleted = false;
-        boolean removeFlow = true;
-        for (Action action : actionList) {
-            if (action.getAction() instanceof OutputActionCase) {
-                OutputActionCase opAction = (OutputActionCase)action.getAction();
-                if (opAction.getOutputAction().getOutputNodeConnector().equals(new Uri(ncid))) {
-                    /* Find the output port in action list and remove */
-                    index = actionList.indexOf(action);
-                    actionList.remove(action);
-                    isPortDeleted = true;
-                    break;
-                }
-                removeFlow = false;
-            }
-        }
-
-        if (isPortDeleted) {
-            for (int i = index; i< actionList.size(); i++) {
-                Action action = actionList.get(i);
-                if (action.getOrder() != i) {
-                    /* Shift the action order */
-                    ab = new ActionBuilder();
-                    ab.setAction(action.getAction());
-                    ab.setOrder(i);
-                    ab.setKey(new ActionKey(i));
-                    Action actionNewOrder = ab.build();
-                    actionList.remove(action);
-                    actionList.add(i, actionNewOrder);
-                }
-                if (action.getAction() instanceof OutputActionCase) {
-                    removeFlow = false;
-                }
-            }
-        }
-
-        /* Put new action list in Apply Action instruction */
-        if (!removeFlow) {
-            ApplyActionsBuilder aab = new ApplyActionsBuilder();
-            aab.setAction(actionList);
-            ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
-            logger.debug("removeOutputPortFromInstructions() : applyAction {}", aab.build());
-            return false;
-        } else {
-            /* if all output port are removed. Return true to indicate flow remove */
-            return true;
-        }
-    }
-
-    /**
-     * Create Set Vlan ID Instruction - This includes push vlan action, and set field -> vlan vid action
-     *
-     * @param ib     Map InstructionBuilder without any instructions
-     * @param vlanId Integer representing a VLAN ID Integer representing a VLAN ID
-     * @return ib Map InstructionBuilder with instructions
-     */
-    protected static InstructionBuilder createSetVlanInstructions(InstructionBuilder ib, VlanId vlanId) {
-
-        List<Action> actionList = Lists.newArrayList();
-        ActionBuilder ab = new ActionBuilder();
-
-        /* First we push vlan header */
-        PushVlanActionBuilder vlan = new PushVlanActionBuilder();
-        vlan.setEthernetType(new Integer(0x8100));
-        ab.setAction(new PushVlanActionCaseBuilder().setPushVlanAction(vlan.build()).build());
-        ab.setOrder(0);
-        actionList.add(ab.build());
-
-        /* Then we set vlan id value as vlanId */
-        SetVlanIdActionBuilder vl = new SetVlanIdActionBuilder();
-        vl.setVlanId(vlanId);
-        ab = new ActionBuilder();
-        ab.setAction(new SetVlanIdActionCaseBuilder().setSetVlanIdAction(vl.build()).build());
-        ab.setOrder(1);
-        actionList.add(ab.build());
-        // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
-        aab.setAction(actionList);
-
-        // Wrap our Apply Action in an Instruction
-        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
-
-        return ib;
-    }
-
-    /**
-     * Create Pop Vlan Instruction - this remove vlan header
-     *
-     * @param ib Map InstructionBuilder without any instructions
-     * @return ib Map InstructionBuilder with instructions
-     */
-    protected static InstructionBuilder createPopVlanInstructions(InstructionBuilder ib) {
-
-        List<Action> actionList = Lists.newArrayList();
-        ActionBuilder ab = new ActionBuilder();
-
-        PopVlanActionBuilder popVlanActionBuilder = new PopVlanActionBuilder();
-        ab.setAction(new PopVlanActionCaseBuilder().setPopVlanAction(popVlanActionBuilder.build()).build());
-        ab.setOrder(0);
-        actionList.add(ab.build());
-
-        // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
-        aab.setAction(actionList);
-
-        // Wrap our Apply Action in an Instruction
-        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
-
-        return ib;
-    }
-
-    /**
-     * Create Set IPv4 Source Instruction
-     *
-     * @param ib        Map InstructionBuilder without any instructions
-     * @param prefixsrc String containing an IPv4 prefix
-     * @return ib Map InstructionBuilder with instructions
-     */
-    protected static InstructionBuilder createNwSrcInstructions(InstructionBuilder ib, Ipv4Prefix prefixsrc) {
-
-        List<Action> actionList = Lists.newArrayList();
-        ActionBuilder ab = new ActionBuilder();
-
-        SetNwSrcActionBuilder setNwsrcActionBuilder = new SetNwSrcActionBuilder();
-        Ipv4Builder ipsrc = new Ipv4Builder();
-        ipsrc.setIpv4Address(prefixsrc);
-        setNwsrcActionBuilder.setAddress(ipsrc.build());
-        ab.setAction(new SetNwSrcActionCaseBuilder().setSetNwSrcAction(setNwsrcActionBuilder.build()).build());
-        actionList.add(ab.build());
-
-        // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
-        aab.setAction(actionList);
-
-        // Wrap our Apply Action in an Instruction
-        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
-
-        return ib;
-    }
-
-    /**
-     * Create Set IPv4 Destination Instruction
-     *
-     * @param ib           Map InstructionBuilder without any instructions
-     * @param prefixdst    String containing an IPv4 prefix
-     * @return ib Map InstructionBuilder with instructions
-     */
-    protected static InstructionBuilder createNwDstInstructions(InstructionBuilder ib, Ipv4Prefix prefixdst) {
-
-        List<Action> actionList = Lists.newArrayList();
-        ActionBuilder ab = new ActionBuilder();
-
-        SetNwDstActionBuilder setNwDstActionBuilder = new SetNwDstActionBuilder();
-        Ipv4Builder ipdst = new Ipv4Builder();
-        ipdst.setIpv4Address(prefixdst);
-        setNwDstActionBuilder.setAddress(ipdst.build());
-        ab.setAction(new SetNwDstActionCaseBuilder().setSetNwDstAction(setNwDstActionBuilder.build()).build());
-        actionList.add(ab.build());
-
-        // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
-        aab.setAction(actionList);
-
-        // Wrap our Apply Action in an Instruction
-        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
-
-        return ib;
-    }
-
-    /**
-     * Create Drop Instruction
-     *
-     * @param ib Map InstructionBuilder without any instructions
-     * @return ib Map InstructionBuilder with instructions
-     */
-    protected static InstructionBuilder createDropInstructions(InstructionBuilder ib) {
-
-        DropActionBuilder dab = new DropActionBuilder();
-        DropAction dropAction = dab.build();
-        ActionBuilder ab = new ActionBuilder();
-        ab.setAction(new DropActionCaseBuilder().setDropAction(dropAction).build());
-        ab.setOrder(0);
-
-        // Add our drop action to a list
-        List<Action> actionList = Lists.newArrayList();
-        actionList.add(ab.build());
-
-        // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
-        aab.setAction(actionList);
-
-        // Wrap our Apply Action in an Instruction
-        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
-
-        return ib;
-    }
-
-    /**
-     * Create GOTO Table Instruction Builder
-     *
-     * @param ib      Map InstructionBuilder without any instructions
-     * @param tableId short representing a flow table ID short representing a flow table ID
-     * @return ib Map InstructionBuilder with instructions
-     */
-    protected static InstructionBuilder createGotoTableInstructions(InstructionBuilder ib, short tableId) {
-
-        GoToTableBuilder gttb = new GoToTableBuilder();
-        gttb.setTableId(tableId);
-
-        // Wrap our Apply Action in an InstructionBuilder
-        ib.setInstruction(new GoToTableCaseBuilder().setGoToTable(gttb.build()).build());
-
-        return ib;
-    }
-
-    /**
-     * Create Set Tunnel ID Instruction Builder
-     *
-     * @param ib       Map InstructionBuilder without any instructions
-     * @param tunnelId BigInteger representing a tunnel ID
-     * @return ib Map InstructionBuilder with instructions
-     */
-    protected static InstructionBuilder createSetTunnelIdInstructions(InstructionBuilder ib, BigInteger tunnelId) {
-
-        List<Action> actionList = Lists.newArrayList();
-        ActionBuilder ab = new ActionBuilder();
-        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
-
-        // Build the Set Tunnel Field Action
-        TunnelBuilder tunnel = new TunnelBuilder();
-        tunnel.setTunnelId(tunnelId);
-        setFieldBuilder.setTunnel(tunnel.build());
-        ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
-        ab.setOrder(0);
-        actionList.add(ab.build());
-
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
-        aab.setAction(actionList);
-
-        // Wrap the Apply Action in an InstructionBuilder and return
-        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
-
-        return ib;
-    }
-
-    /**
-     * Create Set Source TCP Port Instruction
-     *
-     * @param ib      Map InstructionBuilder without any instructions
-     * @param tcpport Integer representing a source TCP port
-     * @return ib Map InstructionBuilder with instructions
-     */
-    protected static InstructionBuilder createSetSrcTCPPort(InstructionBuilder ib, PortNumber tcpport) {
-
-        List<Action> actionList = Lists.newArrayList();
-        ActionBuilder ab = new ActionBuilder();
-        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
-
-        // Build the Destination TCP Port
-        PortNumber tcpsrcport = new PortNumber(tcpport);
-        TcpMatchBuilder tcpmatch = new TcpMatchBuilder();
-        tcpmatch.setTcpSourcePort(tcpsrcport);
-
-        setFieldBuilder.setLayer4Match(tcpmatch.build());
-        ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
-        ab.setKey(new ActionKey(1));
-        actionList.add(ab.build());
-
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
-        aab.setAction(actionList);
-        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
-
-        return ib;
-    }
-
-    /**
-     * Create Set Destination TCP Port Instruction
-     *
-     * @param ib      Map InstructionBuilder without any instructions
-     * @param tcpport Integer representing a source TCP port
-     * @return ib Map InstructionBuilder with instructions
-     */
-    protected static InstructionBuilder createSetDstTCPPort(InstructionBuilder ib, PortNumber tcpport) {
-
-        List<Action> actionList = Lists.newArrayList();
-        ActionBuilder ab = new ActionBuilder();
-        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
-
-        // Build the Destination TCP Port
-        PortNumber tcpdstport = new PortNumber(tcpport);
-        TcpMatchBuilder tcpmatch = new TcpMatchBuilder();
-        tcpmatch.setTcpDestinationPort(tcpdstport);
-
-        setFieldBuilder.setLayer4Match(tcpmatch.build());
-        ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
-        ab.setKey(new ActionKey(1));
-        actionList.add(ab.build());
-
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
-        aab.setAction(actionList);
-        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
-
-        return ib;
-    }
-
-    /**
-     * Create Set Source UDP Port Instruction
-     *
-     * @param ib      Map InstructionBuilder without any instructions
-     * @param udpport Integer representing a source UDP port
-     * @return ib Map InstructionBuilder with instructions
-     */
-    protected static InstructionBuilder createSetSrcUDPPort(InstructionBuilder ib, PortNumber udpport) {
-
-        List<Action> actionList = Lists.newArrayList();
-        ActionBuilder ab = new ActionBuilder();
-        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
-
-        // Build the Destination TCP Port
-        PortNumber udpsrcport = new PortNumber(udpport);
-        UdpMatchBuilder udpmatch = new UdpMatchBuilder();
-        udpmatch.setUdpSourcePort(udpsrcport);
-
-        setFieldBuilder.setLayer4Match(udpmatch.build());
-        ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
-        ab.setKey(new ActionKey(1));
-        actionList.add(ab.build());
-
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
-        aab.setAction(actionList);
-        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
-
-        return ib;
-    }
-
-    /**
-     * Create Set Destination UDP Port Instruction
-     *
-     * @param ib      Map InstructionBuilder without any instructions
-     * @param udpport Integer representing a destination UDP port
-     * @return ib Map InstructionBuilder with instructions
-     */
-    protected static InstructionBuilder createSetDstUDPPort(InstructionBuilder ib, PortNumber udpport) {
-
-        List<Action> actionList = Lists.newArrayList();
-        ActionBuilder ab = new ActionBuilder();
-        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
-
-        // Build the Destination TCP Port
-        PortNumber udpdstport = new PortNumber(udpport);
-        UdpMatchBuilder udpmatch = new UdpMatchBuilder();
-        udpmatch.setUdpDestinationPort(udpdstport);
-
-        setFieldBuilder.setLayer4Match(udpmatch.build());
-        ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
-        ab.setKey(new ActionKey(1));
-        actionList.add(ab.build());
-
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
-        aab.setAction(actionList);
-        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
-
-        return ib;
-    }
-
-    /**
-     * Create Set ICMP Code Instruction
-     *
-     * @param ib   Map InstructionBuilder without any instructions
-     * @param code short repesenting an ICMP code
-     * @return ib Map InstructionBuilder with instructions
-     */
-
-    private static InstructionBuilder createSetIcmpCodeInstruction(InstructionBuilder ib, short code) {
-
-        List<Action> actionList = Lists.newArrayList();
-        ActionBuilder ab = new ActionBuilder();
-        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
-        Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder();
-
-        // Build the ICMPv4 Code Match
-        icmpv4match.setIcmpv4Code(code);
-        setFieldBuilder.setIcmpv4Match(icmpv4match.build());
-
-        ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
-        ab.setKey(new ActionKey(0));
-        actionList.add(ab.build());
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
-        aab.setAction(actionList);
-
-        // Wrap our Apply Action in an Instruction
-        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
-
-        return ib;
-    }
-
-    /**
-     * Create Set ICMP Code Instruction
-     *
-     * @param ib Map InstructionBuilder without any instructions
-     * @return ib Map InstructionBuilder with instructions
-     */
-    private static InstructionBuilder createSetIcmpTypeInstruction(InstructionBuilder ib, short type) {
-
-        List<Action> actionList = Lists.newArrayList();
-        ActionBuilder ab = new ActionBuilder();
-        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
-        Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder();
-
-        // Build the ICMPv4 Code Match
-        icmpv4match.setIcmpv4Code(type);
-        setFieldBuilder.setIcmpv4Match(icmpv4match.build());
-
-        ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
-        ab.setKey(new ActionKey(1));
-        actionList.add(ab.build());
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
-        aab.setAction(actionList);
-
-        // Wrap our Apply Action in an Instruction
-        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
-
-        return ib;
-    }
-
-    /**
-     * Create Decrement TTL Instruction
-     *
-     * @param ib Map InstructionBuilder without any instructions
-     * @return ib Map InstructionBuilder with instructions
-     */
-    private static InstructionBuilder createDecNwTtlInstructions(InstructionBuilder ib) {
-        DecNwTtlBuilder decNwTtlBuilder = new DecNwTtlBuilder();
-        DecNwTtl decNwTtl = decNwTtlBuilder.build();
-        ActionBuilder ab = new ActionBuilder();
-        ab.setAction(new DecNwTtlCaseBuilder().setDecNwTtl(decNwTtl).build());
-
-        // Add our drop action to a list
-        List<Action> actionList = Lists.newArrayList();
-        actionList.add(ab.build());
-
-        // Create an Apply Action
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
-        aab.setAction(actionList);
-
-        // Wrap our Apply Action in an Instruction
-        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
-
-        return ib;
-    }
-
-    /**
-     * Set Src Arp MAC
-     */
-    private static InstructionBuilder createSrcArpMacInstructions(InstructionBuilder ib, MacAddress macsrc) {
-
-        List<Action> actionList = Lists.newArrayList();
-        ActionBuilder ab = new ActionBuilder();
-
-        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
-        ArpMatchBuilder arpmatch = new ArpMatchBuilder();
-        ArpSourceHardwareAddressBuilder arpsrc = new ArpSourceHardwareAddressBuilder();
-        arpsrc.setAddress(macsrc);
-        arpmatch.setArpSourceHardwareAddress(arpsrc.build());
-        setFieldBuilder.setLayer3Match(arpmatch.build());
-        ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
-        ab.setKey(new ActionKey(0));
-        actionList.add(ab.build());
-
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
-        aab.setAction(actionList);
-
-        return ib;
-    }
-
-    /**
-     * Set Dst Arp MAC
-     */
-    private static InstructionBuilder createDstArpMacInstructions(InstructionBuilder ib, MacAddress macdst) {
-
-        List<Action> actionList = Lists.newArrayList();
-        ActionBuilder ab = new ActionBuilder();
-        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
-
-        ArpMatchBuilder arpmatch = new ArpMatchBuilder();
-        ArpTargetHardwareAddressBuilder arpdst = new ArpTargetHardwareAddressBuilder();
-        arpdst.setAddress(macdst);
-        setFieldBuilder.setLayer3Match(arpmatch.build());
-        ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
-        ab.setKey(new ActionKey(0));
-        actionList.add(ab.build());
-
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
-        aab.setAction(actionList);
-
-        return ib;
-    }
-
-    /**
-     * Set Dst Arp IP
-     */
-    private static InstructionBuilder createDstArpIpInstructions(InstructionBuilder ib, Ipv4Prefix dstiparp) {
-
-        List<Action> actionList = Lists.newArrayList();
-        ActionBuilder ab = new ActionBuilder();
-        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
-
-        ArpMatchBuilder arpmatch = new ArpMatchBuilder();
-        arpmatch.setArpTargetTransportAddress(dstiparp);
-        setFieldBuilder.setLayer3Match(arpmatch.build());
-        ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
-        ab.setKey(new ActionKey(0));
-        actionList.add(ab.build());
-
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
-        aab.setAction(actionList);
-
-        return ib;
-    }
-
-    /**
-     * Set Src Arp IP
-     */
-    private static InstructionBuilder createSrcArpIpInstructions(InstructionBuilder ib, Ipv4Prefix srciparp) {
-
-        List<Action> actionList = Lists.newArrayList();
-        ActionBuilder ab = new ActionBuilder();
-        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
-
-        ArpMatchBuilder arpmatch = new ArpMatchBuilder();
-        arpmatch.setArpSourceTransportAddress(srciparp);
-        setFieldBuilder.setLayer3Match(arpmatch.build());
-        ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
-        ab.setKey(new ActionKey(0));
-        actionList.add(ab.build());
-
-        ApplyActionsBuilder aab = new ApplyActionsBuilder();
-        aab.setAction(actionList);
-
-        return ib;
-    }
-
     @Override
     public void initializeOFFlowRules(Node openflowNode) {
         Preconditions.checkNotNull(connectionService);
diff --git a/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/mdsalopenflow13/OF13MdSalInstruction.java b/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/mdsalopenflow13/OF13MdSalInstruction.java
new file mode 100644 (file)
index 0000000..41a0f83
--- /dev/null
@@ -0,0 +1,845 @@
+/*
+ * Copyright (C) 2013 Red Hat, Inc.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.providers.mdsalopenflow13;
+
+import com.google.common.collect.Lists;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtl;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtlBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.go.to.table._case.GoToTableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddressBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddressBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TunnelBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+
+public class OF13MdSalInstruction {
+    private static final Logger logger = LoggerFactory.getLogger(OF13MdSalInstruction.class);
+    private static final int IPV4 = 0x8100;
+    private static final int MAX_LENGTH = 0xffff;
+
+    /**
+     * Create Send to Controller Reserved Port Instruction (packet_in)
+     *
+     * @param ib Map InstructionBuilder without any instructions
+     * @return ib Map InstructionBuilder with instructions
+     */
+    public static InstructionBuilder createSendToControllerInstructions(InstructionBuilder ib) {
+
+        List<Action> actionList = Lists.newArrayList();
+        ActionBuilder ab = new ActionBuilder();
+
+        OutputActionBuilder output = new OutputActionBuilder();
+        output.setMaxLength(MAX_LENGTH);
+        Uri value = new Uri("CONTROLLER");
+        output.setOutputNodeConnector(value);
+        ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
+        ab.setOrder(0);
+        ab.setKey(new ActionKey(0));
+        actionList.add(ab.build());
+
+        // Create an Apply Action
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+
+        // Wrap our Apply Action in an Instruction
+        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+        return ib;
+    }
+
+    /**
+     * Create NORMAL Reserved Port Instruction (packet_in)
+     *
+     * @param ib Map InstructionBuilder without any instructions
+     * @return ib Map InstructionBuilder with instructions
+     */
+
+    public static InstructionBuilder createNormalInstructions(InstructionBuilder ib) {
+
+        List<Action> actionList = Lists.newArrayList();
+        ActionBuilder ab = new ActionBuilder();
+
+        OutputActionBuilder output = new OutputActionBuilder();
+        Uri value = new Uri("NORMAL");
+        output.setOutputNodeConnector(value);
+        ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
+        ab.setOrder(0);
+        ab.setKey(new ActionKey(0));
+        actionList.add(ab.build());
+
+        // Create an Apply Action
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+
+        // Wrap our Apply Action in an Instruction
+        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+        return ib;
+    }
+
+    /**
+     * Create Output Port Instruction
+     *
+     * @param ib       Map InstructionBuilder without any instructions
+     * @param dpidLong Long the datapath ID of a switch/node
+     * @param port     Long representing a port on a switch/node
+     * @return ib InstructionBuilder Map with instructions
+     */
+    public static InstructionBuilder createOutputPortInstructions(InstructionBuilder ib, Long dpidLong, Long port) {
+
+        NodeConnectorId ncid = new NodeConnectorId("openflow:" + dpidLong + ":" + port);
+        logger.debug("createOutputPortInstructions() Node Connector ID is - Type=openflow: DPID={} inPort={} ",
+                dpidLong, port);
+
+        List<Action> actionList = Lists.newArrayList();
+        ActionBuilder ab = new ActionBuilder();
+        OutputActionBuilder oab = new OutputActionBuilder();
+        oab.setOutputNodeConnector(ncid);
+
+        ab.setAction(new OutputActionCaseBuilder().setOutputAction(oab.build()).build());
+        ab.setOrder(0);
+        ab.setKey(new ActionKey(0));
+        actionList.add(ab.build());
+
+        // Create an Apply Action
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+        return ib;
+    }
+
+    /**
+     * add Output Port action to Instruction action list.
+     * This is use for flow with single output port actions.
+     * Flow with mutiple output port actions should use createOutputPortInstructions() method.
+     *
+     * @param ib       Map InstructionBuilder without any instructions
+     * @param dpidLong Long the datapath ID of a switch/node
+     * @param port     Long representing a port on a switch/node
+     * @return ib InstructionBuilder Map with instructions
+     */
+    public static InstructionBuilder addOutputPortInstructions(InstructionBuilder ib,
+            Long dpidLong, Long port,
+            List<Instruction> instructions) {
+        NodeConnectorId ncid = new NodeConnectorId("openflow:" + dpidLong + ":" + port);
+        logger.debug(
+                "addOutputPortInstructions() Node Connector ID is - Type=openflow: DPID={} port={} existingInstructions={}",
+                dpidLong, port, instructions);
+
+        List<Action> actionList = Lists.newArrayList();
+        ActionBuilder ab = new ActionBuilder();
+
+        List<Action> existingActions;
+        if (instructions != null) {
+            for (Instruction in : instructions) {
+                if (in.getInstruction() instanceof ApplyActionsCase) {
+                    existingActions = (((ApplyActionsCase) in.getInstruction()).getApplyActions().getAction());
+                    actionList.addAll(existingActions);
+                }
+            }
+        }
+
+        /* Create output action for this port*/
+        OutputActionBuilder oab = new OutputActionBuilder();
+        oab.setOutputNodeConnector(ncid);
+        ab.setAction(new OutputActionCaseBuilder().setOutputAction(oab.build()).build());
+        ab.setOrder(actionList.size());
+        ab.setKey(new ActionKey(actionList.size()));
+        actionList.add(ab.build());
+
+        // Create an Apply Action
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+        return ib;
+    }
+
+    /**
+     * Remove Output Port from Instruction
+     *
+     * @param ib       Map InstructionBuilder without any instructions
+     * @param dpidLong Long the datapath ID of a switch/node
+     * @param port     Long representing a port on a switch/node
+     * @return ib InstructionBuilder Map with instructions
+     */
+    public static boolean removeOutputPortFromInstructions(InstructionBuilder ib,
+            Long dpidLong, Long port, List<Instruction> instructions) {
+
+        NodeConnectorId ncid = new NodeConnectorId("openflow:" + dpidLong + ":" + port);
+        logger.debug(
+                "removeOutputPortFromInstructions() Node Connector ID is - Type=openflow: DPID={} port={} existingInstructions={}",
+                dpidLong, port, instructions);
+
+        List<Action> actionList = Lists.newArrayList();
+        ActionBuilder ab;
+
+        List<Action> existingActions;
+        if (instructions != null) {
+            for (Instruction in : instructions) {
+                if (in.getInstruction() instanceof ApplyActionsCase) {
+                    existingActions = (((ApplyActionsCase) in.getInstruction()).getApplyActions().getAction());
+                    actionList.addAll(existingActions);
+                    break;
+                }
+            }
+        }
+
+        int index = 0;
+        boolean isPortDeleted = false;
+        boolean removeFlow = true;
+        for (Action action : actionList) {
+            if (action.getAction() instanceof OutputActionCase) {
+                OutputActionCase opAction = (OutputActionCase) action.getAction();
+                if (opAction.getOutputAction().getOutputNodeConnector().equals(new Uri(ncid))) {
+                    /* Find the output port in action list and remove */
+                    index = actionList.indexOf(action);
+                    actionList.remove(action);
+                    isPortDeleted = true;
+                    break;
+                }
+                removeFlow = false;
+            }
+        }
+
+        if (isPortDeleted) {
+            for (int i = index; i < actionList.size(); i++) {
+                Action action = actionList.get(i);
+                if (action.getOrder() != i) {
+                    /* Shift the action order */
+                    ab = new ActionBuilder();
+                    ab.setAction(action.getAction());
+                    ab.setOrder(i);
+                    ab.setKey(new ActionKey(i));
+                    Action actionNewOrder = ab.build();
+                    actionList.remove(action);
+                    actionList.add(i, actionNewOrder);
+                }
+                if (action.getAction() instanceof OutputActionCase) {
+                    removeFlow = false;
+                }
+            }
+        }
+
+        /* Put new action list in Apply Action instruction */
+        if (!removeFlow) {
+            ApplyActionsBuilder aab = new ApplyActionsBuilder();
+            aab.setAction(actionList);
+            ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+            logger.debug("removeOutputPortFromInstructions() : applyAction {}", aab.build());
+            return false;
+        } else {
+            /* if all output port are removed. Return true to indicate flow remove */
+            return true;
+        }
+    }
+
+    /**
+     * Create Set Vlan ID Instruction - This includes push vlan action, and set field -> vlan vid action
+     *
+     * @param ib     Map InstructionBuilder without any instructions
+     * @param vlanId Integer representing a VLAN ID Integer representing a VLAN ID
+     * @return ib Map InstructionBuilder with instructions
+     */
+    public static InstructionBuilder createSetVlanInstructions(InstructionBuilder ib, VlanId vlanId) {
+
+        List<Action> actionList = Lists.newArrayList();
+        ActionBuilder ab = new ActionBuilder();
+
+        /* First we push vlan header */
+        PushVlanActionBuilder vlan = new PushVlanActionBuilder();
+        vlan.setEthernetType(IPV4);
+        ab.setAction(new PushVlanActionCaseBuilder().setPushVlanAction(vlan.build()).build());
+        ab.setOrder(0);
+        actionList.add(ab.build());
+
+        /* Then we set vlan id value as vlanId */
+        SetVlanIdActionBuilder vl = new SetVlanIdActionBuilder();
+        vl.setVlanId(vlanId);
+        ab = new ActionBuilder();
+        ab.setAction(new SetVlanIdActionCaseBuilder().setSetVlanIdAction(vl.build()).build());
+        ab.setOrder(1);
+        actionList.add(ab.build());
+        // Create an Apply Action
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+
+        // Wrap our Apply Action in an Instruction
+        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+        return ib;
+    }
+
+    /**
+     * Create Pop Vlan Instruction - this remove vlan header
+     *
+     * @param ib Map InstructionBuilder without any instructions
+     * @return ib Map InstructionBuilder with instructions
+     */
+    public static InstructionBuilder createPopVlanInstructions(InstructionBuilder ib) {
+
+        List<Action> actionList = Lists.newArrayList();
+        ActionBuilder ab = new ActionBuilder();
+
+        PopVlanActionBuilder popVlanActionBuilder = new PopVlanActionBuilder();
+        ab.setAction(new PopVlanActionCaseBuilder().setPopVlanAction(popVlanActionBuilder.build()).build());
+        ab.setOrder(0);
+        actionList.add(ab.build());
+
+        // Create an Apply Action
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+
+        // Wrap our Apply Action in an Instruction
+        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+        return ib;
+    }
+
+    /**
+     * Create Set IPv4 Source Instruction
+     *
+     * @param ib        Map InstructionBuilder without any instructions
+     * @param prefixsrc String containing an IPv4 prefix
+     * @return ib Map InstructionBuilder with instructions
+     */
+    public static InstructionBuilder createNwSrcInstructions(InstructionBuilder ib, Ipv4Prefix prefixsrc) {
+
+        List<Action> actionList = Lists.newArrayList();
+        ActionBuilder ab = new ActionBuilder();
+
+        SetNwSrcActionBuilder setNwsrcActionBuilder = new SetNwSrcActionBuilder();
+        Ipv4Builder ipsrc = new Ipv4Builder();
+        ipsrc.setIpv4Address(prefixsrc);
+        setNwsrcActionBuilder.setAddress(ipsrc.build());
+        ab.setAction(new SetNwSrcActionCaseBuilder().setSetNwSrcAction(setNwsrcActionBuilder.build()).build());
+        actionList.add(ab.build());
+
+        // Create an Apply Action
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+
+        // Wrap our Apply Action in an Instruction
+        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+        return ib;
+    }
+
+    /**
+     * Create Set IPv4 Destination Instruction
+     *
+     * @param ib        Map InstructionBuilder without any instructions
+     * @param prefixdst String containing an IPv4 prefix
+     * @return ib Map InstructionBuilder with instructions
+     */
+    public static InstructionBuilder createNwDstInstructions(InstructionBuilder ib, Ipv4Prefix prefixdst) {
+
+        List<Action> actionList = Lists.newArrayList();
+        ActionBuilder ab = new ActionBuilder();
+
+        SetNwDstActionBuilder setNwDstActionBuilder = new SetNwDstActionBuilder();
+        Ipv4Builder ipdst = new Ipv4Builder();
+        ipdst.setIpv4Address(prefixdst);
+        setNwDstActionBuilder.setAddress(ipdst.build());
+        ab.setAction(new SetNwDstActionCaseBuilder().setSetNwDstAction(setNwDstActionBuilder.build()).build());
+        actionList.add(ab.build());
+
+        // Create an Apply Action
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+
+        // Wrap our Apply Action in an Instruction
+        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+        return ib;
+    }
+
+    /**
+     * Create Drop Instruction
+     *
+     * @param ib Map InstructionBuilder without any instructions
+     * @return ib Map InstructionBuilder with instructions
+     */
+    public static InstructionBuilder createDropInstructions(InstructionBuilder ib) {
+
+        DropActionBuilder dab = new DropActionBuilder();
+        DropAction dropAction = dab.build();
+        ActionBuilder ab = new ActionBuilder();
+        ab.setAction(new DropActionCaseBuilder().setDropAction(dropAction).build());
+        ab.setOrder(0);
+
+        // Add our drop action to a list
+        List<Action> actionList = Lists.newArrayList();
+        actionList.add(ab.build());
+
+        // Create an Apply Action
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+
+        // Wrap our Apply Action in an Instruction
+        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+        return ib;
+    }
+
+    /**
+     * Create GOTO Table Instruction Builder
+     *
+     * @param ib      Map InstructionBuilder without any instructions
+     * @param tableId short representing a flow table ID short representing a flow table ID
+     * @return ib Map InstructionBuilder with instructions
+     */
+    public static InstructionBuilder createGotoTableInstructions(InstructionBuilder ib, short tableId) {
+
+        GoToTableBuilder gttb = new GoToTableBuilder();
+        gttb.setTableId(tableId);
+
+        // Wrap our Apply Action in an InstructionBuilder
+        ib.setInstruction(new GoToTableCaseBuilder().setGoToTable(gttb.build()).build());
+
+        return ib;
+    }
+
+    /**
+     * Create Set Tunnel ID Instruction Builder
+     *
+     * @param ib       Map InstructionBuilder without any instructions
+     * @param tunnelId BigInteger representing a tunnel ID
+     * @return ib Map InstructionBuilder with instructions
+     */
+    public static InstructionBuilder createSetTunnelIdInstructions(InstructionBuilder ib, BigInteger tunnelId) {
+
+        List<Action> actionList = Lists.newArrayList();
+        ActionBuilder ab = new ActionBuilder();
+        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+
+        // Build the Set Tunnel Field Action
+        TunnelBuilder tunnel = new TunnelBuilder();
+        tunnel.setTunnelId(tunnelId);
+        setFieldBuilder.setTunnel(tunnel.build());
+        ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
+        ab.setOrder(0);
+        actionList.add(ab.build());
+
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+
+        // Wrap the Apply Action in an InstructionBuilder and return
+        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+        return ib;
+    }
+
+    /**
+     * Create Set Source TCP Port Instruction
+     *
+     * @param ib      Map InstructionBuilder without any instructions
+     * @param tcpport Integer representing a source TCP port
+     * @return ib Map InstructionBuilder with instructions
+     */
+    public static InstructionBuilder createSetSrcTCPPort(InstructionBuilder ib, PortNumber tcpport) {
+
+        List<Action> actionList = Lists.newArrayList();
+        ActionBuilder ab = new ActionBuilder();
+        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+
+        // Build the Destination TCP Port
+        PortNumber tcpsrcport = new PortNumber(tcpport);
+        TcpMatchBuilder tcpmatch = new TcpMatchBuilder();
+        tcpmatch.setTcpSourcePort(tcpsrcport);
+
+        setFieldBuilder.setLayer4Match(tcpmatch.build());
+        ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
+        ab.setKey(new ActionKey(1));
+        actionList.add(ab.build());
+
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+        return ib;
+    }
+
+    /**
+     * Create Set Destination TCP Port Instruction
+     *
+     * @param ib      Map InstructionBuilder without any instructions
+     * @param tcpport Integer representing a source TCP port
+     * @return ib Map InstructionBuilder with instructions
+     */
+    public static InstructionBuilder createSetDstTCPPort(InstructionBuilder ib, PortNumber tcpport) {
+
+        List<Action> actionList = Lists.newArrayList();
+        ActionBuilder ab = new ActionBuilder();
+        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+
+        // Build the Destination TCP Port
+        PortNumber tcpdstport = new PortNumber(tcpport);
+        TcpMatchBuilder tcpmatch = new TcpMatchBuilder();
+        tcpmatch.setTcpDestinationPort(tcpdstport);
+
+        setFieldBuilder.setLayer4Match(tcpmatch.build());
+        ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
+        ab.setKey(new ActionKey(1));
+        actionList.add(ab.build());
+
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+        return ib;
+    }
+
+    /**
+     * Create Set Source UDP Port Instruction
+     *
+     * @param ib      Map InstructionBuilder without any instructions
+     * @param udpport Integer representing a source UDP port
+     * @return ib Map InstructionBuilder with instructions
+     */
+    public static InstructionBuilder createSetSrcUDPPort(InstructionBuilder ib, PortNumber udpport) {
+
+        List<Action> actionList = Lists.newArrayList();
+        ActionBuilder ab = new ActionBuilder();
+        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+
+        // Build the Destination TCP Port
+        PortNumber udpsrcport = new PortNumber(udpport);
+        UdpMatchBuilder udpmatch = new UdpMatchBuilder();
+        udpmatch.setUdpSourcePort(udpsrcport);
+
+        setFieldBuilder.setLayer4Match(udpmatch.build());
+        ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
+        ab.setKey(new ActionKey(1));
+        actionList.add(ab.build());
+
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+        return ib;
+    }
+
+    /**
+     * Create Set Destination UDP Port Instruction
+     *
+     * @param ib      Map InstructionBuilder without any instructions
+     * @param udpport Integer representing a destination UDP port
+     * @return ib Map InstructionBuilder with instructions
+     */
+    public static InstructionBuilder createSetDstUDPPort(InstructionBuilder ib, PortNumber udpport) {
+
+        List<Action> actionList = Lists.newArrayList();
+        ActionBuilder ab = new ActionBuilder();
+        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+
+        // Build the Destination TCP Port
+        PortNumber udpdstport = new PortNumber(udpport);
+        UdpMatchBuilder udpmatch = new UdpMatchBuilder();
+        udpmatch.setUdpDestinationPort(udpdstport);
+
+        setFieldBuilder.setLayer4Match(udpmatch.build());
+        ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
+        ab.setKey(new ActionKey(1));
+        actionList.add(ab.build());
+
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+        return ib;
+    }
+
+    /**
+     * Create Set ICMP Code Instruction
+     *
+     * @param ib   Map InstructionBuilder without any instructions
+     * @param code short repesenting an ICMP code
+     * @return ib Map InstructionBuilder with instructions
+     */
+
+    public static InstructionBuilder createSetIcmpCodeInstruction(InstructionBuilder ib, short code) {
+
+        List<Action> actionList = Lists.newArrayList();
+        ActionBuilder ab = new ActionBuilder();
+        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+        Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder();
+
+        // Build the ICMPv4 Code Match
+        icmpv4match.setIcmpv4Code(code);
+        setFieldBuilder.setIcmpv4Match(icmpv4match.build());
+
+        ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
+        ab.setKey(new ActionKey(0));
+        actionList.add(ab.build());
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+
+        // Wrap our Apply Action in an Instruction
+        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+        return ib;
+    }
+
+    /**
+     * Create Set ICMP Code Instruction
+     *
+     * @param ib Map InstructionBuilder without any instructions
+     * @return ib Map InstructionBuilder with instructions
+     */
+    public static InstructionBuilder createSetIcmpTypeInstruction(InstructionBuilder ib, short type) {
+
+        List<Action> actionList = Lists.newArrayList();
+        ActionBuilder ab = new ActionBuilder();
+        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+        Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder();
+
+        // Build the ICMPv4 Code Match
+        icmpv4match.setIcmpv4Code(type);
+        setFieldBuilder.setIcmpv4Match(icmpv4match.build());
+
+        ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
+        ab.setKey(new ActionKey(1));
+        actionList.add(ab.build());
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+
+        // Wrap our Apply Action in an Instruction
+        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+        return ib;
+    }
+
+    /**
+     * Create Decrement TTL Instruction
+     *
+     * @param ib Map InstructionBuilder without any instructions
+     * @return ib Map InstructionBuilder with instructions
+     */
+    public static InstructionBuilder createDecNwTtlInstructions(InstructionBuilder ib) {
+        DecNwTtlBuilder decNwTtlBuilder = new DecNwTtlBuilder();
+        DecNwTtl decNwTtl = decNwTtlBuilder.build();
+        ActionBuilder ab = new ActionBuilder();
+        ab.setAction(new DecNwTtlCaseBuilder().setDecNwTtl(decNwTtl).build());
+
+        // Add our drop action to a list
+        List<Action> actionList = Lists.newArrayList();
+        actionList.add(ab.build());
+
+        // Create an Apply Action
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+
+        // Wrap our Apply Action in an Instruction
+        ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+        return ib;
+    }
+
+    /**
+     * Set ARP_SHA Instructions
+     * @param ib Map InstructionBuilder
+     * @param macsrc the macsrc
+     * @return instructionbuilder with new instructions
+     */
+    public static InstructionBuilder createSrcArpMacInstructions(InstructionBuilder ib, MacAddress macsrc) {
+
+        List<Action> actionList = Lists.newArrayList();
+        ActionBuilder ab = new ActionBuilder();
+
+        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+        ArpMatchBuilder arpmatch = new ArpMatchBuilder();
+        ArpSourceHardwareAddressBuilder arpsrc = new ArpSourceHardwareAddressBuilder();
+        arpsrc.setAddress(macsrc);
+        arpmatch.setArpSourceHardwareAddress(arpsrc.build());
+        setFieldBuilder.setLayer3Match(arpmatch.build());
+        ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
+        ab.setKey(new ActionKey(0));
+        actionList.add(ab.build());
+
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+
+        return ib;
+    }
+
+    /**
+     * Set ARP_THA Instructions
+     * @param ib Map InstructionBuilder
+     * @param macdst the macdst
+     * @return instructionbuilder with new attributes
+     */
+    public static InstructionBuilder createDstArpMacInstructions(InstructionBuilder ib, MacAddress macdst) {
+
+        List<Action> actionList = Lists.newArrayList();
+        ActionBuilder ab = new ActionBuilder();
+        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+
+        ArpMatchBuilder arpmatch = new ArpMatchBuilder();
+        ArpTargetHardwareAddressBuilder arpdst = new ArpTargetHardwareAddressBuilder();
+        arpdst.setAddress(macdst);
+        setFieldBuilder.setLayer3Match(arpmatch.build());
+        ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
+        ab.setKey(new ActionKey(0));
+        actionList.add(ab.build());
+
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+
+        return ib;
+    }
+
+    /**
+     * Set ARP_TPA Instructions
+     * @param ib Map InstructionBuilder
+     * @param dstiparp the dstiparp
+     * @return instructionbuilder with new attributes
+     */
+    public static InstructionBuilder createDstArpIpInstructions(InstructionBuilder ib, Ipv4Prefix dstiparp) {
+
+        List<Action> actionList = Lists.newArrayList();
+        ActionBuilder ab = new ActionBuilder();
+        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+
+        ArpMatchBuilder arpmatch = new ArpMatchBuilder();
+        arpmatch.setArpTargetTransportAddress(dstiparp);
+        setFieldBuilder.setLayer3Match(arpmatch.build());
+        ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
+        ab.setKey(new ActionKey(0));
+        actionList.add(ab.build());
+
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+
+        return ib;
+    }
+
+    /**
+     * Set ARP_SPA Instructions
+     * @param ib Map InstructionBuilder
+     * @param srciparp the srciparp
+     * @return instructionbuilder with new attributes
+     */
+    public static InstructionBuilder createSrcArpIpInstructions(InstructionBuilder ib, Ipv4Prefix srciparp) {
+
+        List<Action> actionList = Lists.newArrayList();
+        ActionBuilder ab = new ActionBuilder();
+        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+
+        ArpMatchBuilder arpmatch = new ArpMatchBuilder();
+        arpmatch.setArpSourceTransportAddress(srciparp);
+        setFieldBuilder.setLayer3Match(arpmatch.build());
+        ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
+        ab.setKey(new ActionKey(0));
+        actionList.add(ab.build());
+
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+
+        return ib;
+    }
+
+    public static InstructionBuilder createTunnelIpv4SrcInstructions(InstructionBuilder ib, Ipv4Prefix srcIp) {
+
+        List<Action> actionList = new ArrayList<Action>();
+        ActionBuilder ab = new ActionBuilder();
+
+        // Build the tunnel endpoint source IPv4 address
+        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+
+        // Add the new IPv4 object as the tunnel destination
+        TunnelIpv4MatchBuilder tunnelIpv4MatchBuilder = new TunnelIpv4MatchBuilder();
+        tunnelIpv4MatchBuilder.setTunnelIpv4Source(srcIp);
+        setFieldBuilder.setLayer3Match(tunnelIpv4MatchBuilder.build());
+
+        // Add the IPv4 tunnel src to the set_field value
+        ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
+        ab.setOrder(0);
+        ab.setKey(new ActionKey(0));
+        actionList.add(ab.build());
+
+        // Resulting action is a per/flow src TEP (set_field:172.16.100.100->tun_src)
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+
+        return ib;
+    }
+
+    public static InstructionBuilder createTunnelIpv4DstInstructions(InstructionBuilder ib, Ipv4Prefix srcIp) {
+
+        List<Action> actionList = new ArrayList<Action>();
+        ActionBuilder ab = new ActionBuilder();
+
+        // Build the tunnel endpoint dst IPv4 address
+        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+
+        // Add the new IPv4 object as the tunnel destination
+        TunnelIpv4MatchBuilder tunnelIpv4MatchBuilder = new TunnelIpv4MatchBuilder();
+        tunnelIpv4MatchBuilder.setTunnelIpv4Destination(srcIp);
+        setFieldBuilder.setLayer3Match(tunnelIpv4MatchBuilder.build());
+
+        // Add the IPv4 tunnel src to the set_field value
+        ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
+        ab.setOrder(0);
+        ab.setKey(new ActionKey(0));
+        actionList.add(ab.build());
+
+        // Resulting action is a per/flow src TEP (set_field:172.16.100.100->tun_src)
+        ApplyActionsBuilder aab = new ApplyActionsBuilder();
+        aab.setAction(actionList);
+
+        return ib;
+    }
+}
\ No newline at end of file
diff --git a/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/mdsalopenflow13/OF13MdSalMatch.java b/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/mdsalopenflow13/OF13MdSalMatch.java
new file mode 100644 (file)
index 0000000..e8a5d21
--- /dev/null
@@ -0,0 +1,310 @@
+/*
+ * Copyright (C) 2013 Red Hat, Inc.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.providers.mdsalopenflow13;
+
+import org.opendaylight.ovsdb.openstack.netvirt.providers.OF13Provider;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TcpFlagMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TunnelBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.math.BigInteger;
+
+public class OF13MdSalMatch extends OF13Provider {
+    private static final Logger logger = LoggerFactory.getLogger(OF13MdSalMatch.class);
+
+    /**
+     * Create Ingress Port Match dpidLong, inPort
+     *
+     * @param matchBuilder Map matchBuilder MatchBuilder Object without a match
+     * @param dpidLong     Long the datapath ID of a switch/node
+     * @param inPort       Long ingress port on a switch
+     * @return matchBuilder Map MatchBuilder Object with a match
+     */
+    public static MatchBuilder createInPortMatch(MatchBuilder matchBuilder, Long dpidLong, Long inPort) {
+
+        NodeConnectorId ncid = new NodeConnectorId("openflow:" + dpidLong + ":" + inPort);
+        logger.debug("createInPortMatch() Node Connector ID is - Type=openflow: DPID={} inPort={} ", dpidLong, inPort);
+        matchBuilder.setInPort(NodeConnectorId.getDefaultInstance(ncid.getValue()));
+        matchBuilder.setInPort(ncid);
+
+        return matchBuilder;
+    }
+
+    /**
+     * Create EtherType Match
+     *
+     * @param matchBuilder Map matchBuilder MatchBuilder Object without a match
+     * @param etherType    Long EtherType
+     * @return matchBuilder Map MatchBuilder Object with a match
+     */
+    public static MatchBuilder createEtherTypeMatch(MatchBuilder matchBuilder, EtherType etherType) {
+
+        EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
+        EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+        ethTypeBuilder.setType(new EtherType(etherType));
+        ethernetMatch.setEthernetType(ethTypeBuilder.build());
+        matchBuilder.setEthernetMatch(ethernetMatch.build());
+
+        return matchBuilder;
+    }
+
+    /**
+     * Create Ethernet Source Match
+     *
+     * @param matchBuilder MatchBuilder Object without a match yet
+     * @param sMacAddr     String representing a source MAC
+     * @return matchBuilder Map MatchBuilder Object with a match
+     */
+    public static MatchBuilder createEthSrcMatch(MatchBuilder matchBuilder, MacAddress sMacAddr) {
+
+        EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
+        EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
+        ethSourceBuilder.setAddress(new MacAddress(sMacAddr));
+        ethernetMatch.setEthernetSource(ethSourceBuilder.build());
+        matchBuilder.setEthernetMatch(ethernetMatch.build());
+
+        return matchBuilder;
+    }
+
+    /**
+     * Create Ethernet Destination Match
+     *
+     * @param matchBuilder MatchBuilder Object without a match yet
+     * @param vlanId       Integer representing a VLAN ID Integer representing a VLAN ID
+     * @return matchBuilder Map MatchBuilder Object with a match
+     */
+    public static MatchBuilder createVlanIdMatch(MatchBuilder matchBuilder, VlanId vlanId) {
+        VlanMatchBuilder vlanMatchBuilder = new VlanMatchBuilder();
+        VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
+        vlanIdBuilder.setVlanId(new VlanId(vlanId));
+        vlanIdBuilder.setVlanIdPresent(true);
+        vlanMatchBuilder.setVlanId(vlanIdBuilder.build());
+        matchBuilder.setVlanMatch(vlanMatchBuilder.build());
+
+        return matchBuilder;
+    }
+
+    /**
+     * Create Ethernet Destination Match
+     *
+     * @param matchBuilder MatchBuilder Object without a match yet
+     * @param dMacAddr     String representing a destination MAC
+     * @return matchBuilder Map MatchBuilder Object with a match
+     */
+    public static MatchBuilder createDestEthMatch(MatchBuilder matchBuilder, MacAddress dMacAddr, MacAddress mask) {
+
+        EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
+        EthernetDestinationBuilder ethDestinationBuilder = new EthernetDestinationBuilder();
+        ethDestinationBuilder.setAddress(new MacAddress(dMacAddr));
+        if (mask != null) {
+            ethDestinationBuilder.setMask(mask);
+        }
+        ethernetMatch.setEthernetDestination(ethDestinationBuilder.build());
+        matchBuilder.setEthernetMatch(ethernetMatch.build());
+
+        return matchBuilder;
+    }
+
+    /**
+     * Tunnel ID Match Builder
+     *
+     * @param matchBuilder MatchBuilder Object without a match yet
+     * @param tunnelId     BigInteger representing a tunnel ID
+     * @return matchBuilder Map MatchBuilder Object with a match
+     */
+    public static MatchBuilder createTunnelIDMatch(MatchBuilder matchBuilder, BigInteger tunnelId) {
+
+        TunnelBuilder tunnelBuilder = new TunnelBuilder();
+        tunnelBuilder.setTunnelId(tunnelId);
+        matchBuilder.setTunnel(tunnelBuilder.build());
+
+        return matchBuilder;
+    }
+
+    /**
+     * Match ICMP code and type
+     *
+     * @param matchBuilder MatchBuilder Object without a match yet
+     * @param type         short representing an ICMP type
+     * @param code         short representing an ICMP code
+     * @return matchBuilder Map MatchBuilder Object with a match
+     */
+    public static MatchBuilder createICMPv4Match(MatchBuilder matchBuilder, short type, short code) {
+
+        EthernetMatchBuilder eth = new EthernetMatchBuilder();
+        EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+        ethTypeBuilder.setType(new EtherType(0x0800L));
+        eth.setEthernetType(ethTypeBuilder.build());
+        matchBuilder.setEthernetMatch(eth.build());
+
+        // Build the IPv4 Match requied per OVS Syntax
+        IpMatchBuilder ipmatch = new IpMatchBuilder();
+        ipmatch.setIpProtocol((short) 1);
+        matchBuilder.setIpMatch(ipmatch.build());
+
+        // Build the ICMPv4 Match
+        Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder();
+        icmpv4match.setIcmpv4Type(type);
+        icmpv4match.setIcmpv4Code(code);
+        matchBuilder.setIcmpv4Match(icmpv4match.build());
+
+        return matchBuilder;
+    }
+
+    /**
+     * @param matchBuilder MatchBuilder Object without a match yet
+     * @param dstip        String containing an IPv4 prefix
+     * @return matchBuilder Map Object with a match
+     */
+    public static MatchBuilder createDstL3IPv4Match(MatchBuilder matchBuilder, Ipv4Prefix dstip) {
+
+        EthernetMatchBuilder eth = new EthernetMatchBuilder();
+        EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+        ethTypeBuilder.setType(new EtherType(0x0800L));
+        eth.setEthernetType(ethTypeBuilder.build());
+        matchBuilder.setEthernetMatch(eth.build());
+
+        Ipv4MatchBuilder ipv4match = new Ipv4MatchBuilder();
+        ipv4match.setIpv4Destination(dstip);
+
+        matchBuilder.setLayer3Match(ipv4match.build());
+
+        return matchBuilder;
+
+    }
+
+    /**
+     * @param matchBuilder MatchBuilder Object without a match yet
+     * @param srcip        String containing an IPv4 prefix
+     * @return matchBuilder Map Object with a match
+     */
+    public static MatchBuilder createSrcL3IPv4Match(MatchBuilder matchBuilder, Ipv4Prefix srcip) {
+
+        EthernetMatchBuilder eth = new EthernetMatchBuilder();
+        EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+        ethTypeBuilder.setType(new EtherType(0x0800L));
+        eth.setEthernetType(ethTypeBuilder.build());
+        matchBuilder.setEthernetMatch(eth.build());
+
+        Ipv4MatchBuilder ipv4match = new Ipv4MatchBuilder();
+        ipv4match.setIpv4Source(srcip);
+        matchBuilder.setLayer3Match(ipv4match.build());
+
+        return matchBuilder;
+
+    }
+
+    /**
+     * Create Source TCP Port Match
+     *
+     * @param matchBuilder @param matchbuilder MatchBuilder Object without a match yet
+     * @param tcpport      Integer representing a source TCP port
+     * @return matchBuilder Map MatchBuilder Object with a match
+     */
+    public static MatchBuilder createSetSrcTcpMatch(MatchBuilder matchBuilder, PortNumber tcpport) {
+
+        EthernetMatchBuilder ethType = new EthernetMatchBuilder();
+        EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+        ethTypeBuilder.setType(new EtherType(0x0800L));
+        ethType.setEthernetType(ethTypeBuilder.build());
+        matchBuilder.setEthernetMatch(ethType.build());
+
+        IpMatchBuilder ipmatch = new IpMatchBuilder();
+        ipmatch.setIpProtocol((short) 6);
+        matchBuilder.setIpMatch(ipmatch.build());
+
+        TcpMatchBuilder tcpmatch = new TcpMatchBuilder();
+        tcpmatch.setTcpSourcePort(tcpport);
+        matchBuilder.setLayer4Match(tcpmatch.build());
+
+        return matchBuilder;
+
+    }
+
+    /**
+     * Create Destination TCP Port Match
+     *
+     * @param matchBuilder MatchBuilder Object without a match yet
+     * @param tcpDstPort   Integer representing a destination TCP port
+     * @return matchBuilder Map MatchBuilder Object with a match
+     */
+    public static MatchBuilder createSetDstTcpMatch(MatchBuilder matchBuilder, PortNumber tcpDstPort) {
+
+        EthernetMatchBuilder ethType = new EthernetMatchBuilder();
+        EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+        ethTypeBuilder.setType(new EtherType(0x0800L));
+        ethType.setEthernetType(ethTypeBuilder.build());
+        matchBuilder.setEthernetMatch(ethType.build());
+
+        IpMatchBuilder ipmatch = new IpMatchBuilder();
+        ipmatch.setIpProtocol((short) 6);
+        matchBuilder.setIpMatch(ipmatch.build());
+
+        TcpMatchBuilder tcpmatch = new TcpMatchBuilder();
+        tcpmatch.setTcpDestinationPort(tcpDstPort);
+        matchBuilder.setLayer4Match(tcpmatch.build());
+
+        return matchBuilder;
+    }
+
+    /**
+     * Test match for TCP_Flags
+     *
+     * @return match containing TCP_Flag (), IP Protocol (TCP), TCP_Flag (SYN)
+     * <p/>
+     * Defined TCP Flag values in OVS v2.1+
+     * TCP_FIN 0x001 / TCP_SYN 0x002 / TCP_RST 0x004
+     * TCP_PSH 0x008 / TCP_ACK 0x010 / TCP_URG 0x020
+     * TCP_ECE 0x040 / TCP_CWR 0x080 / TCP_NS  0x100
+     */
+    public static MatchBuilder createTcpFlagMatch(MatchBuilder matchBuilder, int tcpFlag) {
+
+        // Ethertype match
+        EthernetMatchBuilder ethernetType = new EthernetMatchBuilder();
+        EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+        ethTypeBuilder.setType(new EtherType(0x0800L));
+        ethernetType.setEthernetType(ethTypeBuilder.build());
+        matchBuilder.setEthernetMatch(ethernetType.build());
+
+        // TCP Protocol Match
+        IpMatchBuilder ipMatch = new IpMatchBuilder(); // ipv4 version
+        ipMatch.setIpProtocol((short) 6);
+        matchBuilder.setIpMatch(ipMatch.build());
+
+        // TCP Port Match
+        PortNumber dstPort = new PortNumber(80);
+        TcpMatchBuilder tcpMatch = new TcpMatchBuilder();
+        tcpMatch.setTcpDestinationPort(dstPort);
+        matchBuilder.setLayer4Match(tcpMatch.build());
+
+        TcpFlagMatchBuilder tcpFlagMatch = new TcpFlagMatchBuilder();
+        tcpFlagMatch.setTcpFlag(0x002);
+        matchBuilder.setTcpFlagMatch(tcpFlagMatch.build());
+        return matchBuilder;
+    }
+}