+ 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();
+ }