Cleanup of Lisp in VPP renderer
[groupbasedpolicy.git] / renderers / vpp / src / main / java / org / opendaylight / groupbasedpolicy / renderer / vpp / iface / InterfaceManager.java
index cf1ad19a3132df4d1ff906fb6a5d92084469f239..8d0ddbf6402f3684170b8a2d647f94a334104c2b 100644 (file)
@@ -8,28 +8,33 @@
 
 package org.opendaylight.groupbasedpolicy.renderer.vpp.iface;
 
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.base.Strings;
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.SetMultimap;
+import com.google.common.eventbus.Subscribe;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.MoreExecutors;
+
 import java.util.List;
 import java.util.Set;
+import java.util.concurrent.ExecutionException;
 
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
-import com.google.common.eventbus.Subscribe;
-import com.google.common.util.concurrent.AsyncFunction;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.groupbasedpolicy.renderer.vpp.commands.AbstractInterfaceCommand;
-import org.opendaylight.groupbasedpolicy.renderer.vpp.commands.interfaces.ConfigCommand;
 import org.opendaylight.groupbasedpolicy.renderer.vpp.commands.LoopbackCommand;
 import org.opendaylight.groupbasedpolicy.renderer.vpp.commands.TapPortCommand;
 import org.opendaylight.groupbasedpolicy.renderer.vpp.commands.VhostUserCommand;
 import org.opendaylight.groupbasedpolicy.renderer.vpp.commands.VhostUserCommand.VhostUserCommandBuilder;
-import org.opendaylight.groupbasedpolicy.renderer.vpp.commands.interfaces.InterfaceCommand;
+import org.opendaylight.groupbasedpolicy.renderer.vpp.commands.interfaces.ConfigCommand;
+import org.opendaylight.groupbasedpolicy.renderer.vpp.config.ConfigUtil;
 import org.opendaylight.groupbasedpolicy.renderer.vpp.event.NodeOperEvent;
 import org.opendaylight.groupbasedpolicy.renderer.vpp.event.VppEndpointConfEvent;
 import org.opendaylight.groupbasedpolicy.renderer.vpp.policy.acl.AccessListWrapper;
@@ -39,6 +44,7 @@ import org.opendaylight.groupbasedpolicy.renderer.vpp.util.MountedDataBrokerProv
 import org.opendaylight.groupbasedpolicy.renderer.vpp.util.VppIidFactory;
 import org.opendaylight.groupbasedpolicy.renderer.vpp.util.VppRendererProcessingException;
 import org.opendaylight.groupbasedpolicy.util.DataStoreHelper;
