use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan._interface.forwarding.entries.ElanInterfaceMac in project netvirt by opendaylight.
the class ElanInterfaceManager method removeEntriesForElanInterface.
List<ListenableFuture<Void>> removeEntriesForElanInterface(ElanInstance elanInfo, InterfaceInfo interfaceInfo, String interfaceName, boolean isLastElanInterface) {
String elanName = elanInfo.getElanInstanceName();
List<ListenableFuture<Void>> futures = new ArrayList<>();
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(flowTx -> {
futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(interfaceTx -> {
InstanceIdentifier<ElanInterfaceMac> elanInterfaceId = ElanUtils.getElanInterfaceMacEntriesOperationalDataPath(interfaceName);
Optional<ElanInterfaceMac> existingElanInterfaceMac = interfaceTx.read(LogicalDatastoreType.OPERATIONAL, elanInterfaceId).checkedGet();
LOG.debug("Removing the Interface:{} from elan:{}", interfaceName, elanName);
if (interfaceInfo != null) {
if (existingElanInterfaceMac.isPresent()) {
List<MacEntry> existingMacEntries = existingElanInterfaceMac.get().getMacEntry();
if (existingMacEntries != null) {
List<PhysAddress> macAddresses = new ArrayList<>();
for (MacEntry macEntry : existingMacEntries) {
PhysAddress macAddress = macEntry.getMacAddress();
LOG.debug("removing the mac-entry:{} present on elanInterface:{}", macAddress.getValue(), interfaceName);
Optional<MacEntry> macEntryOptional = elanUtils.getMacEntryForElanInstance(interfaceTx, elanName, macAddress);
if (!isLastElanInterface && macEntryOptional.isPresent()) {
interfaceTx.delete(LogicalDatastoreType.OPERATIONAL, ElanUtils.getMacEntryOperationalDataPath(elanName, macAddress));
}
elanUtils.deleteMacFlows(elanInfo, interfaceInfo, macEntry, flowTx);
macAddresses.add(macAddress);
}
// to this ELAN
if (isVxlanNetworkOrVxlanSegment(elanInfo) && !macAddresses.isEmpty()) {
elanL2GatewayUtils.removeMacsFromElanExternalDevices(elanInfo, macAddresses);
}
}
}
removeDefaultTermFlow(interfaceInfo.getDpId(), interfaceInfo.getInterfaceTag());
removeFilterEqualsTable(elanInfo, interfaceInfo, flowTx);
} else if (existingElanInterfaceMac.isPresent()) {
// Interface does not exist in ConfigDS, so lets remove everything
// about that interface related to Elan
List<MacEntry> macEntries = existingElanInterfaceMac.get().getMacEntry();
if (macEntries != null) {
for (MacEntry macEntry : macEntries) {
PhysAddress macAddress = macEntry.getMacAddress();
if (elanUtils.getMacEntryForElanInstance(elanName, macAddress).isPresent()) {
interfaceTx.delete(LogicalDatastoreType.OPERATIONAL, ElanUtils.getMacEntryOperationalDataPath(elanName, macAddress));
}
}
}
}
if (existingElanInterfaceMac.isPresent()) {
interfaceTx.delete(LogicalDatastoreType.OPERATIONAL, elanInterfaceId);
}
unbindService(interfaceName, interfaceTx);
deleteElanInterfaceFromConfigDS(interfaceName, interfaceTx);
}));
}));
return futures;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan._interface.forwarding.entries.ElanInterfaceMac in project netvirt by opendaylight.
the class ElanInterfaceManager method deleteAllRemoteMacsInADpn.
private void deleteAllRemoteMacsInADpn(String elanName, BigInteger dpId, long elanTag) {
List<DpnInterfaces> dpnInterfaces = elanUtils.getInvolvedDpnsInElan(elanName);
for (DpnInterfaces dpnInterface : dpnInterfaces) {
BigInteger currentDpId = dpnInterface.getDpId();
if (!currentDpId.equals(dpId)) {
for (String elanInterface : dpnInterface.getInterfaces()) {
ElanInterfaceMac macs = elanUtils.getElanInterfaceMacByInterfaceName(elanInterface);
if (macs == null || macs.getMacEntry() == null) {
continue;
}
for (MacEntry mac : macs.getMacEntry()) {
removeTheMacFlowInTheDPN(dpId, elanTag, currentDpId, mac);
removeEtreeMacFlowInTheDPN(dpId, elanTag, currentDpId, mac);
}
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan._interface.forwarding.entries.ElanInterfaceMac in project netvirt by opendaylight.
the class ElanInterfaceManager method installDMacAddressTables.
// Install DMAC entry on dst DPN
public List<ListenableFuture<Void>> installDMacAddressTables(ElanInstance elanInfo, InterfaceInfo interfaceInfo, BigInteger dstDpId) throws ElanException {
String interfaceName = interfaceInfo.getInterfaceName();
ElanInterfaceMac elanInterfaceMac = elanUtils.getElanInterfaceMacByInterfaceName(interfaceName);
if (elanInterfaceMac != null && elanInterfaceMac.getMacEntry() != null) {
List<MacEntry> macEntries = elanInterfaceMac.getMacEntry();
WriteTransaction writeFlowTx = broker.newWriteOnlyTransaction();
for (MacEntry macEntry : macEntries) {
String macAddress = macEntry.getMacAddress().getValue();
LOG.info("Installing remote dmac for mac address {} and interface {}", macAddress, interfaceName);
synchronized (ElanUtils.getElanMacDPNKey(elanInfo.getElanTag(), macAddress, interfaceInfo.getDpId())) {
LOG.info("Acquired lock for mac : {}, proceeding with remote dmac install operation", macAddress);
elanUtils.setupDMacFlowOnRemoteDpn(elanInfo, interfaceInfo, dstDpId, macAddress, writeFlowTx);
}
}
return Collections.singletonList(ElanUtils.waitForTransactionToComplete(writeFlowTx));
}
return Collections.emptyList();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan._interface.forwarding.entries.ElanInterfaceMac in project netvirt by opendaylight.
the class ElanInterfaceManager method programRemoteDmacFlow.
void programRemoteDmacFlow(ElanInstance elanInstance, InterfaceInfo interfaceInfo, WriteTransaction writeFlowGroupTx) throws ElanException {
ElanDpnInterfacesList elanDpnInterfacesList = elanUtils.getElanDpnInterfacesList(elanInstance.getElanInstanceName());
List<DpnInterfaces> dpnInterfaceLists = null;
if (elanDpnInterfacesList != null) {
dpnInterfaceLists = elanDpnInterfacesList.getDpnInterfaces();
}
if (dpnInterfaceLists == null) {
dpnInterfaceLists = new ArrayList<>();
}
for (DpnInterfaces dpnInterfaces : dpnInterfaceLists) {
BigInteger dstDpId = interfaceInfo.getDpId();
if (dpnInterfaces.getDpId().equals(dstDpId)) {
continue;
}
List<String> remoteElanInterfaces = dpnInterfaces.getInterfaces();
for (String remoteIf : remoteElanInterfaces) {
ElanInterfaceMac elanIfMac = elanUtils.getElanInterfaceMacByInterfaceName(remoteIf);
InterfaceInfo remoteInterface = interfaceManager.getInterfaceInfo(remoteIf);
if (elanIfMac == null) {
continue;
}
List<MacEntry> remoteMacEntries = elanIfMac.getMacEntry();
if (remoteMacEntries != null) {
for (MacEntry macEntry : remoteMacEntries) {
String macAddress = macEntry.getMacAddress().getValue();
LOG.info("Programming remote dmac {} on the newly added DPN {} for elan {}", macAddress, dstDpId, elanInstance.getElanInstanceName());
elanUtils.setupRemoteDmacFlow(dstDpId, remoteInterface.getDpId(), remoteInterface.getInterfaceTag(), elanInstance.getElanTag(), macAddress, elanInstance.getElanInstanceName(), writeFlowGroupTx, remoteIf, elanInstance);
}
}
}
}
}
Aggregations