--- /dev/null
+/*
+ * Copyright (c) 2019 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,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.genius.itm.cache;
+
+import java.math.BigInteger;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import javax.inject.Singleton;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Singleton
+public class OfEndPointCache {
+
+ private static final Logger LOG = LoggerFactory.getLogger(OfEndPointCache.class);
+
+ private final ConcurrentMap<BigInteger, String> ofEndPtMap =
+ new ConcurrentHashMap<>();
+
+ public void add(BigInteger dpnId, String ofTunnelName) {
+ ofEndPtMap.put(dpnId, ofTunnelName);
+ }
+
+ public String get(BigInteger dpnId) {
+ return ofEndPtMap.get(dpnId);
+ }
+
+ public String remove(BigInteger dpnId) {
+ return ofEndPtMap.remove(dpnId);
+ }
+
+ public Set<BigInteger> getAll() {
+ return ofEndPtMap.keySet();
+ }
+}
\ No newline at end of file
import org.opendaylight.genius.infra.TypedReadWriteTransaction;
import org.opendaylight.genius.infra.TypedWriteTransaction;
import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
+import org.opendaylight.genius.itm.cache.OfEndPointCache;
import org.opendaylight.genius.itm.cache.OvsBridgeRefEntryCache;
import org.opendaylight.genius.itm.globals.ITMConstants;
import org.opendaylight.genius.itm.impl.ITMBatchingUtils;
private final DirectTunnelUtils directTunnelUtils;
private final IInterfaceManager interfaceManager;
private final OvsBridgeRefEntryCache ovsBridgeRefEntryCache;
+ private final OfEndPointCache ofEndPointCache;
public ItmInternalTunnelAddWorker(DataBroker dataBroker, JobCoordinator jobCoordinator,
TunnelMonitoringConfig tunnelMonitoringConfig, ItmConfig itmCfg,
DirectTunnelUtils directTunnelUtil,
IInterfaceManager interfaceManager,
- OvsBridgeRefEntryCache ovsBridgeRefEntryCache) {
+ OvsBridgeRefEntryCache ovsBridgeRefEntryCache,
+ OfEndPointCache ofEndPointCache) {
this.dataBroker = dataBroker;
this.txRunner = new ManagedNewTransactionRunnerImpl(dataBroker);
this.jobCoordinator = jobCoordinator;
this.directTunnelUtils = directTunnelUtil;
this.interfaceManager = interfaceManager;
this.ovsBridgeRefEntryCache = ovsBridgeRefEntryCache;
+ this.ofEndPointCache = ofEndPointCache;
isTunnelMonitoringEnabled = tunnelMonitoringConfig.isTunnelMonitoringEnabled();
monitorProtocol = tunnelMonitoringConfig.getMonitorProtocol();
final DpnsTepsBuilder dpnsTepsBuilder = new DpnsTepsBuilder();
final List<DpnsTeps> dpnTeps = new ArrayList<>();
final List<RemoteDpns> remoteDpns = new ArrayList<>();
+ String ofTunnelPortName = null;
dpnsTepsBuilder.withKey(new DpnsTepsKey(srcDpnId));
dpnsTepsBuilder.setTunnelType(srcte.getTunnelType());
dpnsTepsBuilder.setSourceDpnId(srcDpnId);
+ if (itmCfg.isUseOfTunnels()) {
+ String tunnelType = ItmUtils.convertTunnelTypetoString(srcte.getTunnelType());
+ ofTunnelPortName = directTunnelUtils.generateOfPortName(srcDpnId, tunnelType);
+ dpnsTepsBuilder.setOfTunnel(ofTunnelPortName);
+ }
RemoteDpnsBuilder remoteDpn = new RemoteDpnsBuilder();
remoteDpn.withKey(new RemoteDpnsKey(dstDpnId));
dpnTeps.add(dpnsTepsBuilder.build());
dpnTepsStateBuilder.setDpnsTeps(dpnTeps);
updateDpnTepInterfaceInfoToConfig(dpnTepsStateBuilder.build());
- addTunnelConfiguration(iface);
+ addTunnelConfiguration(iface, ofTunnelPortName);
}
private static void updateDpnTepInterfaceInfoToConfig(DpnTepsState dpnTeps) {
ITMBatchingUtils.update(dpnTepsII, dpnTeps, ITMBatchingUtils.EntityType.DEFAULT_CONFIG);
}
- private void addTunnelConfiguration(Interface iface) throws ReadFailedException {
+ private void addTunnelConfiguration(Interface iface, String ofTunnelPortName)
+ throws ReadFailedException {
// ITM Direct Tunnels This transaction is not being used -- CHECK
ParentRefs parentRefs = iface.augmentation(ParentRefs.class);
if (parentRefs == null) {
iface.getName());
return;
}
-
- LOG.info("adding tunnel configuration for {}", iface.getName());
- LOG.debug("creating bridge interfaceEntry in ConfigDS {}", dpId);
- DirectTunnelUtils.createBridgeTunnelEntryInConfigDS(dpId, iface.getName());
-
+ String tunnelName = ofTunnelPortName != null ? ofTunnelPortName : iface.getName();
// create bridge on switch, if switch is connected
Optional<OvsBridgeRefEntry> ovsBridgeRefEntry = ovsBridgeRefEntryCache.get(dpId);
-
- if (ovsBridgeRefEntry.isPresent()) {
- LOG.debug("creating bridge interface on dpn {}", dpId);
- InstanceIdentifier<OvsdbBridgeAugmentation> bridgeIid =
- (InstanceIdentifier<OvsdbBridgeAugmentation>) ovsBridgeRefEntry.get()
- .getOvsBridgeReference().getValue();
- addPortToBridge(bridgeIid, iface, iface.getName());
+ LOG.info("adding tunnel port configuration for tunnelName: {}", tunnelName);
+ if (createTunnelPort(dpId)) {
+ LOG.debug("creating dpn tunnel mapping for dpn: {} tunnelName: {}", dpId, tunnelName);
+ DirectTunnelUtils.createBridgeTunnelEntryInConfigDS(dpId, tunnelName);
+ if (ofTunnelPortName != null) {
+ ofEndPointCache.add(dpId, tunnelName);
+ }
+ if (ovsBridgeRefEntry.isPresent()) {
+ LOG.debug("creating bridge interface on dpn {}", dpId);
+ InstanceIdentifier<OvsdbBridgeAugmentation> bridgeIid =
+ (InstanceIdentifier<OvsdbBridgeAugmentation>) ovsBridgeRefEntry.get()
+ .getOvsBridgeReference().getValue();
+ LOG.debug("adding port to the bridge:{} tunnelName: {}", bridgeIid, tunnelName);
+ addPortToBridge(bridgeIid, iface, tunnelName);
+ }
}
}
directTunnelUtils.addTunnelPortToBridge(ifTunnel, bridgeIid, iface, portName);
}
}
+
+ private boolean createTunnelPort(BigInteger dpId) {
+ if (!itmCfg.isUseOfTunnels()) {
+ return true;
+ }
+ return (ofEndPointCache.get(dpId) == null);
+ }
}
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.util.concurrent.ListenableFuture;
import java.math.BigInteger;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
+import java.util.UUID;
import java.util.concurrent.ExecutionException;
import java.util.function.Predicate;
import java.util.regex.Pattern;
tpAugmentationBuilder.setVlanTag(new VlanId(vlanId));
}
- if (ifTunnel.isMonitorEnabled()
+ if (itmConfig.isUseOfTunnels()) {
+ LOG.warn("BFD Monitoring not supported for OFTunnels");
+ } else if (ifTunnel.isMonitorEnabled()
&& TunnelMonitoringTypeBfd.class.isAssignableFrom(ifTunnel.getMonitorProtocol())) { //checkBfdMonEnabled
List<InterfaceBfd> bfdParams = DirectTunnelUtils.getBfdParams(ifTunnel);
tpAugmentationBuilder.setInterfaceBfd(bfdParams);
public boolean isEntityOwner() {
return entityOwnershipUtils.isEntityOwner(ITMConstants.ITM_CONFIG_ENTITY, ITMConstants.ITM_CONFIG_ENTITY);
}
+
+ public static String generateOfPortName(BigInteger dpId, String tunnelType) {
+ String trunkInterfaceName = String.format("%s:%s", dpId.toString(), tunnelType);
+ String uuidStr = UUID.nameUUIDFromBytes(trunkInterfaceName.getBytes(StandardCharsets.UTF_8)).toString()
+ .substring(0, 12).replace("-", "");
+ return String.format("%s%s", "of", uuidStr);
+ }
}
\ No newline at end of file
import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
import org.opendaylight.genius.itm.cache.DPNTEPsInfoCache;
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;
final DpnTepStateCache dpnTepStateCache, final OvsBridgeEntryCache ovsBridgeEntryCache,
final OvsBridgeRefEntryCache ovsBridgeRefEntryCache,
final IInterfaceManager interfaceManager,
+ final OfEndPointCache ofEndPointCache,
final ServiceRecoveryRegistry serviceRecoveryRegistry) {
super(dataBroker, LogicalDatastoreType.CONFIGURATION,
InstanceIdentifier.create(TransportZones.class).child(TransportZone.class));
tunnelMonitoringConfig, interfaceManager, dpnTepStateCache, ovsBridgeEntryCache,
ovsBridgeRefEntryCache, tunnelStateCache, directTunnelUtils);
this.itmInternalTunnelAddWorker = new ItmInternalTunnelAddWorker(dataBroker, jobCoordinator,
- tunnelMonitoringConfig, itmConfig, directTunnelUtils, interfaceManager, ovsBridgeRefEntryCache);
+ tunnelMonitoringConfig, itmConfig, directTunnelUtils, interfaceManager,
+ ovsBridgeRefEntryCache, ofEndPointCache);
this.externalTunnelAddWorker = new ItmExternalTunnelAddWorker(itmConfig, dpnTEPsInfoCache);
serviceRecoveryRegistry.addRecoverableListener(ItmServiceRecoveryHandler.getServiceRegistryKey(), this);
}
import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
import org.opendaylight.genius.itm.cache.DPNTEPsInfoCache;
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;
IInterfaceManager interfaceManager,
ServiceRecoveryRegistry serviceRecoveryRegistry,
EntityOwnershipUtils entityOwnershipUtils,
+ OfEndPointCache ofEndPointCache,
DataTreeEventCallbackRegistrar eventCallbacks) {
this.dataBroker = dataBroker;
this.itmConfig = itmConfig;
this.eventCallbacks = eventCallbacks;
this.txRunner = new ManagedNewTransactionRunnerImpl(dataBroker);
this.itmInternalTunnelAddWorker = new ItmInternalTunnelAddWorker(dataBroker, jobCoordinator,
- tunnelMonitoringConfig, itmConfig, directTunnelUtils, interfaceManager, ovsBridgeRefEntryCache);
- this.itmExternalTunnelAddWorker = new ItmExternalTunnelAddWorker(itmConfig, dpntePsInfoCache);
+ tunnelMonitoringConfig, itmConfig, directTunnelUtils, interfaceManager,
+ ovsBridgeRefEntryCache, ofEndPointCache);
+ this.itmExternalTunnelAddWorker = new ItmExternalTunnelAddWorker(itmConfig,
+ dpntePsInfoCache);
this.itmInternalTunnelDeleteWorker = new ItmInternalTunnelDeleteWorker(dataBroker, jobCoordinator,
tunnelMonitoringConfig, interfaceManager, dpnTepStateCache, ovsBridgeEntryCache,
ovsBridgeRefEntryCache, tunnelStateCache, directTunnelUtils);
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
+import org.opendaylight.genius.itm.cache.OfEndPointCache;
import org.opendaylight.genius.itm.cache.OvsBridgeRefEntryCache;
import org.opendaylight.genius.itm.confighelpers.ItmInternalTunnelAddWorker;
import org.opendaylight.genius.itm.globals.ITMConstants;
directTunnelUtils = new DirectTunnelUtils(idManagerService, mdsalApiManager, entityOwnershipUtils, itmConfig);
itmInternalTunnelAddWorker = new ItmInternalTunnelAddWorker(dataBroker, jobCoordinator,
new TunnelMonitoringConfig(dataBroker, new GuavaCacheProvider(new CacheManagersRegistryImpl())),
- itmConfig, directTunnelUtils, interfaceManager, new OvsBridgeRefEntryCache(dataBroker,
- new GuavaCacheProvider(new CacheManagersRegistryImpl())));
+ itmConfig, directTunnelUtils, interfaceManager,
+ new OvsBridgeRefEntryCache(dataBroker, new GuavaCacheProvider(new CacheManagersRegistryImpl())),
+ new OfEndPointCache());
}
@After