use of org.opendaylight.genius.interfacemanager.globals.InterfaceInfo in project netvirt by opendaylight.
the class EvpnUtils method advertisePrefix.
public void advertisePrefix(ElanInstance elanInfo, MacEntry macEntry) {
InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(macEntry.getInterface());
if (interfaceInfo == null) {
LOG.debug("advertisePrefix, interfaceInfo is null for interface {}", macEntry.getInterface());
return;
}
if (!isIpv4PrefixAvailable.test(macEntry)) {
LOG.debug("advertisePrefix macEntry does not have IPv4 prefix {}", macEntry);
return;
}
advertisePrefix(elanInfo, macEntry.getMacAddress().getValue(), macEntry.getIpPrefix().getIpv4Address().getValue(), interfaceInfo.getInterfaceName(), interfaceInfo.getDpId());
}
use of org.opendaylight.genius.interfacemanager.globals.InterfaceInfo in project netvirt by opendaylight.
the class EvpnUtils method advertiseEvpnRT2Routes.
@SuppressWarnings("checkstyle:IllegalCatch")
public void advertiseEvpnRT2Routes(EvpnAugmentation evpnAugmentation, String elanName) {
if (evpnAugmentation == null || evpnAugmentation.getEvpnName() == null) {
return;
}
String evpnName = evpnAugmentation.getEvpnName();
List<MacEntry> macEntries = elanUtils.getElanMacEntries(elanName);
if (macEntries == null || macEntries.isEmpty()) {
LOG.trace("advertiseEvpnRT2Routes no elan mac entries found for {}", elanName);
return;
}
String rd = vpnManager.getVpnRd(broker, evpnName);
ElanInstance elanInfo = elanInstanceCache.get(elanName).orNull();
macEntries.stream().filter(isIpv4PrefixAvailable).forEach(macEntry -> {
InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(macEntry.getInterface());
if (interfaceInfo == null) {
LOG.debug("advertiseEvpnRT2Routes, interfaceInfo is null for interface {}", macEntry.getInterface());
return;
}
advertisePrefix(elanInfo, rd, macEntry.getMacAddress().getValue(), macEntry.getIpPrefix().getIpv4Address().getValue(), interfaceInfo.getInterfaceName(), interfaceInfo.getDpId());
});
}
use of org.opendaylight.genius.interfacemanager.globals.InterfaceInfo in project netvirt by opendaylight.
the class ElanInstanceManager method remove.
@Override
protected void remove(InstanceIdentifier<ElanInstance> identifier, ElanInstance deletedElan) {
LOG.trace("Remove ElanInstance - Key: {}, value: {}", identifier, deletedElan);
String elanName = deletedElan.getElanInstanceName();
// check the elan Instance present in the Operational DataStore
Elan existingElan = ElanUtils.getElanByName(broker, elanName);
long elanTag = deletedElan.getElanTag();
// Cleaning up the existing Elan Instance
if (existingElan != null) {
List<String> elanInterfaces = existingElan.getElanInterfaces();
if (elanInterfaces != null && !elanInterfaces.isEmpty()) {
for (String elanInterfaceName : elanInterfaces) {
InstanceIdentifier<ElanInterface> elanInterfaceId = ElanUtils.getElanInterfaceConfigurationDataPathId(elanInterfaceName);
InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(elanInterfaceName);
elanInterfaceManager.removeElanInterface(deletedElan, elanInterfaceName, interfaceInfo);
ElanUtils.delete(broker, LogicalDatastoreType.CONFIGURATION, elanInterfaceId);
}
}
ElanUtils.delete(broker, LogicalDatastoreType.OPERATIONAL, ElanUtils.getElanInstanceOperationalDataPath(elanName));
Optional<ElanDpnInterfacesList> elanDpnInterfaceList = MDSALUtil.read(broker, LogicalDatastoreType.OPERATIONAL, ElanUtils.getElanDpnOperationDataPath(elanName));
if (elanDpnInterfaceList.isPresent()) {
ElanUtils.delete(broker, LogicalDatastoreType.OPERATIONAL, getElanDpnOperationDataPath(elanName));
}
ElanUtils.delete(broker, LogicalDatastoreType.OPERATIONAL, ElanUtils.getElanInfoEntriesOperationalDataPath(elanTag));
}
elanInterfaceCache.getInterfaceNames(elanName).forEach(elanInterfaceName -> jobCoordinator.enqueueJob(ElanUtils.getElanInterfaceJobKey(elanInterfaceName), () -> Collections.singletonList(txRunner.callWithNewReadWriteTransactionAndSubmit(tx -> {
LOG.info("Deleting the elanInterface present under ConfigDS:{}", elanInterfaceName);
ElanUtils.delete(broker, LogicalDatastoreType.CONFIGURATION, ElanUtils.getElanInterfaceConfigurationDataPathId(elanInterfaceName));
elanInterfaceManager.unbindService(elanInterfaceName, tx);
LOG.info("unbind the Interface:{} service bounded to Elan:{}", elanInterfaceName, elanName);
})), ElanConstants.JOB_MAX_RETRIES));
// Release tag
ElanUtils.releaseId(idManager, ElanConstants.ELAN_ID_POOL_NAME, elanName);
if (deletedElan.getAugmentation(EtreeInstance.class) != null) {
removeEtreeInstance(deletedElan);
}
}
use of org.opendaylight.genius.interfacemanager.globals.InterfaceInfo in project netvirt by opendaylight.
the class ElanInterfaceManager method handleunprocessedElanInterfaces.
List<ListenableFuture<Void>> handleunprocessedElanInterfaces(ElanInstance elanInstance) throws ElanException {
List<ListenableFuture<Void>> futures = new ArrayList<>();
Queue<ElanInterface> elanInterfaces = unProcessedElanInterfaces.get(elanInstance.getElanInstanceName());
if (elanInterfaces == null || elanInterfaces.isEmpty()) {
return futures;
}
for (ElanInterface elanInterface : elanInterfaces) {
String interfaceName = elanInterface.getName();
InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(interfaceName);
futures.addAll(addElanInterface(elanInterface, interfaceInfo, elanInstance));
}
return futures;
}
use of org.opendaylight.genius.interfacemanager.globals.InterfaceInfo in project netvirt by opendaylight.
the class ElanSmacFlowEventListener method onFlowRemoved.
@Override
public void onFlowRemoved(FlowRemoved flowRemoved) {
short tableId = flowRemoved.getTableId();
if (tableId == NwConstants.ELAN_SMAC_TABLE) {
BigInteger metadata = flowRemoved.getMatch().getMetadata().getMetadata();
long elanTag = MetaDataUtil.getElanTagFromMetadata(metadata);
ElanTagName elanTagInfo = elanUtils.getElanInfoByElanTag(elanTag);
if (elanTagInfo == null) {
return;
}
final String srcMacAddress = flowRemoved.getMatch().getEthernetMatch().getEthernetSource().getAddress().getValue().toUpperCase(Locale.getDefault());
int portTag = MetaDataUtil.getLportFromMetadata(metadata).intValue();
if (portTag == 0) {
LOG.debug("Flow removed event on SMAC flow entry. But having port Tag as 0 ");
return;
}
Optional<IfIndexInterface> existingInterfaceInfo = elanUtils.getInterfaceInfoByInterfaceTag(portTag);
if (!existingInterfaceInfo.isPresent()) {
LOG.debug("Interface is not available for port Tag {}", portTag);
return;
}
String interfaceName = existingInterfaceInfo.get().getInterfaceName();
PhysAddress physAddress = new PhysAddress(srcMacAddress);
if (interfaceName == null) {
LOG.error("LPort record not found for tag {}", portTag);
return;
}
jobCoordinator.enqueueJob(ElanUtils.getElanInterfaceJobKey(interfaceName), () -> {
List<ListenableFuture<Void>> elanFutures = new ArrayList<>();
MacEntry macEntry = elanUtils.getInterfaceMacEntriesOperationalDataPath(interfaceName, physAddress);
InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(interfaceName);
String elanInstanceName = elanTagInfo.getName();
LOG.info("Deleting the Mac-Entry:{} present on ElanInstance:{}", macEntry, elanInstanceName);
if (macEntry != null && interfaceInfo != null) {
ListenableFuture<Void> result = txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> elanUtils.deleteMacFlows(elanInstanceCache.get(elanInstanceName).orNull(), interfaceInfo, macEntry, tx));
elanFutures.add(result);
addCallBack(result, srcMacAddress);
}
InstanceIdentifier<MacEntry> macEntryIdForElanInterface = ElanUtils.getInterfaceMacEntriesIdentifierOperationalDataPath(interfaceName, physAddress);
Optional<MacEntry> existingInterfaceMacEntry = ElanUtils.read(broker, LogicalDatastoreType.OPERATIONAL, macEntryIdForElanInterface);
if (existingInterfaceMacEntry.isPresent()) {
ListenableFuture<Void> future = txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
tx.delete(LogicalDatastoreType.OPERATIONAL, macEntryIdForElanInterface);
MacEntry macEntryInElanInstance = elanUtils.getMacEntryForElanInstance(elanInstanceName, physAddress).orNull();
if (macEntryInElanInstance != null && macEntryInElanInstance.getInterface().equals(interfaceName)) {
InstanceIdentifier<MacEntry> macEntryIdForElanInstance = ElanUtils.getMacEntryOperationalDataPath(elanInstanceName, physAddress);
tx.delete(LogicalDatastoreType.OPERATIONAL, macEntryIdForElanInstance);
}
});
elanFutures.add(future);
addCallBack(future, srcMacAddress);
}
return elanFutures;
}, ElanConstants.JOB_MAX_RETRIES);
}
}
Aggregations