public boolean isItmDirectTunnelsEnabled() {
return false;
}
+
+ @Override
+ public boolean isItmOfTunnelsEnabled() {
+ return false;
+ }
}
--- /dev/null
+/*
+ * Copyright (c) 2020 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 javax.inject.Inject;
+import javax.inject.Singleton;
+import org.opendaylight.genius.mdsalutil.cache.DataObjectCache;
+import org.opendaylight.infrautils.caches.CacheProvider;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.DpnTepConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.tep.config.OfDpnTep;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.tep.config.OfDpnTepKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.Uint64;
+
+@Singleton
+public class OfDpnTepConfigCache extends DataObjectCache<BigInteger, OfDpnTep> {
+
+ @Inject
+ public OfDpnTepConfigCache(DataBroker dataBroker, CacheProvider cacheProvider) {
+ super(OfDpnTep.class, dataBroker, LogicalDatastoreType.CONFIGURATION,
+ InstanceIdentifier.builder(DpnTepConfig.class).child(OfDpnTep.class).build(), cacheProvider,
+ (iid, dpnsTeps) -> dpnsTeps.getSourceDpnId().toJava(),
+ sourceDpnId -> InstanceIdentifier.builder(DpnTepConfig.class)
+ .child(OfDpnTep.class, new OfDpnTepKey(Uint64.valueOf(sourceDpnId))).build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 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 javax.inject.Inject;
+import javax.inject.Singleton;
+import org.opendaylight.genius.mdsalutil.cache.DataObjectCache;
+import org.opendaylight.infrautils.caches.CacheProvider;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.OfTepsState;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.of.teps.state.OfTep;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.of.teps.state.OfTepKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+@Singleton
+public class OfTepStateCache extends DataObjectCache<String, OfTep> {
+
+ private static final Logger LOG = LoggerFactory.getLogger(OfTepStateCache.class);
+
+ @Inject
+ public OfTepStateCache(DataBroker dataBroker, CacheProvider cacheProvider) {
+ super(OfTep.class, dataBroker, LogicalDatastoreType.OPERATIONAL,
+ InstanceIdentifier.builder(OfTepsState.class).child(OfTep.class).build(), cacheProvider,
+ (iid, ofTepList) -> ofTepList.getOfPortName(), ofPortName -> InstanceIdentifier.builder(OfTepsState.class)
+ .child(OfTep.class, new OfTepKey(ofPortName)).build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 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.confighelpers;
+
+import com.google.common.util.concurrent.ListenableFuture;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.tep.config.OfDpnTep;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.tep.config.OfDpnTepKey;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ItmOfPortAddWorker implements Callable<List<? extends ListenableFuture<?>>> {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ItmOfPortAddWorker.class);
+
+ private final Map<OfDpnTepKey, OfDpnTep> dpnsTepMap;
+ private final ItmOfTunnelAddWorker itmOfTunnelAddWorker;
+
+ public ItmOfPortAddWorker(Map<OfDpnTepKey, OfDpnTep> dpnsTepMap, ItmOfTunnelAddWorker itmOfTunnelAddWorker) {
+ this.dpnsTepMap = dpnsTepMap;
+ this.itmOfTunnelAddWorker = itmOfTunnelAddWorker;
+ }
+
+ @Override
+ public List<ListenableFuture<Void>> call() throws Exception {
+ List<ListenableFuture<Void>> futures = new ArrayList<>() ;
+ futures.addAll(itmOfTunnelAddWorker.addOfPort(dpnsTepMap));
+ return futures;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 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.confighelpers;
+
+import com.google.common.util.concurrent.ListenableFuture;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.tep.config.OfDpnTep;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.tep.config.OfDpnTepKey;
+
+public class ItmOfPortRemoveWorker implements Callable<List<? extends ListenableFuture<?>>> {
+ public ItmOfPortRemoveWorker(Map<OfDpnTepKey, OfDpnTep> oldDpnTepList, DataBroker dataBroker,
+ ItmOfTunnelDeleteWorker itmOfTunnelDeleteWorker) {
+ }
+
+ @Override
+ public List<ListenableFuture<Void>> call() throws Exception {
+ return null;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 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.confighelpers;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.util.concurrent.ListenableFuture;
+import java.time.Duration;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+import org.opendaylight.genius.datastoreutils.listeners.DataTreeEventCallbackRegistrar;
+import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
+import org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl;
+import org.opendaylight.genius.itm.cache.OvsBridgeRefEntryCache;
+import org.opendaylight.genius.itm.impl.ITMBatchingUtils;
+import org.opendaylight.genius.itm.itmdirecttunnels.renderer.ovs.utilities.DirectTunnelUtils;
+import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.WriteTransaction;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.ReadFailedException;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlanGpe;
+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.OvsBridgeRefInfo;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.meta.rev171210.ovs.bridge.ref.info.OvsBridgeRefEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.meta.rev171210.ovs.bridge.ref.info.OvsBridgeRefEntryKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.DpnTepConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.DpnTepConfigBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.tep.config.OfDpnTep;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.tep.config.OfDpnTepKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbPortInterfaceAttributes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.Options;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.OptionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.OptionsKey;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.Uint16;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ItmOfTunnelAddWorker {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ItmOfTunnelAddWorker.class) ;
+ private static final Logger EVENT_LOGGER = LoggerFactory.getLogger("GeniusEventLogger");
+
+ private final DataBroker dataBroker;
+ private final ManagedNewTransactionRunner txRunner;
+ private final JobCoordinator jobCoordinator;
+ private final DirectTunnelUtils directTunnelUtils;
+ private final OvsBridgeRefEntryCache ovsBridgeRefEntryCache;
+ private final DataTreeEventCallbackRegistrar eventCallbacks;
+ private final ItmConfig itmCfg;
+
+ public ItmOfTunnelAddWorker(DataBroker dataBroker, JobCoordinator jobCoordinator, ItmConfig itmCfg,
+ DirectTunnelUtils directTunnelUtils, OvsBridgeRefEntryCache ovsBridgeRefEntryCache,
+ DataTreeEventCallbackRegistrar eventCallbacks) {
+ this.dataBroker = dataBroker;
+ this.txRunner = new ManagedNewTransactionRunnerImpl(dataBroker);
+ this.jobCoordinator = jobCoordinator;
+ this.itmCfg = itmCfg;
+ this.directTunnelUtils = directTunnelUtils;
+ this.ovsBridgeRefEntryCache = ovsBridgeRefEntryCache;
+ this.eventCallbacks = eventCallbacks;
+ }
+
+ public Collection<? extends ListenableFuture<Void>> addOfPort(Map<OfDpnTepKey, OfDpnTep> dpnsTepMap) {
+ return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(transaction -> {
+ for (OfDpnTep dpn : dpnsTepMap.values()) {
+ buildOfPort(dpn, transaction);
+ }
+ updateOfDpnsConfig(dpnsTepMap, transaction);
+ }));
+ }
+
+ private void updateOfDpnsConfig(Map<OfDpnTepKey, OfDpnTep> dpnsTepMap, WriteTransaction tx) {
+ DpnTepConfigBuilder tepConfigBuilder = new DpnTepConfigBuilder();
+ tepConfigBuilder.setOfDpnTep(dpnsTepMap);
+ InstanceIdentifier<DpnTepConfig> dpnTepsConfII = InstanceIdentifier.builder(DpnTepConfig.class).build();
+ tx.merge(LogicalDatastoreType.CONFIGURATION, dpnTepsConfII, tepConfigBuilder.build());
+ }
+
+ private void buildOfPort(OfDpnTep dpnTep, WriteTransaction transaction) throws ReadFailedException {
+ Optional<OvsBridgeRefEntry> ovsBridgeRefEntry = ovsBridgeRefEntryCache.get(dpnTep.getSourceDpnId());
+ DirectTunnelUtils.createBridgeTunnelEntryInConfigDS(dpnTep.getSourceDpnId(), dpnTep.getOfPortName());
+
+ if (ovsBridgeRefEntry.isPresent()) {
+ LOG.debug("creating bridge interface on dpn {}", dpnTep.getSourceDpnId());
+ InstanceIdentifier<OvsdbBridgeAugmentation> bridgeIid =
+ (InstanceIdentifier<OvsdbBridgeAugmentation>) ovsBridgeRefEntry.get()
+ .getOvsBridgeReference().getValue();
+ LOG.debug("adding port to the bridge:{} tunnelName: {}", bridgeIid, dpnTep.getOfPortName());
+ addOfPortToBridge(bridgeIid, dpnTep);
+ } else {
+ LOG.debug("Bridge not found. Registering Eventcallback for dpid {}", dpnTep.getSourceDpnId());
+
+ InstanceIdentifier<OvsBridgeRefEntry> bridgeRefEntryFromDS =
+ InstanceIdentifier.builder(OvsBridgeRefInfo.class)
+ .child(OvsBridgeRefEntry.class, new OvsBridgeRefEntryKey(dpnTep.getSourceDpnId())).build();
+
+ eventCallbacks.onAdd(LogicalDatastoreType.OPERATIONAL, bridgeRefEntryFromDS, (refEntryIid) -> {
+ addPortToBridgeOnCallback(dpnTep, refEntryIid);
+ return DataTreeEventCallbackRegistrar.NextAction.UNREGISTER;
+ }, Duration.ofMillis(5000), (id) -> {
+ try {
+ Optional<OvsBridgeRefEntry> ovsBridgeRefEntryOnCallback =
+ ovsBridgeRefEntryCache.get(dpnTep.getSourceDpnId());
+ InstanceIdentifier<OvsdbBridgeAugmentation> bridgeIidOnCallback =
+ (InstanceIdentifier<OvsdbBridgeAugmentation>) ovsBridgeRefEntryOnCallback.get()
+ .getOvsBridgeReference().getValue();
+ addOfPortToBridge(bridgeIidOnCallback, dpnTep);
+ } catch (ReadFailedException e) {
+ LOG.error("Bridge not found in DS/cache for dpId {}", dpnTep.getSourceDpnId());
+ }
+ });
+ }
+
+ }
+
+ private void addPortToBridgeOnCallback(OfDpnTep dpnTep, OvsBridgeRefEntry bridgeRefEntry) {
+ InstanceIdentifier<OvsdbBridgeAugmentation> bridgeIid =
+ (InstanceIdentifier<OvsdbBridgeAugmentation>) bridgeRefEntry.getOvsBridgeReference().getValue();
+ addOfPortToBridge(bridgeIid, dpnTep);
+ }
+
+ private void addOfPortToBridge(InstanceIdentifier<OvsdbBridgeAugmentation> bridgeIid, OfDpnTep dpnTep) {
+ Class<? extends InterfaceTypeBase> type =
+ DirectTunnelUtils.TUNNEL_TYPE_MAP.get(dpnTep.getTunnelType());
+ if (type == null) {
+ LOG.warn("Unknown Tunnel Type obtained while creating port {} on dpn {}",
+ dpnTep.getOfPortName(), dpnTep.getSourceDpnId());
+ return;
+ }
+
+ ImmutableMap.Builder<String, String> options = new ImmutableMap.Builder<>();
+
+ // Options common to any kind of tunnel
+ options.put(directTunnelUtils.TUNNEL_OPTIONS_KEY, directTunnelUtils.TUNNEL_OPTIONS_VALUE_FLOW);
+ IpAddress localIp = dpnTep.getTepIp();
+ options.put(DirectTunnelUtils.TUNNEL_OPTIONS_LOCAL_IP, localIp.stringValue());
+ options.put(directTunnelUtils.TUNNEL_OPTIONS_REMOTE_IP, directTunnelUtils.TUNNEL_OPTIONS_VALUE_FLOW);
+ options.put(DirectTunnelUtils.TUNNEL_OPTIONS_TOS, DirectTunnelUtils.TUNNEL_OPTIONS_TOS_VALUE_INHERIT);
+
+ if (TunnelTypeVxlanGpe.class.equals(type)) {
+ options.put(DirectTunnelUtils.TUNNEL_OPTIONS_EXTS, DirectTunnelUtils.TUNNEL_OPTIONS_VALUE_GPE);
+ options.put(DirectTunnelUtils.TUNNEL_OPTIONS_NSI, DirectTunnelUtils.TUNNEL_OPTIONS_VALUE_FLOW);
+ options.put(DirectTunnelUtils.TUNNEL_OPTIONS_NSP, DirectTunnelUtils.TUNNEL_OPTIONS_VALUE_FLOW);
+ options.put(DirectTunnelUtils.TUNNEL_OPTIONS_NSHC1, DirectTunnelUtils.TUNNEL_OPTIONS_VALUE_FLOW);
+ options.put(DirectTunnelUtils.TUNNEL_OPTIONS_NSHC2, DirectTunnelUtils.TUNNEL_OPTIONS_VALUE_FLOW);
+ options.put(DirectTunnelUtils.TUNNEL_OPTIONS_NSHC3, DirectTunnelUtils.TUNNEL_OPTIONS_VALUE_FLOW);
+ options.put(DirectTunnelUtils.TUNNEL_OPTIONS_NSHC4, DirectTunnelUtils.TUNNEL_OPTIONS_VALUE_FLOW);
+ // VxLAN-GPE interfaces will not use the default UDP port to avoid problems with other meshes
+ options.put(DirectTunnelUtils.TUNNEL_OPTIONS_DESTINATION_PORT,
+ DirectTunnelUtils.TUNNEL_OPTIONS_VALUE_GPE_DESTINATION_PORT);
+ }
+
+ addTerminationPoint(bridgeIid, dpnTep.getOfPortName(), 0, type, options.build());
+ }
+
+ private void addTerminationPoint(InstanceIdentifier<?> bridgeIid, String ofPortName, int vlanId,
+ Class<? extends InterfaceTypeBase> type, Map<String, String> options) {
+
+ final InstanceIdentifier<TerminationPoint> tpIid = DirectTunnelUtils.createTerminationPointInstanceIdentifier(
+ InstanceIdentifier.keyOf(bridgeIid.firstIdentifierOf(
+ org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang
+ .network.topology.rev131021.network.topology.topology.Node.class)), ofPortName);
+ OvsdbTerminationPointAugmentationBuilder tpAugmentationBuilder = new OvsdbTerminationPointAugmentationBuilder();
+
+ tpAugmentationBuilder.setName(ofPortName);
+
+ if (type != null) {
+ tpAugmentationBuilder.setInterfaceType(type);
+ }
+
+ if (options != null) {
+ Map<OptionsKey, Options> optionsMap = new HashMap<>();
+ for (Map.Entry<String, String> entry : options.entrySet()) {
+ OptionsBuilder optionsBuilder = new OptionsBuilder();
+ optionsBuilder.withKey(new OptionsKey(entry.getKey()));
+ optionsBuilder.setOption(entry.getKey());
+ optionsBuilder.setValue(entry.getValue());
+ optionsMap.put(optionsBuilder.key(),optionsBuilder.build());
+ }
+ tpAugmentationBuilder.setOptions(optionsMap);
+ }
+
+ if (vlanId != 0) {
+ tpAugmentationBuilder.setVlanMode(OvsdbPortInterfaceAttributes.VlanMode.Access);
+ tpAugmentationBuilder.setVlanTag(new VlanId(Uint16.valueOf(vlanId)));
+ }
+
+ TerminationPointBuilder tpBuilder = new TerminationPointBuilder();
+ tpBuilder.withKey(InstanceIdentifier.keyOf(tpIid));
+ tpBuilder.addAugmentation(tpAugmentationBuilder.build());
+
+ ITMBatchingUtils.write(tpIid, tpBuilder.build(), ITMBatchingUtils.EntityType.TOPOLOGY_CONFIG);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 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.confighelpers;
+
+import org.opendaylight.genius.datastoreutils.listeners.DataTreeEventCallbackRegistrar;
+import org.opendaylight.genius.itm.cache.OvsBridgeRefEntryCache;
+import org.opendaylight.genius.itm.itmdirecttunnels.renderer.ovs.utilities.DirectTunnelUtils;
+import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.ItmConfig;
+
+public class ItmOfTunnelDeleteWorker {
+ public ItmOfTunnelDeleteWorker(DataBroker dataBroker, JobCoordinator jobCoordinator, ItmConfig itmConfig,
+ DirectTunnelUtils directTunnelUtils, OvsBridgeRefEntryCache ovsBridgeRefEntryCache,
+ DataTreeEventCallbackRegistrar eventCallbackRegistrar) {
+ }
+}
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.tunnel.end.points.TzMembership;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.tunnel.end.points.TzMembershipBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.tunnel.end.points.TzMembershipKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.tep.config.OfDpnTep;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.tep.config.OfDpnTepBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.tep.config.OfDpnTepKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnel;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnelBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnelKey;
}
return listOfDpId;
}
+
+ public static String generateOfPortName(Uint64 dpId, IpAddress tepIp, String tunnelType) {
+ String trunkInterfaceName = String.format("%s:%s:%s", dpId.toString(), tepIp.stringValue(),
+ tunnelType);
+ String uuidStr = UUID.nameUUIDFromBytes(trunkInterfaceName.getBytes(StandardCharsets.UTF_8)).toString()
+ .substring(0, 12).replace("-", "");
+ return String.format("%s%s", "of", uuidStr);
+ }
+
+ public static OfDpnTep createDpnOFTepInfo(Uint64 dpnID, IpAddress ipAddress,
+ String ofPortName, Class<? extends TunnelTypeBase> tunnelType) {
+ OfDpnTepBuilder tepBuilder = new OfDpnTepBuilder();
+ tepBuilder.withKey(new OfDpnTepKey(dpnID));
+ tepBuilder.setOfPortName(ofPortName);
+ tepBuilder.setSourceDpnId(dpnID);
+ tepBuilder.setTepIp(ipAddress);
+ tepBuilder.setTunnelType(tunnelType);
+ return tepBuilder.build();
+ }
}
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.stream.Collectors;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.genius.itm.confighelpers.ItmExternalTunnelAddWorker;
import org.opendaylight.genius.itm.confighelpers.ItmInternalTunnelAddWorker;
import org.opendaylight.genius.itm.confighelpers.ItmInternalTunnelDeleteWorker;
+import org.opendaylight.genius.itm.confighelpers.ItmOfPortAddWorker;
+import org.opendaylight.genius.itm.confighelpers.ItmOfPortRemoveWorker;
+import org.opendaylight.genius.itm.confighelpers.ItmOfTunnelAddWorker;
+import org.opendaylight.genius.itm.confighelpers.ItmOfTunnelDeleteWorker;
import org.opendaylight.genius.itm.confighelpers.ItmTepAddWorker;
import org.opendaylight.genius.itm.confighelpers.ItmTepRemoveWorker;
import org.opendaylight.genius.itm.confighelpers.ItmTepsNotHostedAddWorker;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPoints;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.tunnel.end.points.TzMembership;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.tep.config.OfDpnTep;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.tep.config.OfDpnTepKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.NotHostedTransportZones;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZonesBuilder;
private final ManagedNewTransactionRunner txRunner;
private final DataTreeEventCallbackRegistrar eventCallbacks;
private final TombstonedNodeManager tombstonedNodeManager;
+ private final IInterfaceManager interfaceManager;
+ private final ItmOfTunnelAddWorker itmOfTunnelAddWorker;
+ private final ItmOfTunnelDeleteWorker itmOfTunnelDeleteWorker;
@Inject
public TransportZoneListener(final DataBroker dataBroker,
tunnelMonitoringConfig, itmConfig, directTunnelUtils, interfaceManager,
ovsBridgeRefEntryCache, ofEndPointCache, eventCallbacks);
this.externalTunnelAddWorker = new ItmExternalTunnelAddWorker(itmConfig, dpnTEPsInfoCache);
+ this.interfaceManager = interfaceManager;
+ this.itmOfTunnelAddWorker = new ItmOfTunnelAddWorker(dataBroker, jobCoordinator,itmConfig,
+ directTunnelUtils, ovsBridgeRefEntryCache, eventCallbacks);
+ this.itmOfTunnelDeleteWorker = new ItmOfTunnelDeleteWorker(dataBroker, jobCoordinator,itmConfig,
+ directTunnelUtils, ovsBridgeRefEntryCache, eventCallbacks);
serviceRecoveryRegistry.addRecoverableListener(ItmServiceRecoveryHandler.getServiceRegistryKey(),
this);
}
LOG.debug("Received Transport Zone Update Event: Old - {}, Updated - {}", originalTransportZone,
updatedTransportZone);
EVENT_LOGGER.debug("ITM-Transportzone,UPDATE {}", updatedTransportZone.getZoneName());
- List<DPNTEPsInfo> oldDpnTepsList = createDPNTepInfo(originalTransportZone);
- List<DPNTEPsInfo> newDpnTepsList = createDPNTepInfo(updatedTransportZone);
- List<DPNTEPsInfo> oldDpnTepsListcopy = new ArrayList<>();
- oldDpnTepsListcopy.addAll(oldDpnTepsList);
- LOG.trace("oldcopy0 {}", oldDpnTepsListcopy);
- List<DPNTEPsInfo> newDpnTepsListcopy = new ArrayList<>();
- newDpnTepsListcopy.addAll(newDpnTepsList);
- LOG.trace("newcopy0 {}", newDpnTepsListcopy);
-
- oldDpnTepsList.removeAll(newDpnTepsListcopy);
- newDpnTepsList.removeAll(oldDpnTepsListcopy);
-
- LOG.trace("oldDpnTepsList {}", oldDpnTepsList);
- LOG.trace("newDpnTepsList {}", newDpnTepsList);
- LOG.trace("oldcopy {}", oldDpnTepsListcopy);
- LOG.trace("newcopy {}", newDpnTepsListcopy);
- LOG.trace("oldcopy Size {}", oldDpnTepsList.size());
- LOG.trace("newcopy Size {}", newDpnTepsList.size());
-
- boolean equalLists = newDpnTepsList.size() == oldDpnTepsList.size()
- && newDpnTepsList.containsAll(oldDpnTepsList);
- LOG.trace("Is List Duplicate {} ", equalLists);
- if (!newDpnTepsList.isEmpty() && !equalLists) {
- LOG.trace("Adding TEPs ");
- jobCoordinator.enqueueJob(updatedTransportZone.getZoneName(),
- new ItmTepAddWorker(newDpnTepsList, Collections.emptyList(), dataBroker, mdsalManager,
- itmInternalTunnelAddWorker, externalTunnelAddWorker));
- }
- if (!oldDpnTepsList.isEmpty() && !equalLists) {
- LOG.trace("Removing TEPs ");
- jobCoordinator.enqueueJob(updatedTransportZone.getZoneName(),
- new ItmTepRemoveWorker(oldDpnTepsList, Collections.emptyList(), originalTransportZone, mdsalManager,
- itmInternalTunnelDeleteWorker, dpnTEPsInfoCache, txRunner, itmConfig));
- }
- List<HwVtep> oldHwList = createhWVteps(originalTransportZone);
- List<HwVtep> newHwList = createhWVteps(updatedTransportZone);
- List<HwVtep> oldHwListcopy = new ArrayList<>();
- oldHwListcopy.addAll(oldHwList);
- LOG.trace("oldHwListcopy0 {}", oldHwListcopy);
- List<HwVtep> newHwListcopy = new ArrayList<>();
- newHwListcopy.addAll(newHwList);
- LOG.trace("newHwListcopy0 {}", newHwListcopy);
-
- oldHwList.removeAll(newHwListcopy);
- newHwList.removeAll(oldHwListcopy);
- LOG.trace("oldHwList {}", oldHwList);
- LOG.trace("newHwList {}", newHwList);
- LOG.trace("oldHwListcopy {}", oldHwListcopy);
- LOG.trace("newHwListcopy {}", newHwListcopy);
- if (!newHwList.isEmpty()) {
- LOG.trace("Adding HW TEPs ");
- jobCoordinator.enqueueJob(updatedTransportZone.getZoneName(), new ItmTepAddWorker(Collections.emptyList(),
- newHwList, dataBroker, mdsalManager, itmInternalTunnelAddWorker, externalTunnelAddWorker));
- }
- if (!oldHwList.isEmpty()) {
- LOG.trace("Removing HW TEPs ");
- jobCoordinator.enqueueJob(updatedTransportZone.getZoneName(),
- new ItmTepRemoveWorker(Collections.emptyList(), oldHwList, originalTransportZone, mdsalManager,
- itmInternalTunnelDeleteWorker, dpnTEPsInfoCache, txRunner, itmConfig));
+
+ if (interfaceManager.isItmOfTunnelsEnabled()) {
+ updateTransportZone(originalTransportZone, updatedTransportZone);
+ } else {
+ List<DPNTEPsInfo> oldDpnTepsList = createDPNTepInfo(originalTransportZone);
+ List<DPNTEPsInfo> newDpnTepsList = createDPNTepInfo(updatedTransportZone);
+ List<DPNTEPsInfo> oldDpnTepsListcopy = new ArrayList<>();
+ oldDpnTepsListcopy.addAll(oldDpnTepsList);
+ LOG.trace("oldcopy0 {}", oldDpnTepsListcopy);
+ List<DPNTEPsInfo> newDpnTepsListcopy = new ArrayList<>();
+ newDpnTepsListcopy.addAll(newDpnTepsList);
+ LOG.trace("newcopy0 {}", newDpnTepsListcopy);
+
+ oldDpnTepsList.removeAll(newDpnTepsListcopy);
+ newDpnTepsList.removeAll(oldDpnTepsListcopy);
+
+ LOG.trace("oldDpnTepsList {}", oldDpnTepsList);
+ LOG.trace("newDpnTepsList {}", newDpnTepsList);
+ LOG.trace("oldcopy {}", oldDpnTepsListcopy);
+ LOG.trace("newcopy {}", newDpnTepsListcopy);
+ LOG.trace("oldcopy Size {}", oldDpnTepsList.size());
+ LOG.trace("newcopy Size {}", newDpnTepsList.size());
+
+ boolean equalLists = newDpnTepsList.size() == oldDpnTepsList.size()
+ && newDpnTepsList.containsAll(oldDpnTepsList);
+ LOG.trace("Is List Duplicate {} ", equalLists);
+ if (!newDpnTepsList.isEmpty() && !equalLists) {
+ LOG.trace("Adding TEPs ");
+ jobCoordinator.enqueueJob(updatedTransportZone.getZoneName(),
+ new ItmTepAddWorker(newDpnTepsList, Collections.emptyList(), dataBroker, mdsalManager,
+ itmInternalTunnelAddWorker, externalTunnelAddWorker));
+ }
+ if (!oldDpnTepsList.isEmpty() && !equalLists) {
+ LOG.trace("Removing TEPs ");
+ jobCoordinator.enqueueJob(updatedTransportZone.getZoneName(),
+ new ItmTepRemoveWorker(oldDpnTepsList, Collections.emptyList(), originalTransportZone,
+ mdsalManager, itmInternalTunnelDeleteWorker, dpnTEPsInfoCache, txRunner, itmConfig));
+ }
+ List<HwVtep> oldHwList = createhWVteps(originalTransportZone);
+ List<HwVtep> newHwList = createhWVteps(updatedTransportZone);
+ List<HwVtep> oldHwListcopy = new ArrayList<>();
+ oldHwListcopy.addAll(oldHwList);
+ LOG.trace("oldHwListcopy0 {}", oldHwListcopy);
+ List<HwVtep> newHwListcopy = new ArrayList<>();
+ newHwListcopy.addAll(newHwList);
+ LOG.trace("newHwListcopy0 {}", newHwListcopy);
+
+ oldHwList.removeAll(newHwListcopy);
+ newHwList.removeAll(oldHwListcopy);
+ LOG.trace("oldHwList {}", oldHwList);
+ LOG.trace("newHwList {}", newHwList);
+ LOG.trace("oldHwListcopy {}", oldHwListcopy);
+ LOG.trace("newHwListcopy {}", newHwListcopy);
+ if (!newHwList.isEmpty()) {
+ LOG.trace("Adding HW TEPs ");
+ jobCoordinator.enqueueJob(updatedTransportZone.getZoneName(),
+ new ItmTepAddWorker(Collections.emptyList(),
+ newHwList, dataBroker, mdsalManager, itmInternalTunnelAddWorker, externalTunnelAddWorker));
+ }
+ if (!oldHwList.isEmpty()) {
+ LOG.trace("Removing HW TEPs ");
+ jobCoordinator.enqueueJob(updatedTransportZone.getZoneName(),
+ new ItmTepRemoveWorker(Collections.emptyList(), oldHwList, originalTransportZone, mdsalManager,
+ itmInternalTunnelDeleteWorker, dpnTEPsInfoCache, txRunner, itmConfig));
+ }
}
}
public void add(@NonNull TransportZone transportZone) {
LOG.debug("Received Transport Zone Add Event: {}", transportZone);
EVENT_LOGGER.debug("ITM-Transportzone,ADD {}", transportZone.getZoneName());
- List<DPNTEPsInfo> opDpnList = createDPNTepInfo(transportZone);
- //avoiding adding duplicates from nothosted to new dpnlist.
- List<DPNTEPsInfo> duplicateFound = new ArrayList<>();
- List<DPNTEPsInfo> notHostedDpnList = getDPNTepInfoFromNotHosted(transportZone, opDpnList);
- for (DPNTEPsInfo notHostedDPN:notHostedDpnList) {
- for (DPNTEPsInfo newlyAddedDPN:opDpnList) {
- if (newlyAddedDPN.getDPNID().compareTo(notHostedDPN.getDPNID()) == 0
- || newlyAddedDPN.getTunnelEndPoints().get(0).getIpAddress()
- .equals(notHostedDPN.getTunnelEndPoints().get(0).getIpAddress())) {
- duplicateFound.add(notHostedDPN);
+ if (interfaceManager.isItmOfTunnelsEnabled()) {
+ Map<OfDpnTepKey, OfDpnTep> dpnTepMap = createOfTepInfo(transportZone);
+
+ if (!dpnTepMap.isEmpty()) {
+ jobCoordinator.enqueueJob(transportZone.getZoneName(),
+ new ItmOfPortAddWorker(dpnTepMap, itmOfTunnelAddWorker));
+ } else {
+ EVENT_LOGGER.debug("DPN List in TZ is empty");
+ }
+ } else {
+ List<DPNTEPsInfo> opDpnList = createDPNTepInfo(transportZone);
+ //avoiding adding duplicates from nothosted to new dpnlist.
+ List<DPNTEPsInfo> duplicateFound = new ArrayList<>();
+ List<DPNTEPsInfo> notHostedDpnList = getDPNTepInfoFromNotHosted(transportZone, opDpnList);
+ for (DPNTEPsInfo notHostedDPN : notHostedDpnList) {
+ for (DPNTEPsInfo newlyAddedDPN : opDpnList) {
+ if (newlyAddedDPN.getDPNID().compareTo(notHostedDPN.getDPNID()) == 0
+ || newlyAddedDPN.getTunnelEndPoints().get(0).getIpAddress()
+ .equals(notHostedDPN.getTunnelEndPoints().get(0).getIpAddress())) {
+ duplicateFound.add(notHostedDPN);
+ }
}
}
- }
- notHostedDpnList.removeAll(duplicateFound);
- opDpnList.addAll(notHostedDpnList);
-
- List<HwVtep> hwVtepList = createhWVteps(transportZone);
- LOG.trace("Add: Operational dpnTepInfo - Before invoking ItmManager {}", opDpnList);
- if (!opDpnList.isEmpty() || !hwVtepList.isEmpty()) {
- LOG.trace("Add: Invoking ItmManager with DPN List {} ", opDpnList);
- LOG.trace("Add: Invoking ItmManager with hwVtep List {} ", hwVtepList);
- jobCoordinator.enqueueJob(transportZone.getZoneName(),
- new ItmTepAddWorker(opDpnList, hwVtepList, dataBroker, mdsalManager, itmInternalTunnelAddWorker,
- externalTunnelAddWorker));
+ notHostedDpnList.removeAll(duplicateFound);
+ opDpnList.addAll(notHostedDpnList);
+
+ List<HwVtep> hwVtepList = createhWVteps(transportZone);
+ LOG.trace("Add: Operational dpnTepInfo - Before invoking ItmManager {}", opDpnList);
+ if (!opDpnList.isEmpty() || !hwVtepList.isEmpty()) {
+ LOG.trace("Add: Invoking ItmManager with DPN List {} ", opDpnList);
+ LOG.trace("Add: Invoking ItmManager with hwVtep List {} ", hwVtepList);
+ jobCoordinator.enqueueJob(transportZone.getZoneName(),
+ new ItmTepAddWorker(opDpnList, hwVtepList, dataBroker, mdsalManager, itmInternalTunnelAddWorker,
+ externalTunnelAddWorker));
+ }
}
}
return notHostedOpDpnList;
}
+ private void updateTransportZone(TransportZone originalTransportZone, TransportZone updatedTransportZone) {
+ Map<OfDpnTepKey, OfDpnTep> oldDpnTepMap = createOfTepInfo(originalTransportZone);
+ Map<OfDpnTepKey, OfDpnTep> newDpnTepMap = createOfTepInfo(updatedTransportZone);
+ List<OfDpnTep> oldDpnTepList = oldDpnTepMap.values().stream().collect(Collectors.toList());
+ List<OfDpnTep> newDpnTepList = newDpnTepMap.values().stream().collect(Collectors.toList());
+ List<OfDpnTep> oldDpnTepListcopy = new ArrayList<>();
+ oldDpnTepListcopy.addAll(oldDpnTepList);
+ List<OfDpnTep> newDpnTepListcopy = new ArrayList<>();
+ newDpnTepListcopy.addAll(newDpnTepList);
+
+ oldDpnTepList.removeAll(newDpnTepListcopy);
+ newDpnTepList.removeAll(oldDpnTepListcopy);
+ oldDpnTepMap.clear();
+ newDpnTepMap.clear();
+ for (OfDpnTep tep:oldDpnTepList) {
+ oldDpnTepMap.put(tep.key(), tep);
+ }
+
+ for (OfDpnTep tep:newDpnTepList) {
+ newDpnTepMap.put(tep.key(), tep);
+ }
+
+ boolean equalLists = newDpnTepList.size() == oldDpnTepList.size()
+ && newDpnTepList.containsAll(oldDpnTepList);
+ LOG.trace("Is List Duplicate? {} ", equalLists);
+
+ if (!newDpnTepList.isEmpty() && !equalLists) {
+ jobCoordinator.enqueueJob(updatedTransportZone.getZoneName(),
+ new ItmOfPortAddWorker(newDpnTepMap, itmOfTunnelAddWorker));
+ }
+
+ if (!oldDpnTepList.isEmpty() && !equalLists) {
+ jobCoordinator.enqueueJob(updatedTransportZone.getZoneName(),
+ new ItmOfPortRemoveWorker(oldDpnTepMap, dataBroker, itmOfTunnelDeleteWorker));
+ }
+ }
+
private List<DPNTEPsInfo> createDPNTepInfoFromNotHosted(TransportZone tzNew, List<DPNTEPsInfo> opDpnList) {
Map<Uint64, List<TunnelEndPoints>> mapNotHostedDPNToTunnelEndpt = new ConcurrentHashMap<>();
List<DPNTEPsInfo> notHostedDpnTepInfo = new ArrayList<>();
LOG.trace("returning hwvteplist {}", hwVtepsList);
return hwVtepsList;
}
+
+ private Map<OfDpnTepKey, OfDpnTep> createOfTepInfo(TransportZone transportZone) {
+ String tunnelType = ItmUtils.convertTunnelTypetoString(transportZone.getTunnelType());
+ Map<OfDpnTepKey, OfDpnTep> dpnTepMap = new HashMap<>();
+ Map<VtepsKey, Vteps> vtepsMap = transportZone.getVteps();
+ if (vtepsMap != null && !vtepsMap.isEmpty()) {
+ for (Vteps vteps : vtepsMap.values()) {
+ Uint64 dpnID = vteps.getDpnId();
+ IpAddress ipAddress = vteps.getIpAddress();
+ String ofPortName = ItmUtils.generateOfPortName(dpnID, ipAddress, tunnelType);
+ OfDpnTep dpnTep = ItmUtils.createDpnOFTepInfo(dpnID, ipAddress, ofPortName,
+ transportZone.getTunnelType());
+ dpnTepMap.put(dpnTep.key(), dpnTep);
+ }
+ }
+ return dpnTepMap;
+ }
}
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.SettableFuture;
+import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import org.opendaylight.genius.interfacemanager.interfaces.InterfaceManagerService;
import org.opendaylight.genius.itm.cache.DPNTEPsInfoCache;
import org.opendaylight.genius.itm.cache.DpnTepStateCache;
+import org.opendaylight.genius.itm.cache.OfDpnTepConfigCache;
+import org.opendaylight.genius.itm.cache.OfTepStateCache;
import org.opendaylight.genius.itm.cache.OvsBridgeRefEntryCache;
import org.opendaylight.genius.itm.cache.TunnelStateCache;
import org.opendaylight.genius.itm.confighelpers.ItmExternalTunnelAddWorker;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfoKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPoints;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.tep.config.OfDpnTep;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.teps.state.DpnsTeps;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.teps.state.DpnsTepsKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.teps.state.dpns.teps.RemoteDpns;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.teps.state.dpns.teps.RemoteDpnsKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnel;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnelKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.of.teps.state.OfTep;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnel.list.InternalTunnel;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.DcGatewayIpList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetInternalOrExternalInterfaceNameOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetTepIpInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetTepIpOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetTepIpOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetTunnelInterfaceNameInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetTunnelInterfaceNameOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetTunnelInterfaceNameOutputBuilder;
private final ManagedNewTransactionRunner txRunner;
private final RetryingManagedNewTransactionRunner retryingTxRunner;
private final ItmConfig itmConfig;
+ private final OfDpnTepConfigCache ofDpnTepConfigCache;
+ private final OfTepStateCache ofTepStateCache;
@Inject
public ItmManagerRpcService(final DataBroker dataBroker, final IMdsalApiManager mdsalManager,
final TunnelStateCache tunnelStateCache,
final InterfaceManagerService interfaceManagerService,
final OvsBridgeRefEntryCache ovsBridgeRefEntryCache,
- final DirectTunnelUtils directTunnelUtils) {
+ final DirectTunnelUtils directTunnelUtils, OfDpnTepConfigCache ofDpnTepConfigCache,
+ OfTepStateCache ofTepStateCache) {
this.dataBroker = dataBroker;
this.mdsalManager = mdsalManager;
this.dpnTEPsInfoCache = dpnTEPsInfoCache;
this.txRunner = new ManagedNewTransactionRunnerImpl(dataBroker);
this.retryingTxRunner = new RetryingManagedNewTransactionRunner(dataBroker);
this.itmConfig = itmConfig;
+ this.ofDpnTepConfigCache = ofDpnTepConfigCache;
+ this.ofTepStateCache = ofTepStateCache;
}
@PostConstruct
Uint64 destinationDpn = input.getDestinationDpid();
Optional<InternalTunnel> optTunnel = Optional.empty();
+ if (interfaceManager.isItmOfTunnelsEnabled()) {
+ //Destination DPN Id is not relevant in OF Tunnel scenario and so is ignored
+ try {
+ Optional<OfDpnTep> dpnstep = ofDpnTepConfigCache.get(sourceDpn.toJava());
+ if (dpnstep.isPresent()) {
+ resultBld = RpcResultBuilder.success();
+ resultBld.withResult(new GetTunnelInterfaceNameOutputBuilder()
+ .setInterfaceName(dpnstep.get().getOfPortName())).build();
+ return Futures.immediateFuture(resultBld.build());
+ } else {
+ LOG.error("OF tunnel is not available in ITM for source dpn {}", sourceDpn);
+ resultBld = RpcResultBuilder.failed();
+ return Futures.immediateFuture(resultBld.build());
+ }
+ } catch (ReadFailedException e) {
+ LOG.error("ReadFailedException: cache read failed for source dpn {} reason: {}", sourceDpn,
+ e.getMessage());
+ resultBld = RpcResultBuilder.failed();
+ return Futures.immediateFuture(resultBld.build());
+ }
+ }
if (interfaceManager.isItmDirectTunnelsEnabled()) {
DpnTepInterfaceInfo interfaceInfo = dpnTepStateCache.getDpnTepInterface(sourceDpn, destinationDpn);
if (interfaceInfo != null) {
.withError(RpcError.ErrorType.APPLICATION,
"tunnel name not set for GetEgressActionsForTunnel call").build());
}
- if (!dpnTepStateCache.isInternal(tunnelName) || !interfaceManager.isItmDirectTunnelsEnabled()) {
+ if (tunnelName.startsWith("of")
+ || (interfaceManager.isItmDirectTunnelsEnabled() && dpnTepStateCache.isInternal(tunnelName))) {
+ return fromListenableFuture(LOG, input, () -> getEgressActionsForInternalTunnels(input.getIntfName(),
+ input.getTunnelKey() != null ? input.getTunnelKey().toJava() : null,
+ input.getActionKey())).onFailureLogLevel(LogLevel.ERROR).build();
+ } else {
// Re-direct the RPC to Interface Manager
// From the rpc input and get the output and copy to output
org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406
}
} ,MoreExecutors.directExecutor());
return settableFuture;
- } else {
- return fromListenableFuture(LOG, input, () -> getEgressActionsForInternalTunnels(input.getIntfName(),
- input.getTunnelKey() != null ? input.getTunnelKey().toJava() : null,
- input.getActionKey())).onFailureLogLevel(LogLevel.ERROR).build();
}
}
RpcResultBuilder<GetExternalTunnelInterfaceNameOutput> resultBld;
String sourceNode = input.getSourceNode();
String dstNode = input.getDestinationNode();
+ if (interfaceManager.isItmOfTunnelsEnabled()) {
+ Optional<OfDpnTep> tepDetail;
+ try {
+ tepDetail = ofDpnTepConfigCache.get(new BigInteger(sourceNode));
+ } catch (ReadFailedException e) {
+ LOG.error("ReadFailedException: OF tunnel interface is not available in config DS for "
+ + "source dpn {} reason: {}", sourceNode, e.getMessage());
+ resultBld = failed();
+ return Futures.immediateFuture(resultBld.build());
+ }
+ if (tepDetail.isPresent()) {
+ GetExternalTunnelInterfaceNameOutputBuilder output =
+ new GetExternalTunnelInterfaceNameOutputBuilder()
+ .setInterfaceName(tepDetail.get().getOfPortName());
+ resultBld = RpcResultBuilder.success();
+ resultBld.withResult(output.build());
+ return Futures.immediateFuture(resultBld.build());
+ } else {
+ LOG.error("OF tunnel interface is not available in config DS for source dpn {}", sourceNode);
+ resultBld = failed();
+ return Futures.immediateFuture(resultBld.build());
+ }
+ }
ExternalTunnelKey externalTunnelKey = new ExternalTunnelKey(dstNode, sourceNode, input.getTunnelType());
InstanceIdentifier<ExternalTunnel> path = InstanceIdentifier.create(
ExternalTunnelList.class)
GetInternalOrExternalInterfaceNameInput input) {
RpcResultBuilder<GetInternalOrExternalInterfaceNameOutput> resultBld = failed();
Uint64 srcDpn = input.getSourceDpid();
- IpAddress dstIp = input.getDestinationIp() ;
+ IpAddress dstIp = input.getDestinationIp();
+ if (interfaceManager.isItmOfTunnelsEnabled()) {
+ Optional<OfDpnTep> tepDetail;
+ try {
+ tepDetail = ofDpnTepConfigCache.get(srcDpn.toJava());
+ } catch (ReadFailedException e) {
+ LOG.error("ReadFailedException: OF tunnel interface is not available in config DS for "
+ + "source dpn {} reason: {}", srcDpn, e.getMessage());
+ return Futures.immediateFuture(resultBld.build());
+ }
+ if (tepDetail.isPresent()) {
+ GetInternalOrExternalInterfaceNameOutputBuilder output =
+ new GetInternalOrExternalInterfaceNameOutputBuilder()
+ .setInterfaceName(tepDetail.get().getOfPortName());
+ resultBld = RpcResultBuilder.success();
+ resultBld.withResult(output.build());
+ return Futures.immediateFuture(resultBld.build());
+ } else {
+ LOG.error("OF tunnel interface is not available in config DS for source dpn {}", srcDpn);
+ return Futures.immediateFuture(resultBld.build());
+ }
+ }
InstanceIdentifier<ExternalTunnel> path1 = InstanceIdentifier.create(ExternalTunnelList.class)
.child(ExternalTunnel.class,
new ExternalTunnelKey(dstIp.stringValue(), srcDpn.toString(), input.getTunnelType()));
}
public ListenableFuture<RpcResult<GetTepIpOutput>> getTepIp(GetTepIpInput input) {
- return null;
+ RpcResultBuilder<GetTepIpOutput> resultBld;
+ Uint64 sourceDpn = input.getDpnId();
+ Optional<OfDpnTep> dpnstep;
+ try {
+ dpnstep = ofDpnTepConfigCache.get(sourceDpn.toJava());
+ } catch (ReadFailedException e) {
+ LOG.error("ReadFailedException: OF tunnel is not available in ITM for source dpn {} reason: {}",sourceDpn,
+ e.getMessage());
+ resultBld = RpcResultBuilder.failed();
+ return Futures.immediateFuture(resultBld.build());
+ }
+ if (dpnstep.isPresent()) {
+ resultBld = RpcResultBuilder.success();
+ resultBld.withResult(new GetTepIpOutputBuilder()
+ .setTepIp(dpnstep.get().getTepIp())).build();
+ return Futures.immediateFuture(resultBld.build());
+ } else {
+ LOG.error("OF tunnel is not available in ITM for source dpn {}",sourceDpn);
+ resultBld = RpcResultBuilder.failed();
+ return Futures.immediateFuture(resultBld.build());
+ }
}
@SuppressWarnings("checkstyle:IllegalCatch")
getEgressActionsForInternalTunnels(String interfaceName, Long tunnelKey, Integer actionKey)
throws ExecutionException, InterruptedException, OperationFailedException {
- DpnTepInterfaceInfo interfaceInfo = dpnTepStateCache.getTunnelFromCache(interfaceName);
- if (interfaceInfo == null) {
- throw new IllegalStateException("Interface information not present in config DS for" + interfaceName);
- }
+ if (interfaceName.startsWith("of")) {
+ Optional<OfTep> oftep = ofTepStateCache.get(interfaceName);
+ if (!oftep.isPresent()) {
+ throw new IllegalStateException("Interface information not present in oper DS for" + interfaceName);
+ }
+ List<ActionInfo> actions = getEgressActionInfosForOpenFlowTunnel(oftep.get().getIfIndex(),
+ oftep.get().getTepIp(), tunnelKey, actionKey);
+ return Futures.immediateFuture(new GetEgressActionsForTunnelOutputBuilder()
+ .setAction(actions.stream().map(ActionInfo::buildAction).collect(Collectors.toList())).build());
+ } else {
+ DpnTepInterfaceInfo interfaceInfo = dpnTepStateCache.getTunnelFromCache(interfaceName);
+ if (interfaceInfo == null) {
+ throw new IllegalStateException("Interface information not present in config DS for" + interfaceName);
+ }
- String tunnelType = ItmUtils.convertTunnelTypetoString(interfaceInfo.getTunnelType());
- if (!tunnelType.equalsIgnoreCase(ITMConstants.TUNNEL_TYPE_VXLAN)) {
- throw new IllegalArgumentException(tunnelType + " tunnel not handled by ITM");
- }
+ String tunnelType = ItmUtils.convertTunnelTypetoString(interfaceInfo.getTunnelType());
+ if (!tunnelType.equalsIgnoreCase(ITMConstants.TUNNEL_TYPE_VXLAN)) {
+ throw new IllegalArgumentException(tunnelType + " tunnel not handled by ITM");
+ }
- Optional<DPNTEPsInfo> dpntePsInfoOptional = dpnTEPsInfoCache.get(InstanceIdentifier.builder(DpnEndpoints.class)
- .child(DPNTEPsInfo.class, new DPNTEPsInfoKey(
- // FIXME: the cache should be caching this value, not just as a String
- Uint64.valueOf(dpnTepStateCache.getTunnelEndPointInfoFromCache(interfaceInfo.getTunnelName())
- .getDstEndPointInfo())))
- .build());
- Integer dstId;
- if (dpntePsInfoOptional.isPresent()) {
- dstId = dpntePsInfoOptional.get().getDstId();
- } else {
- dstId = directTunnelUtils.allocateId(ITMConstants.ITM_IDPOOL_NAME, interfaceInfo.getRemoteDPN().toString());
+ Optional<DPNTEPsInfo> dpntePsInfoOptional = dpnTEPsInfoCache.get(InstanceIdentifier
+ .builder(DpnEndpoints.class)
+ .child(DPNTEPsInfo.class, new DPNTEPsInfoKey(
+ // FIXME: the cache should be caching this value, not just as a String
+ Uint64.valueOf(dpnTepStateCache.getTunnelEndPointInfoFromCache(
+ interfaceInfo.getTunnelName()).getDstEndPointInfo())))
+ .build());
+ Integer dstId;
+ if (dpntePsInfoOptional.isPresent()) {
+ dstId = dpntePsInfoOptional.get().getDstId();
+ } else {
+ dstId = directTunnelUtils.allocateId(ITMConstants.ITM_IDPOOL_NAME,
+ interfaceInfo.getRemoteDPN().toString());
+ }
+
+ List<ActionInfo> result = new ArrayList<>();
+ long regValue = MetaDataUtil.getRemoteDpnMetadatForEgressTunnelTable(dstId);
+ int actionKeyStart = actionKey == null ? 0 : actionKey;
+ result.add(new ActionSetFieldTunnelId(actionKeyStart++,
+ Uint64.valueOf(tunnelKey != null ? tunnelKey : 0L)));
+ result.add(new ActionRegLoad(actionKeyStart++, NxmNxReg6.class, MetaDataUtil.REG6_START_INDEX,
+ MetaDataUtil.REG6_END_INDEX, regValue));
+ result.add(new ActionNxResubmit(actionKeyStart, NwConstants.EGRESS_TUNNEL_TABLE));
+
+ return Futures.immediateFuture(new GetEgressActionsForTunnelOutputBuilder()
+ .setAction(result.stream().map(ActionInfo::buildAction).collect(Collectors.toList())).build());
}
+ }
+ private static List<ActionInfo> getEgressActionInfosForOpenFlowTunnel(Uint16 ifIndex, IpAddress ipAddress,
+ Long tunnelKey, Integer actionKey) {
List<ActionInfo> result = new ArrayList<>();
- long regValue = MetaDataUtil.getRemoteDpnMetadatForEgressTunnelTable(dstId);
int actionKeyStart = actionKey == null ? 0 : actionKey;
result.add(new ActionSetFieldTunnelId(actionKeyStart++,
Uint64.valueOf(tunnelKey != null ? tunnelKey : 0L)));
- result.add(new ActionRegLoad(actionKeyStart++, NxmNxReg6.class, MetaDataUtil.REG6_START_INDEX,
- MetaDataUtil.REG6_END_INDEX, regValue));
- result.add(new ActionNxResubmit(actionKeyStart, NwConstants.EGRESS_TUNNEL_TABLE));
+ long regValue = MetaDataUtil.getReg6ValueForLPortDispatcher(ifIndex.intValue() ,
+ NwConstants.DEFAULT_SERVICE_INDEX);
+ result.add(new ActionRegLoad(actionKeyStart++, NxmNxReg6.class, ITMConstants.REG6_START_INDEX,
+ ITMConstants.REG6_END_INDEX, regValue));
+ result.add(new ActionNxResubmit(actionKeyStart, NwConstants.EGRESS_LPORT_DISPATCHER_TABLE));
- return Futures.immediateFuture(new GetEgressActionsForTunnelOutputBuilder()
- .setAction(result.stream().map(ActionInfo::buildAction).collect(Collectors.toList())).build());
+ return result;
}
public static Map<DcGatewayIpKey, DcGatewayIp>
import org.opendaylight.genius.interfacemanager.interfaces.InterfaceManagerService;
import org.opendaylight.genius.itm.cache.DPNTEPsInfoCache;
import org.opendaylight.genius.itm.cache.DpnTepStateCache;
+import org.opendaylight.genius.itm.cache.OfDpnTepConfigCache;
+import org.opendaylight.genius.itm.cache.OfTepStateCache;
import org.opendaylight.genius.itm.cache.OvsBridgeRefEntryCache;
import org.opendaylight.genius.itm.cache.TunnelStateCache;
import org.opendaylight.genius.itm.cache.UnprocessedNodeConnectorCache;
new TunnelStateCache(dataBroker, new GuavaCacheProvider(new CacheManagersRegistryImpl()));
OvsBridgeRefEntryCache ovsBridgeRefEntryCache =
new OvsBridgeRefEntryCache(dataBroker, new GuavaCacheProvider(new CacheManagersRegistryImpl()));
+ OfDpnTepConfigCache ofDpnTepConfigCache = new OfDpnTepConfigCache(dataBroker, new GuavaCacheProvider(
+ new CacheManagersRegistryImpl()));
+
+ OfTepStateCache ofTepStateCache = new OfTepStateCache(dataBroker, new GuavaCacheProvider(
+ new CacheManagersRegistryImpl()));
itmManagerRpcService = new ItmManagerRpcService(dataBroker, mdsalApiManager, itmConfig,
dpntePsInfoCache, interfaceManager, dpnTepStateCache, tunnelStateCache, interfaceManagerService,
- ovsBridgeRefEntryCache, directTunnelUtils);
+ ovsBridgeRefEntryCache, directTunnelUtils, ofDpnTepConfigCache, ofTepStateCache);
}
@After
.setUseOfTunnels(true)
.build();
bind(ItmConfig.class).toInstance(itmConfigObj);
- IfmConfig interfaceConfig = new IfmConfigBuilder().setItmDirectTunnels(false).build();
+ IfmConfig interfaceConfig = new IfmConfigBuilder().setItmDirectTunnels(false).setItmOfTunnels(false).build();
bind(IfmConfig.class).toInstance(interfaceConfig);
bind(TunnelMonitorIntervalListener.class);
bind(TransportZoneListener.class);