import com.google.common.base.Optional;
import com.google.common.util.concurrent.ListenableFuture;
-import java.math.BigInteger;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
+import java.util.Objects;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.genius.infra.TypedWriteTransaction;
import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
import org.opendaylight.genius.itm.cache.DpnTepStateCache;
+import org.opendaylight.genius.itm.cache.OfEndPointCache;
import org.opendaylight.genius.itm.cache.OvsBridgeEntryCache;
import org.opendaylight.genius.itm.cache.OvsBridgeRefEntryCache;
import org.opendaylight.genius.itm.cache.TunnelStateCache;
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.config.rev160406.ItmConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.meta.rev171210.bridge.tunnel.info.OvsBridgeEntry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.meta.rev171210.bridge.tunnel.info.OvsBridgeEntryKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.meta.rev171210.bridge.tunnel.info.ovs.bridge.entry.OvsBridgeTunnelEntry;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.OperationFailedException;
+import org.opendaylight.yangtools.yang.common.Uint64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private final OvsBridgeRefEntryCache ovsBridgeRefEntryCache;
private final TunnelStateCache tunnelStateCache;
private final DirectTunnelUtils directTunnelUtils;
+ private final OfEndPointCache ofEndPointCache;
+ private final ItmConfig itmConfig;
public ItmInternalTunnelDeleteWorker(DataBroker dataBroker, JobCoordinator jobCoordinator,
TunnelMonitoringConfig tunnelMonitoringConfig,
OvsBridgeEntryCache ovsBridgeEntryCache,
OvsBridgeRefEntryCache ovsBridgeRefEntryCache,
TunnelStateCache tunnelStateCache,
- DirectTunnelUtils directTunnelUtils) {
+ DirectTunnelUtils directTunnelUtils,
+ OfEndPointCache ofEndPointCache,
+ ItmConfig itmConfig) {
this.dataBroker = dataBroker;
this.txRunner = new ManagedNewTransactionRunnerImpl(dataBroker);
this.jobCoordinator = jobCoordinator;
this.ovsBridgeRefEntryCache = ovsBridgeRefEntryCache;
this.tunnelStateCache = tunnelStateCache;
this.directTunnelUtils = directTunnelUtils;
+ this.ofEndPointCache = ofEndPointCache;
+ this.itmConfig = itmConfig;
}
@SuppressWarnings("checkstyle:IllegalCatch")
continue;
}
LOG.debug("Entries in meshEndPointCache {} for DPN Id{} ", meshedEndPtCache.size(), srcDpn.getDPNID());
- for (TunnelEndPoints srcTep : srcDpn.getTunnelEndPoints()) {
+ for (TunnelEndPoints srcTep : srcDpn.nonnullTunnelEndPoints()) {
LOG.trace("Processing srcTep {}", srcTep);
- List<TzMembership> srcTZones = srcTep.getTzMembership();
+ List<TzMembership> srcTZones = srcTep.nonnullTzMembership();
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
// 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()) {
+ if (!Objects.equals(srcDpn.getDPNID(), dstDpn.getDPNID())) {
+ for (TunnelEndPoints dstTep : dstDpn.nonnullTunnelEndPoints()) {
+ if (!ItmUtils.getIntersection(dstTep.nonnullTzMembership(), srcTZones).isEmpty()) {
List<TzMembership> originalTzMembership =
ItmUtils.getOriginalTzMembership(srcTep, srcDpn.getDPNID(), meshedDpnList);
if (ItmUtils.getIntersection(dstTep.getTzMembership(),
} else {
if (checkIfTrunkExists(dstDpn.getDPNID(), srcDpn.getDPNID(),
- srcTep.getTunnelType(), dataBroker)) {
+ srcTep.getTunnelType(), dataBroker)) {
// remove all trunk interfaces
LOG.trace("Invoking removeTrunkInterface between source TEP {} , "
+ "Destination TEP {} ", srcTep, dstTep);
}
}
}
+
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 (Objects.equals(srcDpn.getDPNID(), dstDpn.getDPNID())) {
// Same DPN, so remove the TZ membership
- for (TunnelEndPoints dstTep : dstDpn.getTunnelEndPoints()) {
- if (dstTep.getIpAddress().equals(srcTep.getIpAddress())) {
+ for (TunnelEndPoints dstTep : dstDpn.nonnullTunnelEndPoints()) {
+ if (Objects.equals(dstTep.getIpAddress(), srcTep.getIpAddress())) {
// Remove the deleted TZ membership from the TEP
LOG.debug("Removing TZ list {} from Existing TZ list {} ", srcTZones,
dstTep.getTzMembership());
}
private void removeTrunkInterface(TypedWriteTransaction<Configuration> tx, TunnelEndPoints srcTep,
- TunnelEndPoints dstTep, BigInteger srcDpnId, BigInteger dstDpnId) {
+ TunnelEndPoints dstTep, Uint64 srcDpnId, Uint64 dstDpnId) {
String trunkfwdIfName = ItmUtils.getTrunkInterfaceName(srcTep.getInterfaceName(),
- new String(srcTep.getIpAddress().getValue()),
- new String(dstTep.getIpAddress().getValue()),
+ srcTep.getIpAddress().stringValue(),
+ dstTep.getIpAddress().stringValue(),
srcTep.getTunnelType().getName());
LOG.trace("Removing forward Trunk Interface {}" , trunkfwdIfName);
InstanceIdentifier<Interface> trunkIdentifier = ItmUtils.buildId(trunkfwdIfName);
ItmUtils.ITM_CACHE.removeInternalTunnel(trunkfwdIfName);
// Release the Ids for the forward trunk interface Name
ItmUtils.releaseIdForTrunkInterfaceName(srcTep.getInterfaceName(),
- new String(srcTep.getIpAddress().getValue()),
- new String(dstTep.getIpAddress().getValue()),
+ srcTep.getIpAddress().stringValue(),
+ dstTep.getIpAddress().stringValue(),
srcTep.getTunnelType().getName());
removeLogicalGroupTunnel(srcDpnId, dstDpnId);
String trunkRevIfName = ItmUtils.getTrunkInterfaceName(dstTep.getInterfaceName(),
- new String(dstTep.getIpAddress().getValue()),
- new String(srcTep.getIpAddress().getValue()),
+ dstTep.getIpAddress().stringValue(),
+ srcTep.getIpAddress().stringValue(),
srcTep.getTunnelType().getName());
LOG.trace("Removing Reverse Trunk Interface {}", trunkRevIfName);
trunkIdentifier = ItmUtils.buildId(trunkRevIfName);
// Release the Ids for the reverse trunk interface Name
ItmUtils.releaseIdForTrunkInterfaceName(dstTep.getInterfaceName(),
- new String(dstTep.getIpAddress().getValue()),
- new String(srcTep.getIpAddress().getValue()),
+ dstTep.getIpAddress().stringValue(),
+ srcTep.getIpAddress().stringValue(),
dstTep.getTunnelType().getName());
removeLogicalGroupTunnel(dstDpnId, srcDpnId);
}
- private static boolean checkIfTrunkExists(BigInteger srcDpnId, BigInteger dstDpnId,
+ private static boolean checkIfTrunkExists(Uint64 srcDpnId, Uint64 dstDpnId,
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();
}
- private void removeLogicalGroupTunnel(BigInteger srcDpnId, BigInteger dstDpnId) {
+ private void removeLogicalGroupTunnel(Uint64 srcDpnId, Uint64 dstDpnId) {
boolean tunnelAggregationEnabled = ItmTunnelAggregationHelper.isTunnelAggregationEnabled();
if (!tunnelAggregationEnabled) {
return;
private static class ItmTunnelAggregationDeleteWorker implements Callable<List<ListenableFuture<Void>>> {
private final String logicTunnelName;
- private final BigInteger srcDpnId;
- private final BigInteger dstDpnId;
+ private final Uint64 srcDpnId;
+ private final Uint64 dstDpnId;
private final ManagedNewTransactionRunner txRunner;
- ItmTunnelAggregationDeleteWorker(String groupName, BigInteger srcDpnId, BigInteger dstDpnId, DataBroker db) {
+ ItmTunnelAggregationDeleteWorker(String groupName, Uint64 srcDpnId, Uint64 dstDpnId, DataBroker db) {
this.logicTunnelName = groupName;
this.srcDpnId = srcDpnId;
this.dstDpnId = dstDpnId;
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)
+ if (Objects.equals(tunl.getSourceDPN(), srcDpnId) && Objects.equals(tunl.getDestinationDPN(),
+ dstDpnId)) {
+ if (tunl.getTransportType() != null && tunl.getTransportType().isAssignableFrom(
+ TunnelTypeVxlan.class)
&& tunl.getTunnelInterfaceNames() != null && !tunl.getTunnelInterfaceNames().isEmpty()) {
emptyTunnelGroup = false;
break;
- } else if (tunl.getTransportType().isAssignableFrom(TunnelTypeLogicalGroup.class)) {
+ } else if (tunl.getTransportType() != null && tunl.getTransportType().isAssignableFrom(
+ TunnelTypeLogicalGroup.class)) {
foundLogicGroupIface = true;
}
}
}
private void removeTunnelInterfaceFromOvsdb(TypedReadWriteTransaction<Configuration> tx, TunnelEndPoints srcTep,
- TunnelEndPoints dstTep, BigInteger srcDpnId, BigInteger dstDpnId) {
+ TunnelEndPoints dstTep, Uint64 srcDpnId, Uint64 dstDpnId) {
String trunkfwdIfName = ItmUtils.getTrunkInterfaceName(srcTep.getInterfaceName(),
srcTep.getIpAddress().getIpv4Address().getValue(),
dstTep.getIpAddress().getIpv4Address().getValue(),
}
}
- private boolean checkIfTepInterfaceExists(BigInteger srcDpnId, BigInteger dstDpnId) {
- DpnTepInterfaceInfo dpnTepInterfaceInfo = dpnTepStateCache.getDpnTepInterface(srcDpnId,dstDpnId);
+ private boolean checkIfTepInterfaceExists(Uint64 srcDpnId, Uint64 dstDpnId) {
+ DpnTepInterfaceInfo dpnTepInterfaceInfo = dpnTepStateCache.getDpnTepInterface(srcDpnId, dstDpnId);
if (dpnTepInterfaceInfo != null) {
return dpnTepInterfaceInfo.getTunnelName() != null;
}
}
private void removeConfiguration(TypedReadWriteTransaction<Configuration> tx, Interface interfaceOld,
- ParentRefs parentRefs) throws ExecutionException, InterruptedException, OperationFailedException {
+ ParentRefs parentRefs) throws ExecutionException, InterruptedException, OperationFailedException {
IfTunnel ifTunnel = interfaceOld.augmentation(IfTunnel.class);
if (ifTunnel != null) {
// Check if the same transaction can be used across Config and operational shards
throws ExecutionException, InterruptedException, OperationFailedException {
LOG.info("removing tunnel configuration for {}", interfaceName);
- BigInteger dpId = null;
+ Uint64 dpId = null;
if (parentRefs != null) {
dpId = parentRefs.getDatapathNodeIdentifier();
}
return;
}
+ OvsdbBridgeRef ovsdbBridgeRef = getOvsdbBridgeRef(dpId);
+ Optional<OvsBridgeEntry> ovsBridgeEntryOptional = ovsBridgeEntryCache.get(dpId);
+
+ // delete bridge to tunnel interface mappings
+ OvsBridgeEntryKey bridgeEntryKey = new OvsBridgeEntryKey(dpId);
+ InstanceIdentifier<OvsBridgeEntry> bridgeEntryIid =
+ DirectTunnelUtils.getOvsBridgeEntryIdentifier(bridgeEntryKey);
+
+
+ if (ovsBridgeEntryOptional.isPresent()) {
+ List<OvsBridgeTunnelEntry> bridgeTunnelEntries = ovsBridgeEntryOptional.get().nonnullOvsBridgeTunnelEntry();
+
+ if (ovsdbBridgeRef != null) {
+ if (!itmConfig.isUseOfTunnels()) {
+ removeTerminationEndPoint(ovsdbBridgeRef.getValue(), interfaceName);
+ } else if (bridgeTunnelEntries.size() <= 1) {
+ removeTerminationEndPoint(ovsdbBridgeRef.getValue(), ofEndPointCache.get(dpId));
+ ofEndPointCache.remove(dpId);
+ }
+ }
+
+ deleteBridgeInterfaceEntry(bridgeEntryKey, bridgeTunnelEntries, bridgeEntryIid, interfaceName);
+ // IfIndex needs to be removed only during State Clean up not Config
+ }
+
+ directTunnelUtils.deleteTunnelStateEntry(interfaceName);
+ // delete tunnel ingress flow
+ removeTunnelIngressFlow(tx, interfaceName, dpId);
+ directTunnelUtils.removeTunnelEgressFlow(tx, dpId, interfaceName);
+ cleanUpInterfaceWithUnknownState(interfaceName, parentRefs, ifTunnel);
+ directTunnelUtils.removeLportTagInterfaceMap(interfaceName);
+ }
+
+ private OvsdbBridgeRef getOvsdbBridgeRef(Uint64 dpId) throws ReadFailedException {
Optional<OvsBridgeRefEntry> ovsBridgeRefEntryOptional = ovsBridgeRefEntryCache.get(dpId);
Optional<OvsBridgeEntry> ovsBridgeEntryOptional;
OvsdbBridgeRef ovsdbBridgeRef = null;
ovsdbBridgeRef = ovsBridgeEntryOptional.get().getOvsBridgeReference();
}
}
-
- if (ovsdbBridgeRef != null) {
- removeTerminationEndPoint(ovsdbBridgeRef.getValue(), interfaceName);
- }
-
- // delete tunnel ingress flow
- removeTunnelIngressFlow(tx, interfaceName, dpId);
-
- // delete bridge to tunnel interface mappings
- OvsBridgeEntryKey bridgeEntryKey = new OvsBridgeEntryKey(dpId);
- InstanceIdentifier<OvsBridgeEntry> bridgeEntryIid =
- DirectTunnelUtils.getOvsBridgeEntryIdentifier(bridgeEntryKey);
-
- ovsBridgeEntryOptional = ovsBridgeEntryCache.get(dpId);
- if (ovsBridgeEntryOptional.isPresent()) {
- List<OvsBridgeTunnelEntry> bridgeTunnelEntries = ovsBridgeEntryOptional.get().getOvsBridgeTunnelEntry();
- deleteBridgeInterfaceEntry(bridgeEntryKey, bridgeTunnelEntries, bridgeEntryIid, interfaceName);
- // IfIndex needs to be removed only during State Clean up not Config
- // TunnelMetaUtils.removeLportTagInterfaceMap(idManager, defaultOperationalShardTransaction, interfaceName);
- cleanUpInterfaceWithUnknownState(interfaceName, parentRefs, ifTunnel);
- directTunnelUtils.removeLportTagInterfaceMap(interfaceName);
- }
+ return ovsdbBridgeRef;
}
private void removeTerminationEndPoint(InstanceIdentifier<?> bridgeIid, String interfaceName) {
}
private void removeTunnelIngressFlow(TypedReadWriteTransaction<Configuration> tx, String interfaceName,
- BigInteger dpId) throws ExecutionException, InterruptedException {
+ Uint64 dpId) throws ExecutionException, InterruptedException {
directTunnelUtils.removeTunnelIngressFlow(tx, dpId, interfaceName);
}