use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.endpoint.endpoint.type.Interface in project netvirt by opendaylight.
the class ElanInterfaceManager method installDpnMacsInL2gwDevice.
/**
* Installs dpn macs in external device. first it checks if the physical
* locator towards this dpn tep is present or not if the physical locator is
* present go ahead and add the ucast macs otherwise update the mcast mac
* entry to include this dpn tep ip and schedule the job to put ucast macs
* once the physical locator is programmed in device
*
* @param elanName
* the elan name
* @param lstElanInterfaceNames
* the lst Elan interface names
* @param dpnId
* the dpn id
* @param externalNodeId
* the external node id
*/
private void installDpnMacsInL2gwDevice(String elanName, Set<String> lstElanInterfaceNames, BigInteger dpnId, NodeId externalNodeId) {
L2GatewayDevice elanL2GwDevice = ElanL2GwCacheUtils.getL2GatewayDeviceFromCache(elanName, externalNodeId.getValue());
if (elanL2GwDevice == null) {
LOG.debug("L2 gw device not found in elan cache for device name {}", externalNodeId);
return;
}
IpAddress dpnTepIp = elanItmUtils.getSourceDpnTepIp(dpnId, externalNodeId);
if (dpnTepIp == null) {
LOG.warn("Could not install dpn macs in l2gw device , dpnTepIp not found dpn : {} , nodeid : {}", dpnId, externalNodeId);
return;
}
String logicalSwitchName = ElanL2GatewayUtils.getLogicalSwitchFromElan(elanName);
RemoteMcastMacs remoteMcastMac = elanL2GatewayUtils.readRemoteMcastMac(externalNodeId, logicalSwitchName, LogicalDatastoreType.OPERATIONAL);
boolean phyLocAlreadyExists = ElanL2GatewayUtils.checkIfPhyLocatorAlreadyExistsInRemoteMcastEntry(externalNodeId, remoteMcastMac, dpnTepIp);
LOG.debug("phyLocAlreadyExists = {} for locator [{}] in remote mcast entry for elan [{}], nodeId [{}]", phyLocAlreadyExists, String.valueOf(dpnTepIp.getValue()), elanName, externalNodeId.getValue());
List<PhysAddress> staticMacs = elanL2GatewayUtils.getElanDpnMacsFromInterfaces(lstElanInterfaceNames);
if (phyLocAlreadyExists) {
elanL2GatewayUtils.scheduleAddDpnMacsInExtDevice(elanName, dpnId, staticMacs, elanL2GwDevice);
return;
}
elanL2GatewayMulticastUtils.scheduleMcastMacUpdateJob(elanName, elanL2GwDevice);
elanL2GatewayUtils.scheduleAddDpnMacsInExtDevice(elanName, dpnId, staticMacs, elanL2GwDevice);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.endpoint.endpoint.type.Interface in project netvirt by opendaylight.
the class ElanInterfaceManager method validateExternalTunnelStateEvent.
/**
* Validate external tunnel state event.
*
* @param externalTunnel
* the external tunnel
* @param intrf
* the intrf
* @return true, if successful
*/
private boolean validateExternalTunnelStateEvent(ExternalTunnel externalTunnel, Interface intrf) {
if (intrf.getOperStatus() == Interface.OperStatus.Up) {
String srcDevice = externalTunnel.getDestinationDevice();
String destDevice = externalTunnel.getSourceDevice();
ExternalTunnel otherEndPointExtTunnel = elanUtils.getExternalTunnel(srcDevice, destDevice, LogicalDatastoreType.CONFIGURATION);
LOG.trace("Validating external tunnel state: src tunnel {}, dest tunnel {}", externalTunnel, otherEndPointExtTunnel);
if (otherEndPointExtTunnel != null) {
boolean otherEndPointInterfaceOperational = ElanUtils.isInterfaceOperational(otherEndPointExtTunnel.getTunnelInterfaceName(), broker);
if (otherEndPointInterfaceOperational) {
return true;
} else {
LOG.debug("Other end [{}] of the external tunnel is not yet UP for {}", otherEndPointExtTunnel.getTunnelInterfaceName(), externalTunnel);
}
}
}
return false;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.endpoint.endpoint.type.Interface in project netvirt by opendaylight.
the class ElanInterfaceManager method addElanInterface.
List<ListenableFuture<Void>> addElanInterface(ElanInterface elanInterface, InterfaceInfo interfaceInfo, ElanInstance elanInstance) throws ElanException {
Preconditions.checkNotNull(elanInstance, "elanInstance cannot be null");
Preconditions.checkNotNull(interfaceInfo, "interfaceInfo cannot be null");
Preconditions.checkNotNull(elanInterface, "elanInterface cannot be null");
String interfaceName = elanInterface.getName();
String elanInstanceName = elanInterface.getElanInstanceName();
Elan elanInfo = ElanUtils.getElanByName(broker, elanInstanceName);
WriteTransaction tx = broker.newWriteOnlyTransaction();
if (elanInfo == null) {
List<String> elanInterfaces = new ArrayList<>();
elanInterfaces.add(interfaceName);
ElanUtils.updateOperationalDataStore(idManager, elanInstance, elanInterfaces, tx);
} else {
createElanStateList(elanInstanceName, interfaceName, tx);
}
boolean isFirstInterfaceInDpn = false;
// Specific actions to the DPN where the ElanInterface has been added,
// for example, programming the
// External tunnel table if needed or adding the ElanInterface to the
// DpnInterfaces in the operational DS.
BigInteger dpId = interfaceInfo.getDpId();
DpnInterfaces dpnInterfaces = null;
if (dpId != null && !dpId.equals(ElanConstants.INVALID_DPN)) {
InstanceIdentifier<DpnInterfaces> elanDpnInterfaces = ElanUtils.getElanDpnInterfaceOperationalDataPath(elanInstanceName, dpId);
Optional<DpnInterfaces> existingElanDpnInterfaces = ElanUtils.read(broker, LogicalDatastoreType.OPERATIONAL, elanDpnInterfaces);
if (!existingElanDpnInterfaces.isPresent()) {
isFirstInterfaceInDpn = true;
// ELAN's 1st ElanInterface added to this DPN
dpnInterfaces = createElanInterfacesList(elanInstanceName, interfaceName, dpId, tx);
// table, but only if Elan has VNI
if (isVxlanNetworkOrVxlanSegment(elanInstance)) {
setExternalTunnelTable(dpId, elanInstance);
}
elanL2GatewayUtils.installElanL2gwDevicesLocalMacsInDpn(dpId, elanInstance, interfaceName);
} else {
List<String> elanInterfaces = existingElanDpnInterfaces.get().getInterfaces();
elanInterfaces.add(interfaceName);
if (elanInterfaces.size() == 1) {
// 1st dpn interface
elanL2GatewayUtils.installElanL2gwDevicesLocalMacsInDpn(dpId, elanInstance, interfaceName);
}
dpnInterfaces = updateElanDpnInterfacesList(elanInstanceName, dpId, elanInterfaces, tx);
}
}
// add code to install Local/Remote BC group, unknow DMAC entry,
// terminating service table flow entry
// call bindservice of interfacemanager to create ingress table flow
// enty.
// Add interface to the ElanInterfaceForwardingEntires Container
createElanInterfaceTablesList(interfaceName, tx);
List<ListenableFuture<Void>> futures = new ArrayList<>();
futures.add(ElanUtils.waitForTransactionToComplete(tx));
installEntriesForFirstInterfaceonDpn(elanInstance, interfaceInfo, dpnInterfaces, isFirstInterfaceInDpn);
// for internal vlan networks
if (ElanUtils.isVlan(elanInstance) && !elanInstance.isExternal()) {
if (interfaceManager.isExternalInterface(interfaceName)) {
LOG.debug("adding vlan prv intf {} to elan {} BC group", interfaceName, elanInstanceName);
handleExternalInterfaceEvent(elanInstance, dpnInterfaces, dpId);
}
}
if (isFirstInterfaceInDpn && isVxlanNetworkOrVxlanSegment(elanInstance)) {
// update the remote-DPNs remoteBC group entry with Tunnels
LOG.trace("update remote bc group for elan {} on other DPNs for newly added dpn {}", elanInstance, dpId);
setElanAndEtreeBCGrouponOtherDpns(elanInstance, dpId);
}
String jobKey = ElanUtils.getElanInterfaceJobKey(interfaceName);
InterfaceAddWorkerOnElanInterface addWorker = new InterfaceAddWorkerOnElanInterface(jobKey, elanInterface, interfaceInfo, elanInstance, isFirstInterfaceInDpn, this);
jobCoordinator.enqueueJob(jobKey, addWorker, ElanConstants.JOB_MAX_RETRIES);
return futures;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.endpoint.endpoint.type.Interface in project netvirt by opendaylight.
the class ElanInterfaceManager method handleInternalTunnelStateEvent.
@SuppressWarnings("checkstyle:IllegalCatch")
public void handleInternalTunnelStateEvent(BigInteger srcDpId, BigInteger dstDpId) {
ElanDpnInterfaces dpnInterfaceLists = elanUtils.getElanDpnInterfacesList();
LOG.trace("processing tunnel state event for srcDpId {} dstDpId {}" + " and dpnInterfaceList {}", srcDpId, dstDpId, dpnInterfaceLists);
if (dpnInterfaceLists == null) {
return;
}
List<ElanDpnInterfacesList> elanDpnIf = dpnInterfaceLists.getElanDpnInterfacesList();
for (ElanDpnInterfacesList elanDpns : elanDpnIf) {
int cnt = 0;
String elanName = elanDpns.getElanInstanceName();
ElanInstance elanInfo = elanInstanceCache.get(elanName).orNull();
if (elanInfo == null) {
LOG.warn("ELAN Info is null for elanName {} that does exist in elanDpnInterfaceList, " + "skipping this ELAN for tunnel handling", elanName);
continue;
}
if (ElanUtils.isFlat(elanInfo) || ElanUtils.isVlan(elanInfo)) {
LOG.debug("Ignoring internal tunnel state event for Flat/Vlan elan {}", elanName);
continue;
}
List<DpnInterfaces> dpnInterfaces = elanDpns.getDpnInterfaces();
if (dpnInterfaces == null) {
continue;
}
DpnInterfaces dstDpnIf = null;
for (DpnInterfaces dpnIf : dpnInterfaces) {
BigInteger dpnIfDpId = dpnIf.getDpId();
if (dpnIfDpId.equals(srcDpId)) {
cnt++;
} else if (dpnIfDpId.equals(dstDpId)) {
cnt++;
dstDpnIf = dpnIf;
}
}
if (cnt == 2) {
LOG.info("Elan instance:{} is present b/w srcDpn:{} and dstDpn:{}", elanName, srcDpId, dstDpId);
// var needs to be final so it can be accessed in lambda
final DpnInterfaces finalDstDpnIf = dstDpnIf;
jobCoordinator.enqueueJob(elanName, () -> {
// update Remote BC Group
LOG.trace("procesing elan remote bc group for tunnel event {}", elanInfo);
try {
elanL2GatewayMulticastUtils.setupElanBroadcastGroups(elanInfo, srcDpId);
} catch (RuntimeException e) {
LOG.error("Error while adding remote bc group for {} on dpId {} ", elanName, srcDpId);
}
Set<String> interfaceLists = new HashSet<>();
interfaceLists.addAll(finalDstDpnIf.getInterfaces());
for (String ifName : interfaceLists) {
jobCoordinator.enqueueJob(ElanUtils.getElanInterfaceJobKey(ifName), () -> {
LOG.info("Processing tunnel up event for elan {} and interface {}", elanName, ifName);
InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(ifName);
if (isOperational(interfaceInfo)) {
return installDMacAddressTables(elanInfo, interfaceInfo, srcDpId);
}
return Collections.emptyList();
}, ElanConstants.JOB_MAX_RETRIES);
}
return Collections.emptyList();
}, ElanConstants.JOB_MAX_RETRIES);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.endpoint.endpoint.type.Interface in project netvirt by opendaylight.
the class ElanInterfaceManager method setupEntriesForElanInterface.
List<ListenableFuture<Void>> setupEntriesForElanInterface(ElanInstance elanInstance, ElanInterface elanInterface, InterfaceInfo interfaceInfo, boolean isFirstInterfaceInDpn) throws ElanException {
String elanInstanceName = elanInstance.getElanInstanceName();
String interfaceName = elanInterface.getName();
WriteTransaction tx = broker.newWriteOnlyTransaction();
BigInteger dpId = interfaceInfo.getDpId();
WriteTransaction writeFlowGroupTx = broker.newWriteOnlyTransaction();
installEntriesForElanInterface(elanInstance, elanInterface, interfaceInfo, isFirstInterfaceInDpn, tx, writeFlowGroupTx);
List<StaticMacEntries> staticMacEntriesList = elanInterface.getStaticMacEntries();
List<PhysAddress> staticMacAddresses = Lists.newArrayList();
boolean isInterfaceOperational = isOperational(interfaceInfo);
if (ElanUtils.isNotEmpty(staticMacEntriesList)) {
for (StaticMacEntries staticMacEntry : staticMacEntriesList) {
InstanceIdentifier<MacEntry> macId = getMacEntryOperationalDataPath(elanInstanceName, staticMacEntry.getMacAddress());
Optional<MacEntry> existingMacEntry = ElanUtils.read(broker, LogicalDatastoreType.OPERATIONAL, macId);
if (existingMacEntry.isPresent()) {
elanForwardingEntriesHandler.updateElanInterfaceForwardingTablesList(elanInstanceName, interfaceName, existingMacEntry.get().getInterface(), existingMacEntry.get(), tx);
} else {
elanForwardingEntriesHandler.addElanInterfaceForwardingTableList(elanInstanceName, interfaceName, staticMacEntry, tx);
}
if (isInterfaceOperational) {
// Setting SMAC, DMAC, UDMAC in this DPN and also in other
// DPNs
String macAddress = staticMacEntry.getMacAddress().getValue();
LOG.info("programming smac and dmacs for {} on source and other DPNs for elan {} and interface {}", macAddress, elanInstanceName, interfaceName);
elanUtils.setupMacFlows(elanInstance, interfaceInfo, ElanConstants.STATIC_MAC_TIMEOUT, staticMacEntry.getMacAddress().getValue(), true, writeFlowGroupTx);
}
}
if (isInterfaceOperational) {
// on purpose.
for (StaticMacEntries staticMacEntry : staticMacEntriesList) {
staticMacAddresses.add(staticMacEntry.getMacAddress());
}
elanL2GatewayUtils.scheduleAddDpnMacInExtDevices(elanInstance.getElanInstanceName(), dpId, staticMacAddresses);
}
}
List<ListenableFuture<Void>> futures = new ArrayList<>();
futures.add(ElanUtils.waitForTransactionToComplete(tx));
futures.add(ElanUtils.waitForTransactionToComplete(writeFlowGroupTx));
if (isInterfaceOperational && !interfaceManager.isExternalInterface(interfaceName)) {
// At this point, the interface is operational and D/SMAC flows have been configured, mark the port active
try {
Port neutronPort = neutronVpnManager.getNeutronPort(interfaceName);
if (neutronPort != null) {
NeutronUtils.updatePortStatus(interfaceName, NeutronUtils.PORT_STATUS_ACTIVE, broker);
}
} catch (IllegalArgumentException ex) {
LOG.trace("Interface: {} is not part of Neutron Network", interfaceName);
}
}
return futures;
}
Aggregations