Policy exclusions & parallel netconf transactions
[groupbasedpolicy.git] / renderers / vpp / src / main / java / org / opendaylight / groupbasedpolicy / renderer / vpp / nat / NatUtil.java
index f612716f85672ede5712e18615cfc92475db8957..6f9a2f76a66f117cb9e56942a7b45cd441cf6544 100644 (file)
@@ -19,7 +19,6 @@ import javax.annotation.Nonnull;
 import javax.annotation.Nullable;\r
 \r
 import org.apache.commons.net.util.SubnetUtils;\r
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;\r
 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;\r
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;\r
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;\r
@@ -28,6 +27,7 @@ import org.opendaylight.groupbasedpolicy.renderer.vpp.util.GbpNetconfTransaction
 import org.opendaylight.groupbasedpolicy.renderer.vpp.util.VppIidFactory;\r
 import org.opendaylight.groupbasedpolicy.util.DataStoreHelper;\r
 import org.opendaylight.groupbasedpolicy.util.NetUtils;\r
+import org.opendaylight.vbd.impl.transaction.VbdNetconfTransaction;\r
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;\r
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;\r
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;\r
@@ -69,16 +69,16 @@ public class NatUtil {
         wTx.put(LogicalDatastoreType.CONFIGURATION, natIid, nat);\r
     }\r
 \r
-    public static void setOutboundInterface(Interface iface, DataBroker dataBroker) {\r
+    public static void setOutboundInterface(Interface iface, InstanceIdentifier<Node> vppIid) {\r
         InstanceIdentifier<Nat> natIid = buildNatIid(VppIidFactory.getInterfaceIID(iface.getKey()));\r
         Nat nat = new NatBuilder().setOutbound(new OutboundBuilder().build()).build();\r
-        GbpNetconfTransaction.netconfSyncedWrite(dataBroker, natIid, nat, GbpNetconfTransaction.RETRY_COUNT);\r
+        GbpNetconfTransaction.netconfSyncedWrite(vppIid, natIid, nat, GbpNetconfTransaction.RETRY_COUNT);\r
 \r
     }\r
 \r
-    public static void unsetOutboundInterface(Interface iface, DataBroker dataBroker) {\r
+    public static void unsetOutboundInterface(Interface iface, InstanceIdentifier<Node> vppIid) {\r
         InstanceIdentifier<Nat> natIid = buildNatIid(VppIidFactory.getInterfaceIID(iface.getKey()));\r
-        GbpNetconfTransaction.netconfSyncedDelete(dataBroker, natIid, GbpNetconfTransaction.RETRY_COUNT);\r
+        GbpNetconfTransaction.netconfSyncedDelete(vppIid, natIid, GbpNetconfTransaction.RETRY_COUNT);\r
     }\r
 \r
     public static InstanceIdentifier<Nat> buildNatIid(InstanceIdentifier<Interface> ifaceIid) {\r
@@ -190,17 +190,18 @@ public class NatUtil {
         return extCache;\r
     }\r
 \r
-    public static void resolveOutboundNatInterface(DataBroker mountpoint, InstanceIdentifier<Node> mountPointIid,\r
+    public static void resolveOutboundNatInterface(InstanceIdentifier<Node> mountPointIid,\r
         NodeId nodeId, Map<NodeId, PhysicalInterfaceKey> extInterfaces) {\r
         if (extInterfaces.containsKey(nodeId)){\r
             PhysicalInterfaceKey physicalInterfaceKey = extInterfaces.get(nodeId);\r
             Optional<Interfaces> readIfaces = DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION,\r
-                InstanceIdentifier.create(Interfaces.class), mountpoint.newReadOnlyTransaction());\r
+                InstanceIdentifier.create(Interfaces.class),\r
+                VbdNetconfTransaction.NODE_DATA_BROKER_MAP.get(mountPointIid).getKey().newReadOnlyTransaction());\r
             if(readIfaces.isPresent() ) {\r
                 for (Interface nodeInterface : readIfaces.get().getInterface()) {\r
                     if (nodeInterface.getName().equals(physicalInterfaceKey.getInterfaceName())) {\r
                         LOG.trace("Setting outbound NAT on interface {} on node: {}", nodeInterface.getName(), mountPointIid);\r
-                        NatUtil.setOutboundInterface(nodeInterface, mountpoint);\r
+                        NatUtil.setOutboundInterface(nodeInterface, mountPointIid);\r
                     }\r
                 }\r
 \r