Bug 7700: create-l3vpn (REST/CLI) should not allow another VPN to use the same VPNID
[netvirt.git] / vpnservice / neutronvpn / neutronvpn-impl / src / main / java / org / opendaylight / netvirt / neutronvpn / NeutronvpnManager.java
index e87274d7997694c36ce5eaa71526c649bc29a356..71c2e3866df6458d7ee680ff296b1489263fa947 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ * Copyright © 2015, 2017 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -7,18 +7,20 @@
  */
 package org.opendaylight.netvirt.neutronvpn;
 
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.SettableFuture;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.EventListener;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
-
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
@@ -44,14 +46,12 @@ import org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev14081
 import org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterfaceKey;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInstances;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.Adjacencies;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.AdjacenciesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.AdjacencyBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.AdjacencyKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPort;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.config.rev160806.NeutronvpnConfig;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.AssociateNetworksInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.AssociateNetworksOutput;
@@ -81,15 +81,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev15060
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.RouterDisassociatedFromVpn;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.RouterDisassociatedFromVpnBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.RouterInterfacesMap;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.SubnetAddedToVpnBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.SubnetDeletedFromVpnBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.SubnetUpdatedInVpnBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.Subnetmaps;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.VpnMaps;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.createl3vpn.input.L3vpn;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.getl3vpn.output.L3vpnInstances;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.getl3vpn.output.L3vpnInstancesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.neutron.vpn.portip.port.data.VpnPortipToPort;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.router.interfaces.map.RouterInterfaces;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.router.interfaces.map.RouterInterfacesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.router.interfaces.map.RouterInterfacesKey;
@@ -125,10 +121,6 @@ import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.SettableFuture;
-
 public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, EventListener {
     private static final Logger LOG = LoggerFactory.getLogger(NeutronvpnManager.class);
     private final DataBroker dataBroker;
@@ -139,18 +131,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
     private final NeutronvpnConfig neutronvpnConfig;
     private final IMdsalApiManager mdsalUtil;
     private final IElanService elanService;
-    Boolean isExternalVpn;
 
-    /**
-     * @param dataBroker DataBroker reference
-     * @param mdsalManager MDSAL Util API access
-     * @param notiPublishService notificationPublishService
-     * @param vpnNatMgr VPN NAT manager service
-     * @param vpnRpcSrv VPN RPC service
-     * @param elanService ELAN service
-     * @param neutronFloatingToFixedIpMappingChangeListener FIP to FixedIP listener
-     * @param neutronvpnConfig Neutronvpn configuration service
-     */
     public NeutronvpnManager(
             final DataBroker dataBroker, final IMdsalApiManager mdsalManager,
             final NotificationPublishService notiPublishService, final NeutronvpnNatManager vpnNatMgr,
@@ -177,38 +158,32 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
         return neutronvpnConfig;
     }
 
+    // TODO Clean up the exception handling
+    @SuppressWarnings("checkstyle:IllegalCatch")
     protected void updateSubnetNodeWithFixedIps(Uuid subnetId, Uuid routerId,
                                                 Uuid routerInterfaceName, String fixedIp,
                                                 String routerIntfMacAddress) {
         Subnetmap subnetmap = null;
         SubnetmapBuilder builder = null;
-        InstanceIdentifier<Subnetmap> id = InstanceIdentifier.builder(Subnetmaps.class).
-                child(Subnetmap.class, new SubnetmapKey(subnetId)).build();
+        InstanceIdentifier<Subnetmap> id =
+            InstanceIdentifier.builder(Subnetmaps.class).child(Subnetmap.class, new SubnetmapKey(subnetId)).build();
         try {
             synchronized (subnetId.getValue().intern()) {
                 Optional<Subnetmap> sn = NeutronvpnUtils.read(dataBroker, LogicalDatastoreType.CONFIGURATION, id);
                 if (sn.isPresent()) {
                     builder = new SubnetmapBuilder(sn.get());
-                    LOG.debug("WithRouterFixedIPs: Updating existing subnetmap node for subnet ID {}", subnetId.getValue());
+                    LOG.debug("WithRouterFixedIPs: Updating existing subnetmap node for subnet ID {}",
+                        subnetId.getValue());
                 } else {
                     builder = new SubnetmapBuilder().setKey(new SubnetmapKey(subnetId)).setId(subnetId);
-                    LOG.debug("WithRouterFixedIPs: creating new subnetmap node for subnet ID {}", subnetId.getValue());
-                }
-                if (routerId != null) {
-                    builder.setRouterId(routerId);
-                } else {
-                    builder.setRouterId(null);
-                }
-                if (routerInterfaceName != null) {
-                    builder.setRouterInterfaceName(routerInterfaceName);
-                } else {
-                    builder.setRouterInterfaceName(null);
-                }
-                if (routerIntfMacAddress != null) {
-                    builder.setRouterIntfMacAddress(routerIntfMacAddress);
-                } else {
-                    builder.setRouterIntfMacAddress(null);
+                    LOG.debug("WithRouterFixedIPs: creating new subnetmap node for subnet ID {}",
+                        subnetId.getValue());
                 }
+
+                builder.setRouterId(routerId);
+                builder.setRouterInterfaceName(routerInterfaceName);
+                builder.setRouterIntfMacAddress(routerIntfMacAddress);
+
                 if (fixedIp != null) {
                     List<String> fixedIps = builder.getRouterInterfaceFixedIps();
                     if (fixedIps == null) {
@@ -220,14 +195,18 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                     builder.setRouterInterfaceFixedIps(null);
                 }
                 subnetmap = builder.build();
-                LOG.debug("WithRouterFixedIPs Creating/Updating subnetMap node for Router FixedIps: {} ", subnetId.getValue());
+                LOG.debug("WithRouterFixedIPs Creating/Updating subnetMap node for Router FixedIps: {} ",
+                    subnetId.getValue());
                 MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, id, subnetmap);
             }
         } catch (Exception e) {
-            LOG.error("WithRouterFixedIPs: Updation of subnetMap for Router FixedIps failed for node: {}", subnetId.getValue());
+            LOG.error("WithRouterFixedIPs: Updation of subnetMap for Router FixedIps failed for node: {}",
+                subnetId.getValue());
         }
     }
 
+    // TODO Clean up the exception handling
+    @SuppressWarnings("checkstyle:IllegalCatch")
     protected Subnetmap updateSubnetNode(Uuid subnetId, String subnetIp, Uuid tenantId, Uuid networkId, Uuid routerId,
                                          Uuid vpnId) {
         Subnetmap subnetmap = null;
@@ -272,6 +251,8 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
         return subnetmap;
     }
 
+    // TODO Clean up the exception handling
+    @SuppressWarnings("checkstyle:IllegalCatch")
     protected Subnetmap removeFromSubnetNode(Uuid subnetId, Uuid networkId, Uuid routerId, Uuid vpnId, Uuid portId) {
         Subnetmap subnetmap = null;
         InstanceIdentifier<Subnetmap> id = InstanceIdentifier.builder(Subnetmaps.class)
@@ -310,6 +291,8 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
         return subnetmap;
     }
 
+    // TODO Clean up the exception handling
+    @SuppressWarnings("checkstyle:IllegalCatch")
     protected Subnetmap updateSubnetmapNodeWithPorts(Uuid subnetId, Uuid portId, Uuid directPortId) {
         Subnetmap subnetmap = null;
         InstanceIdentifier<Subnetmap> id = InstanceIdentifier.builder(Subnetmaps.class).child(Subnetmap.class,
@@ -322,7 +305,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                     if (null != portId) {
                         List<Uuid> portList = builder.getPortList();
                         if (null == portList) {
-                            portList = new ArrayList<Uuid>();
+                            portList = new ArrayList<>();
                         }
                         portList.add(portId);
                         builder.setPortList(portList);
@@ -332,7 +315,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                     if (null != directPortId) {
                         List<Uuid> directPortList = builder.getDirectPortList();
                         if (null == directPortList) {
-                            directPortList = new ArrayList<Uuid>();
+                            directPortList = new ArrayList<>();
                         }
                         directPortList.add(directPortId);
                         builder.setDirectPortList(directPortList);
@@ -352,6 +335,8 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
         return subnetmap;
     }
 
+    // TODO Clean up the exception handling
+    @SuppressWarnings("checkstyle:IllegalCatch")
     protected Subnetmap removePortsFromSubnetmapNode(Uuid subnetId, Uuid portId, Uuid directPortId) {
         Subnetmap subnetmap = null;
         InstanceIdentifier<Subnetmap> id = InstanceIdentifier.builder(Subnetmaps.class).child(Subnetmap.class,
@@ -388,6 +373,8 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
         return subnetmap;
     }
 
+    // TODO Clean up the exception handling
+    @SuppressWarnings("checkstyle:IllegalCatch")
     protected void deleteSubnetMapNode(Uuid subnetId) {
         InstanceIdentifier<Subnetmap> subnetMapIdentifier =
                 InstanceIdentifier.builder(Subnetmaps.class).child(Subnetmap.class,new SubnetmapKey(subnetId)).build();
@@ -401,13 +388,15 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
         }
     }
 
+    // TODO Clean up the exception handling
+    @SuppressWarnings("checkstyle:IllegalCatch")
     private void updateVpnInstanceNode(String vpnName, List<String> rd, List<String> irt, List<String> ert) {
 
         VpnInstanceBuilder builder = null;
         List<VpnTarget> vpnTargetList = new ArrayList<>();
         boolean isLockAcquired = false;
-        InstanceIdentifier<VpnInstance> vpnIdentifier = InstanceIdentifier.builder(VpnInstances.class).child
-                (VpnInstance.class, new VpnInstanceKey(vpnName)).build();
+        InstanceIdentifier<VpnInstance> vpnIdentifier = InstanceIdentifier.builder(VpnInstances.class)
+            .child(VpnInstance.class, new VpnInstanceKey(vpnName)).build();
         try {
             Optional<VpnInstance> optionalVpn = NeutronvpnUtils.read(dataBroker, LogicalDatastoreType.CONFIGURATION,
                     vpnIdentifier);
@@ -470,6 +459,8 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
         }
     }
 
+    // TODO Clean up the exception handling
+    @SuppressWarnings("checkstyle:IllegalCatch")
     private void deleteVpnMapsNode(Uuid vpnid) {
         boolean isLockAcquired = false;
         InstanceIdentifier<VpnMap> vpnMapIdentifier = InstanceIdentifier.builder(VpnMaps.class)
@@ -488,6 +479,8 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
         }
     }
 
+    // TODO Clean up the exception handling
+    @SuppressWarnings("checkstyle:IllegalCatch")
     private void updateVpnMaps(Uuid vpnId, String name, Uuid router, Uuid tenantId, List<Uuid> networks) {
         VpnMapBuilder builder;
         boolean isLockAcquired = false;
@@ -534,6 +527,8 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
         }
     }
 
+    // TODO Clean up the exception handling
+    @SuppressWarnings("checkstyle:IllegalCatch")
     private void clearFromVpnMaps(Uuid vpnId, Uuid routerId, List<Uuid> networkIds) {
         boolean isLockAcquired = false;
         InstanceIdentifier<VpnMap> vpnMapIdentifier = InstanceIdentifier.builder(VpnMaps.class)
@@ -593,6 +588,8 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
         LOG.debug("Clear from VPNMaps DS successful for VPN {} ", vpnId.getValue());
     }
 
+    // TODO Clean up the exception handling
+    @SuppressWarnings("checkstyle:IllegalCatch")
     private void deleteVpnInstance(Uuid vpnId) {
         boolean isLockAcquired = false;
         InstanceIdentifier<VpnInstance> vpnIdentifier = InstanceIdentifier.builder(VpnInstances.class)
@@ -616,7 +613,6 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                                       WriteTransaction wrtConfigTxn) {
         String infName = port.getUuid().getValue();
         List<Adjacency> adjList = new ArrayList<>();
-        List<FixedIps> ips = port.getFixedIps();
         Boolean isRouterInterface = false;
         if (port.getDeviceOwner() != null) {
             isRouterInterface = port.getDeviceOwner().equals(NeutronConstants.DEVICE_OWNER_ROUTER_INF);
@@ -626,6 +622,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
         if (routerId != null) {
             rtr = NeutronvpnUtils.getNeutronRouter(dataBroker, routerId);
         }
+        List<FixedIps> ips = port.getFixedIps();
         // create adjacency list
         for (FixedIps ip : ips) {
             // create vm adjacency
@@ -644,7 +641,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                 }
             }
             NeutronvpnUtils.createVpnPortFixedIpToPort(dataBroker, vpnId.getValue(), ipValue, infName, port
-                            .getMacAddress().getValue(), isRouterInterface, true, false);
+                            .getMacAddress().getValue(), isRouterInterface, wrtConfigTxn);
         }
         // create vpn-interface on this neutron port
         Adjacencies adjs = new AdjacenciesBuilder().setAdjacency(adjList).build();
@@ -654,6 +651,8 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
         }
     }
 
