Adjust to odlparent 3 Checkstyle settings
[genius.git] / itm / itm-impl / src / main / java / org / opendaylight / genius / itm / confighelpers / ItmInternalTunnelDeleteWorker.java
index ab5bbee6cc5a4ed915a5dcb57ee86866a34e9f3d..79d8eefa9974bf9f5fcdb61d61d9b41635b788b0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ * Copyright (c) 2016, 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,21 +7,30 @@
  */
 package org.opendaylight.genius.itm.confighelpers;
 
+import static java.util.Collections.singletonList;
+
 import com.google.common.base.Optional;
 import com.google.common.util.concurrent.ListenableFuture;
 import java.math.BigInteger;
-import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
 import java.util.List;
+import java.util.concurrent.Callable;
+
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
+import org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl;
 import org.opendaylight.genius.itm.impl.ItmUtils;
 import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
+import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelMonitoringTypeBase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelMonitoringTypeLldp;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeLogicalGroup;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.DpnEndpoints;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TunnelList;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo;
@@ -35,49 +44,66 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class ItmInternalTunnelDeleteWorker {
-    private static final Logger logger = LoggerFactory.getLogger(ItmInternalTunnelDeleteWorker.class);
-
-    public static List<ListenableFuture<Void>> deleteTunnels(DataBroker dataBroker, IdManagerService idManagerService,
-            IMdsalApiManager mdsalManager, List<DPNTEPsInfo> dpnTepsList, List<DPNTEPsInfo> meshedDpnList) {
-        logger.trace("TEPs to be deleted {} ", dpnTepsList);
-        List<ListenableFuture<Void>> futures = new ArrayList<>();
-        WriteTransaction t = dataBroker.newWriteOnlyTransaction();
-        try {
+
+    private static final Logger LOG = LoggerFactory.getLogger(ItmInternalTunnelDeleteWorker.class) ;
+
+    private final DataBroker dataBroker;
+    private final ManagedNewTransactionRunner txRunner;
+    private final JobCoordinator jobCoordinator;
+
+    public ItmInternalTunnelDeleteWorker(DataBroker dataBroker, JobCoordinator jobCoordinator) {
+        this.dataBroker = dataBroker;
+        this.txRunner = new ManagedNewTransactionRunnerImpl(dataBroker);
+        this.jobCoordinator = jobCoordinator;
+    }
+
+    @SuppressWarnings("checkstyle:IllegalCatch")
+    public List<ListenableFuture<Void>> deleteTunnels(IMdsalApiManager mdsalManager, List<DPNTEPsInfo> dpnTepsList,
+                                                      List<DPNTEPsInfo> meshedDpnList) {
+        LOG.trace("TEPs to be deleted {} " , dpnTepsList);
+        return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeTransaction -> {
             if (dpnTepsList == null || dpnTepsList.size() == 0) {
-                logger.debug("no vtep to delete");
-                return futures;
+                LOG.debug("no vtep to delete");
+                return;
             }
 
             if (meshedDpnList == null || meshedDpnList.size() == 0) {
-                logger.debug("No Meshed Vteps");
-                return futures;
+                LOG.debug("No Meshed Vteps");
+                return;
             }
             for (DPNTEPsInfo srcDpn : dpnTepsList) {
-                logger.trace("Processing srcDpn " + srcDpn);
+                LOG.trace("Processing srcDpn {}", srcDpn);
 
                 List<TunnelEndPoints> meshedEndPtCache = ItmUtils.getTEPsForDpn(srcDpn.getDPNID(), meshedDpnList);
                 if (meshedEndPtCache == null) {
-                    logger.debug("No Tunnel End Point configured for this DPN {}", srcDpn.getDPNID());
+                    LOG.debug("No Tunnel End Point configured for this DPN {}", srcDpn.getDPNID());
                     continue;
                 }
-                logger.debug( "Entries in meshEndPointCache {} for DPN Id{} ", meshedEndPtCache.size(), srcDpn.getDPNID() );
+                LOG.debug("Entries in meshEndPointCache {} for DPN Id{} ", meshedEndPtCache.size(), srcDpn.getDPNID());
                 for (TunnelEndPoints srcTep : srcDpn.getTunnelEndPoints()) {
-                    logger.trace("Processing srcTep " + srcTep);
+                    LOG.trace("Processing srcTep {}", srcTep);
                     List<TzMembership> srcTZones = srcTep.getTzMembership();
                     boolean tepDeleteFlag = false;
                     // First, take care of tunnel removal, so run through all other DPNS other than srcDpn
-                    // In the tep received from Delete DCN, the membership list will always be 1 as the DCN is at transport zone level
-                    // Hence if a tunnel is shared across TZs, compare the original membership list between end points to decide if tunnel to be deleted.
+                    // In the tep received from Delete DCN, the membership list will always be 1
+                    // as the DCN is at transport zone level
+                    // Hence if a tunnel is shared across TZs, compare the original membership list between end points
+                    // to decide if tunnel to be deleted.
                     for (DPNTEPsInfo dstDpn : meshedDpnList) {
                         if (!srcDpn.getDPNID().equals(dstDpn.getDPNID())) {
                             for (TunnelEndPoints dstTep : dstDpn.getTunnelEndPoints()) {
                                 if (!ItmUtils.getIntersection(dstTep.getTzMembership(), srcTZones).isEmpty()) {
-                                    List<TzMembership> originalTzMembership = ItmUtils.getOriginalTzMembership(srcTep, srcDpn.getDPNID(), meshedDpnList);
-                                    if (ItmUtils.getIntersection(dstTep.getTzMembership(), originalTzMembership).size() == 1) {
-                                        if (checkIfTrunkExists(dstDpn.getDPNID(), srcDpn.getDPNID(), srcTep.getTunnelType(), dataBroker)) {
+                                    List<TzMembership> originalTzMembership =
+                                            ItmUtils.getOriginalTzMembership(srcTep, srcDpn.getDPNID(), meshedDpnList);
+                                    if (ItmUtils.getIntersection(dstTep.getTzMembership(), originalTzMembership).size()
+                                            == 1) {
+                                        if (checkIfTrunkExists(dstDpn.getDPNID(), srcDpn.getDPNID(),
+                                                srcTep.getTunnelType(), dataBroker)) {
                                             // remove all trunk interfaces
-                                            logger.trace("Invoking removeTrunkInterface between source TEP {} , Destination TEP {} ", srcTep, dstTep);
-                                            removeTrunkInterface(dataBroker, idManagerService, srcTep, dstTep, srcDpn.getDPNID(), dstDpn.getDPNID(), t, futures);
+                                            LOG.trace("Invoking removeTrunkInterface between source TEP {} , "
+                                                    + "Destination TEP {} ", srcTep, dstTep);
+                                            removeTrunkInterface(srcTep, dstTep, srcDpn.getDPNID(), dstDpn.getDPNID(),
+                                                    writeTransaction);
                                         }
                                     }
                                 }
@@ -86,26 +112,29 @@ public class ItmInternalTunnelDeleteWorker {
                     }
                     for (DPNTEPsInfo dstDpn : meshedDpnList) {
                         // Second, take care of Tep TZ membership and identify if tep can be removed
-                        if (srcDpn.getDPNID().equals(dstDpn.getDPNID())){
+                        if (srcDpn.getDPNID().equals(dstDpn.getDPNID())) {
                             // Same DPN, so remove the TZ membership
                             for (TunnelEndPoints dstTep : dstDpn.getTunnelEndPoints()) {
                                 if (dstTep.getIpAddress().equals(srcTep.getIpAddress())) {
                                     // Remove the deleted TZ membership from the TEP
-                                    logger.debug("Removing TZ list {} from Existing TZ list {} ", srcTZones, dstTep.getTzMembership());
-                                    List<TzMembership> updatedList = ItmUtils.removeTransportZoneMembership(dstTep, srcTZones);
+                                    LOG.debug("Removing TZ list {} from Existing TZ list {} ",
+                                            srcTZones, dstTep.getTzMembership());
+                                    List<TzMembership> updatedList =
+                                            ItmUtils.removeTransportZoneMembership(dstTep, srcTZones);
                                     if (updatedList.isEmpty()) {
-                                        logger.debug(" This TEP can be deleted " + srcTep);
+                                        LOG.debug(" This TEP can be deleted {}", srcTep);
                                         tepDeleteFlag = true;
-                                    }else {
+                                    } else {
                                         TunnelEndPointsBuilder modifiedTepBld = new TunnelEndPointsBuilder(dstTep);
                                         modifiedTepBld.setTzMembership(updatedList);
                                         TunnelEndPoints modifiedTep = modifiedTepBld.build() ;
-                                        InstanceIdentifier<TunnelEndPoints> tepPath =
-                                                InstanceIdentifier.builder(DpnEndpoints.class).child(DPNTEPsInfo.class, dstDpn.getKey())
-                                                        .child(TunnelEndPoints.class, dstTep.getKey()).build();
+                                        InstanceIdentifier<TunnelEndPoints> tepPath = InstanceIdentifier
+                                                .builder(DpnEndpoints.class)
+                                                .child(DPNTEPsInfo.class, dstDpn.getKey())
+                                                .child(TunnelEndPoints.class, dstTep.getKey()).build();
 
-                                        logger.debug(" Store the modified Tep in DS {} ", modifiedTep);
-                                        t.put(LogicalDatastoreType.CONFIGURATION, tepPath, modifiedTep);
+                                        LOG.debug(" Store the modified Tep in DS {} ", modifiedTep);
+                                        writeTransaction.put(LogicalDatastoreType.CONFIGURATION, tepPath, modifiedTep);
                                     }
                                 }
                             }
@@ -117,11 +146,13 @@ public class ItmInternalTunnelDeleteWorker {
                                 InstanceIdentifier.builder(DpnEndpoints.class).child(DPNTEPsInfo.class, srcDpn.getKey())
                                         .child(TunnelEndPoints.class, srcTep.getKey()).build();
 
-                        logger.trace("Tep Removal of TEP {} from DPNTEPSINFO CONFIG DS with Key {} " + srcTep, srcTep.getKey());
-                        t.delete(LogicalDatastoreType.CONFIGURATION, tepPath);
+                        LOG.trace("Tep Removal of TEP {} from DPNTEPSINFO CONFIG DS with Key {} ",
+                                srcTep, srcTep.getKey());
+                        writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, tepPath);
                         // remove the tep from the cache
                         meshedEndPtCache.remove(srcTep);
-                        Class<? extends TunnelMonitoringTypeBase> monitorProtocol = ItmUtils.determineMonitorProtocol(dataBroker);
+                        Class<? extends TunnelMonitoringTypeBase> monitorProtocol =
+                                ItmUtils.determineMonitorProtocol(dataBroker);
                         InstanceIdentifier<DPNTEPsInfo> dpnPath =
                                 InstanceIdentifier.builder(DpnEndpoints.class).child(DPNTEPsInfo.class, srcDpn.getKey())
                                         .build();
@@ -129,11 +160,11 @@ public class ItmInternalTunnelDeleteWorker {
                         if (meshedEndPtCache.isEmpty()) {
                             // remove dpn if no vteps exist on dpn
                             if (monitorProtocol.isAssignableFrom(TunnelMonitoringTypeLldp.class)) {
-                                logger.debug("Removing Terminating Service Table Flow ");
+                                LOG.debug("Removing Terminating Service Table Flow ");
                                 ItmUtils.setUpOrRemoveTerminatingServiceTable(srcDpn.getDPNID(), mdsalManager, false);
                             }
-                            logger.trace("DPN Removal from DPNTEPSINFO CONFIG DS " + srcDpn.getDPNID());
-                            t.delete(LogicalDatastoreType.CONFIGURATION, dpnPath);
+                            LOG.trace("DPN Removal from DPNTEPSINFO CONFIG DS {}", srcDpn.getDPNID());
+                            writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, dpnPath);
                             InstanceIdentifier<DpnEndpoints> tnlContainerPath =
                                     InstanceIdentifier.builder(DpnEndpoints.class).build();
                             Optional<DpnEndpoints> containerOptional =
@@ -143,67 +174,133 @@ public class ItmInternalTunnelDeleteWorker {
                             if (containerOptional.isPresent()) {
                                 DpnEndpoints deps = containerOptional.get();
                                 if (deps.getDPNTEPsInfo() == null || deps.getDPNTEPsInfo().isEmpty()) {
-                                    logger.trace("Container Removal from DPNTEPSINFO CONFIG DS");
-                                    t.delete(LogicalDatastoreType.CONFIGURATION, tnlContainerPath);
+                                    LOG.trace("Container Removal from DPNTEPSINFO CONFIG DS");
+                                    writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, tnlContainerPath);
                                 }
                             }
                         }
                     }
                 }
             }
-            futures.add(t.submit());
-        } catch (Exception e1) {
-            logger.error("exception while deleting tep", e1);
-        }
-        return futures;
+        }));
     }
 
-    private static void removeTrunkInterface(DataBroker dataBroker, IdManagerService idManagerService,
-            TunnelEndPoints srcTep, TunnelEndPoints dstTep, BigInteger srcDpnId, BigInteger dstDpnId,
-            WriteTransaction t, List<ListenableFuture<Void>> futures) {
-        String trunkfwdIfName = ItmUtils.getTrunkInterfaceName(idManagerService, srcTep.getInterfaceName(),
-                new String(srcTep.getIpAddress().getValue()), new String(dstTep.getIpAddress().getValue()),
+    private void removeTrunkInterface(TunnelEndPoints srcTep, TunnelEndPoints dstTep,
+                                      BigInteger srcDpnId, BigInteger dstDpnId, WriteTransaction transaction) {
+        String trunkfwdIfName = ItmUtils.getTrunkInterfaceName(srcTep.getInterfaceName(),
+                new String(srcTep.getIpAddress().getValue()),
+                new String(dstTep.getIpAddress().getValue()),
                 srcTep.getTunnelType().getName());
-        logger.trace("Removing forward Trunk Interface " + trunkfwdIfName);
+        LOG.trace("Removing forward Trunk Interface " + trunkfwdIfName);
         InstanceIdentifier<Interface> trunkIdentifier = ItmUtils.buildId(trunkfwdIfName);
-        logger.debug(" Removing Trunk Interface Name - {} , Id - {} from Config DS ", trunkfwdIfName, trunkIdentifier);
-        t.delete(LogicalDatastoreType.CONFIGURATION, trunkIdentifier);
-        ItmUtils.itmCache.removeInterface(trunkfwdIfName);
-        // also update itm-state ds -- Delete the forward tunnel-interface from
-        // the tunnel list
+        LOG.debug(" Removing Trunk Interface Name - {} , Id - {} from Config DS ",
+                trunkfwdIfName, trunkIdentifier) ;
+        transaction.delete(LogicalDatastoreType.CONFIGURATION, trunkIdentifier);
+        ItmUtils.ITM_CACHE.removeInterface(trunkfwdIfName);
+        // also update itm-state ds -- Delete the forward tunnel-interface from the tunnel list
         InstanceIdentifier<InternalTunnel> path = InstanceIdentifier.create(TunnelList.class)
                 .child(InternalTunnel.class, new InternalTunnelKey(dstDpnId, srcDpnId, srcTep.getTunnelType()));
-        t.delete(LogicalDatastoreType.CONFIGURATION, path);
-        ItmUtils.itmCache.removeInternalTunnel(trunkfwdIfName);
+        transaction.delete(LogicalDatastoreType.CONFIGURATION,path) ;
+        ItmUtils.ITM_CACHE.removeInternalTunnel(trunkfwdIfName);
         // Release the Ids for the forward trunk interface Name
-        ItmUtils.releaseIdForTrunkInterfaceName(idManagerService, srcTep.getInterfaceName(),
-                new String(srcTep.getIpAddress().getValue()), new String(dstTep.getIpAddress().getValue()),
+        ItmUtils.releaseIdForTrunkInterfaceName(srcTep.getInterfaceName(),
+                new String(srcTep.getIpAddress().getValue()),
+                new String(dstTep.getIpAddress().getValue()),
                 srcTep.getTunnelType().getName());
+        removeLogicalGroupTunnel(srcDpnId, dstDpnId);
 
-        String trunkRevIfName = ItmUtils.getTrunkInterfaceName(idManagerService, dstTep.getInterfaceName(),
-                new String(dstTep.getIpAddress().getValue()), new String(srcTep.getIpAddress().getValue()),
+        String trunkRevIfName = ItmUtils.getTrunkInterfaceName(dstTep.getInterfaceName(),
+                new String(dstTep.getIpAddress().getValue()),
+                new String(srcTep.getIpAddress().getValue()),
                 srcTep.getTunnelType().getName());
-        logger.trace("Removing Reverse Trunk Interface " + trunkRevIfName);
+        LOG.trace("Removing Reverse Trunk Interface {}", trunkRevIfName);
         trunkIdentifier = ItmUtils.buildId(trunkRevIfName);
-        logger.debug(" Removing Trunk Interface Name - {} , Id - {} from Config DS ", trunkRevIfName, trunkIdentifier);
-        t.delete(LogicalDatastoreType.CONFIGURATION, trunkIdentifier);
-
-        // also update itm-state ds -- Delete the reverse tunnel-interface from
-        // the tunnel list
-        path = InstanceIdentifier.create(TunnelList.class).child(InternalTunnel.class,
-                new InternalTunnelKey(srcDpnId, dstDpnId, dstTep.getTunnelType()));
-        t.delete(LogicalDatastoreType.CONFIGURATION, path);
+        LOG.debug(" Removing Trunk Interface Name - {} , Id - {} from Config DS ",
+                trunkRevIfName, trunkIdentifier) ;
+        transaction.delete(LogicalDatastoreType.CONFIGURATION, trunkIdentifier);
+        ItmUtils.ITM_CACHE.removeInternalTunnel(trunkRevIfName);
+        // also update itm-state ds -- Delete the reverse tunnel-interface from the tunnel list
+        path = InstanceIdentifier.create(TunnelList.class)
+                .child(InternalTunnel.class, new InternalTunnelKey(srcDpnId, dstDpnId, dstTep.getTunnelType()));
+        transaction.delete(LogicalDatastoreType.CONFIGURATION,path) ;
 
         // Release the Ids for the reverse trunk interface Name
-        ItmUtils.releaseIdForTrunkInterfaceName(idManagerService, dstTep.getInterfaceName(),
-                new String(dstTep.getIpAddress().getValue()), new String(srcTep.getIpAddress().getValue()),
+        ItmUtils.releaseIdForTrunkInterfaceName(dstTep.getInterfaceName(),
+                new String(dstTep.getIpAddress().getValue()),
+                new String(srcTep.getIpAddress().getValue()),
                 dstTep.getTunnelType().getName());
+        removeLogicalGroupTunnel(dstDpnId, srcDpnId);
     }
 
     private static boolean checkIfTrunkExists(BigInteger srcDpnId, BigInteger dstDpnId,
-            Class<? extends TunnelTypeBase> tunType, DataBroker dataBroker) {
+                                              Class<? extends TunnelTypeBase> tunType, DataBroker dataBroker) {
         InstanceIdentifier<InternalTunnel> path = InstanceIdentifier.create(TunnelList.class)
                 .child(InternalTunnel.class, new InternalTunnelKey(dstDpnId, srcDpnId, tunType));
-        return ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, dataBroker).isPresent();
+        return ItmUtils.read(LogicalDatastoreType.CONFIGURATION,path, dataBroker).isPresent();
+    }
+
+    private void removeLogicalGroupTunnel(BigInteger srcDpnId, BigInteger dstDpnId) {
+        boolean tunnelAggregationEnabled = ItmTunnelAggregationHelper.isTunnelAggregationEnabled();
+        if (!tunnelAggregationEnabled) {
+            return;
+        }
+        String logicTunnelName = ItmUtils.getLogicalTunnelGroupName(srcDpnId, dstDpnId);
+        ItmTunnelAggregationDeleteWorker addWorker =
+                new ItmTunnelAggregationDeleteWorker(logicTunnelName, srcDpnId, dstDpnId, dataBroker);
+        jobCoordinator.enqueueJob(logicTunnelName, addWorker);
+    }
+
+    private static class ItmTunnelAggregationDeleteWorker implements Callable<List<ListenableFuture<Void>>> {
+
+        private final String logicTunnelName;
+        private final BigInteger srcDpnId;
+        private final BigInteger dstDpnId;
+        private final ManagedNewTransactionRunner txRunner;
+
+        ItmTunnelAggregationDeleteWorker(String groupName, BigInteger srcDpnId, BigInteger dstDpnId, DataBroker db) {
+            this.logicTunnelName = groupName;
+            this.srcDpnId = srcDpnId;
+            this.dstDpnId = dstDpnId;
+            this.txRunner = new ManagedNewTransactionRunnerImpl(db);
+        }
+
+        @Override
+        public List<ListenableFuture<Void>> call() throws Exception {
+            Collection<InternalTunnel> tunnels = ItmUtils.ITM_CACHE.getAllInternalTunnel();
+            if (tunnels == null) {
+                return Collections.emptyList();
+            }
+            //The logical tunnel interface be removed only when the last tunnel interface on each OVS is deleted
+            boolean emptyTunnelGroup = true;
+            boolean foundLogicGroupIface = false;
+            for (InternalTunnel tunl : tunnels) {
+                if (tunl.getSourceDPN().equals(srcDpnId) && tunl.getDestinationDPN().equals(dstDpnId)) {
+                    if (tunl.getTransportType().isAssignableFrom(TunnelTypeVxlan.class)
+                            && tunl.getTunnelInterfaceNames() != null && !tunl.getTunnelInterfaceNames().isEmpty()) {
+                        emptyTunnelGroup = false;
+                        break;
+                    } else if (tunl.getTransportType().isAssignableFrom(TunnelTypeLogicalGroup.class)) {
+                        foundLogicGroupIface = true;
+                    }
+                }
+            }
+            if (emptyTunnelGroup && foundLogicGroupIface) {
+                return singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
+                    LOG.debug("MULTIPLE_VxLAN_TUNNELS: remove the logical tunnel group {} because a last tunnel"
+                        + " interface on srcDpnId {} dstDpnId {} is removed", logicTunnelName, srcDpnId, dstDpnId);
+                    InstanceIdentifier<Interface> trunkIdentifier = ItmUtils.buildId(logicTunnelName);
+                    tx.delete(LogicalDatastoreType.CONFIGURATION, trunkIdentifier);
+                    ItmUtils.ITM_CACHE.removeInterface(logicTunnelName);
+                    InstanceIdentifier<InternalTunnel> path = InstanceIdentifier.create(TunnelList.class)
+                            .child(InternalTunnel.class,
+                                    new InternalTunnelKey(dstDpnId, srcDpnId, TunnelTypeLogicalGroup.class));
+                    tx.delete(LogicalDatastoreType.CONFIGURATION, path);
+                    ItmUtils.ITM_CACHE.removeInternalTunnel(logicTunnelName);
+                }));
+            } else if (!emptyTunnelGroup) {
+                LOG.debug("MULTIPLE_VxLAN_TUNNELS: not last tunnel in logical tunnel group {}", logicTunnelName);
+            }
+            return Collections.emptyList();
+        }
     }
 }