This patch removes unused methods, classes and fields.
Change-Id: Ia14e3ff0a304ca9c9db16562c1c766f07f98b9f2
Signed-off-by: Stephen Kitt <skitt@redhat.com>
+++ /dev/null
-/*
- * Copyright (c) 2016 Hewlett Packard Enterprise, Co. 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.netvirt.elanmanager.api;
-
-import java.math.BigInteger;
-import java.util.Map;
-import java.util.Optional;
-
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
-
-public interface IElanBridgeManager {
-
- /**
- * Get integration bridge node with dpId.
- *
- * @param dpId
- * datapath id
- * @return integration bridge {@code Node} or null if not found
- */
- Node getBridgeNode(BigInteger dpId);
-
- /**
- * Extract OpenvSwitch other-config to key value map.
- *
- * @param node
- * OVSDB node
- * @param key
- * key to extract from other-config
- * @return key-value Map or empty map if key was not found
- */
- Map<String, String> getOpenvswitchOtherConfigMap(Node node, String key);
-
- /**
- * Extract multi key-value into Map.
- *
- * @param multiKeyValueStr
- * multi key-value formatted using colon key-value
- * separator and comma multi-value separator
- * @return Map containing key value pairs or empty map if no key value pairs
- * where found
- */
- Map<String, String> getMultiValueMap(String multiKeyValueStr);
-
- /**
- * Get the integration bridge DPN id from the manager node UUID.
- *
- * @param managerNodeId
- * node-id of the OVSDB node managing br-int
- * @return Optional containing the dp-id or empty Optional if not found
- */
- Optional<BigInteger> getDpIdFromManagerNodeId(String managerNodeId);
-
-}
import java.math.BigInteger;
import java.util.Collection;
import java.util.List;
-
-import org.opendaylight.genius.mdsalutil.MatchInfoBase;
import org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance;
void removeKnownL3DmacAddress(String macAddress, String elanInstanceName);
- List<MatchInfoBase> getEgressMatchesForElanInstance(String elanInstanceName);
-
Boolean isOpenStackVniSemanticsEnforced();
/**
+++ /dev/null
-/*
- * Copyright (c) 2016 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.netvirt.elanmanager.exceptions;
-
-/**
- * Exception thrown when a MAC address was not found.
- */
-public class MacNotFoundException extends Exception {
-
- private static final long serialVersionUID = 1L;
-
- /**
- * Constructor.
- * @param message the eror message text, which must include the MAC address that was not found
- */
- public MacNotFoundException(String message) {
- super(message);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Red Hat, Inc. 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.netvirt.elan;
-
-public class ElanException extends Exception {
- private static final long serialVersionUID = -2491313989449541864L;
-
- public ElanException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public ElanException(String message) {
- super(message);
- }
-
-}
import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
import org.opendaylight.genius.itm.globals.ITMConstants;
import org.opendaylight.genius.mdsalutil.MDSALUtil;
-import org.opendaylight.netvirt.elanmanager.api.IElanBridgeManager;
import org.opendaylight.ovsdb.utils.southbound.utils.SouthboundUtils;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.config.rev150710.ElanConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.DatapathId;
@Singleton
// Checkstyle expects the first sentence to end with a period, question marks don’t count
@SuppressWarnings("checkstyle:SummaryJavadoc")
-public class ElanBridgeManager implements IElanBridgeManager {
+public class ElanBridgeManager {
private static final Logger LOG = LoggerFactory.getLogger(ElanBridgeManager.class);
public static final String PROVIDER_MAPPINGS_KEY = "provider_mappings";
/**
* {@inheritDoc}.
*/
- @Override
public Map<String, String> getOpenvswitchOtherConfigMap(Node node, String key) {
String otherConfigVal = southboundUtils.getOpenvswitchOtherConfig(node, key);
return getMultiValueMap(otherConfigVal);
return rv;
}
- @Override
public Optional<BigInteger> getDpIdFromManagerNodeId(String managerNodeId) {
InstanceIdentifier<Node> identifier = getIntegrationBridgeIdentifier(managerNodeId);
OvsdbBridgeAugmentation integrationBridgeAugmentation = interfaceManager.getOvsdbBridgeForNodeIid(identifier);
return stringBuilder.toString();
}
- @Override
- public Map<String, String> getMultiValueMap(String multiKeyValueStr) {
+ private Map<String, String> getMultiValueMap(String multiKeyValueStr) {
if (Strings.isNullOrEmpty(multiKeyValueStr)) {
return Collections.emptyMap();
}
/**
* {@inheritDoc}.
*/
- @Override
@Nullable
- public Node getBridgeNode(BigInteger dpId) {
+ private Node getBridgeNode(BigInteger dpId) {
List<Node> ovsdbNodes = southboundUtils.getOvsdbNodes();
if (null == ovsdbNodes) {
LOG.debug("Could not find any (?) ovsdb nodes");
futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, confTx -> {
futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, operTx -> {
installEntriesForElanInterface(elanInstance, elanInterface, interfaceInfo,
- isFirstInterfaceInDpn, confTx, operTx);
+ isFirstInterfaceInDpn, confTx);
List<StaticMacEntries> staticMacEntriesList = elanInterface.getStaticMacEntries();
List<PhysAddress> staticMacAddresses = Lists.newArrayList();
}
private void installEntriesForElanInterface(ElanInstance elanInstance, ElanInterface elanInterface,
- InterfaceInfo interfaceInfo, boolean isFirstInterfaceInDpn, TypedWriteTransaction<Configuration> confTx,
- TypedWriteTransaction<Operational> operTx) {
+ InterfaceInfo interfaceInfo, boolean isFirstInterfaceInDpn, TypedWriteTransaction<Configuration> confTx) {
if (!isOperational(interfaceInfo)) {
return;
}
+++ /dev/null
-/*
- * Copyright (c) 2016 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.netvirt.elan.internal;
-
-public class ElanItmEventListener{
-
-}
-//public class ElanItmEventListener extends AbstractDataChangeListener<DataObject> implements AutoCloseable {
-//FIXME: This class is to be made functional once ITM is added
-// private static final Logger LOG = LoggerFactory.getLogger(ElanItmEventListener.class);
-// private final DataBroker broker;
-// private ListenerRegistration<DataChangeListener> listenerRegistration;
-// private ElanInterfaceManager elanInterfaceManager;
-//
-// public ElanItmEventListener(final DataBroker db, final ElanInterfaceManager ifManager) {
-// super(StateTunnelList.class);
-// broker = db;
-// elanInterfaceManager = ifManager;
-// registerListener(db);
-// }
-//
-// private void registerListener(final DataBroker db) {
-// try {
-// listenerRegistration = broker.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
-// getWildCardPath(), ElanItmEventListener.this, AsyncDataBroker.DataChangeScope.SUBTREE);
-// } catch (final Exception e) {
-// LOG.error("ITM Monitor Interfaces DataChange listener registration fail!", e);
-// throw new IllegalStateException("ITM Monitor registration Listener failed.", e);
-// }
-// }
-//
-// private InstanceIdentifier<StateTunnelList> getWildCardPath() {
-// return InstanceIdentifier.create(TunnelsState.class).child(StateTunnelList.class);
-// }
-//
-// @Override
-// public void close() throws Exception {
-// if (listenerRegistration != null) {
-// try {
-// listenerRegistration.close();
-// } catch (final Exception e) {
-// LOG.error("Error when cleaning up DataChangeListener.", e);
-// }
-// listenerRegistration = null;
-// }
-// }
-//
-// @Override
-// protected void remove(InstanceIdentifier<StateTunnelList> identifier, StateTunnelList del) {
-//
-// }
-//
-// @Override
-// protected void update(InstanceIdentifier<StateTunnelList> identifier,
-// StateTunnelList original, StateTunnelList update) {
-//
-// BigInteger srcDpId = update.getSourceDPN();
-// BigInteger dstDpId = update.getDestinationDPN();
-// LOG.trace("ITM Tunnel state event changed from :{} to :{} for transportZone:{}",
-// original.isLogicalTunnelState(), update.isLogicalTunnelState(), update.getLogicalTunnelGroupName());
-//
-// if(update.isLogicalTunnelState()) {
-// LOG.trace("ITM Tunnel State is Up b/w srcDpn: {} and dstDpn: {}", srcDpId, dstDpId);
-// elanInterfaceManager.handleTunnelStateEvent(srcDpId, dstDpId);
-// }
-// }
-//
-// @Override
-// protected void add(InstanceIdentifier<StateTunnelList> identifier, StateTunnelList add) {
-// BigInteger srcDpId = add.getSourceDPN();
-// BigInteger dstDpId = add.getDestinationDPN();
-// LOG.trace("ITM Tunnel state event:{} for transportZone:{} of {}", add.isLogicalTunnelState(),
-// add.getLogicalTunnelGroupName());
-//
-// if(add.isLogicalTunnelState()) {
-// LOG.trace("ITM Tunnel State is Up b/w srcDpn: {} and dstDpn: {}", srcDpId, dstDpId);
-// elanInterfaceManager.handleTunnelStateEvent(srcDpId, dstDpId);
-// }
-// }
-//}
private final Meter unknownSmacPktinForwardingEntriesRemovedMeter;
private final Meter unknownSmacPktinRcvMeter;
private final Meter unknownSmacPktinLearnedMeter;
- private final Meter unknownSmacPktinIgnoredDueProtectionMeter;
private final Meter unknownSmacPktinFlowsRemovedForRelearnedMeter;
private final Meter unknownSmacPktinRemovedForRelearnedMeter;
private final Meter unknownSmacPktinMacMigrationIgnoredDueToProtectionMeter;
meter(metricProvider, "unknown_smac_pktin_forwarding_entries_removed");
this.unknownSmacPktinRcvMeter = meter(metricProvider, "unknown_smac_pktin_rcv");
this.unknownSmacPktinLearnedMeter = meter(metricProvider, "unknown_smac_pktin_learned");
- this.unknownSmacPktinIgnoredDueProtectionMeter =
- meter(metricProvider, "unknown_smac_pktin_ignored_due_protection");
this.unknownSmacPktinFlowsRemovedForRelearnedMeter =
meter(metricProvider, "unknown_smac_pktin_flows_removed_for_relearned");
this.unknownSmacPktinRemovedForRelearnedMeter =
unknownSmacPktinLearnedMeter.mark();
}
- public void unknownSmacPktinIgnoredDueProtection() {
- unknownSmacPktinIgnoredDueProtectionMeter.mark();
- }
-
public void unknownSmacPktinFlowsRemovedForRelearned() {
unknownSmacPktinFlowsRemovedForRelearnedMeter.mark();
}
import org.opendaylight.genius.interfacemanager.globals.IfmConstants;
import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
import org.opendaylight.genius.mdsalutil.MDSALUtil;
-import org.opendaylight.genius.mdsalutil.MatchInfoBase;
-import org.opendaylight.genius.mdsalutil.MetaDataUtil;
import org.opendaylight.genius.mdsalutil.NwConstants;
import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
-import org.opendaylight.genius.mdsalutil.nxmatches.NxMatchRegister;
import org.opendaylight.genius.utils.ServiceIndex;
import org.opendaylight.genius.utils.hwvtep.HwvtepSouthboundConstants;
import org.opendaylight.infrautils.inject.AbstractLifecycle;
elanUtils.removeDmacRedirectToDispatcherFlows(elanInstance.getElanTag(), macAddress, dpnsIdsForElanInstance);
}
- @Override
- public List<MatchInfoBase> getEgressMatchesForElanInstance(String elanInstanceName) {
- ElanInstance elanInstance = getElanInstance(elanInstanceName);
- if (elanInstance == null) {
- LOG.debug("No ELAN instance found for {}", elanInstanceName);
- return emptyList();
- }
-
- Long elanTag = elanInstance.getElanTag();
- if (elanTag == null) {
- LOG.debug("No ELAN tag found for {}", elanInstanceName);
- return emptyList();
- }
- return Collections.singletonList(
- new NxMatchRegister(ElanConstants.ELAN_REG_ID, elanTag, MetaDataUtil.getElanMaskForReg()));
- }
-
/**
* Create ietf-interfaces based on the ELAN segment type.<br>
* For segment type flat - create transparent interface pointing to the
+++ /dev/null
-/*
- * Copyright (c) 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,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.netvirt.elan.l2gw.ha;
-
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.FluentFuture;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.genius.utils.batching.ResourceBatchingManager;
-import org.opendaylight.mdsal.common.api.CommitInfo;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-public class BatchedTransaction implements ReadWriteTransaction {
-
- @Override
- public <T extends DataObject> CheckedFuture<Optional<T>, ReadFailedException> read(
- LogicalDatastoreType logicalDatastoreType, InstanceIdentifier<T> instanceIdentifier) {
- return ResourceBatchingManager.getInstance().read(getShard(logicalDatastoreType).name(), instanceIdentifier);
- }
-
- ResourceBatchingManager.ShardResource getShard(LogicalDatastoreType logicalDatastoreType) {
- if (logicalDatastoreType == LogicalDatastoreType.CONFIGURATION) {
- return ResourceBatchingManager.ShardResource.CONFIG_TOPOLOGY;
- }
- return ResourceBatchingManager.ShardResource.OPERATIONAL_TOPOLOGY;
- }
-
- @Override
- public <T extends DataObject> void put(
- LogicalDatastoreType logicalDatastoreType, InstanceIdentifier<T> instanceIdentifier, T dataObj) {
- ResourceBatchingManager.getInstance().put(getShard(logicalDatastoreType), instanceIdentifier, dataObj);
- }
-
- @Override
- public <T extends DataObject> void put(LogicalDatastoreType logicalDatastoreType,
- InstanceIdentifier<T> instanceIdentifier, T dataObj, boolean flag) {
- ResourceBatchingManager.getInstance().put(getShard(logicalDatastoreType), instanceIdentifier, dataObj);
- }
-
- @Override
- public <T extends DataObject> void merge(LogicalDatastoreType logicalDatastoreType,
- InstanceIdentifier<T> instanceIdentifier, T dataObj) {
- ResourceBatchingManager.getInstance().merge(getShard(logicalDatastoreType), instanceIdentifier, dataObj);
- }
-
- @Override
- public <T extends DataObject> void merge(LogicalDatastoreType logicalDatastoreType,
- InstanceIdentifier<T> instanceIdentifier, T dataObj, boolean flag) {
- ResourceBatchingManager.getInstance().merge(getShard(logicalDatastoreType), instanceIdentifier, dataObj);
- }
-
- @Override
- public boolean cancel() {
- return false;
- }
-
- @Override
- public void delete(LogicalDatastoreType logicalDatastoreType, InstanceIdentifier<?> instanceIdentifier) {
- ResourceBatchingManager.getInstance().delete(getShard(logicalDatastoreType), instanceIdentifier);
- }
-
- @Override
- public @NonNull FluentFuture<? extends @NonNull CommitInfo> commit() {
- return CommitInfo.emptyFluentFuture();
- }
-
- @Override
- public Object getIdentifier() {
- return "BatchedTransaction";
- }
-}
package org.opendaylight.netvirt.elan.l2gw.ha;
import static org.opendaylight.controller.md.sal.binding.api.WriteTransaction.CREATE_MISSING_PARENTS;
-import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.OPERATIONAL;
import com.google.common.base.Optional;
import com.google.common.base.Strings;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
-import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.genius.infra.Datastore;
import org.opendaylight.genius.infra.Datastore.Configuration;
-import org.opendaylight.genius.infra.Datastore.Operational;
import org.opendaylight.genius.infra.TypedReadWriteTransaction;
import org.opendaylight.genius.infra.TypedWriteTransaction;
import org.opendaylight.genius.utils.hwvtep.HwvtepNodeHACache;
return tpId.firstKeyOf(TerminationPoint.class).getTpId().getValue().substring("vxlan_over_ipv4:".length());
}
- public static String getLogicalSwitchSwitchName(HwvtepLogicalSwitchRef logicalSwitchRef) {
- InstanceIdentifier<LogicalSwitches> id = (InstanceIdentifier<LogicalSwitches>) logicalSwitchRef.getValue();
- return id.firstKeyOf(LogicalSwitches.class).getHwvtepNodeName().getValue();
- }
-
- public static String getNodeIdFromLocatorRef(HwvtepPhysicalLocatorRef locatorRef) {
- InstanceIdentifier<TerminationPoint> tpId = (InstanceIdentifier<TerminationPoint>) locatorRef.getValue();
- return tpId.firstKeyOf(Node.class).getNodeId().getValue();
- }
-
- public static String getNodeIdFromLogicalSwitches(HwvtepLogicalSwitchRef logicalSwitchRef) {
- InstanceIdentifier<LogicalSwitches> id = (InstanceIdentifier<LogicalSwitches>) logicalSwitchRef.getValue();
- return id.firstKeyOf(Node.class).getNodeId().getValue();
- }
-
public static InstanceIdentifier<Node> createInstanceIdentifierFromHAId(String haUUidVal) {
String nodeString = HWVTEP_URI_PREFIX + "://"
+ UUID + "/" + java.util.UUID.nameUUIDFromBytes(haUUidVal.getBytes(StandardCharsets.UTF_8)).toString();
return null;
}
- @Nullable
- public static String getPsName(Node psNode) {
- String psNodeId = psNode.getNodeId().getValue();
- if (psNodeId.contains(PHYSICALSWITCH)) {
- return psNodeId.substring(psNodeId.indexOf(PHYSICALSWITCH) + PHYSICALSWITCH.length());
- }
- return null;
- }
-
@Nullable
public static String getPsName(InstanceIdentifier<Node> psNodeIid) {
String psNodeId = psNodeIid.firstKeyOf(Node.class).getNodeId().getValue();
}
}
- /**
- * Delete switches from Node in Operational Data Tree .
- *
- * @param haPath HA node path from whih switches will be deleted
- * @param tx Transaction object
- */
- public static void deleteSwitchesManagedByNode(InstanceIdentifier<Node> haPath,
- TypedReadWriteTransaction<Operational> tx) throws ExecutionException, InterruptedException {
-
- Optional<Node> nodeOptional = tx.read(haPath).get();
- if (!nodeOptional.isPresent()) {
- return;
- }
- Node node = nodeOptional.get();
- HwvtepGlobalAugmentation globalAugmentation = node.augmentation(HwvtepGlobalAugmentation.class);
- if (globalAugmentation == null) {
- return;
- }
- List<Switches> switches = globalAugmentation.getSwitches();
- if (switches != null) {
- for (Switches switche : switches) {
- InstanceIdentifier<Node> id = (InstanceIdentifier<Node>)switche.getSwitchRef().getValue();
- deleteNodeIfPresent(tx, id);
- }
- }
- }
-
- /**
- * Returns true/false if all the childrens are deleted from Operational Data store.
- *
- * @param children IID for the child node to read from OP data tree
- * @param tx Transaction
- * @return true/false boolean
- * @throws ReadFailedException Exception thrown if read fails
- */
- public static boolean areAllChildDeleted(Set<InstanceIdentifier<Node>> children,
- ReadWriteTransaction tx) throws ReadFailedException {
- for (InstanceIdentifier<Node> childId : children) {
- if (tx.read(OPERATIONAL, childId).checkedGet().isPresent()) {
- return false;
- }
- }
- return true;
- }
-
public static void addToCacheIfHAChildNode(InstanceIdentifier<Node> childPath, Node childNode,
HwvtepNodeHACache hwvtepNodeHACache) {
String haId = HwvtepHAUtil.getHAIdFromManagerOtherConfig(childNode);
Z src,
InstanceIdentifier<Node> nodePath);
- /**
- * Abstract function to merge data from src to dst in Config Topology.
- * @param dst builder which will be used to build concrete object
- * @param src builder which are to be merged in destination
- * @param nodePath nodePath of dest
- */
- void mergeConfigData(Y dst,
- Z src,
- InstanceIdentifier<Node> nodePath);
-
- /**
- * Abstract function to update data from src to dst in Config Topology.
- * while existing data helps in keeping track of data only updated
- * @param existingData dataObject which are already exisitng
- * @param updated updated data
- * @param orig original data
- * @param nodePath nodePath of dest
- * @param tx ReadWriteTransaction
- */
- void mergeConfigUpdate(Z existingData,
- Z updated,
- Z orig,
- InstanceIdentifier<Node> nodePath,
- ReadWriteTransaction tx);
-
/**
* Abstract function to update data from src to dst in Operational Topology.
* while existing data helps in keeping track of data only updated
*/
package org.opendaylight.netvirt.elan.l2gw.ha.commands;
-import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION;
import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.OPERATIONAL;
import static org.opendaylight.netvirt.elan.l2gw.ha.HwvtepHAUtil.isEmptyList;
}
}
- @Override
public void mergeConfigData(Y dst,
Z src,
InstanceIdentifier<Node> nodePath) {
}
}
- @Override
- public void mergeConfigUpdate(Z existing,
- Z updated,
- Z orig,
- InstanceIdentifier<Node> nodePath,
- ReadWriteTransaction tx) {
- List<T> updatedData = getData(updated);
- List<T> origData = getData(orig);
- List<T> existingData = getData(existing);
- transformUpdate(existingData, updatedData, origData, nodePath, CONFIGURATION, tx);
- }
-
@Override
public void mergeOpUpdate(Z origDst,
Z updatedSrc,
*/
package org.opendaylight.netvirt.elan.l2gw.ha.handlers;
-import com.google.common.base.Optional;
-import java.util.concurrent.ExecutionException;
import javax.inject.Inject;
import javax.inject.Singleton;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.genius.infra.Datastore.Configuration;
import org.opendaylight.genius.infra.Datastore.Operational;
import org.opendaylight.genius.infra.TypedReadWriteTransaction;
-import org.opendaylight.genius.utils.hwvtep.HwvtepNodeHACache;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@Singleton
public class HAEventHandler implements IHAEventHandler {
- private final NodeConnectedHandler nodeConnectedHandler;
private final ConfigNodeUpdatedHandler configNodeUpdatedHandler = new ConfigNodeUpdatedHandler();
private final OpNodeUpdatedHandler opNodeUpdatedHandler = new OpNodeUpdatedHandler();
@Inject
- public HAEventHandler(DataBroker db, HwvtepNodeHACache hwvtepNodeHACache) {
- nodeConnectedHandler = new NodeConnectedHandler(db, hwvtepNodeHACache);
- }
-
- @Override
- public void handleChildNodeConnected(Node connectedNode,
- InstanceIdentifier<Node> connectedNodePath,
- InstanceIdentifier<Node> haNodePath,
- TypedReadWriteTransaction<Configuration> confTx,
- TypedReadWriteTransaction<Operational> operTx)
- throws ReadFailedException, ExecutionException, InterruptedException {
- if (haNodePath == null) {
- return;
- }
- nodeConnectedHandler.handleNodeConnected(connectedNode, connectedNodePath, haNodePath,
- Optional.absent(), Optional.absent(), confTx, operTx);
- }
-
- @Override
- public void handleChildNodeReConnected(Node connectedNode,
- InstanceIdentifier<Node> connectedNodePath,
- InstanceIdentifier<Node> haNodePath,
- Optional<Node> haGlobalCfg,
- Optional<Node> haPSCfg,
- TypedReadWriteTransaction<Configuration> confTx,
- TypedReadWriteTransaction<Operational> operTx)
- throws ReadFailedException, ExecutionException, InterruptedException {
- if (haNodePath == null) {
- return;
- }
- nodeConnectedHandler.handleNodeConnected(connectedNode, connectedNodePath, haNodePath,
- haGlobalCfg, haPSCfg, confTx, operTx);
+ public HAEventHandler() {
}
@Override
*/
package org.opendaylight.netvirt.elan.l2gw.ha.handlers;
-import com.google.common.base.Optional;
-
-import java.util.concurrent.ExecutionException;
import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.genius.infra.Datastore.Configuration;
import org.opendaylight.genius.infra.Datastore.Operational;
import org.opendaylight.genius.infra.TypedReadWriteTransaction;
public interface IHAEventHandler {
- void handleChildNodeConnected(Node connectedNode,
- InstanceIdentifier<Node> connectedNodePath,
- InstanceIdentifier<Node> haNodePath,
- TypedReadWriteTransaction<Configuration> confTx,
- TypedReadWriteTransaction<Operational> operTx)
- throws ReadFailedException, ExecutionException, InterruptedException;
-
- void handleChildNodeReConnected(Node connectedNode,
- InstanceIdentifier<Node> connectedNodePath,
- InstanceIdentifier<Node> haNodePath,
- Optional<Node> haGlobalCfg,
- Optional<Node> haPSCfg,
- TypedReadWriteTransaction<Configuration> confTx,
- TypedReadWriteTransaction<Operational> operTx)
- throws ReadFailedException, ExecutionException, InterruptedException;
-
void copyChildGlobalOpUpdateToHAParent(InstanceIdentifier<Node> haPath,
DataObjectModification<Node> mod,
+++ /dev/null
-/*
- * Copyright (c) 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,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.netvirt.elan.l2gw.ha.handlers;
-
-import com.google.common.base.Optional;
-import java.util.concurrent.ExecutionException;
-import org.opendaylight.genius.infra.Datastore;
-import org.opendaylight.genius.infra.TypedReadWriteTransaction;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-public interface INodeCopier {
-
- <D extends Datastore> void copyGlobalNode(Optional<Node> globalNodeOptional,
- InstanceIdentifier<Node> srcPath,
- InstanceIdentifier<Node> dstPath,
- Class<D> datastoreType,
- TypedReadWriteTransaction<D> tx)
- throws ExecutionException, InterruptedException;
-
- <D extends Datastore> void copyPSNode(Optional<Node> psNodeOptional,
- InstanceIdentifier<Node> srcPsPath,
- InstanceIdentifier<Node> dstPsPath,
- InstanceIdentifier<Node> dstGlobalPath,
- Class<D> datastoreType,
- TypedReadWriteTransaction<D> tx)
- throws ExecutionException, InterruptedException;
-}
import org.slf4j.LoggerFactory;
@Singleton
-public class NodeCopier implements INodeCopier {
+public class NodeCopier {
private static final Logger LOG = LoggerFactory.getLogger(NodeCopier.class);
this.txRunner = new ManagedNewTransactionRunnerImpl(db);
}
- @Override
public <D extends Datastore> void copyGlobalNode(Optional<Node> srcGlobalNodeOptional,
InstanceIdentifier<Node> srcPath,
InstanceIdentifier<Node> dstPath,
}
}
- @Override
public <D extends Datastore> void copyPSNode(Optional<Node> srcPsNodeOptional,
InstanceIdentifier<Node> srcPsPath,
InstanceIdentifier<Node> dstPsPath,
+++ /dev/null
-/*
- * Copyright (c) 2016 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.netvirt.elan.l2gw.ha.handlers;
-
-public class NodeDisconnectedHandler {
-}
@Override
void onPsNodeUpdate(Node haPSUpdated,
- Node haPSOriginal,
- DataObjectModification<Node> mod,
- TypedReadWriteTransaction<Configuration> tx) {
+ DataObjectModification<Node> mod,
+ TypedReadWriteTransaction<Configuration> tx) {
//copy the ps node data to children
String psId = haPSUpdated.getNodeId().getValue();
Set<InstanceIdentifier<Node>> childSwitchIds = getPSChildrenIdsForHAPSNode(psId);
package org.opendaylight.netvirt.elan.l2gw.ha.listeners;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
-
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
return instance;
}
- public void setThreadPool(ExecutorService service) {
- executorService = service;
- }
-
public void submitJob(Runnable runnable) {
executorService.execute(runnable);
}
@Override
void onPsNodeUpdate(Node updatedChildPSNode,
- Node originalChildPSNode,
- DataObjectModification<Node> mod,
- TypedReadWriteTransaction<Operational> tx) {
+ DataObjectModification<Node> mod,
+ TypedReadWriteTransaction<Operational> tx) {
InstanceIdentifier<Node> childGlobalPath = HwvtepHAUtil.getGlobalNodePathFromPSNode(updatedChildPSNode);
if (isNotHAChild(childGlobalPath)) {
return;
onGlobalNodeUpdate(key, updated, original, mod, tx);
subMod = change.getRootNode().getModifiedAugmentation(HwvtepGlobalAugmentation.class);
} else {
- onPsNodeUpdate(updated, original, mod, tx);
+ onPsNodeUpdate(updated, mod, tx);
subMod = change.getRootNode().getModifiedAugmentation(PhysicalSwitchAugmentation.class);
}
if (subMod != null) {
}
- void onPsNodeUpdate(Node updated, Node original,
+ void onPsNodeUpdate(Node updated,
DataObjectModification<Node> mod, TypedReadWriteTransaction<D> tx)
throws ReadFailedException, InterruptedException, ExecutionException {
LogicalSwitchAddedJob logicalSwitchAddedJob =
new LogicalSwitchAddedJob(elanL2GatewayUtils, elanL2GatewayMulticastUtils,
- logicalSwitchName, l2Device, l2GatewayDevice, defaultVlan,
- () -> elanInstanceCache.get(logicalSwitchName).orNull());
+ logicalSwitchName, l2Device, l2GatewayDevice, defaultVlan
+ );
return logicalSwitchAddedJob.call();
}
}
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
-import java.util.function.Supplier;
import javax.annotation.Nullable;
import org.opendaylight.netvirt.elan.l2gw.ha.HwvtepHAUtil;
import org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayMulticastUtils;
import org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayUtils;
import org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
import org.slf4j.Logger;
private final Integer defaultVlan;
private final boolean isLastL2GwConnDeleted;
private final NodeId hwvtepNodeId;
- private final Supplier<ElanInstance> elanInstanceSupplier;
public DisAssociateHwvtepFromElanJob(ElanL2GatewayUtils elanL2GatewayUtils,
ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils,
- @Nullable L2GatewayDevice l2GatewayDevice, String elanName,
- Supplier<ElanInstance> elanInstanceSupplier, Devices l2Device,
+ @Nullable L2GatewayDevice l2GatewayDevice, String elanName,
+ Devices l2Device,
Integer defaultVlan, String nodeId, boolean isLastL2GwConnDeleted) {
this.elanL2GatewayUtils = elanL2GatewayUtils;
this.elanL2GatewayMulticastUtils = elanL2GatewayMulticastUtils;
this.l2GatewayDevice = l2GatewayDevice;
this.elanName = elanName;
- this.elanInstanceSupplier = elanInstanceSupplier;
this.l2Device = l2Device;
this.defaultVlan = defaultVlan;
this.isLastL2GwConnDeleted = isLastL2GwConnDeleted;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
-import java.util.function.Supplier;
import org.opendaylight.netvirt.elan.l2gw.ha.HwvtepHAUtil;
import org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayMulticastUtils;
import org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayUtils;
import org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
import org.slf4j.Logger;
private final ElanL2GatewayUtils elanL2GatewayUtils;
private final ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils;
- private final Supplier<ElanInstance> elanInstanceSupplier;
public LogicalSwitchAddedJob(ElanL2GatewayUtils elanL2GatewayUtils,
ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils, String logicalSwitchName,
- Devices physicalDevice, L2GatewayDevice l2GatewayDevice, Integer defaultVlanId,
- Supplier<ElanInstance> elanInstanceSupplier) {
+ Devices physicalDevice, L2GatewayDevice l2GatewayDevice, Integer defaultVlanId) {
this.elanL2GatewayUtils = elanL2GatewayUtils;
this.elanL2GatewayMulticastUtils = elanL2GatewayMulticastUtils;
this.logicalSwitchName = logicalSwitchName;
this.physicalDevice = physicalDevice;
this.elanL2GwDevice = l2GatewayDevice;
this.defaultVlanId = defaultVlanId;
- this.elanInstanceSupplier = elanInstanceSupplier;
LOG.debug("created logical switch added job for {} {}", logicalSwitchName, elanL2GwDevice.getHwvtepNodeId());
}
+++ /dev/null
-/*
- * Copyright (c) 2016 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.netvirt.elan.l2gw.listeners;
-
-import java.util.Collections;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.genius.datastoreutils.hwvtep.HwvtepClusteredDataTreeChangeListener;
-import org.opendaylight.genius.utils.batching.ResourceBatchingManager;
-import org.opendaylight.genius.utils.hwvtep.HwvtepNodeHACache;
-import org.opendaylight.genius.utils.hwvtep.HwvtepUtils;
-import org.opendaylight.netvirt.elan.cache.ElanInstanceCache;
-import org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayUtils;
-import org.opendaylight.netvirt.elanmanager.utils.ElanL2GwCacheUtils;
-import org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.IetfYangUtil;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LocalUcastMacs;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * A listener for Ucast MAC entries that are added/removed to/from an External
- * Device (e.g., TOR).
- *
- * <p>When a Ucast MAC addr appears in the hwvtep's operational DS, that MAC must
- * be populated in DMAC tables in all Elan participating DPNs. ELAN is selected
- * according to field 'tunnel_key' of the Logical Switch to which the new MAC
- * belongs.
- */
-public class HwvtepLocalUcastMacListener extends
- HwvtepClusteredDataTreeChangeListener<LocalUcastMacs, HwvtepLocalUcastMacListener> {
-
- private static final Logger LOG = LoggerFactory.getLogger(HwvtepLocalUcastMacListener.class);
-
- private final DataBroker broker;
- private final ElanL2GatewayUtils elanL2GatewayUtils;
- private final ElanInstanceCache elanInstanceCache;
-
- public HwvtepLocalUcastMacListener(DataBroker broker, ElanL2GatewayUtils elanL2GatewayUtils,
- ElanInstanceCache elanInstanceCache, HwvtepNodeHACache hwvtepNodeHACache) {
- super(LocalUcastMacs.class, HwvtepLocalUcastMacListener.class, hwvtepNodeHACache);
-
- this.broker = broker;
- this.elanL2GatewayUtils = elanL2GatewayUtils;
- this.elanInstanceCache = elanInstanceCache;
- ResourceBatchingManager.getInstance().registerDefaultBatchHandlers(this.broker);
- }
-
- public void init() {
- registerListener(LogicalDatastoreType.OPERATIONAL, broker);
- }
-
- @Override
- protected void removed(InstanceIdentifier<LocalUcastMacs> identifier, LocalUcastMacs macRemoved) {
- String hwvtepNodeId = identifier.firstKeyOf(Node.class).getNodeId().getValue();
- MacAddress macAddress = IetfYangUtil.INSTANCE.canonizeMacAddress(macRemoved.getMacEntryKey());
-
- LOG.trace("LocalUcastMacs {} removed from {}", macAddress.getValue(), hwvtepNodeId);
-
- String elanName = getElanName(macRemoved);
-
- L2GatewayDevice elanL2GwDevice = ElanL2GwCacheUtils.getL2GatewayDeviceFromCache(elanName, hwvtepNodeId);
- if (elanL2GwDevice == null) {
- LOG.warn("Could not find L2GatewayDevice for ELAN: {}, nodeID:{} from cache", elanName, hwvtepNodeId);
- return;
- }
-
- // Remove MAC from cache
- elanL2GwDevice.removeUcastLocalMac(macRemoved);
- elanL2GatewayUtils.unInstallL2GwUcastMacFromL2gwDevices(elanName, elanL2GwDevice,
- Collections.singletonList(macAddress));
- elanL2GatewayUtils.unInstallL2GwUcastMacFromElanDpns(elanInstanceCache.get(elanName).orNull(),
- elanL2GwDevice, Collections.singletonList(macAddress));
- }
-
- protected String getElanName(LocalUcastMacs mac) {
- return mac.getLogicalSwitchRef().getValue()
- .firstKeyOf(LogicalSwitches.class).getHwvtepNodeName().getValue();
- }
-
- @Override
- protected void updated(InstanceIdentifier<LocalUcastMacs> identifier, LocalUcastMacs original,
- LocalUcastMacs update) {
- // TODO (eperefr) what can change here?
-
- }
-
- @Override
- public void added(InstanceIdentifier<LocalUcastMacs> identifier, LocalUcastMacs macAdded) {
- String hwvtepNodeId = identifier.firstKeyOf(Node.class).getNodeId().getValue();
- String macAddress = IetfYangUtil.INSTANCE.canonizeMacAddress(macAdded.getMacEntryKey()).getValue();
-
- LOG.trace("LocalUcastMacs {} added to {}", macAddress, hwvtepNodeId);
-
- String elanName = getElanName(macAdded);
- ElanInstance elan = elanInstanceCache.get(elanName).orNull();
- if (elan == null) {
- LOG.warn("Could not find ELAN for mac {} being added", macAddress);
- return;
- }
-
- L2GatewayDevice elanL2GwDevice = ElanL2GwCacheUtils.getL2GatewayDeviceFromCache(elanName, hwvtepNodeId);
- if (elanL2GwDevice == null) {
- LOG.warn("Could not find L2GatewayDevice for ELAN: {}, nodeID:{} from cache", elanName, hwvtepNodeId);
- return;
- }
-
- // Cache MAC for furthur processing later
- elanL2GwDevice.addUcastLocalMac(macAdded);
-
- elanL2GatewayUtils.installL2GwUcastMacInElan(elan, elanL2GwDevice, macAddress, macAdded, null);
- }
-
- @Override
- protected InstanceIdentifier<LocalUcastMacs> getWildCardPath() {
- return HwvtepUtils.getWildCardPathForLocalUcastMacs();
- }
-
- @Override
- protected HwvtepLocalUcastMacListener getDataTreeChangeListener() {
- return this;
- }
-}
LogicalSwitchAddedJob logicalSwitchAddedWorker = new LogicalSwitchAddedJob(
elanL2GatewayUtils, elanL2GatewayMulticastUtils, logicalSwitchName, physicalDevice, elanDevice,
- defaultVlanId, () -> elanInstanceCache.get(logicalSwitchName).orNull());
+ defaultVlanId);
elanClusterUtils.runOnlyInOwnerNode(logicalSwitchAddedWorker.getJobKey(),
"create vlan mappings and mcast configurations", logicalSwitchAddedWorker);
} catch (RuntimeException e) {
return HwvtepUtils.deleteRemoteUcastMacs(broker, nodeId, logicalSwitchName, lstMac);
}
- @Nullable
- public ElanInstance getElanInstanceForUcastLocalMac(LocalUcastMacs localUcastMac) {
- Optional<LogicalSwitches> lsOpc = ElanUtils.read(broker, LogicalDatastoreType.OPERATIONAL,
- (InstanceIdentifier<LogicalSwitches>) localUcastMac.getLogicalSwitchRef().getValue());
- if (lsOpc.isPresent()) {
- LogicalSwitches ls = lsOpc.get();
- // Logical switch name is Elan name
- String elanName = getElanFromLogicalSwitch(ls.getHwvtepNodeName().getValue());
- return elanInstanceCache.get(elanName).orNull();
- }
- return null;
- }
-
/**
* Install external device local macs in dpn.
*
});
}
- /**
- * Gets the elan name from logical switch name.
- *
- * @param logicalSwitchName
- * the logical switch name
- * @return the elan name from logical switch name
- */
- public static String getElanFromLogicalSwitch(String logicalSwitchName) {
- // Assuming elan name is same as logical switch name
- String elanName = logicalSwitchName;
- return elanName;
- }
-
/**
* Gets the logical switch name from elan name.
*
}
}
- public static String getNodeIdFromDpnId(BigInteger dpnId) {
- return MDSALUtil.NODE_PREFIX + MDSALUtil.SEPARATOR + dpnId.toString();
- }
-
public void scheduleAddDpnMacInExtDevices(String elanName, BigInteger dpId,
List<PhysAddress> staticMacAddresses) {
ConcurrentMap<String, L2GatewayDevice> elanDevices = ElanL2GwCacheUtils.getInvolvedL2GwDevices(elanName);
DisAssociateHwvtepFromElanJob disAssociateHwvtepToElanJob =
new DisAssociateHwvtepFromElanJob(elanL2GatewayUtils, elanL2GatewayMulticastUtils,
- elanL2GwDevice, elanName, () -> elanInstanceCache.get(elanName).orNull(),
- l2Device, defaultVlan, hwvtepNodeId, isLastL2GwConnDeleted);
+ elanL2GwDevice, elanName,
+ l2Device, defaultVlan, hwvtepNodeId, isLastL2GwConnDeleted);
elanClusterUtils.runOnlyInOwnerNode(disAssociateHwvtepToElanJob.getJobKey(), "remove l2gw connection job",
disAssociateHwvtepToElanJob);
}
return getFutureWithAppErrorMessage(rpcResultBuilder,
String.format("Interface %s is not a ELAN interface", interfaceName));
}
- String elanInstanceName = elanInterface.get().getElanInstanceName();
InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(interfaceName);
- //FIXME [ELANBE] Get this API Later
- short tableId = 0;
-// try {
-//
-// //tableId = interfaceManager.getTableIdForService(interfaceName, serviceInfo);
-// } catch (InterfaceNotFoundException | InterfaceServiceNotFoundException e) {
-// rpcResultBuilder = RpcResultBuilder.failed();
-// return getFutureWithAppErrorMessage(rpcResultBuilder,
-// String.format("Interface %s or Service %s doesn't exist", interfaceName, serviceInfo));
-// }
if (!interfaceInfo.isOperational()) {
LOG.debug("interface {} is down and returning with no statistics", interfaceName);
rpcResultBuilder = RpcResultBuilder.success();
.build()).buildFuture();
}
rpcResultBuilder = RpcResultBuilder.success();
- return Futures.immediateFuture(rpcResultBuilder
- .withResult(queryforElanInterfaceStatistics(tableId, elanInstanceName, interfaceInfo)).build());
+ return Futures.immediateFuture(rpcResultBuilder.withResult(queryforElanInterfaceStatistics()).build());
}
@Nullable
- private GetElanInterfaceStatisticsOutput queryforElanInterfaceStatistics(short tableId, String elanInstanceName,
- InterfaceInfo interfaceInfo) {
-// BigInteger dpId = interfaceInfo.getDpId();
-// List<MatchInfo> matches;
-// String interfaceName = interfaceInfo.getInterfaceName();
-// if (interfaceInfo instanceof VlanInterfaceInfo) {
-// VlanInterfaceInfo vlanInterfaceInfo = (VlanInterfaceInfo)interfaceInfo;
-// matches = InterfaceServiceUtil.getMatchInfoForVlanLPort(dpId, interfaceInfo.getPortNo(),
-// InterfaceServiceUtil.getVlanId(interfaceName, dataBroker), vlanInterfaceInfo.isVlanTransparent());
-// } else {
-// matches = InterfaceServiceUtil.getLPortDispatcherMatches(
-// ServiceIndex.getIndex(NwConstants.ELAN_SERVICE_NAME, NwConstants.ELAN_SERVICE_INDEX),
-// interfaceInfo.getInterfaceTag());
-// }
-// long groupId = interfaceInfo.getGroupId();
-// Set<Object> statRequestKeys = InterfaceServiceUtil.getStatRequestKeys(dpId, tableId, matches,
-// String.format("%s.%s", elanInstanceName, interfaceName), groupId);
- // StatisticsInfo statsInfo = new StatisticsInfo(statRequestKeys);
-// org.opendaylight.vpnservice.ericsson.mdsalutil.statistics.StatResult statResult
-// = mdsalMgr.queryForStatistics(interfaceName, statsInfo);
-// ResultCode resultCode = ResultCode.Success;
-// if (!statResult.isComplete()) {
-// resultCode = ResultCode.Incomplete;
-// }
-
- //StatValue ingressFlowStats = statResult.getStatResult(InterfaceServiceUtil
-// .getFlowStatisticsKey(dpId, tableId, matches, elanInstanceName));
- //StatValue groupStats = statResult.getStatResult(InterfaceServiceUtil.getGroupStatisticsKey(dpId, groupId));
-// return new GetElanInterfaceStatisticsOutputBuilder().setStatResult(new
-// StatResultBuilder().setStatResultCode(resultCode)
-// .setByteRxCount(ingressFlowStats.getByteCount()).setPacketRxCount(ingressFlowStats.getPacketCount())
-// .setByteTxCount(groupStats.getByteCount()).setPacketTxCount(groupStats.getPacketCount()).build())
-// .build();
+ private GetElanInterfaceStatisticsOutput queryforElanInterfaceStatistics() {
return null;
}
import javax.annotation.Nullable;
import javax.inject.Inject;
import javax.inject.Singleton;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.genius.mdsalutil.MDSALUtil;
import org.opendaylight.genius.mdsalutil.MatchInfo;
import org.opendaylight.genius.mdsalutil.NwConstants;
private static final boolean SH_FLAG_SET = true;
private static final boolean SH_FLAG_UNSET = false;
- private final DataBroker broker;
private final ElanItmUtils elanItmUtils;
private final ElanEtreeUtils elanEtreeUtils;
private final ElanInterfaceCache elanInterfaceCache;
@Inject
- public ElanDmacUtils(DataBroker broker, ElanItmUtils elanItmUtils, ElanEtreeUtils elanEtreeUtils,
+ public ElanDmacUtils(ElanItmUtils elanItmUtils, ElanEtreeUtils elanEtreeUtils,
ElanInterfaceCache elanInterfaceCache) {
- this.broker = broker;
this.elanItmUtils = elanItmUtils;
this.elanEtreeUtils = elanEtreeUtils;
this.elanInterfaceCache = elanInterfaceCache;
ElanConstants.COOKIE_ELAN_KNOWN_DMAC.add(BigInteger.valueOf(elanTag)), mkMatches, mkInstructions);
}
- /**
- * Installs a Flow in the specified DPN's DMAC table. The flow is for a MAC
- * that is connected remotely in an External Device (TOR) and that is
- * accessible through an external tunnel. It also installs the flow for
- * dropping the packet if it came over an ITM tunnel (that is, if the
- * Split-Horizon flag is set)
- *
- * @param dpnId
- * Id of the DPN where the flow must be installed
- * @param extDeviceNodeId
- * the ext device node id
- * @param elanTag
- * the elan tag
- * @param vni
- * the vni
- * @param macAddress
- * the mac address
- * @param displayName
- * the display name
- * @param interfaceName
- * the interface name
- *
- * @return the dmac flows
- */
- public List<ListenableFuture<Void>> installDmacFlowsToExternalRemoteMac(BigInteger dpnId,
- String extDeviceNodeId, Long elanTag, Long vni, String macAddress, String displayName,
- String interfaceName) {
- synchronized (ElanUtils.getElanMacDPNKey(elanTag, macAddress, dpnId)) {
- Flow flow = buildDmacFlowForExternalRemoteMac(dpnId, extDeviceNodeId, elanTag, vni, macAddress,
- displayName);
- ResourceBatchingManager.getInstance().put(
- ResourceBatchingManager.ShardResource.CONFIG_TOPOLOGY, ElanUtils.getFlowIid(flow, dpnId), flow);
-
- Flow dropFlow = buildDmacFlowDropIfPacketComingFromTunnel(dpnId, extDeviceNodeId, elanTag, macAddress);
- ResourceBatchingManager.getInstance().put(ResourceBatchingManager.ShardResource.CONFIG_TOPOLOGY,
- ElanUtils.getFlowIid(dropFlow, dpnId), dropFlow);
- installEtreeDmacFlowsToExternalRemoteMac(dpnId, extDeviceNodeId, elanTag, vni, macAddress, displayName,
- interfaceName);
- }
- return Collections.emptyList();
- }
-
- /**
- * Installs or removes flows in DMAC table for MACs that are/were located in
- * an external Elan Device.
- *
- * @param dpId
- * Id of the DPN where the DMAC table is going to be modified
- * @param extNodeId
- * Id of the External Device where the MAC is located
- * @param elanTag
- * Id of the ELAN
- * @param vni
- * VNI of the LogicalSwitch to which the MAC belongs to, and that
- * is associated with the ELAN
- * @param macAddress
- * the mac address
- * @param elanInstanceName
- * the elan instance name
- * @param addOrRemove
- * Indicates if flows must be installed or removed.
- * @param interfaceName
- * the interface name
- * @see org.opendaylight.genius.mdsalutil.MDSALUtil.MdsalOp
- */
- public void setupDmacFlowsToExternalRemoteMac(BigInteger dpId, String extNodeId, Long elanTag, Long vni,
- String macAddress, String elanInstanceName, MDSALUtil.MdsalOp addOrRemove, String interfaceName) {
- if (addOrRemove == MDSALUtil.MdsalOp.CREATION_OP) {
- installDmacFlowsToExternalRemoteMac(dpId, extNodeId, elanTag, vni, macAddress, elanInstanceName,
- interfaceName);
- } else if (addOrRemove == MDSALUtil.MdsalOp.REMOVAL_OP) {
- deleteDmacFlowsToExternalMac(elanTag, dpId, extNodeId, macAddress);
- }
- }
-
/**
* Delete dmac flows to external mac.
*
ResourceBatchingManager.ShardResource.CONFIG_TOPOLOGY, ElanUtils.getFlowIid(flowToRemove, dpId));
}
- private List<ListenableFuture<Void>> installEtreeDmacFlowsToExternalRemoteMac(
- BigInteger dpnId, String extDeviceNodeId, Long elanTag,
- Long vni, String macAddress, String displayName, String interfaceName) {
- EtreeLeafTagName etreeLeafTag = elanEtreeUtils.getEtreeLeafTagByElanTag(elanTag);
- if (etreeLeafTag != null) {
- return Lists.newArrayList(
- buildEtreeDmacFlowDropIfPacketComingFromTunnel(
- dpnId, extDeviceNodeId, macAddress, etreeLeafTag),
- buildEtreeDmacFlowForExternalRemoteMac(
- dpnId, extDeviceNodeId, vni, macAddress, displayName, interfaceName, etreeLeafTag));
- }
- return Collections.emptyList();
- }
-
- private ListenableFuture<Void> buildEtreeDmacFlowForExternalRemoteMac(
- BigInteger dpnId, String extDeviceNodeId, Long vni,
- String macAddress, String displayName, String interfaceName,
- EtreeLeafTagName etreeLeafTag) {
- boolean isRoot;
- if (interfaceName == null) {
- isRoot = true;
- } else {
- Optional<EtreeInterface> etreeInterface = elanInterfaceCache.getEtreeInterface(interfaceName);
- isRoot = etreeInterface.isPresent() ? etreeInterface.get().getEtreeInterfaceType()
- == EtreeInterface.EtreeInterfaceType.Root : false;
- }
- if (isRoot) {
- Flow flow = buildDmacFlowForExternalRemoteMac(dpnId, extDeviceNodeId,
- etreeLeafTag.getEtreeLeafTag().getValue(), vni, macAddress, displayName);
- return ResourceBatchingManager.getInstance().put(
- ResourceBatchingManager.ShardResource.CONFIG_TOPOLOGY, ElanUtils.getFlowIid(flow, dpnId), flow);
- }
- return Futures.immediateFuture(null);
- }
-
- private ListenableFuture<Void> buildEtreeDmacFlowDropIfPacketComingFromTunnel(
- BigInteger dpnId, String extDeviceNodeId, String macAddress, EtreeLeafTagName etreeLeafTag) {
- if (etreeLeafTag != null) {
- Flow dropFlow = buildDmacFlowDropIfPacketComingFromTunnel(dpnId, extDeviceNodeId,
- etreeLeafTag.getEtreeLeafTag().getValue(), macAddress);
- return ResourceBatchingManager.getInstance().put(
- ResourceBatchingManager.ShardResource.CONFIG_TOPOLOGY, ElanUtils.getFlowIid(dropFlow, dpnId),
- dropFlow);
- }
- return Futures.immediateFuture(null);
- }
-
/**
* Builds the flow that drops the packet if it came through an external
* tunnel, that is, if the Split-Horizon flag is set.
import com.google.common.base.Optional;
import com.google.common.util.concurrent.ListenableFuture;
-
import java.util.ArrayList;
import java.util.List;
-
import java.util.concurrent.ExecutionException;
import javax.inject.Inject;
import javax.inject.Singleton;
-
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.Datastore.Operational;
import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
import org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl;
import org.opendaylight.genius.infra.TypedReadWriteTransaction;
import org.opendaylight.genius.interfacemanager.globals.InterfaceInfo;
import org.opendaylight.infrautils.utils.concurrent.ListenableFutures;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.elan._interface.StaticMacEntries;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry;
ListenableFutures.addErrorLogging(future, LOG, "Error deleting ELAN interface forwarding entries");
}
}
-
- public void deleteElanInterfaceMacForwardingEntries(String interfaceName, PhysAddress physAddress,
- WriteTransaction tx) {
- InstanceIdentifier<MacEntry> macEntryId = ElanUtils
- .getInterfaceMacEntriesIdentifierOperationalDataPath(interfaceName, physAddress);
- tx.delete(LogicalDatastoreType.OPERATIONAL, macEntryId);
- }
-
-
}
import org.opendaylight.genius.infra.TypedReadWriteTransaction;
import org.opendaylight.genius.infra.TypedWriteTransaction;
import org.opendaylight.genius.interfacemanager.globals.InterfaceInfo;
-import org.opendaylight.genius.interfacemanager.globals.InterfaceServiceUtil;
import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
import org.opendaylight.genius.itm.api.IITMProvider;
import org.opendaylight.genius.itm.globals.ITMConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeLeafTagNameBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanForwardingTables;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInstances;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInterfaceForwardingEntries;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInterfaces;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanState;
Futures.addCallback(tx.submit(), DEFAULT_CALLBACK, MoreExecutors.directExecutor());
}
- @SuppressWarnings("checkstyle:ForbidCertainMethod")
- public static <T extends DataObject> void delete(DataBroker broker, LogicalDatastoreType datastoreType,
- InstanceIdentifier<T> path, FutureCallback<Void> callback) {
- WriteTransaction tx = broker.newWriteOnlyTransaction();
- tx.delete(datastoreType, path);
- Futures.addCallback(tx.submit(), callback, MoreExecutors.directExecutor());
- }
-
- public static InstanceIdentifier<ElanInstance> getElanInstanceIdentifier() {
- return InstanceIdentifier.builder(ElanInstances.class).child(ElanInstance.class).build();
- }
-
public static InstanceIdentifier<ElanInterface> getElanInterfaceConfigurationDataPathId(String interfaceName) {
return InstanceIdentifier.builder(ElanInterfaces.class)
.child(ElanInterface.class, new ElanInterfaceKey(interfaceName)).build();
return read(dataBroker, LogicalDatastoreType.OPERATIONAL, elanInterfaceId).orNull();
}
- /**
- * Gets the elan interface mac addresses.
- *
- * @param interfaceName
- * the interface name
- * @return the elan interface mac addresses
- */
- public List<PhysAddress> getElanInterfaceMacAddresses(String interfaceName) {
- List<PhysAddress> macAddresses = new ArrayList<>();
- ElanInterfaceMac elanInterfaceMac = getElanInterfaceMacByInterfaceName(interfaceName);
- if (elanInterfaceMac != null && elanInterfaceMac.getMacEntry() != null) {
- List<MacEntry> macEntries = elanInterfaceMac.getMacEntry();
- for (MacEntry macEntry : macEntries) {
- macAddresses.add(macEntry.getMacAddress());
- }
- }
- return macAddresses;
- }
-
public static InstanceIdentifier<ElanInterfaceMac> getElanInterfaceMacEntriesOperationalDataPath(
String interfaceName) {
return InstanceIdentifier.builder(ElanInterfaceForwardingEntries.class)
return dpIds;
}
- /**
- * To check given dpId is already present in Elan instance. This can be used
- * to program flow entry in external tunnel table when a new access port
- * added for first time into the ELAN instance
- *
- * @param dpId
- * the dp id
- * @param elanInstanceName
- * the elan instance name
- * @return true if dpId is already present, otherwise return false
- */
- public boolean isDpnAlreadyPresentInElanInstance(BigInteger dpId, String elanInstanceName) {
- InstanceIdentifier<ElanDpnInterfacesList> elanDpnInterfaceId = getElanDpnOperationDataPath(elanInstanceName);
- Optional<ElanDpnInterfacesList> existingElanDpnInterfaces = read(broker,
- LogicalDatastoreType.OPERATIONAL, elanDpnInterfaceId);
- if (!existingElanDpnInterfaces.isPresent()) {
- return false;
- }
- List<DpnInterfaces> dpnInterfaces = existingElanDpnInterfaces.get().nonnullDpnInterfaces();
- for (DpnInterfaces dpnInterface : dpnInterfaces) {
- if (Objects.equals(dpnInterface.getDpId(), dpId)) {
- return true;
- }
- }
- return false;
- }
-
- @Nullable
- public ElanForwardingTables getElanForwardingList() {
- InstanceIdentifier<ElanForwardingTables> elanForwardingTableId = InstanceIdentifier
- .builder(ElanForwardingTables.class).build();
- return read(broker, LogicalDatastoreType.OPERATIONAL, elanForwardingTableId).orNull();
- }
-
public static long getElanRemoteBroadCastGroupID(long elanTag) {
return ElanConstants.ELAN_GID_MIN + elanTag % ElanConstants.ELAN_GID_MIN * 2;
}
return read(broker, LogicalDatastoreType.CONFIGURATION, node).isPresent();
}
- public static ServicesInfo getServiceInfo(String elanInstanceName, String interfaceName) {
- return InterfaceServiceUtil.buildServiceInfo(elanInstanceName + "." + interfaceName,
- ElanConstants.ELAN_SERVICE_PRIORITY);
- }
-
public static String getElanServiceName(String elanName, String interfaceName) {
return "elan." + elanName + interfaceName;
}
return idBuilder.build();
}
- @CheckReturnValue
- public static CheckedFuture<Void, TransactionCommitFailedException> waitForTransactionToComplete(
- WriteTransaction tx) {
- CheckedFuture<Void, TransactionCommitFailedException> futures = tx.submit();
- try {
- futures.get();
- } catch (InterruptedException | ExecutionException e) {
- // NETVIRT-1215: Do not log.error() here, only debug(); but callers *MUST* @CheckReturnValue
- LOG.debug("Error writing to datastore", e);
- }
- return futures;
- }
-
@CheckReturnValue
public static ListenableFuture<Void> waitForTransactionToComplete(ListenableFuture<Void> future) {
try {
new StaticMacEntriesKey(new PhysAddress(macAddress))).build();
}
- public static List<StaticMacEntries> getDeletedEntries(List<StaticMacEntries> originalStaticMacEntries,
- List<StaticMacEntries> updatedStaticMacEntries) {
- if (isEmpty(originalStaticMacEntries)) {
- return Collections.EMPTY_LIST;
- }
- List<StaticMacEntries> deleted = Lists.newArrayList(originalStaticMacEntries);
- if (isNotEmpty(updatedStaticMacEntries)) {
- deleted.removeAll(updatedStaticMacEntries);
- }
- return deleted;
- }
-
public static <T> List<T> diffOf(List<T> orig, List<T> updated) {
if (isEmpty(orig)) {
return Collections.EMPTY_LIST;
return diff;
}
- public static void segregateToBeDeletedAndAddEntries(List<StaticMacEntries> originalStaticMacEntries,
- List<StaticMacEntries> updatedStaticMacEntries) {
- if (isNotEmpty(updatedStaticMacEntries)) {
- List<StaticMacEntries> existingClonedStaticMacEntries = new ArrayList<>();
- if (isNotEmpty(originalStaticMacEntries)) {
- existingClonedStaticMacEntries.addAll(0, originalStaticMacEntries);
- originalStaticMacEntries.removeAll(updatedStaticMacEntries);
- updatedStaticMacEntries.removeAll(existingClonedStaticMacEntries);
- }
- }
- }
-
public static boolean isEmpty(Collection collection) {
return collection == null || collection.isEmpty();
}
<service ref="elanServiceProvider" odl:type="default"
interface="org.opendaylight.netvirt.elanmanager.api.IElanService" />
- <service ref="elanBridgeManager" odl:type="default"
- interface="org.opendaylight.netvirt.elanmanager.api.IElanBridgeManager" />
-
- <!--<bean id="hwvtepLocalUcastMacListener"
- class="org.opendaylight.netvirt.elan.l2gw.listeners.HwvtepLocalUcastMacListener"
- init-method="init" destroy-method="close">
- <argument ref="dataBroker" />
- <argument ref="elanL2GatewayUtils" />
- </bean>-->
-
<service ref="l2gwServiceProvider" odl:type="default"
interface="org.opendaylight.netvirt.elanmanager.api.IL2gwService" />