+import org.opendaylight.vbd.impl.transaction.VbdNetconfTransaction;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.has.absolute.location.absolute.location.LocationType;
@@ -51,25 +57,19 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.vpp_render
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.vpp_renderer.rev160425._interface.attributes._interface.type.choice.TapCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.vpp_renderer.rev160425._interface.attributes._interface.type.choice.VhostUserCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.vpp_renderer.rev160425.config.VppEndpoint;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170315.VhostUserRole;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170315.VppInterfaceAugmentation;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170315.interfaces._interface.L2;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170315.interfaces._interface.L2Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170315.l2.base.attributes.Interconnection;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170315.l2.base.attributes.interconnection.BridgeBased;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170315.l2.base.attributes.interconnection.BridgeBasedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170607.VhostUserRole;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170607.VppInterfaceAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170607.interfaces._interface.L2;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170607.interfaces._interface.L2Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170607.l2.config.attributes.Interconnection;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170607.l2.config.attributes.interconnection.BridgeBased;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170607.l2.config.attributes.interconnection.BridgeBasedBuilder;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Strings;
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.SetMultimap;
-
 public class InterfaceManager implements AutoCloseable {
 
     private static final Logger LOG = LoggerFactory.getLogger(InterfaceManager.class);
@@ -85,75 +85,51 @@ public class InterfaceManager implements AutoCloseable {
     @Subscribe
     @SuppressWarnings("OptionalGetWithoutIsPresent")
     public synchronized void vppEndpointChanged(VppEndpointConfEvent event) {
-        ListenableFuture<Void> modificationFuture;
-        ListenableFuture<Boolean> policyExcludedFuture;
         String message;
         final VppEndpoint oldVppEndpoint = event.getBefore().orNull();
         final VppEndpoint newVppEndpoint = event.getAfter().orNull();
+        try {
         switch (event.getDtoModificationType()) {
             case CREATED: {
                 Preconditions.checkNotNull(newVppEndpoint);
-                modificationFuture = vppEndpointCreated(newVppEndpoint);
+                    vppEndpointCreated(newVppEndpoint).get();
                 message = String.format("Vpp endpoint %s on node %s and interface %s created",
                         newVppEndpoint.getAddress(), newVppEndpoint.getVppNodeId().getValue(),
                         newVppEndpoint.getVppInterfaceName());
-                policyExcludedFuture = updatePolicyExcludedEndpoints(newVppEndpoint, true);
+                updatePolicyExcludedEndpoints(newVppEndpoint, true).get();
             }
             break;
             case UPDATED: {
                 Preconditions.checkNotNull(oldVppEndpoint);
                 Preconditions.checkNotNull(newVppEndpoint);
-                modificationFuture = vppEndpointUpdated(oldVppEndpoint, newVppEndpoint);
+                vppEndpointUpdated(oldVppEndpoint, newVppEndpoint).get();
                 message = String.format("Vpp endpoint %s on node %s and interface %s updated",
                         newVppEndpoint.getAddress(), newVppEndpoint.getVppNodeId().getValue(),
                         newVppEndpoint.getVppInterfaceName());
-                final ListenableFuture<Boolean> partialOldPolicyExcludedFuture =
-                        updatePolicyExcludedEndpoints(oldVppEndpoint, false);
-                policyExcludedFuture =
-                        Futures.transform(partialOldPolicyExcludedFuture, (AsyncFunction<Boolean, Boolean>) input ->
-                                updatePolicyExcludedEndpoints(newVppEndpoint, true));
+                        updatePolicyExcludedEndpoints(oldVppEndpoint, true).get();
             }
             break;
             case DELETED: {
                 Preconditions.checkNotNull(oldVppEndpoint);
-                modificationFuture = vppEndpointDeleted(oldVppEndpoint);
+                vppEndpointDeleted(oldVppEndpoint).get();
                 message = String.format("Vpp endpoint %s on node %s and interface %s removed",
                         oldVppEndpoint.getAddress(), oldVppEndpoint.getVppNodeId().getValue(),
                         oldVppEndpoint.getVppInterfaceName());
-                policyExcludedFuture = updatePolicyExcludedEndpoints(event.getBefore().get(), false);
+                updatePolicyExcludedEndpoints(event.getBefore().get(), false).get();
             }
             break;
-            default: {
-                message = "Unknown event modification type: " + event.getDtoModificationType();
-                modificationFuture = Futures.immediateFailedFuture(new VppRendererProcessingException(message));
-                policyExcludedFuture = Futures.immediateFailedFuture(new VppRendererProcessingException(message));
-            }
+                default: {
+                    message = "Unknown event modification type: " + event.getDtoModificationType();
+                    LOG.error("Failed to process VPP endpoint {}. {}",
+                            (oldVppEndpoint != null) ? oldVppEndpoint.getKey() : newVppEndpoint.getKey(),
+                            event.getAfter(), new VppRendererProcessingException(message));
+                }
+        }
+        LOG.info(message);
+        } catch (InterruptedException | ExecutionException e) {
+            LOG.error("Failed to process changed vpp endpoint. before: {}, after: {}.Exception: {} ", event.getBefore(),
+                    event.getAfter(), e);
         }
-        // Modification
-        Futures.addCallback(modificationFuture, new FutureCallback<Void>() {
-            @Override
-            public void onSuccess(@Nullable Void result) {
-                LOG.info(message);
-            }
-
-            @Override
-            public void onFailure(@Nonnull Throwable t) {
-                LOG.warn("Vpp endpoint change event failed. Old ep: {}, new ep: {}", oldVppEndpoint, newVppEndpoint);
-            }
-        });
-
-        // Excluded policy
-        Futures.addCallback(policyExcludedFuture, new FutureCallback<Boolean>() {
-            @Override
-            public void onSuccess(@Nullable Boolean input) {
-                // NO-OP
-            }
-
-            @Override
-            public void onFailure(@Nonnull Throwable throwable) {
-                LOG.warn("Vpp endpoint exclusion failed. Odl ep: {}, new ep: {}", oldVppEndpoint, newVppEndpoint);
-            }
-        });
     }
 
     private ListenableFuture<Boolean> updatePolicyExcludedEndpoints(VppEndpoint vppEndpoint, boolean created) {
@@ -161,6 +137,8 @@ public class InterfaceManager implements AutoCloseable {
             return Futures.immediateFuture(true);
         }
         if (created) {
+            LOG.trace("Interface excluded from policy: node:{} interface:{}", vppEndpoint.getVppNodeId(),
+                    vppEndpoint.getVppInterfaceName());
             excludedFromPolicy.put(vppEndpoint.getVppNodeId(), vppEndpoint.getVppInterfaceName());
             return Futures.immediateFuture(true);
         }
@@ -173,11 +151,16 @@ public class InterfaceManager implements AutoCloseable {
         LOG.trace("Creating VPP endpoint {}, type of {}", vppEndpoint, interfaceTypeChoice);
         Optional<AbstractInterfaceCommand> potentialIfaceCommand = Optional.absent();
         if (interfaceTypeChoice instanceof VhostUserCase) {
-            potentialIfaceCommand = createInterfaceWithoutBdCommand(vppEndpoint, Operations.PUT);
+            potentialIfaceCommand = createVhostInterfaceWithoutBdCommand(vppEndpoint, Operations.PUT);
         } else if (interfaceTypeChoice instanceof TapCase) {
             potentialIfaceCommand = createTapInterfaceWithoutBdCommand(vppEndpoint, Operations.PUT);
         } else if (interfaceTypeChoice instanceof LoopbackCase){
-            potentialIfaceCommand = createLoopbackWithoutBdCommand(vppEndpoint, Operations.PUT);
+            if (!ConfigUtil.getInstance().isL3FlatEnabled()) {
+                potentialIfaceCommand = createLoopbackWithoutBdCommand(vppEndpoint, Operations.PUT);
+            }
+            else {
+                LOG.trace("L3 flat enabled: LISP in VPP renderer will take care of creating loopback.");
+            }
         }
         if (!potentialIfaceCommand.isPresent()) {
             LOG.debug("Interface/PUT command was not created for VppEndpoint point {}", vppEndpoint);
@@ -185,19 +168,18 @@ public class InterfaceManager implements AutoCloseable {
         }
         ConfigCommand ifaceWithoutBdCommand = potentialIfaceCommand.get();
         InstanceIdentifier<Node> vppNodeIid = VppIidFactory.getNetconfNodeIid(vppEndpoint.getVppNodeId());
-        Optional<DataBroker> potentialVppDataProvider = mountDataProvider.getDataBrokerForMountPoint(vppNodeIid);
+        Optional<DataBroker> potentialVppDataProvider = mountDataProvider.resolveDataBrokerForMountPoint(vppNodeIid);
         if (!potentialVppDataProvider.isPresent()) {
             final String message = "Cannot get data broker for mount point " + vppNodeIid;
             LOG.warn(message);
             return Futures.immediateFailedFuture(new VppRendererProcessingException(message));
         }
-        DataBroker vppDataBroker = potentialVppDataProvider.get();
-        return createInterfaceWithEndpointLocation(ifaceWithoutBdCommand, vppDataBroker, vppEndpoint, vppNodeIid);
+        return createInterfaceWithEndpointLocation(ifaceWithoutBdCommand, vppNodeIid, vppEndpoint);
     }
 
     public ListenableFuture<Void> createInterfaceOnVpp(final ConfigCommand createIfaceWithoutBdCommand,
-                                                       final DataBroker vppDataBroker) {
-        final boolean transactionState = GbpNetconfTransaction.netconfSyncedWrite(vppDataBroker, createIfaceWithoutBdCommand,
+                                                       final InstanceIdentifier<Node> vppIid) {
+        final boolean transactionState = GbpNetconfTransaction.netconfSyncedWrite(vppIid, createIfaceWithoutBdCommand,
                 GbpNetconfTransaction.RETRY_COUNT);
         if (transactionState) {
             LOG.trace("Creating Interface on VPP: {}", createIfaceWithoutBdCommand);
@@ -210,17 +192,16 @@ public class InterfaceManager implements AutoCloseable {
     }
 
     private ListenableFuture<Void> createInterfaceWithEndpointLocation(final ConfigCommand createIfaceWithoutBdCommand,
-                                                                       final DataBroker vppDataBroker,
-                                                                       final VppEndpoint vppEndpoint,
-                                                                       final InstanceIdentifier<?> vppNodeIid) {
-        final boolean transactionState = GbpNetconfTransaction.netconfSyncedWrite(vppDataBroker, createIfaceWithoutBdCommand,
+                                                                       final InstanceIdentifier<Node> vppIid,
+                                                                       final VppEndpoint vppEndpoint) {
+        final boolean transactionState = GbpNetconfTransaction.netconfSyncedWrite(vppIid, createIfaceWithoutBdCommand,
                 GbpNetconfTransaction.RETRY_COUNT);
         if (transactionState) {
-            LOG.debug("Create interface on VPP command was successful. VPP: {} Command: {}", vppNodeIid,
+            LOG.debug("Create interface on VPP command was successful. VPP: {} Command: {}", vppIid,
                     createIfaceWithoutBdCommand);
             return vppEndpointLocationProvider.createLocationForVppEndpoint(vppEndpoint);
         } else {
-            final String message = "Create interface on VPP command was not successful. VPP: " + vppNodeIid
+            final String message = "Create interface on VPP command was not successful. VPP: " + vppIid
             + " Command: " + createIfaceWithoutBdCommand;
             LOG.warn(message);
             return Futures.immediateFailedFuture(new VppRendererProcessingException(message));
@@ -231,8 +212,8 @@ public class InterfaceManager implements AutoCloseable {
                                                       @Nonnull final VppEndpoint newVppEndpoint) {
         if(!oldVppEndpoint.equals(newVppEndpoint)) {
             LOG.debug("Updating vpp endpoint, old EP: {} new EP: {}", oldVppEndpoint, newVppEndpoint);
-            return Futures.transform(vppEndpointDeleted(oldVppEndpoint),
-                    (AsyncFunction<Void, Void>) input -> vppEndpointCreated(newVppEndpoint));
+            return Futures.transformAsync(vppEndpointDeleted(oldVppEndpoint),
+                input -> vppEndpointCreated(newVppEndpoint), MoreExecutors.directExecutor());
         }
         LOG.debug("Update skipped, provided before/after vpp endpoints are equal");
         return Futures.immediateFuture(null);
@@ -243,40 +224,46 @@ public class InterfaceManager implements AutoCloseable {
         LOG.trace("Deleting VPP endpoint {}, type of {}", vppEndpoint, interfaceTypeChoice.toString());
         Optional<AbstractInterfaceCommand> potentialIfaceCommand = Optional.absent();
         if (interfaceTypeChoice instanceof VhostUserCase) {
-            potentialIfaceCommand = createInterfaceWithoutBdCommand(vppEndpoint, Operations.DELETE);
+            potentialIfaceCommand = createVhostInterfaceWithoutBdCommand(vppEndpoint, Operations.DELETE);
         } else if (interfaceTypeChoice instanceof TapCase) {
             potentialIfaceCommand = createTapInterfaceWithoutBdCommand(vppEndpoint, Operations.DELETE);
         } else if (interfaceTypeChoice instanceof LoopbackCase){
-            potentialIfaceCommand = createLoopbackWithoutBdCommand(vppEndpoint, Operations.DELETE);
+            if (!ConfigUtil.getInstance().isL3FlatEnabled()) {
+                potentialIfaceCommand = createLoopbackWithoutBdCommand(vppEndpoint, Operations.DELETE);
+            }
+            else {
+                LOG.trace("L3 flat enabled: LISP in VPP renderer will take care of delete for loopback.");
+            }
         }
 
+
         if (!potentialIfaceCommand.isPresent()) {
             LOG.debug("Interface/DELETE command was not created for VppEndpoint point {}", vppEndpoint);
             return Futures.immediateFuture(null);
         }
         AbstractInterfaceCommand ifaceWithoutBdCommand = potentialIfaceCommand.get();
         InstanceIdentifier<Node> vppNodeIid = VppIidFactory.getNetconfNodeIid(vppEndpoint.getVppNodeId());
-        Optional<DataBroker> potentialVppDataProvider = mountDataProvider.getDataBrokerForMountPoint(vppNodeIid);
+        Optional<DataBroker> potentialVppDataProvider = mountDataProvider.resolveDataBrokerForMountPoint(vppNodeIid);
         if (!potentialVppDataProvider.isPresent()) {
             final String message = "Cannot get data broker for mount point " + vppNodeIid;
             LOG.warn(message);
             return Futures.immediateFailedFuture(new VppRendererProcessingException(message));
         }
-        DataBroker vppDataBroker = potentialVppDataProvider.get();
-        return deleteIfaceOnVpp(ifaceWithoutBdCommand, vppDataBroker, vppEndpoint, vppNodeIid);
+
+        return deleteIfaceOnVpp(ifaceWithoutBdCommand, vppNodeIid, vppEndpoint);
     }
 
-    private ListenableFuture<Void> deleteIfaceOnVpp(AbstractInterfaceCommand deleteIfaceWithoutBdCommand,
-            DataBroker vppDataBroker, VppEndpoint vppEndpoint, InstanceIdentifier<?> vppNodeIid) {
-        final boolean transactionState = GbpNetconfTransaction.netconfSyncedDelete(vppDataBroker,
-            deleteIfaceWithoutBdCommand, GbpNetconfTransaction.RETRY_COUNT);
+    private ListenableFuture<Void> deleteIfaceOnVpp(AbstractInterfaceCommand interfaceCommand,
+        InstanceIdentifier<Node> vppIid, VppEndpoint vppEndpoint) {
+        final boolean transactionState = GbpNetconfTransaction.netconfSyncedDelete(vppIid, interfaceCommand,
+            GbpNetconfTransaction.RETRY_COUNT);
         if (transactionState) {
-            LOG.debug("Delete interface on VPP command was successful: VPP: {} Command: {}", vppNodeIid,
-                    deleteIfaceWithoutBdCommand);
+            LOG.debug("Delete interface on VPP command was successful: VPP: {} Command: {}", vppIid, interfaceCommand);
+            AccessListWrapper.removeAclsForInterface(vppIid, new InterfaceKey(interfaceCommand.getName()));
             return vppEndpointLocationProvider.deleteLocationForVppEndpoint(vppEndpoint);
         } else {
-            final String message = "Delete interface on VPP command was not successful: VPP: " + vppNodeIid +
-                    " Command: " + deleteIfaceWithoutBdCommand;
+            final String message = "Delete interface on VPP command was not successful: VPP: " + vppIid
+                    + " Command: " + interfaceCommand;
             LOG.warn(message);
             return Futures.immediateFailedFuture(new VppRendererProcessingException(message));
         }
@@ -304,8 +291,8 @@ public class InterfaceManager implements AutoCloseable {
         }
     }
 
-    private Optional<AbstractInterfaceCommand> createInterfaceWithoutBdCommand(@Nonnull VppEndpoint vppEp,
-            @Nonnull Operations operations) {
+    private Optional<AbstractInterfaceCommand> createVhostInterfaceWithoutBdCommand(@Nonnull VppEndpoint vppEp,
+                                                                                    @Nonnull Operations operations) {
         if (!hasNodeAndInterface(vppEp)) {
             LOG.debug("Interface command is not created for {}", vppEp);
             return Optional.absent();
@@ -323,6 +310,10 @@ public class InterfaceManager implements AutoCloseable {
             builder.setSocket(socket);
             builder.setRole(VhostUserRole.Client);
         }
+        if (ConfigUtil.getInstance().isL3FlatEnabled()) {
+            builder.setEnableProxyArp(true);
+            builder.setSnatEnabled(true);
+        }
         VhostUserCommand vhostUserCommand =
                 builder.setOperation(operations).setDescription(vppEp.getDescription()).build();
         return Optional.of(vhostUserCommand);
@@ -344,8 +335,12 @@ public class InterfaceManager implements AutoCloseable {
                 return Optional.absent();
             }
             builder.setTapName(name);
-            builder.setPhysAddress(tapIface.getPhysicalAddress());
         }
+
+        if (ConfigUtil.getInstance().isL3FlatEnabled()) {
+            builder.setEnableProxyArp(true);
+        }
+
         TapPortCommand tapPortCommand = builder
                 .setOperation(operation)
                 .setDescription(vppEp.getDescription())
@@ -391,14 +386,15 @@ public class InterfaceManager implements AutoCloseable {
      *                         {@link ExternalLocationCase} where
      *                         {@link ExternalLocationCase#getExternalNodeMountPoint()} MUST NOT be {@code null}
      *                         and {@link ExternalLocationCase#getExternalNodeConnector()} MUST NOT be {@code null}
+     * @param aclWrappers wrappers for ACLs
+     * @param enableBvi BVI enabled/disabled
      * @return {@link ListenableFuture}
      */
     public synchronized ListenableFuture<Void> addBridgeDomainToInterface(@Nonnull String bridgeDomainName,
-                                                                          @Nonnull AddressEndpointWithLocation addrEpWithLoc,
-                                                                          @Nonnull List<AccessListWrapper> aclWrappers,
-                                                                          boolean enableBvi) {
+        @Nonnull AddressEndpointWithLocation addrEpWithLoc, @Nonnull List<AccessListWrapper> aclWrappers,
+        boolean enableBvi) {
         ExternalLocationCase epLoc = resolveAndValidateLocation(addrEpWithLoc);
-        InstanceIdentifier<?> vppNodeIid = epLoc.getExternalNodeMountPoint();
+        InstanceIdentifier<Node> vppNodeIid = (InstanceIdentifier<Node>) epLoc.getExternalNodeMountPoint();
         String interfacePath = epLoc.getExternalNodeConnector();
 
         Optional<InstanceIdentifier<Interface>> optInterfaceIid =
@@ -408,12 +404,11 @@ public class InterfaceManager implements AutoCloseable {
                     new Exception("Cannot resolve interface instance-identifier for interface path" + interfacePath));
         }
         InstanceIdentifier<Interface> interfaceIid = optInterfaceIid.get();
-        Optional<DataBroker> potentialVppDataProvider = mountDataProvider.getDataBrokerForMountPoint(vppNodeIid);
+        Optional<DataBroker> potentialVppDataProvider = mountDataProvider.resolveDataBrokerForMountPoint(vppNodeIid);
         if (!potentialVppDataProvider.isPresent()) {
             return Futures.immediateFailedFuture(new Exception("Cannot get data broker for mount point " + vppNodeIid));
         }
-        final DataBroker mountpoint = potentialVppDataProvider.get();
-        Optional<Interface> optInterface = GbpNetconfTransaction.read(mountpoint, LogicalDatastoreType.CONFIGURATION,
+        Optional<Interface> optInterface = GbpNetconfTransaction.read(vppNodeIid, LogicalDatastoreType.CONFIGURATION,
                 interfaceIid, GbpNetconfTransaction.RETRY_COUNT);
 
         if (!optInterface.isPresent()) {
@@ -435,7 +430,7 @@ public class InterfaceManager implements AutoCloseable {
         }
         InstanceIdentifier<L2> l2Iid =
                 interfaceIid.builder().augmentation(VppInterfaceAugmentation.class).child(L2.class).build();
-        Optional<L2> optL2 = GbpNetconfTransaction.read(mountpoint, LogicalDatastoreType.CONFIGURATION,
+        Optional<L2> optL2 = GbpNetconfTransaction.read(vppNodeIid, LogicalDatastoreType.CONFIGURATION,
                 l2Iid, GbpNetconfTransaction.RETRY_COUNT);
         L2Builder l2Builder = (optL2.isPresent()) ? new L2Builder(optL2.get()) : new L2Builder();
         L2 l2 = l2Builder.setInterconnection(new BridgeBasedBuilder()
@@ -443,18 +438,19 @@ public class InterfaceManager implements AutoCloseable {
                 .setBridgedVirtualInterface(enableBvi)
                 .build()).build();
         LOG.debug("Adding bridge domain {} to interface {}", bridgeDomainName, interfacePath);
-        final boolean transactionState = GbpNetconfTransaction.netconfSyncedWrite(mountpoint, l2Iid, l2,
+        LOG.info("Debugging L2: iid={}, data={}", l2Iid, l2);
+        final boolean transactionState = GbpNetconfTransaction.netconfSyncedWrite(vppNodeIid, l2Iid, l2,
                 GbpNetconfTransaction.RETRY_COUNT);
         if (transactionState) {
             LOG.debug("Adding bridge domain {} to interface {} successful", bridgeDomainName, interfacePath);
             Set<String> excludedIfaces = excludedFromPolicy.get(vppNodeIid.firstKeyOf(Node.class).getNodeId());
-            if(excludedIfaces == null || !excludedIfaces.contains(interfaceIid.firstKeyOf(Interface.class).getName())) {
+            if (!isExcludedFromPolicy(vppNodeIid.firstKeyOf(Node.class).getNodeId(),
+                    interfaceIid.firstKeyOf(Interface.class).getName())) {
                 // can apply ACLs on interfaces in bridge domains
                 aclWrappers.forEach(aclWrapper -> {
-                    LOG.debug("Writing access list for interface {} on a node {}.", interfaceIid,
-                            vppNodeIid);
-                    aclWrapper.writeAcl(mountpoint, interfaceIid.firstKeyOf(Interface.class));
-                    aclWrapper.writeAclRefOnIface(mountpoint, interfaceIid);
+                    LOG.debug("Writing access list for interface {} on a node {}.", interfaceIid, vppNodeIid);
+                    aclWrapper.writeAcl(vppNodeIid, interfaceIid.firstKeyOf(Interface.class));
+                    aclWrapper.writeAclRefOnIface(vppNodeIid, interfaceIid);
                 });
             }
             String bridgeDomainPath = VppPathMapper.bridgeDomainToRestPath(bridgeDomainName);
@@ -464,23 +460,33 @@ public class InterfaceManager implements AutoCloseable {
                     .setExternalNodeConnector(interfacePath)
                     .build(), addrEpWithLoc.getKey());
         } else {
-            final String message = "Adding bridge domain " + bridgeDomainName + " to interface " + interfacePath + " failed";
+            final String message =
+                "Adding bridge domain " + bridgeDomainName + " to interface " + interfacePath + " failed";
             LOG.warn(message);
             return Futures.immediateFailedFuture(new VppRendererProcessingException(message));
         }
     }
 
-    public ListenableFuture<Void> configureInterface(DataBroker mountPoint, InterfaceKey ifaceKey, @Nullable String bridgeDomainName,
-                                                     @Nullable Boolean enableBvi) {
-        L2Builder l2Builder = readL2ForInterface(mountPoint, ifaceKey);
+    public boolean isExcludedFromPolicy(@Nonnull NodeId nodeId,@Nonnull String interfaceName) {
+        Set<String> excludedIfaces = excludedFromPolicy.get(nodeId);
+        if(excludedIfaces != null && excludedIfaces.contains(interfaceName)) {
+            return true;
+        }
+        return false;
+    }
+
+    public ListenableFuture<Void> configureInterface(InstanceIdentifier<Node> vppIid, InterfaceKey ifaceKey,
+        @Nullable String bridgeDomainName, @Nullable Boolean enableBvi) {
+        L2Builder l2Builder = readL2ForInterface(vppIid, ifaceKey);
         L2 l2 = l2Builder.setInterconnection(new BridgeBasedBuilder()
             .setBridgeDomain(bridgeDomainName)
             .setBridgedVirtualInterface(enableBvi)
             .build()).build();
-        final boolean transactionState = GbpNetconfTransaction.netconfSyncedWrite(mountPoint,
+        final boolean transactionState = GbpNetconfTransaction.netconfSyncedWrite(vppIid,
             VppIidFactory.getL2ForInterfaceIid(ifaceKey), l2, GbpNetconfTransaction.RETRY_COUNT);
         if (transactionState) {
-            LOG.debug("Adding bridge domain {} to interface {}", bridgeDomainName, VppIidFactory.getInterfaceIID(ifaceKey));
+            LOG.debug("Adding bridge domain {} to interface {}", bridgeDomainName,
+                VppIidFactory.getInterfaceIID(ifaceKey));
             return Futures.immediateFuture(null);
         } else {
             final String message = "Failed to add bridge domain " + bridgeDomainName + " to interface "
@@ -490,13 +496,14 @@ public class InterfaceManager implements AutoCloseable {
         }
     }
 
-    public ListenableFuture<Void> removeInterfaceFromBridgeDomain(DataBroker mountPoint, InterfaceKey ifaceKey) {
-        L2Builder l2Builder = readL2ForInterface(mountPoint, ifaceKey);
+    public ListenableFuture<Void> removeInterfaceFromBridgeDomain(InstanceIdentifier<Node> vppIid,
+        InterfaceKey ifaceKey) {
+        L2Builder l2Builder = readL2ForInterface(vppIid, ifaceKey);
         if (l2Builder.getInterconnection() == null || !(l2Builder.getInterconnection() instanceof BridgeBased)) {
             LOG.warn("Interface already not in bridge domain {} ", ifaceKey);
             return Futures.immediateFuture(null);
         }
-        final boolean transactionState = GbpNetconfTransaction.netconfSyncedDelete(mountPoint,
+        final boolean transactionState = GbpNetconfTransaction.netconfSyncedDelete(vppIid,
                 VppIidFactory.getL2ForInterfaceIid(ifaceKey), GbpNetconfTransaction.RETRY_COUNT);
         if (transactionState) {
             LOG.debug("Removing bridge domain from interface {}", VppIidFactory.getInterfaceIID(ifaceKey));
@@ -509,9 +516,10 @@ public class InterfaceManager implements AutoCloseable {
         }
     }
 
-    private L2Builder readL2ForInterface(DataBroker mountpoint, InterfaceKey ifaceKey) {
+    private L2Builder readL2ForInterface(InstanceIdentifier<Node> vppIid, InterfaceKey ifaceKey) {
         InstanceIdentifier<L2> l2Iid = VppIidFactory.getL2ForInterfaceIid(ifaceKey);
-        final ReadOnlyTransaction rwTxRead = mountpoint.newReadOnlyTransaction();
+        final ReadOnlyTransaction rwTxRead = VbdNetconfTransaction.NODE_DATA_BROKER_MAP.get(vppIid).getKey()
+            .newReadOnlyTransaction();
         Optional<L2> optL2 = DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION, l2Iid, rwTxRead);
         rwTxRead.close();
         return  (optL2.isPresent()) ? new L2Builder(optL2.get()) : new L2Builder();
@@ -536,7 +544,7 @@ public class InterfaceManager implements AutoCloseable {
             @Nonnull AddressEndpointWithLocation addrEpWithLoc) {
         // TODO update ACLs for peers
         ExternalLocationCase epLoc = resolveAndValidateLocation(addrEpWithLoc);
-        InstanceIdentifier<?> vppNodeIid = epLoc.getExternalNodeMountPoint();
+        InstanceIdentifier<Node> vppNodeIid = (InstanceIdentifier<Node>) epLoc.getExternalNodeMountPoint();
         String interfacePath = epLoc.getExternalNodeConnector();
 
         Optional<InstanceIdentifier<Interface>> optInterfaceIid =
@@ -546,13 +554,11 @@ public class InterfaceManager implements AutoCloseable {
                     new Exception("Cannot resolve interface instance-identifier for interface path" + interfacePath));
         }
         InstanceIdentifier<Interface> interfaceIid = optInterfaceIid.get();
-
-        Optional<DataBroker> potentialVppDataProvider = mountDataProvider.getDataBrokerForMountPoint(vppNodeIid);
+        Optional<DataBroker> potentialVppDataProvider = mountDataProvider.resolveDataBrokerForMountPoint(vppNodeIid);
         if (!potentialVppDataProvider.isPresent()) {
             return Futures.immediateFailedFuture(new Exception("Cannot get data broker for mount point " + vppNodeIid));
         }
-        final DataBroker mountpoint = potentialVppDataProvider.get();
-        final Optional<Interface> optInterface = GbpNetconfTransaction.read(mountpoint,
+        final Optional<Interface> optInterface = GbpNetconfTransaction.read(vppNodeIid,
                 LogicalDatastoreType.CONFIGURATION, interfaceIid, GbpNetconfTransaction.RETRY_COUNT);
         if (!optInterface.isPresent()) {
             // interface does not exist so we consider job done
@@ -574,10 +580,10 @@ public class InterfaceManager implements AutoCloseable {
                 interfaceIid.builder().augmentation(VppInterfaceAugmentation.class).child(L2.class).build();
         LOG.debug("Deleting bridge domain from interface {}", interfacePath);
         final boolean transactionState =
-                GbpNetconfTransaction.netconfSyncedDelete(mountpoint, l2Iid, GbpNetconfTransaction.RETRY_COUNT);
+                GbpNetconfTransaction.netconfSyncedDelete(vppNodeIid, l2Iid, GbpNetconfTransaction.RETRY_COUNT);
         if (transactionState) {
-            AccessListWrapper.removeAclRefFromIface(mountpoint, interfaceIid.firstKeyOf(Interface.class));
-            AccessListWrapper.removeAclsForInterface(mountpoint, interfaceIid.firstKeyOf(Interface.class));
+            AccessListWrapper.removeAclRefFromIface(vppNodeIid, interfaceIid.firstKeyOf(Interface.class));
+            AccessListWrapper.removeAclsForInterface(vppNodeIid, interfaceIid.firstKeyOf(Interface.class));
             return vppEndpointLocationProvider.replaceLocationForEndpoint(
                     new ExternalLocationCaseBuilder().setExternalNode(null)
                         .setExternalNodeMountPoint(vppNodeIid)
@@ -591,7 +597,7 @@ public class InterfaceManager implements AutoCloseable {
         }
     }
 
-    static ExternalLocationCase resolveAndValidateLocation(AddressEndpointWithLocation addrEpWithLoc) {
+    public static ExternalLocationCase resolveAndValidateLocation(AddressEndpointWithLocation addrEpWithLoc) {
         LocationType locationType = addrEpWithLoc.getAbsoluteLocation().getLocationType();
         if (!(locationType instanceof ExternalLocationCase)) {
             throw new IllegalArgumentException("Endpoint does not have external location " + addrEpWithLoc);