Freeze upstream versions
[netvirt.git] / vpnmanager / impl / src / main / java / org / opendaylight / netvirt / vpnmanager / CentralizedSwitchChangeListener.java
index 80da10c4b88102cfa72da5ec7fd9f73183302d06..5581a3d43f6f13eb70d618eb2ccfc4fcdbc9597c 100644 (file)
@@ -8,22 +8,23 @@
 
 package org.opendaylight.netvirt.vpnmanager;
 
-import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
+import static org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION;
 
-import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
 import java.util.Objects;
 import java.util.concurrent.ExecutionException;
 import javax.annotation.PreDestroy;
 import javax.inject.Inject;
 import javax.inject.Singleton;
-import org.opendaylight.genius.infra.Datastore.Configuration;
-import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
-import org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl;
-import org.opendaylight.genius.infra.TypedReadWriteTransaction;
 import org.opendaylight.genius.mdsalutil.NwConstants;
 import org.opendaylight.infrautils.utils.concurrent.Executors;
-import org.opendaylight.infrautils.utils.concurrent.ListenableFutures;
+import org.opendaylight.infrautils.utils.concurrent.LoggingFutures;
 import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.util.Datastore.Configuration;
+import org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner;
+import org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl;
+import org.opendaylight.mdsal.binding.util.TypedReadWriteTransaction;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.netvirt.vpnmanager.api.IVpnManager;
 import org.opendaylight.serviceutils.tools.listener.AbstractAsyncDataTreeChangeListener;
@@ -31,6 +32,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.NaptSwitches;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.routers.ExternalIps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.routers.ExternalIpsKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.napt.switches.RouterToNaptSwitch;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.Uint64;
@@ -85,7 +87,7 @@ public class CentralizedSwitchChangeListener
     @Override
     public void remove(InstanceIdentifier<RouterToNaptSwitch> key, RouterToNaptSwitch routerToNaptSwitch) {
         LOG.debug("Removing {}", routerToNaptSwitch);
-        ListenableFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, tx ->
+        LoggingFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, tx ->
                                             setupRouterGwFlows(routerToNaptSwitch, tx, NwConstants.DEL_FLOW)), LOG,
                                                 "Error processing switch removal for {}", routerToNaptSwitch);
     }
@@ -96,7 +98,7 @@ public class CentralizedSwitchChangeListener
         LOG.debug("Updating old {} new {}", origRouterToNaptSwitch, updatedRouterToNaptSwitch);
         if (!Objects.equals(updatedRouterToNaptSwitch.getPrimarySwitchId(),
                 origRouterToNaptSwitch.getPrimarySwitchId())) {
-            ListenableFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, tx -> {
+            LoggingFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, tx -> {
                 setupRouterGwFlows(origRouterToNaptSwitch, tx, NwConstants.DEL_FLOW);
                 setupRouterGwFlows(updatedRouterToNaptSwitch, tx, NwConstants.ADD_FLOW);
             }), LOG, "Error updating switch {} to {}", origRouterToNaptSwitch, updatedRouterToNaptSwitch);
@@ -106,7 +108,7 @@ public class CentralizedSwitchChangeListener
     @Override
     public void add(InstanceIdentifier<RouterToNaptSwitch> key, RouterToNaptSwitch routerToNaptSwitch) {
         LOG.debug("Adding {}", routerToNaptSwitch);
-        ListenableFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, tx ->
+        LoggingFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, tx ->
                         setupRouterGwFlows(routerToNaptSwitch, tx, NwConstants.ADD_FLOW)), LOG,
                 "Error processing switch addition for {}", routerToNaptSwitch);
     }
@@ -130,13 +132,13 @@ public class CentralizedSwitchChangeListener
         Uuid extNetworkId = router.getNetworkId();
         String extGwMacAddress = router.getExtGwMacAddress();
         String routerName = router.getRouterName();
-        List<ExternalIps> externalIps = router.getExternalIps();
-        if (externalIps.isEmpty()) {
+        Map<ExternalIpsKey, ExternalIps> externalIpsMap = router.getExternalIps();
+        if (externalIpsMap.isEmpty()) {
             LOG.error("CentralizedSwitchChangeListener: setupRouterGwFlows no externalIP present");
             return;
         }
 
-        for (ExternalIps extIp : router.nonnullExternalIps()) {
+        for (ExternalIps extIp : router.nonnullExternalIps().values()) {
             Uuid subnetVpnName = extIp.getSubnetId();
             if (addOrRemove == NwConstants.ADD_FLOW) {
                 vpnManager.addRouterGwMacFlow(routerName, extGwMacAddress, primarySwitchId, extNetworkId,
@@ -151,11 +153,11 @@ public class CentralizedSwitchChangeListener
 
         if (addOrRemove == NwConstants.ADD_FLOW) {
             vpnManager.addArpResponderFlowsToExternalNetworkIps(routerName,
-                    VpnUtil.getIpsListFromExternalIps(router.getExternalIps()),
+                    VpnUtil.getIpsListFromExternalIps(new ArrayList<ExternalIps>(router.nonnullExternalIps().values())),
                     extGwMacAddress, primarySwitchId, extNetworkId);
         } else {
             vpnManager.removeArpResponderFlowsToExternalNetworkIps(routerName,
-                    VpnUtil.getIpsListFromExternalIps(router.getExternalIps()),
+                    VpnUtil.getIpsListFromExternalIps(new ArrayList<ExternalIps>(router.nonnullExternalIps().values())),
                     extGwMacAddress, primarySwitchId, extNetworkId);
         }
     }