+    // TODO Clean up the exception handling
+    @SuppressWarnings("checkstyle:IllegalCatch")
     protected void deleteVpnInterface(Uuid vpnId, Uuid routerId, Port port, WriteTransaction wrtConfigTxn) {
         Boolean wrtConfigTxnPresent = true;
         if (wrtConfigTxn == null) {
@@ -669,7 +668,8 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
             List<FixedIps> ips = port.getFixedIps();
             for (FixedIps ip : ips) {
                 String ipValue = String.valueOf(ip.getIpAddress().getValue());
-                NeutronvpnUtils.removeVpnPortFixedIpToPort(dataBroker, vpnId.getValue(), ipValue);
+                NeutronvpnUtils.removeVpnPortFixedIpToPort(dataBroker, vpnId.getValue(),
+                        ipValue, wrtConfigTxn);
             }
         } catch (Exception ex) {
             LOG.error("Deletion of vpninterface {} failed due to {}", infName, ex);
@@ -682,14 +682,19 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
         }
     }
 
-    protected void updateVpnInterface(Uuid vpnId, Uuid oldVpnId, Port port, boolean  isBeingAssociated, boolean isSubnetIp) {
+    // TODO Clean up the exception handling
+    @SuppressWarnings("checkstyle:IllegalCatch")
+    protected void updateVpnInterface(Uuid vpnId, Uuid oldVpnId, Port port, boolean isBeingAssociated,
+                                      boolean isSubnetIp) {
         if (vpnId == null || port == null) {
             return;
         }
         boolean isLockAcquired = false;
         String infName = port.getUuid().getValue();
         InstanceIdentifier<VpnInterface> vpnIfIdentifier = NeutronvpnUtils.buildVpnInterfaceIdentifier(infName);
+
         try {
+            WriteTransaction writeConfigTxn = dataBroker.newWriteOnlyTransaction();
             isLockAcquired = NeutronvpnUtils.lock(infName);
             Optional<VpnInterface> optionalVpnInterface = NeutronvpnUtils.read(dataBroker, LogicalDatastoreType
                     .CONFIGURATION, vpnIfIdentifier);
@@ -699,23 +704,22 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                 LOG.debug("Updating vpn interface {}", infName);
                 if (!isBeingAssociated) {
                     Adjacencies adjs = vpnIfBuilder.getAugmentation(Adjacencies.class);
-                    List<Adjacency> adjacencyList = (adjs != null) ? adjs.getAdjacency() : new ArrayList<Adjacency>();
+                    List<Adjacency> adjacencyList = (adjs != null) ? adjs.getAdjacency() : new ArrayList<>();
                     Iterator<Adjacency> adjacencyIter = adjacencyList.iterator();
                     while (adjacencyIter.hasNext()) {
                         Adjacency adjacency = adjacencyIter.next();
                         String mipToQuery = adjacency.getIpAddress().split("/")[0];
-                        InstanceIdentifier<VpnPortipToPort> id = NeutronvpnUtils.buildVpnPortipToPortIdentifier
-                                (oldVpnId.getValue(), mipToQuery);
-                        Optional<VpnPortipToPort> optionalVpnPort = NeutronvpnUtils.read(dataBroker,
-                                LogicalDatastoreType
-                                .OPERATIONAL, id);
-                        if (!optionalVpnPort.isPresent() || optionalVpnPort.get().isLearnt()) {
-                            LOG.trace("Removing adjacencies from vpninterface {} upon dissociation of router {} " +
-                                    "from VPN " + "{}", infName, vpnId, oldVpnId);
+                        InstanceIdentifier<LearntVpnVipToPort> id =
+                            NeutronvpnUtils.buildLearntVpnVipToPortIdentifier(oldVpnId.getValue(), mipToQuery);
+                        Optional<LearntVpnVipToPort> optionalVpnVipToPort =
+                            NeutronvpnUtils.read(dataBroker, LogicalDatastoreType.OPERATIONAL, id);
+                        if (optionalVpnVipToPort.isPresent()) {
+                            LOG.trace("Removing adjacencies from vpninterface {} upon dissociation of router {} "
+                                + "from VPN " + "{}", infName, vpnId, oldVpnId);
                             adjacencyIter.remove();
-                            NeutronvpnUtils.removeVpnPortFixedIpToPort(dataBroker, oldVpnId.getValue(), mipToQuery);
-                            LOG.trace("Entry for fixedIP {} for port {} on VPN removed from " +
-                                    "VpnPortFixedIPToPortData", mipToQuery, infName, vpnId.getValue());
+                            NeutronvpnUtils.removeLearntVpnVipToPort(dataBroker, oldVpnId.getValue(), mipToQuery);
+                            LOG.trace("Entry for fixedIP {} for port {} on VPN removed from "
+                                + "VpnPortFixedIPToPortData", mipToQuery, infName, vpnId.getValue());
                         }
                     }
                     Adjacencies adjacencies = new AdjacenciesBuilder().setAdjacency(adjacencyList).build();
@@ -725,13 +729,15 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                 for (FixedIps ip : ips) {
                     String ipValue = String.valueOf(ip.getIpAddress().getValue());
                     if (oldVpnId != null) {
-                        NeutronvpnUtils.removeVpnPortFixedIpToPort(dataBroker, oldVpnId.getValue(), ipValue);
+                        NeutronvpnUtils.removeVpnPortFixedIpToPort(dataBroker, oldVpnId.getValue(),
+                                ipValue, writeConfigTxn);
                     }
                     NeutronvpnUtils.createVpnPortFixedIpToPort(dataBroker, vpnId.getValue(), ipValue, infName, port
-                            .getMacAddress().getValue(), isSubnetIp, true, false);
+                            .getMacAddress().getValue(), isSubnetIp, writeConfigTxn);
                 }
-                MDSALUtil.syncUpdate(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnIfIdentifier, vpnIfBuilder
+                writeConfigTxn.merge(LogicalDatastoreType.CONFIGURATION, vpnIfIdentifier, vpnIfBuilder
                         .build());
+                writeConfigTxn.submit();
             } else {
                 LOG.error("VPN Interface {} not found", infName);
             }
@@ -763,8 +769,8 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                 // preserved upon reboot.
                 // For a non-reboot case #associateRouterToInternalVPN already takes care of adding to
                 // RouterInterfacesMap via #createVPNInterface call.
-                LOG.info("Associating router to Internal VPN skipped for VPN {} due to router {} already associated " +
-                        "to external VPN {}", vpn.getValue(), router.getValue(), existingVpn.getValue());
+                LOG.info("Associating router to Internal VPN skipped for VPN {} due to router {} already associated "
+                    + "to external VPN {}", vpn.getValue(), router.getValue(), existingVpn.getValue());
                 return;
             }
             associateRouterToInternalVpn(vpn, router);
@@ -773,7 +779,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
 
     /**
      * Performs the creation of a Neutron L3VPN, associating the new VPN to the
-     * specified Neutron Networks and Routers
+     * specified Neutron Networks and Routers.
      *
      * @param vpn Uuid of the VPN tp be created
      * @param name Representative name of the new VPN
@@ -810,12 +816,11 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
     }
 
     /**
-     * It handles the invocations to the createL3VPN RPC method
-     *
-     * @see org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.NeutronvpnService#createL3VPN
-     * (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.CreateL3VPNInput)
+     * It handles the invocations to the createL3VPN RPC method.
      */
     @Override
+    // TODO Clean up the exception handling
+    @SuppressWarnings("checkstyle:IllegalCatch")
     public Future<RpcResult<CreateL3VPNOutput>> createL3VPN(CreateL3VPNInput input) {
 
         CreateL3VPNOutputBuilder opBuilder = new CreateL3VPNOutputBuilder();
@@ -826,9 +831,17 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
 
         List<L3vpn> vpns = input.getL3vpn();
         for (L3vpn vpn : vpns) {
-            List<String> existingRDs = NeutronvpnUtils.getExistingRDs(dataBroker);
             RpcError error = null;
             String msg;
+            if (NeutronvpnUtils.doesVpnExist(dataBroker, vpn.getId())) {
+                msg = String.format("Creation of L3VPN failed for VPN %s due to VPN with the same ID already present",
+                                vpn.getId().getValue());
+                LOG.warn(msg);
+                error = RpcResultBuilder.newWarning(ErrorType.PROTOCOL, "invalid-input", msg);
+                errorList.add(error);
+                warningcount++;
+                continue;
+            }
             if (vpn.getRouteDistinguisher() == null || vpn.getImportRT() == null || vpn.getExportRT() == null) {
                 msg = String.format("Creation of L3VPN failed for VPN %s due to absence of RD/iRT/eRT input",
                         vpn.getId().getValue());
@@ -847,9 +860,11 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                 warningcount++;
                 continue;
             }
+            List<String> existingRDs = NeutronvpnUtils.getExistingRDs(dataBroker);
             if (existingRDs.contains(vpn.getRouteDistinguisher().get(0))) {
-                msg = String.format("Creation of L3VPN failed for VPN %s as another VPN with the same RD %s is already configured",
-                        vpn.getId().getValue(), vpn.getRouteDistinguisher().get(0));
+                msg = String.format("Creation of L3VPN failed for VPN %s as another VPN with the same RD %s "
+                    + "is already configured",
+                    vpn.getId().getValue(), vpn.getRouteDistinguisher().get(0));
                 LOG.warn(msg);
                 error = RpcResultBuilder.newWarning(ErrorType.PROTOCOL, "invalid-input", msg);
                 errorList.add(error);
@@ -917,7 +932,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
         // if at least one succeeds; result is success
         // if none succeeds; result is failure
         if (failurecount + warningcount == vpns.size()) {
-            result.set(RpcResultBuilder.<CreateL3VPNOutput> failed().withRpcErrors(errorList).build());
+            result.set(RpcResultBuilder.<CreateL3VPNOutput>failed().withRpcErrors(errorList).build());
         } else {
             List<String> errorResponseList = new ArrayList<>();
             if (!errorList.isEmpty()) {
@@ -930,18 +945,17 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                 errorResponseList.add("Operation successful with no errors");
             }
             opBuilder.setResponse(errorResponseList);
-            result.set(RpcResultBuilder.<CreateL3VPNOutput> success().withResult(opBuilder.build()).build());
+            result.set(RpcResultBuilder.<CreateL3VPNOutput>success().withResult(opBuilder.build()).build());
         }
         return result;
     }
 
     /**
-     * It handles the invocations to the neutronvpn:getL3VPN RPC method
-     *
-     * @see org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.NeutronvpnService#getL3VPN
-     * (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.GetL3VPNInput)
+     * It handles the invocations to the neutronvpn:getL3VPN RPC method.
      */
     @Override
+    // TODO Clean up the exception handling
+    @SuppressWarnings("checkstyle:IllegalCatch")
     public Future<RpcResult<GetL3VPNOutput>> getL3VPN(GetL3VPNInput input) {
 
         GetL3VPNOutputBuilder opBuilder = new GetL3VPNOutputBuilder();
@@ -954,32 +968,31 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                 // get all vpns
                 InstanceIdentifier<VpnInstances> vpnsIdentifier = InstanceIdentifier.builder(VpnInstances.class)
                         .build();
-                Optional<VpnInstances> optionalVpns = NeutronvpnUtils.read(dataBroker,
-                        LogicalDatastoreType.CONFIGURATION,
-                        vpnsIdentifier);
-                if (optionalVpns.isPresent() && optionalVpns.get().getVpnInstance() != null) {
+                Optional<VpnInstances> optionalVpns = NeutronvpnUtils.read(dataBroker, LogicalDatastoreType
+                        .CONFIGURATION, vpnsIdentifier);
+                if (optionalVpns.isPresent() && !optionalVpns.get().getVpnInstance().isEmpty()) {
                     for (VpnInstance vpn : optionalVpns.get().getVpnInstance()) {
-                        // eliminating internal VPNs from getL3VPN output
+                        // eliminating implicitly created (router and VLAN provider external network specific) VPNs
+                        // from getL3VPN output
                         if (vpn.getIpv4Family().getRouteDistinguisher() != null) {
                             vpns.add(vpn);
                         }
                     }
                 } else {
                     // No VPN present
-                    result.set(RpcResultBuilder.<GetL3VPNOutput>failed().withWarning(ErrorType.PROTOCOL, "", "No VPN " +
-                            "is present").build());
+                    result.set(RpcResultBuilder.<GetL3VPNOutput>success().withResult(opBuilder.build()).build());
                     return result;
                 }
             } else {
                 String name = inputVpnId.getValue();
                 InstanceIdentifier<VpnInstance> vpnIdentifier = InstanceIdentifier.builder(VpnInstances.class)
-                        .child(VpnInstance.class,
-                                new VpnInstanceKey(name))
-                        .build();
+                        .child(VpnInstance.class, new VpnInstanceKey(name)).build();
                 // read VpnInstance Info
                 Optional<VpnInstance> optionalVpn = NeutronvpnUtils.read(dataBroker, LogicalDatastoreType.CONFIGURATION,
                         vpnIdentifier);
-                if (optionalVpn.isPresent()) {
+                // eliminating implicitly created (router or VLAN provider external network specific) VPN from
+                // getL3VPN output
+                if (optionalVpn.isPresent() && optionalVpn.get().getIpv4Family().getRouteDistinguisher() != null) {
                     vpns.add(optionalVpn.get());
                 } else {
                     String message = String.format("GetL3VPN failed because VPN %s is not present", name);
@@ -1027,23 +1040,22 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
             }
 
             opBuilder.setL3vpnInstances(l3vpnList);
-            result.set(RpcResultBuilder.<GetL3VPNOutput> success().withResult(opBuilder.build()).build());
+            result.set(RpcResultBuilder.<GetL3VPNOutput>success().withResult(opBuilder.build()).build());
 
         } catch (Exception ex) {
             String message = String.format("GetL3VPN failed due to %s", ex.getMessage());
             LOG.error(message, ex);
-            result.set(RpcResultBuilder.<GetL3VPNOutput> failed().withError(ErrorType.APPLICATION, message).build());
+            result.set(RpcResultBuilder.<GetL3VPNOutput>failed().withError(ErrorType.APPLICATION, message).build());
         }
         return result;
     }
 
     /**
-     * It handles the invocations to the neutronvpn:deleteL3VPN RPC method
-     *
-     * @see org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.NeutronvpnService#deleteL3VPN
-     * (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DeleteL3VPNInput)
+     * It handles the invocations to the neutronvpn:deleteL3VPN RPC method.
      */
     @Override
+    // TODO Clean up the exception handling
+    @SuppressWarnings("checkstyle:IllegalCatch")
     public Future<RpcResult<DeleteL3VPNOutput>> deleteL3VPN(DeleteL3VPNInput input) {
 
         DeleteL3VPNOutputBuilder opBuilder = new DeleteL3VPNOutputBuilder();
@@ -1058,8 +1070,8 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
             String msg;
             try {
                 InstanceIdentifier<VpnInstance> vpnIdentifier =
-                        InstanceIdentifier.builder(VpnInstances.class).child(VpnInstance.class, new VpnInstanceKey
-                                (vpn.getValue())).build();
+                        InstanceIdentifier.builder(VpnInstances.class)
+                            .child(VpnInstance.class, new VpnInstanceKey(vpn.getValue())).build();
                 Optional<VpnInstance> optionalVpn = NeutronvpnUtils.read(dataBroker, LogicalDatastoreType
                         .CONFIGURATION, vpnIdentifier);
                 if (optionalVpn.isPresent()) {
@@ -1082,7 +1094,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
         // if at least one succeeds; result is success
         // if none succeeds; result is failure
         if (failurecount + warningcount == vpns.size()) {
-            result.set(RpcResultBuilder.<DeleteL3VPNOutput> failed().withRpcErrors(errorList).build());
+            result.set(RpcResultBuilder.<DeleteL3VPNOutput>failed().withRpcErrors(errorList).build());
         } else {
             List<String> errorResponseList = new ArrayList<>();
             if (!errorList.isEmpty()) {
@@ -1095,7 +1107,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                 errorResponseList.add("Operation successful with no errors");
             }
             opBuilder.setResponse(errorResponseList);
-            result.set(RpcResultBuilder.<DeleteL3VPNOutput> success().withResult(opBuilder.build()).build());
+            result.set(RpcResultBuilder.<DeleteL3VPNOutput>success().withResult(opBuilder.build()).build());
         }
         return result;
     }
@@ -1104,28 +1116,6 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
         LOG.debug("Adding subnet {} to vpn {}", subnet.getValue(), vpnId.getValue());
         Subnetmap sn = updateSubnetNode(subnet, null, null, null, null, vpnId);
         final Uuid routerId = NeutronvpnUtils.getVpnMap(dataBroker, vpnId).getRouterId();
-        // send subnet added to vpn notification
-        isExternalVpn = vpnId.equals(routerId) ? false : true;
-        String elanInstanceName = sn.getNetworkId().getValue();
-        InstanceIdentifier<ElanInstance> elanIdentifierId = InstanceIdentifier.builder(ElanInstances.class)
-                .child(ElanInstance.class, new ElanInstanceKey(elanInstanceName)).build();
-        try {
-            Optional<ElanInstance> elanInstance = NeutronvpnUtils.read(dataBroker, LogicalDatastoreType
-                    .CONFIGURATION, elanIdentifierId);
-            if (elanInstance.isPresent()) {
-                long elanTag = elanInstance.get().getElanTag();
-                checkAndPublishSubnetAddNotification(subnet, sn.getSubnetIp(), vpnId.getValue(), isExternalVpn,
-                        elanTag);
-                LOG.debug("Subnet added to VPN notification sent for subnet {} on VPN {}", subnet.getValue(),
-                        vpnId.getValue());
-            } else {
-                LOG.error("Subnet added to VPN notification failed for subnet {}  on VPN {} because of failure in " +
-                        "reading ELANInstance {}", subnet.getValue(), vpnId.getValue(), elanInstanceName);
-            }
-        } catch (Exception e) {
-            LOG.error("Subnet added to VPN notification failed for subnet {} on VPN {}", subnet.getValue(), vpnId
-                    .getValue(), e);
-        }
         // Check if there are ports on this subnet and add corresponding
         // vpn-interfaces
         List<Uuid> portList = sn.getPortList();
@@ -1133,17 +1123,13 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
             for (final Uuid portId : sn.getPortList()) {
                 LOG.debug("adding vpn-interface for port {}", portId.getValue());
                 final DataStoreJobCoordinator portDataStoreCoordinator = DataStoreJobCoordinator.getInstance();
-                portDataStoreCoordinator.enqueueJob("PORT-" + portId.getValue(), new
-                        Callable<List<ListenableFuture<Void>>>() {
-                    @Override
-                    public List<ListenableFuture<Void>> call() throws Exception {
-                        WriteTransaction wrtConfigTxn = dataBroker.newWriteOnlyTransaction();
-                        List<ListenableFuture<Void>> futures = new ArrayList<>();
-                        createVpnInterface(vpnId, routerId, NeutronvpnUtils.getNeutronPort(dataBroker, portId),
-                                wrtConfigTxn);
-                        futures.add(wrtConfigTxn.submit());
-                        return futures;
-                    }
+                portDataStoreCoordinator.enqueueJob("PORT-" + portId.getValue(), () -> {
+                    WriteTransaction wrtConfigTxn = dataBroker.newWriteOnlyTransaction();
+                    List<ListenableFuture<Void>> futures = new ArrayList<>();
+                    createVpnInterface(vpnId, routerId, NeutronvpnUtils.getNeutronPort(dataBroker, portId),
+                            wrtConfigTxn);
+                    futures.add(wrtConfigTxn.submit());
+                    return futures;
                 });
             }
         }
@@ -1153,8 +1139,8 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
         LOG.debug("Updating VPN {} for subnet {}", vpnId.getValue(), subnet.getValue());
         // Read the subnet first to see if its already associated to a VPN
         Uuid oldVpnId = null;
-        InstanceIdentifier<Subnetmap> snId = InstanceIdentifier.builder(Subnetmaps.class).
-                child(Subnetmap.class, new SubnetmapKey(subnet)).build();
+        InstanceIdentifier<Subnetmap> snId = InstanceIdentifier.builder(Subnetmaps.class)
+            .child(Subnetmap.class, new SubnetmapKey(subnet)).build();
         Subnetmap sn = null;
         Optional<Subnetmap> optSn = NeutronvpnUtils.read(dataBroker, LogicalDatastoreType.CONFIGURATION, snId);
         if (optSn.isPresent()) {
@@ -1163,39 +1149,23 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
             List<String> ips = sn.getRouterInterfaceFixedIps();
             for (String ipValue : ips) {
                 // Update the association of router-interface to external vpn
-                String PortName = NeutronvpnUtils.getNeutronPortNameFromVpnPortFixedIp(dataBroker, oldVpnId.getValue(), ipValue);
-                updateVpnInterface(vpnId, oldVpnId, NeutronvpnUtils.getNeutronPort(dataBroker, new Uuid(PortName)),
+                String portName =
+                    NeutronvpnUtils.getNeutronPortNameFromVpnPortFixedIp(dataBroker, oldVpnId.getValue(), ipValue);
+                if (portName != null) {
+                    updateVpnInterface(vpnId, oldVpnId,
+                        NeutronvpnUtils.getNeutronPort(dataBroker, new Uuid(portName)),
                         isBeingAssociated, true);
+                }
             }
         }
         sn = updateSubnetNode(subnet, null, null, null, null, vpnId);
-        // send vpn updated for subnet notification
-        String elanInstanceName = sn.getNetworkId().getValue();
-        InstanceIdentifier<ElanInstance> elanIdentifierId = InstanceIdentifier.builder(ElanInstances.class)
-                .child(ElanInstance.class, new ElanInstanceKey(elanInstanceName)).build();
-        try {
-            Optional<ElanInstance> elanInstance = NeutronvpnUtils.read(dataBroker, LogicalDatastoreType
-                    .CONFIGURATION, elanIdentifierId);
-            if (elanInstance.isPresent()) {
-                long elanTag = elanInstance.get().getElanTag();
-                checkAndPublishSubnetUpdNotification(subnet, sn.getSubnetIp(), vpnId.getValue(), isBeingAssociated,
-                        elanTag);
-                LOG.debug("VPN updated for subnet notification sent for subnet {} on VPN {}", subnet.getValue(),
-                        vpnId.getValue());
-            } else {
-                LOG.error("VPN updated for subnet notification failed for subnet {} on VPN {} because of failure " +
-                        "in reading ELANInstance {}", subnet.getValue(), vpnId.getValue(), elanInstanceName);
-            }
-        } catch (Exception e) {
-            LOG.error("VPN updated for subnet notification failed for subnet {} on VPN {}", subnet.getValue(),
-                    vpnId.getValue(), e);
-        }
         // Check for ports on this subnet and update association of
         // corresponding vpn-interfaces to external vpn
         List<Uuid> portList = sn.getPortList();
         if (portList != null) {
             for (Uuid port : sn.getPortList()) {
-                LOG.debug("Updating vpn-interface for port {} isBeingAssociated {}", port.getValue(), isBeingAssociated);
+                LOG.debug("Updating vpn-interface for port {} isBeingAssociated {}",
+                    port.getValue(), isBeingAssociated);
                 updateVpnInterface(vpnId, oldVpnId, NeutronvpnUtils.getNeutronPort(dataBroker, port),
                         isBeingAssociated, false);
             }
@@ -1212,8 +1182,8 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
             InstanceIdentifier<RouterInterfaces> routerInterfacesId = getRouterInterfacesId(routerId);
             Optional<RouterInterfaces> optRouterInterfaces = NeutronvpnUtils.read(dataBroker, LogicalDatastoreType
                     .CONFIGURATION, routerInterfacesId);
-            Interfaces routerInterface = new InterfacesBuilder().setKey(new InterfacesKey(interfaceName)).setInterfaceId
-                    (interfaceName).build();
+            Interfaces routerInterface = new InterfacesBuilder().setKey(new InterfacesKey(interfaceName))
+                .setInterfaceId(interfaceName).build();
             if (optRouterInterfaces.isPresent()) {
                 MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, routerInterfacesId.child(Interfaces
                         .class, new InterfacesKey(interfaceName)), routerInterface);
@@ -1232,8 +1202,8 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
             InstanceIdentifier<RouterInterfaces> routerInterfacesId = getRouterInterfacesId(routerId);
             Optional<RouterInterfaces> optRouterInterfaces = NeutronvpnUtils.read(dataBroker, LogicalDatastoreType
                     .CONFIGURATION, routerInterfacesId);
-            Interfaces routerInterface = new InterfacesBuilder().setKey(new InterfacesKey(interfaceName)).setInterfaceId
-                    (interfaceName).build();
+            Interfaces routerInterface = new InterfacesBuilder().setKey(new InterfacesKey(interfaceName))
+                .setInterfaceId(interfaceName).build();
             if (optRouterInterfaces.isPresent()) {
                 RouterInterfaces routerInterfaces = optRouterInterfaces.get();
                 List<Interfaces> interfaces = routerInterfaces.getInterfaces();
@@ -1349,11 +1319,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                 }
                 LOG.trace("Adding extra route for destination {} onto vpn {} with nexthop {} ", destination,
                         vpnId.getValue(), nextHop);
-                List<String> hops = adjMap.get(destination);
-                if (hops == null) {
-                    hops = new ArrayList<>();
-                    adjMap.put(destination, hops);
-                }
+                List<String> hops = adjMap.computeIfAbsent(destination, k -> new ArrayList<>());
                 if (!hops.contains(nextHop)) {
                     hops.add(nextHop);
                 }
@@ -1361,13 +1327,15 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
         }
 
         for (String destination : adjMap.keySet()) {
-            Adjacency erAdj = new AdjacencyBuilder().setIpAddress(destination).setNextHopIpList(adjMap.get
-                    (destination)).setKey(new AdjacencyKey(destination)).build();
+            Adjacency erAdj = new AdjacencyBuilder().setIpAddress(destination)
+                .setNextHopIpList(adjMap.get(destination)).setKey(new AdjacencyKey(destination)).build();
             adjList.add(erAdj);
         }
         return  adjList;
     }
 
+    // TODO Clean up the exception handling
+    @SuppressWarnings("checkstyle:IllegalCatch")
     protected void updateVpnInterfaceWithExtraRouteAdjacency(Uuid vpnId, List<Routes> routeList) {
         for (Routes route : routeList) {
             if (route == null || route.getNexthop() == null || route.getDestination() == null) {
@@ -1378,33 +1346,37 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                 String infName = NeutronvpnUtils.getNeutronPortNameFromVpnPortFixedIp(dataBroker, vpnId.getValue(),
                         nextHop);
                 if (infName != null) {
-                    LOG.trace("Updating extra route for destination {} onto vpn {} with nexthop {} and infName {}", destination,
-                            vpnId.getValue(), nextHop, infName);
+                    LOG.trace("Updating extra route for destination {} onto vpn {} with nexthop {} and infName {}",
+                        destination, vpnId.getValue(), nextHop, infName);
                     boolean isLockAcquired = false;
                     try {
                         InstanceIdentifier<VpnInterface> identifier = InstanceIdentifier.builder(VpnInterfaces.class)
                                 .child(VpnInterface.class, new VpnInterfaceKey(infName)).build();
-                        InstanceIdentifier<Adjacency> path = identifier.augmentation(Adjacencies.class).
-                                child(Adjacency.class, new AdjacencyKey(destination));
-                        Adjacency erAdj = new AdjacencyBuilder().setIpAddress(destination).setNextHopIpList(Arrays.asList(nextHop)).
-                                setKey(new AdjacencyKey(destination)).build();
+                        InstanceIdentifier<Adjacency> path = identifier.augmentation(Adjacencies.class)
+                            .child(Adjacency.class, new AdjacencyKey(destination));
+                        Adjacency erAdj = new AdjacencyBuilder().setIpAddress(destination)
+                            .setNextHopIpList(Collections.singletonList(nextHop)).setKey(new AdjacencyKey(destination))
+                            .build();
                         isLockAcquired = NeutronvpnUtils.lock(infName);
                         MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, path, erAdj);
                     } catch (Exception e) {
-                        LOG.error("exception in adding extra route with destination: {}, next hop: {}", destination, nextHop, e);
+                        LOG.error("exception in adding extra route with destination: {}, next hop: {}",
+                            destination, nextHop, e);
                     } finally {
                         if (isLockAcquired) {
                             NeutronvpnUtils.unlock(infName);
                         }
                     }
                 } else {
-                    LOG.debug("Unable to find VPN NextHop interface to apply extra-route destination {} on VPN {} " +
-                            "with nexthop {}", destination, vpnId.getValue(), nextHop);
+                    LOG.debug("Unable to find VPN NextHop interface to apply extra-route destination {} on VPN {} "
+                        + "with nexthop {}", destination, vpnId.getValue(), nextHop);
                 }
             }
         }
     }
 
+    // TODO Clean up the exception handling
+    @SuppressWarnings("checkstyle:IllegalCatch")
     protected void removeAdjacencyforExtraRoute(Uuid vpnId, List<Routes> routeList) {
         for (Routes route : routeList) {
             if (route != null && route.getNexthop() != null && route.getDestination() != null) {
@@ -1414,9 +1386,8 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                 String infName = NeutronvpnUtils.getNeutronPortNameFromVpnPortFixedIp(dataBroker, vpnId.getValue(),
                         nextHop);
                 if (infName == null) {
-                    LOG.error("Unable to find VPN NextHop interface to remove extra-route destination {} on VPN {} " +
-                                    "with nexthop {}",
-                            destination, vpnId.getValue(), nextHop);
+                    LOG.error("Unable to find VPN NextHop interface to remove extra-route destination {} on VPN {} "
+                            + "with nexthop {}", destination, vpnId.getValue(), nextHop);
                     // Proceed to remove the next extra-route
                     continue;
                 }
@@ -1458,7 +1429,8 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                                 .setNextHopIpList(nextHopList)
                                 .setKey(new AdjacencyKey(destination))
                                 .build();
-                        Adjacencies erAdjs = new AdjacenciesBuilder().setAdjacency(Arrays.asList(newAdj)).build();
+                        Adjacencies erAdjs =
+                                new AdjacenciesBuilder().setAdjacency(Collections.singletonList(newAdj)).build();
                         VpnInterface vpnIf = new VpnInterfaceBuilder().setKey(new VpnInterfaceKey(infName))
                                 .addAugmentation(Adjacencies.class, erAdjs).build();
                         MDSALUtil.syncUpdate(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnIfIdentifier, vpnIf);
@@ -1483,7 +1455,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
     protected void removeL3Vpn(Uuid id) {
         // read VPNMaps
         VpnMap vpnMap = NeutronvpnUtils.getVpnMap(dataBroker, id);
-        Uuid router = vpnMap.getRouterId();
+        Uuid router = (vpnMap != null) ? vpnMap.getRouterId() : null;
         // dissociate router
         if (router != null) {
             dissociateRouterFromVpn(id, router);
@@ -1503,28 +1475,6 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
         LOG.debug("Removing subnet {} from vpn {}", subnet.getValue(), vpnId.getValue());
         final Uuid routerId = NeutronvpnUtils.getVpnMap(dataBroker, vpnId).getRouterId();
         Subnetmap sn = NeutronvpnUtils.getSubnetmap(dataBroker, subnet);
-        // send subnet removed from vpn notification
-        isExternalVpn = vpnId.equals(routerId) ? false : true;
-        String elanInstanceName = sn.getNetworkId().getValue();
-        InstanceIdentifier<ElanInstance> elanIdentifierId = InstanceIdentifier.builder(ElanInstances.class)
-                .child(ElanInstance.class, new ElanInstanceKey(elanInstanceName)).build();
-        try {
-            Optional<ElanInstance> elanInstance = NeutronvpnUtils.read(dataBroker, LogicalDatastoreType
-                    .CONFIGURATION, elanIdentifierId);
-            if (elanInstance.isPresent()) {
-                long elanTag = elanInstance.get().getElanTag();
-                checkAndPublishSubnetDelNotification(subnet, sn.getSubnetIp(), vpnId.getValue(), isExternalVpn,
-                        elanTag);
-                LOG.debug("Subnet removed from VPN notification sent for subnet {} on VPN {}", subnet.getValue(),
-                        vpnId.getValue());
-            } else {
-                LOG.error("Subnet removed from VPN notification failed for subnet {} on VPN {} because of failure " +
-                        "in reading ELANInstance {}", subnet.getValue(), vpnId.getValue(), elanInstanceName);
-            }
-        } catch (Exception e) {
-            LOG.error("Subnet removed from VPN notification failed for subnet {} on VPN {}", subnet.getValue(),
-                    vpnId.getValue(), e);
-        }
         if (sn != null) {
             // Check if there are ports on this subnet; remove corresponding vpn-interfaces
             List<Uuid> portList = sn.getPortList();
@@ -1535,8 +1485,13 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                     portDataStoreCoordinator.enqueueJob("PORT-" + portId.getValue(), () -> {
                         WriteTransaction wrtConfigTxn = dataBroker.newWriteOnlyTransaction();
                         List<ListenableFuture<Void>> futures = new ArrayList<>();
-                        deleteVpnInterface(vpnId, routerId, NeutronvpnUtils.getNeutronPort(dataBroker, portId),
-                                wrtConfigTxn);
+                        Port port = NeutronvpnUtils.getNeutronPort(dataBroker, portId);
+                        if (port != null) {
+                            deleteVpnInterface(vpnId, routerId, port, wrtConfigTxn);
+                        } else {
+                            LOG.error("Cannot proceed with deleteVpnInterface for port {} in subnet {} since port is "
+                                + "absent in Neutron config DS", portId.getValue(), subnet.getValue());
+                        }
                         futures.add(wrtConfigTxn.submit());
                         return futures;
                     });
@@ -1549,6 +1504,8 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
         }
     }
 
+    // TODO Clean up the exception handling
+    @SuppressWarnings("checkstyle:IllegalCatch")
     protected void associateRouterToVpn(Uuid vpnId, Uuid routerId) {
         updateVpnMaps(vpnId, null, routerId, null, null);
         LOG.debug("Updating association of subnets to external vpn {}", vpnId.getValue());
@@ -1576,6 +1533,8 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
         }
     }
 
+    // TODO Clean up the exception handling
+    @SuppressWarnings("checkstyle:IllegalCatch")
     protected void dissociateRouterFromVpn(Uuid vpnId, Uuid routerId) {
 
         List<Uuid> routerSubnets = NeutronvpnUtils.getNeutronRouterSubnetIds(dataBroker, routerId);
@@ -1620,8 +1579,8 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                                 addSubnetToVpn(vpn, subnet);
                                 passedNwList.add(nw);
                             } else {
-                                failedNwList.add(String.format("subnet %s already added as router interface bound to " +
-                                        "internal/external VPN %s", subnet.getValue (), subnetVpnId.getValue()));
+                                failedNwList.add(String.format("subnet %s already added as router interface bound to "
+                                    + "internal/external VPN %s", subnet.getValue(), subnetVpnId.getValue()));
                             }
                         }
                     }
@@ -1660,8 +1619,8 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                             failedNwList.add(String.format("input network %s not associated to any vpn yet", nw
                                     .getValue()));
                         } else {
-                            failedNwList.add(String.format("input network %s associated to a another vpn %s instead " +
-                                    "of the one given as input", nw.getValue(), vpnId.getValue()));
+                            failedNwList.add(String.format("input network %s associated to a another vpn %s instead "
+                                + "of the one given as input", nw.getValue(), vpnId.getValue()));
                         }
                     }
                     if (NeutronvpnUtils.getIsExternal(network)) {
@@ -1675,12 +1634,11 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
     }
 
     /**
-     * It handles the invocations to the neutronvpn:associateNetworks RPC method
-     *
-     * @see org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.NeutronvpnService#associateNetworks
-     * (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.AssociateNetworksInput)
+     * It handles the invocations to the neutronvpn:associateNetworks RPC method.
      */
     @Override
+    // TODO Clean up the exception handling
+    @SuppressWarnings("checkstyle:IllegalCatch")
     public Future<RpcResult<AssociateNetworksOutput>> associateNetworks(AssociateNetworksInput input) {
 
         AssociateNetworksOutputBuilder opBuilder = new AssociateNetworksOutputBuilder();
@@ -1708,15 +1666,15 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                 String errorResponse = String.format("ErrorType: PROTOCOL, ErrorTag: invalid-value, ErrorMessage: %s",
                         message);
                 opBuilder.setResponse(errorResponse);
-                result.set(RpcResultBuilder.<AssociateNetworksOutput> success().withResult(opBuilder.build()).build());
+                result.set(RpcResultBuilder.<AssociateNetworksOutput>success().withResult(opBuilder.build()).build());
             } else {
-                result.set(RpcResultBuilder.<AssociateNetworksOutput> success().build());
+                result.set(RpcResultBuilder.<AssociateNetworksOutput>success().build());
             }
         } catch (Exception ex) {
             String message = String.format("associate Networks to vpn %s failed due to %s",
                     input.getVpnId().getValue(), ex.getMessage());
             LOG.error(message, ex);
-            result.set(RpcResultBuilder.<AssociateNetworksOutput> failed().withError(ErrorType.APPLICATION, message)
+            result.set(RpcResultBuilder.<AssociateNetworksOutput>failed().withError(ErrorType.APPLICATION, message)
                     .build());
         }
         LOG.debug("associateNetworks returns..");
@@ -1724,12 +1682,11 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
     }
 
     /**
-     * It handles the invocations to the neutronvpn:associateRouter RPC method
-     *
-     * @see org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.NeutronvpnService#associateRouter
-     * (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.AssociateRouterInput)
+     * It handles the invocations to the neutronvpn:associateRouter RPC method.
      */
     @Override
+    // TODO Clean up the exception handling
+    @SuppressWarnings("checkstyle:IllegalCatch")
     public Future<RpcResult<Void>> associateRouter(AssociateRouterInput input) {
 
         SettableFuture<RpcResult<Void>> result = SettableFuture.create();
@@ -1747,8 +1704,8 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                         returnMsg.append("vpn ").append(vpnId.getValue()).append(" already associated to router ")
                                 .append(vpnMap.getRouterId().getValue());
                     } else if (extVpnId != null) {
-                        returnMsg.append("router ").append(routerId.getValue()).append(" already associated to " +
-                                "another VPN ").append(extVpnId.getValue());
+                        returnMsg.append("router ").append(routerId.getValue()).append(" already associated to "
+                            + "another VPN ").append(extVpnId.getValue());
                     } else {
                         associateRouterToVpn(vpnId, routerId);
                     }
@@ -1762,28 +1719,28 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                 String message = String.format("associate router to vpn %s failed due to %s", routerId.getValue(),
                         returnMsg);
                 LOG.error(message);
-                result.set(RpcResultBuilder.<Void> failed().withWarning(ErrorType.PROTOCOL, "invalid-value", message)
+                result.set(RpcResultBuilder.<Void>failed().withWarning(ErrorType.PROTOCOL, "invalid-value", message)
                         .build());
             } else {
-                result.set(RpcResultBuilder.<Void> success().build());
+                result.set(RpcResultBuilder.<Void>success().build());
             }
         } catch (Exception ex) {
             String message = String.format("associate router %s to vpn %s failed due to %s", routerId.getValue(),
                     vpnId.getValue(), ex.getMessage());
             LOG.error(message, ex);
-            result.set(RpcResultBuilder.<Void> failed().withError(ErrorType.APPLICATION, message).build());
+            result.set(RpcResultBuilder.<Void>failed().withError(ErrorType.APPLICATION, message).build());
         }
         LOG.debug("associateRouter returns..");
         return result;
     }
 
-    /** It handles the invocations to the neutronvpn:getFixedIPsForNeutronPort RPC method
-     *
-     * @see org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.NeutronvpnService#getFixedIPsForNeutronPort
-     * (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.GetFixedIPsForNeutronPortInput)
+    /** It handles the invocations to the neutronvpn:getFixedIPsForNeutronPort RPC method.
      */
     @Override
-    public Future<RpcResult<GetFixedIPsForNeutronPortOutput>> getFixedIPsForNeutronPort(GetFixedIPsForNeutronPortInput input) {
+    // TODO Clean up the exception handling
+    @SuppressWarnings("checkstyle:IllegalCatch")
+    public Future<RpcResult<GetFixedIPsForNeutronPortOutput>> getFixedIPsForNeutronPort(
+        GetFixedIPsForNeutronPortInput input) {
         GetFixedIPsForNeutronPortOutputBuilder opBuilder = new GetFixedIPsForNeutronPortOutputBuilder();
         SettableFuture<RpcResult<GetFixedIPsForNeutronPortOutput>> result = SettableFuture.create();
         Uuid portId = input.getPortId();
@@ -1802,32 +1759,30 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
             if (returnMsg.length() != 0) {
                 String message = String.format("Retrieval of FixedIPList for neutron port failed due to %s", returnMsg);
                 LOG.error(message);
-                result.set(RpcResultBuilder.<GetFixedIPsForNeutronPortOutput> failed()
+                result.set(RpcResultBuilder.<GetFixedIPsForNeutronPortOutput>failed()
                         .withWarning(ErrorType.PROTOCOL, "invalid-value", message).build());
             } else {
                 opBuilder.setFixedIPs(fixedIPList);
-                result.set(RpcResultBuilder.<GetFixedIPsForNeutronPortOutput> success().withResult(opBuilder.build())
+                result.set(RpcResultBuilder.<GetFixedIPsForNeutronPortOutput>success().withResult(opBuilder.build())
                         .build());
-                result.set(RpcResultBuilder.<GetFixedIPsForNeutronPortOutput> success().build());
+                result.set(RpcResultBuilder.<GetFixedIPsForNeutronPortOutput>success().build());
             }
         } catch (Exception ex) {
             String message = String.format("Retrieval of FixedIPList for neutron port %s failed due to %s",
                     portId.getValue(), ex.getMessage());
             LOG.error(message, ex);
-            result.set(RpcResultBuilder.<GetFixedIPsForNeutronPortOutput> failed()
+            result.set(RpcResultBuilder.<GetFixedIPsForNeutronPortOutput>failed()
                     .withError(ErrorType.APPLICATION, message).build());
         }
         return result;
     }
 
     /**
-     * It handles the invocations to the neutronvpn:dissociateNetworks RPC method
-     *
-     * @see org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn
-     * .rev150602.NeutronvpnService#dissociateNetworks(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt
-     * .neutronvpn.rev150602.DissociateNetworksInput)
+     * It handles the invocations to the neutronvpn:dissociateNetworks RPC method.
      */
     @Override
+    // TODO Clean up the exception handling
+    @SuppressWarnings("checkstyle:IllegalCatch")
     public Future<RpcResult<DissociateNetworksOutput>> dissociateNetworks(DissociateNetworksInput input) {
 
         DissociateNetworksOutputBuilder opBuilder = new DissociateNetworksOutputBuilder();
@@ -1856,15 +1811,15 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                 String errorResponse = String.format("ErrorType: PROTOCOL, ErrorTag: invalid-value, ErrorMessage: "
                         + message);
                 opBuilder.setResponse(errorResponse);
-                result.set(RpcResultBuilder.<DissociateNetworksOutput> success().withResult(opBuilder.build()).build());
+                result.set(RpcResultBuilder.<DissociateNetworksOutput>success().withResult(opBuilder.build()).build());
             } else {
-                result.set(RpcResultBuilder.<DissociateNetworksOutput> success().build());
+                result.set(RpcResultBuilder.<DissociateNetworksOutput>success().build());
             }
         } catch (Exception ex) {
             String message = String.format("dissociate Networks to vpn %s failed due to %s",
                     input.getVpnId().getValue(), ex.getMessage());
             LOG.error(message, ex);
-            result.set(RpcResultBuilder.<DissociateNetworksOutput> failed().withError(ErrorType.APPLICATION, message)
+            result.set(RpcResultBuilder.<DissociateNetworksOutput>failed().withError(ErrorType.APPLICATION, message)
                     .build());
         }
         LOG.debug("dissociateNetworks returns..");
@@ -1873,12 +1828,10 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
 
     /**
      * It handles the invocations to the neutronvpn:dissociateRouter RPC method.
-     *
-     * @see org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn
-     * .rev150602.NeutronvpnService#dissociateRouter(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn
-     * .rev150602.DissociateRouterInput)
      */
     @Override
+    // TODO Clean up the exception handling
+    @SuppressWarnings("checkstyle:IllegalCatch")
     public Future<RpcResult<Void>> dissociateRouter(DissociateRouterInput input) {
 
         SettableFuture<RpcResult<Void>> result = SettableFuture.create();
@@ -1897,12 +1850,12 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                             dissociateRouterFromVpn(vpnId, routerId);
                         } else {
                             if (routerVpnId == null) {
-                                returnMsg.append("input router ").append(routerId.getValue()).append(" not associated" +
-                                        " to any vpn yet");
+                                returnMsg.append("input router ").append(routerId.getValue())
+                                    .append(" not associated to any vpn yet");
                             } else {
-                                returnMsg.append("input router ").append(routerId.getValue()).append(" associated to " +
-                                        "vpn ").append(routerVpnId.getValue()).append("instead of the vpn given as " +
-                                        "input");
+                                returnMsg.append("input router ").append(routerId.getValue())
+                                    .append(" associated to vpn ")
+                                    .append(routerVpnId.getValue()).append("instead of the vpn given as input");
                             }
                         }
                     } else {
@@ -1918,16 +1871,16 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                 LOG.error(message);
                 String errorResponse = String.format("ErrorType: PROTOCOL, ErrorTag: invalid-value, ErrorMessage: "
                         + message);
-                result.set(RpcResultBuilder.<Void> failed().withWarning(ErrorType.PROTOCOL, "invalid-value", message)
+                result.set(RpcResultBuilder.<Void>failed().withWarning(ErrorType.PROTOCOL, "invalid-value", message)
                         .build());
             } else {
-                result.set(RpcResultBuilder.<Void> success().build());
+                result.set(RpcResultBuilder.<Void>success().build());
             }
         } catch (Exception ex) {
             String message = String.format("disssociate router %s to vpn %s failed due to %s", routerId.getValue(),
                     vpnId.getValue(), ex.getMessage());
             LOG.error(message, ex);
-            result.set(RpcResultBuilder.<Void> failed().withError(ErrorType.APPLICATION, message).build());
+            result.set(RpcResultBuilder.<Void>failed().withError(ErrorType.APPLICATION, message).build());
         }
         LOG.debug("dissociateRouter returns..");
 
@@ -1956,7 +1909,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
         deleteVpnInstance(routerId);
     }
 
-    protected Subnet getNeutronSubnet(Uuid subnetId){
+    protected Subnet getNeutronSubnet(Uuid subnetId) {
         return NeutronvpnUtils.getNeutronSubnet(dataBroker, subnetId);
     }
 
@@ -1999,18 +1952,21 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
     }
 
     /**
-     * Implementation of the "vpnservice:neutron-ports-show" Karaf CLI command
+     * Implementation of the "vpnservice:neutron-ports-show" Karaf CLI command.
      *
      * @return a List of String to be printed on screen
      */
+    // TODO Clean up the exception handling and the console output
+    @SuppressWarnings({"checkstyle:IllegalCatch", "checkstyle:RegexpSinglelineJava"})
     public List<String> showNeutronPortsCLI() {
         List<String> result = new ArrayList<>();
-        result.add(String.format(" %-36s  %-19s  %-13s  %-20s ", "Port ID", "Mac Address", "Prefix Length", "IP " +
-                "Address"));
+        result.add(String.format(" %-36s  %-19s  %-13s  %-20s ", "Port ID", "Mac Address", "Prefix Length",
+            "IP Address"));
         result.add("-------------------------------------------------------------------------------------------");
         InstanceIdentifier<Ports> portidentifier = InstanceIdentifier.create(Neutron.class).child(Ports.class);
         try {
-            Optional<Ports> ports = NeutronvpnUtils.read(dataBroker, LogicalDatastoreType.CONFIGURATION, portidentifier);
+            Optional<Ports> ports =
+                NeutronvpnUtils.read(dataBroker, LogicalDatastoreType.CONFIGURATION, portidentifier);
             if (ports.isPresent() && ports.get().getPort() != null) {
                 for (Port port : ports.get().getPort()) {
                     List<FixedIps> fixedIPs = port.getFixedIps();
@@ -2048,11 +2004,12 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
     }
 
     /**
-     * Implementation of the "vpnservice:l3vpn-config-show" karaf CLI command
+     * Implementation of the "vpnservice:l3vpn-config-show" karaf CLI command.
      *
      * @param vpnuuid Uuid of the VPN whose config must be shown
      * @return formatted output list
      */
+    @SuppressWarnings("checkstyle:RegexpSinglelineJava")
     public List<String> showVpnConfigCLI(Uuid vpnuuid) {
         List<String> result = new ArrayList<>();
         if (vpnuuid == null) {
@@ -2075,19 +2032,19 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                 result.add("");
                 result.add("------------------------------------------------------------------------------------");
                 result.add("");
-                List<L3vpnInstances> VpnList = rpcResult.getResult().getL3vpnInstances();
-                for (L3vpnInstance Vpn : VpnList) {
-                    String tenantId = Vpn.getTenantId() != null ? Vpn.getTenantId().getValue()
+                List<L3vpnInstances> vpnList = rpcResult.getResult().getL3vpnInstances();
+                for (L3vpnInstance vpn : vpnList) {
+                    String tenantId = vpn.getTenantId() != null ? vpn.getTenantId().getValue()
                             : "\"                 " + "                  \"";
-                    result.add(String.format(" %-37s %-37s %-7s ", Vpn.getId().getValue(), tenantId,
-                            Vpn.getRouteDistinguisher()));
+                    result.add(String.format(" %-37s %-37s %-7s ", vpn.getId().getValue(), tenantId,
+                            vpn.getRouteDistinguisher()));
                     result.add("");
-                    result.add(String.format(" %-80s ", Vpn.getImportRT()));
+                    result.add(String.format(" %-80s ", vpn.getImportRT()));
                     result.add("");
-                    result.add(String.format(" %-80s ", Vpn.getExportRT()));
+                    result.add(String.format(" %-80s ", vpn.getExportRT()));
                     result.add("");
 
-                    Uuid vpnid = Vpn.getId();
+                    Uuid vpnid = vpn.getId();
                     List<Uuid> subnetList = getSubnetsforVpn(vpnid);
                     if (!subnetList.isEmpty()) {
                         for (Uuid subnetuuid : subnetList) {
@@ -2132,40 +2089,43 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
             return;
         }
 
+        WriteTransaction wrtConfigTxn = dataBroker.newWriteOnlyTransaction();
         for (String elanInterface : extElanInterfaces) {
-            createExternalVpnInterface(extNetId, elanInterface);
+            createExternalVpnInterface(extNetId, elanInterface, wrtConfigTxn);
         }
+        wrtConfigTxn.submit();
     }
 
+    // TODO Clean up the exception handling
+    @SuppressWarnings("checkstyle:IllegalCatch")
     protected void removeExternalVpnInterfaces(Uuid extNetId) {
         Collection<String> extElanInterfaces = elanService.getExternalElanInterfaces(extNetId.getValue());
         if (extElanInterfaces == null || extElanInterfaces.isEmpty()) {
             LOG.trace("No external ports attached for external network {}", extNetId);
             return;
         }
+        try {
 
-        for (String elanInterface : extElanInterfaces) {
-            boolean isLockAcquired = false;
-            InstanceIdentifier<VpnInterface> vpnIfIdentifier = NeutronvpnUtils
-                    .buildVpnInterfaceIdentifier(elanInterface);
-            try {
-                isLockAcquired = NeutronvpnUtils.lock(elanInterface);
-                LOG.debug("removing vpn interface {}, vpnIfIdentifier", elanInterface, vpnIfIdentifier);
-                MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnIfIdentifier);
-            } catch (Exception ex) {
-                LOG.error("Removal of vpninterface {} failed due to {}", elanInterface, ex);
-            } finally {
-                if (isLockAcquired) {
-                    NeutronvpnUtils.unlock(elanInterface);
-                }
+            WriteTransaction wrtConfigTxn = dataBroker.newWriteOnlyTransaction();
+            for (String elanInterface : extElanInterfaces) {
+                InstanceIdentifier<VpnInterface> vpnIfIdentifier = NeutronvpnUtils
+                        .buildVpnInterfaceIdentifier(elanInterface);
+                LOG.info("Removing vpn interface {}", elanInterface);
+                wrtConfigTxn.delete(LogicalDatastoreType.CONFIGURATION, vpnIfIdentifier);
             }
+            wrtConfigTxn.submit();
+
+        } catch (Exception ex) {
+            LOG.error("Removal of vpninterfaces {} failed due to {}", extElanInterfaces, ex);
         }
     }
 
-    private void createExternalVpnInterface(Uuid vpnId, String infName) {
-        writeVpnInterfaceToDs(vpnId, infName, null, false /* not a router iface */, null);
+    private void createExternalVpnInterface(Uuid vpnId, String infName, WriteTransaction wrtConfigTxn) {
+        writeVpnInterfaceToDs(vpnId, infName, null, false /* not a router iface */, wrtConfigTxn);
     }
 
+    // TODO Clean up the exception handling
+    @SuppressWarnings("checkstyle:IllegalCatch")
     private void writeVpnInterfaceToDs(Uuid vpnId, String infName, Adjacencies adjacencies,
             Boolean isRouterInterface, WriteTransaction wrtConfigTxn) {
         if (vpnId == null || infName == null) {
@@ -2206,51 +2166,6 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
         return help.toString();
     }
 
-    private void checkAndPublishSubnetAddNotification(Uuid subnetId, String subnetIp, String vpnName,
-                                                      Boolean isExternalvpn, Long elanTag) throws InterruptedException {
-        SubnetAddedToVpnBuilder builder = new SubnetAddedToVpnBuilder();
-
-        LOG.info("publish notification called");
-
-        builder.setSubnetId(subnetId);
-        builder.setSubnetIp(subnetIp);
-        builder.setVpnName(vpnName);
-        builder.setExternalVpn(isExternalvpn);
-        builder.setElanTag(elanTag);
-
-        notificationPublishService.putNotification(builder.build());
-    }
-
-    private void checkAndPublishSubnetDelNotification(Uuid subnetId, String subnetIp, String vpnName,
-                                                      Boolean isExternalvpn, Long elanTag) throws InterruptedException {
-        SubnetDeletedFromVpnBuilder builder = new SubnetDeletedFromVpnBuilder();
-
-        LOG.info("publish notification called");
-
-        builder.setSubnetId(subnetId);
-        builder.setSubnetIp(subnetIp);
-        builder.setVpnName(vpnName);
-        builder.setExternalVpn(isExternalvpn);
-        builder.setElanTag(elanTag);
-
-        notificationPublishService.putNotification(builder.build());
-    }
-
-    private void checkAndPublishSubnetUpdNotification(Uuid subnetId, String subnetIp, String vpnName,
-                                                      Boolean isExternalvpn, Long elanTag) throws InterruptedException {
-        SubnetUpdatedInVpnBuilder builder = new SubnetUpdatedInVpnBuilder();
-
-        LOG.info("publish notification called");
-
-        builder.setSubnetId(subnetId);
-        builder.setSubnetIp(subnetIp);
-        builder.setVpnName(vpnName);
-        builder.setExternalVpn(isExternalvpn);
-        builder.setElanTag(elanTag);
-
-        notificationPublishService.putNotification(builder.build());
-    }
-
     private void checkAndPublishRouterAssociatedtoVpnNotification(Uuid routerId, Uuid vpnId) throws
             InterruptedException {
         RouterAssociatedToVpn routerAssociatedToVpn = new RouterAssociatedToVpnBuilder().setRouterId(routerId)
@@ -2261,8 +2176,8 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
 
     private void checkAndPublishRouterDisassociatedFromVpnNotification(Uuid routerId, Uuid vpnId) throws
             InterruptedException {
-        RouterDisassociatedFromVpn routerDisassociatedFromVpn = new RouterDisassociatedFromVpnBuilder().setRouterId
-                (routerId).setVpnId(vpnId).build();
+        RouterDisassociatedFromVpn routerDisassociatedFromVpn =
+            new RouterDisassociatedFromVpnBuilder().setRouterId(routerId).setVpnId(vpnId).build();
         LOG.info("publishing notification upon disassociation of router from VPN");
         notificationPublishService.putNotification(routerDisassociatedFromVpn);
     }