MdsalApiManager cleanup - neutronvpn 67/76167/3
authorStephen Kitt <skitt@redhat.com>
Mon, 17 Sep 2018 13:24:11 +0000 (15:24 +0200)
committerFaseela K <faseela.k@ericsson.com>
Tue, 26 Mar 2019 08:56:24 +0000 (08:56 +0000)
This removes all calls to deprecated methods in MdsalManager, so that
they can be removed in the near future.

Change-Id: Ifb524445efc0bc324e7ea42fb404acedae98f5da
Signed-off-by: Stephen Kitt <skitt@redhat.com>
neutronvpn/impl/src/main/java/org/opendaylight/netvirt/neutronvpn/IPV6InternetDefaultRouteProgrammer.java
neutronvpn/impl/src/main/java/org/opendaylight/netvirt/neutronvpn/NeutronvpnUtils.java

index 6cf49d923c3fbe58570392636292474bd7dcdb5d..921ae76a970459fd07f8f685eaca5c5ea752eaa2 100644 (file)
@@ -10,10 +10,12 @@ package org.opendaylight.netvirt.neutronvpn;
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.List;
-
+import java.util.concurrent.ExecutionException;
 import javax.inject.Inject;
 import javax.inject.Singleton;
-
+import org.opendaylight.genius.infra.Datastore.Configuration;
+import org.opendaylight.genius.infra.TypedReadWriteTransaction;
+import org.opendaylight.genius.infra.TypedWriteTransaction;
 import org.opendaylight.genius.mdsalutil.ActionInfo;
 import org.opendaylight.genius.mdsalutil.FlowEntity;
 import org.opendaylight.genius.mdsalutil.InstructionInfo;
@@ -78,16 +80,18 @@ public class IPV6InternetDefaultRouteProgrammer {
      * @param internetBgpVpnId internetVpn id as long
      * @param vpnId id of router associated to internet bgpvpn as long
      */
-    public void installDefaultRoute(BigInteger dpnId, String routerId, long internetBgpVpnId, long vpnId) {
+    public void installDefaultRoute(TypedWriteTransaction<Configuration> tx, BigInteger dpnId, String routerId,
+            long internetBgpVpnId, long vpnId) {
         FlowEntity flowEntity = buildIPv6FallbacktoExternalVpn(dpnId, routerId, internetBgpVpnId, vpnId, true);
         LOG.trace("installDefaultRoute: flowEntity: {} ", flowEntity);
-        mdsalManager.installFlow(flowEntity);
+        mdsalManager.addFlow(tx, flowEntity);
     }
 
-    public void removeDefaultRoute(BigInteger dpnId, String routerId, long internetBgpVpnId, long vpnId) {
+    public void removeDefaultRoute(TypedReadWriteTransaction<Configuration> tx, BigInteger dpnId, String routerId,
+            long internetBgpVpnId, long vpnId) throws ExecutionException, InterruptedException {
         FlowEntity flowEntity = buildIPv6FallbacktoExternalVpn(dpnId, routerId, internetBgpVpnId, vpnId, false);
         LOG.trace("removeDefaultRoute: flowEntity: {} ", flowEntity);
-        mdsalManager.removeFlow(flowEntity);
+        mdsalManager.removeFlow(tx, flowEntity);
     }
 
     public String getIPv6FlowRefL3(BigInteger dpnId, short tableId, String destPrefix, String routerId) {
index 47f62d0f876f6b9ca78fd696048e153ece230220..58f98a6aec262c579e687350fef362fef2d8a5c1 100644 (file)
@@ -18,7 +18,6 @@ import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.MoreExecutors;
 import com.google.common.util.concurrent.SettableFuture;
-
 import java.math.BigInteger;
 import java.net.Inet4Address;
 import java.net.Inet6Address;
@@ -43,7 +42,6 @@ import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 import javax.inject.Inject;
 import javax.inject.Singleton;
-
 import org.apache.commons.lang3.StringUtils;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
@@ -58,6 +56,7 @@ import org.opendaylight.genius.mdsalutil.MDSALUtil;
 import org.opendaylight.genius.utils.JvmGlobalLocks;
 import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
 import org.opendaylight.infrautils.utils.concurrent.ListenableFutures;
+import org.opendaylight.infrautils.utils.concurrent.LoggingFutures;
 import org.opendaylight.netvirt.neutronvpn.api.enums.IpVersionChoice;
 import org.opendaylight.netvirt.neutronvpn.api.utils.NeutronUtils;
 import org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.VpnInstances;
@@ -1709,9 +1708,16 @@ public class NeutronvpnUtils {
             }
             for (BigInteger dpnId : dpnIds) {
                 if (add) {
-                    ipV6InternetDefRt.installDefaultRoute(dpnId, rtrId.getValue(), internetBgpVpnId, vpnId);
+                    LoggingFutures.addErrorLogging(
+                        txRunner.callWithNewWriteOnlyTransactionAndSubmit(Datastore.CONFIGURATION,
+                            tx -> ipV6InternetDefRt.installDefaultRoute(tx, dpnId, rtrId.getValue(), internetBgpVpnId,
+                                vpnId)), LOG, "Error adding default route");
                 } else {
-                    ipV6InternetDefRt.removeDefaultRoute(dpnId, rtrId.getValue(), internetBgpVpnId, vpnId);
+                    LoggingFutures.addErrorLogging(
+                        txRunner.callWithNewReadWriteTransactionAndSubmit(Datastore.CONFIGURATION,
+                            tx -> ipV6InternetDefRt.removeDefaultRoute(tx, dpnId, rtrId.getValue(), internetBgpVpnId,
+                                vpnId)), LOG,
+                        "Error removing default route");
                 }
             }
         }