Squashed commit of the following:
[ovsdb.git] / openstack / net-virt-providers / src / main / java / org / opendaylight / ovsdb / openstack / netvirt / providers / openflow13 / services / OutboundNatService.java
index aa3330478e3ed88b19f80848800007f39bce944b..2e70b8c26442aeb81cc68db642830f60613f700c 100644 (file)
@@ -14,12 +14,11 @@ import java.math.BigInteger;
 import java.net.InetAddress;
 import java.util.List;
 
-import org.opendaylight.controller.sal.core.Node;
-import org.opendaylight.controller.sal.utils.Status;
-import org.opendaylight.controller.sal.utils.StatusCode;
 import org.opendaylight.ovsdb.openstack.netvirt.api.Action;
 import org.opendaylight.ovsdb.openstack.netvirt.api.Constants;
 import org.opendaylight.ovsdb.openstack.netvirt.api.OutboundNatProvider;
+import org.opendaylight.ovsdb.openstack.netvirt.api.Status;
+import org.opendaylight.ovsdb.openstack.netvirt.api.StatusCode;
 import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.AbstractServiceInstance;
 import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.OF13Provider;
 import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.Service;
@@ -48,7 +47,7 @@ public class OutboundNatService extends AbstractServiceInstance implements Outbo
     }
 
     @Override
-    public Status programIpRewriteRule(Node node, Long dpid, String segmentationId, InetAddress matchAddress,
+    public Status programIpRewriteRule(Long dpid, String segmentationId, InetAddress matchAddress,
                                        InetAddress rewriteAddress, Action action) {
         String nodeName = Constants.OPENFLOW_NODE_PREFIX + dpid;
 
@@ -61,10 +60,12 @@ public class OutboundNatService extends AbstractServiceInstance implements Outbo
         InstructionBuilder ib = new InstructionBuilder();
 
         MatchUtils.createTunnelIDMatch(matchBuilder, new BigInteger(segmentationId));
-        MatchUtils.createDstL3IPv4Match(matchBuilder, new Ipv4Prefix(matchAddress.getHostAddress()));
+        MatchUtils.createDstL3IPv4Match(matchBuilder,
+                                        MatchUtils.iPv4PrefixFromIPv4Address(matchAddress.getHostAddress()));
 
         // Set Dest IP address
-        InstructionUtils.createNwDstInstructions(ib, new Ipv4Prefix(rewriteAddress.getHostAddress()));
+        InstructionUtils.createNwDstInstructions(ib,
+                                                 MatchUtils.iPv4PrefixFromIPv4Address(rewriteAddress.getHostAddress()));
         ib.setOrder(0);
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
@@ -79,7 +80,7 @@ public class OutboundNatService extends AbstractServiceInstance implements Outbo
         flowBuilder.setMatch(matchBuilder.build());
         flowBuilder.setInstructions(isb.setInstruction(instructions).build());
 
-        String flowId = "OutboundNAT_" + rewriteAddress.getHostAddress();
+        String flowId = "OutboundNAT_" + segmentationId + "_" + rewriteAddress.getHostAddress();
         flowBuilder.setId(new FlowId(flowId));
         FlowKey key = new FlowKey(new FlowId(flowId));
         flowBuilder.setBarrier(true);
@@ -89,7 +90,6 @@ public class OutboundNatService extends AbstractServiceInstance implements Outbo
         flowBuilder.setFlowName(flowId);
         flowBuilder.setHardTimeout(0);
         flowBuilder.setIdleTimeout(0);
-        writeFlow(flowBuilder, nodeBuilder);
 
         if (action.equals(Action.ADD)) {
             writeFlow(flowBuilder, nodeBuilder);
@@ -102,7 +102,7 @@ public class OutboundNatService extends AbstractServiceInstance implements Outbo
     }
 
     @Override
-    public Status programIpRewriteExclusion(Node node, Long dpid, String segmentationId, String excludedCidr,
+    public Status programIpRewriteExclusion(Long dpid, String segmentationId, String excludedCidr,
                                             Action action) {
         String nodeName = Constants.OPENFLOW_NODE_PREFIX + dpid;
 
@@ -127,7 +127,7 @@ public class OutboundNatService extends AbstractServiceInstance implements Outbo
         flowBuilder.setMatch(matchBuilder.build());
         flowBuilder.setInstructions(isb.setInstruction(instructions).build());
 
-        String flowId = "OutboundNATExclusion_" + excludedCidr;
+        String flowId = "OutboundNATExclusion_" + segmentationId + "_" + excludedCidr;
         flowBuilder.setId(new FlowId(flowId));
         FlowKey key = new FlowKey(new FlowId(flowId));
         flowBuilder.setBarrier(true);
@@ -137,7 +137,6 @@ public class OutboundNatService extends AbstractServiceInstance implements Outbo
         flowBuilder.setFlowName(flowId);
         flowBuilder.setHardTimeout(0);
         flowBuilder.setIdleTimeout(0);
-        writeFlow(flowBuilder, nodeBuilder);
 
         if (action.equals(Action.ADD)) {
             writeFlow(flowBuilder, nodeBuilder);