use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.Mac in project netvirt by opendaylight.
the class EvpnMacVrfUtils method removeEvpnDmacFlowOnDetach.
public void removeEvpnDmacFlowOnDetach(InstanceIdentifier<MacVrfEntry> instanceIdentifier, MacVrfEntry macVrfEntry, ElanInstance elanInstance) {
// String elanName = getElanNameByMacvrfiid(instanceIdentifier);
if (elanInstance == null) {
LOG.error("Error : elanInstance is null for iid {}", instanceIdentifier);
return;
}
List<DpnInterfaces> dpnInterfaceLists = elanUtils.getElanDPNByName(elanInstance.getElanInstanceName());
// if (checkEvpnAttachedToNet(elanName)) {
String nexthopIP = getRoutePathNexthopIp(macVrfEntry);
if (nexthopIP == null) {
LOG.debug("nexthopIP is null for iid {}", instanceIdentifier);
return;
}
IpAddress ipAddress = new IpAddress(new Ipv4Address(nexthopIP));
Long elanTag = elanInstance.getElanTag();
String macToRemove = macVrfEntry.getMac();
jobCoordinator.enqueueJob(macToRemove, () -> {
List<ListenableFuture<Void>> futures = new ArrayList<>();
dpnInterfaceLists.forEach(dpnInterfaces -> {
BigInteger dpId = dpnInterfaces.getDpId();
ElanEvpnFlowUtils.EvpnDmacFlowBuilder dmacFlowBuilder = new ElanEvpnFlowUtils.EvpnDmacFlowBuilder();
dmacFlowBuilder.setDpId(dpId).setNexthopIP(ipAddress.toString()).setElanTag(elanTag).setDstMacAddress(macToRemove);
LOG.info("REMOVE: Deleting DMAC Flows for external MAC. elanTag {}, dpId {}," + "nexthopIP {}, macToRemove {}", elanTag, dpId, nexthopIP, macToRemove);
elanEvpnFlowUtils.evpnDeleteDmacFlowsToExternalMac(dmacFlowBuilder.build());
});
return futures;
}, ElanConstants.JOB_MAX_RETRIES);
}
use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.Mac in project netvirt by opendaylight.
the class EvpnMacVrfUtils method removeEvpnDmacFlow.
public void removeEvpnDmacFlow(InstanceIdentifier<MacVrfEntry> instanceIdentifier, MacVrfEntry macVrfEntry) {
String elanName = getElanNameByMacvrfiid(instanceIdentifier);
if (elanName == null) {
LOG.error("Error : elanName is null for iid {}", instanceIdentifier);
return;
}
List<DpnInterfaces> dpnInterfaceLists = elanUtils.getElanDPNByName(elanName);
// if (checkEvpnAttachedToNet(elanName)) {
// TODO(Riyaz) : Check if accessing first nexthop address is right
String nexthopIP = macVrfEntry.getRoutePaths().get(0).getNexthopAddress();
IpAddress ipAddress = new IpAddress(new Ipv4Address(nexthopIP));
Long elanTag = getElanTagByMacvrfiid(instanceIdentifier);
if (elanTag == null) {
return;
}
String macToRemove = macVrfEntry.getMac();
jobCoordinator.enqueueJob(macToRemove, () -> {
List<ListenableFuture<Void>> futures = new ArrayList<>();
dpnInterfaceLists.forEach(dpnInterfaces -> {
BigInteger dpId = dpnInterfaces.getDpId();
ElanEvpnFlowUtils.EvpnDmacFlowBuilder dmacFlowBuilder = new ElanEvpnFlowUtils.EvpnDmacFlowBuilder();
dmacFlowBuilder.setDpId(dpId).setNexthopIP(ipAddress.toString()).setElanTag(elanTag).setDstMacAddress(macToRemove);
LOG.info("REMOVE: Deleting DMAC Flows for external MAC. elanTag {}, dpId {}," + "nexthopIP {}, macToRemove {}", elanTag, dpId, nexthopIP, macToRemove);
futures.addAll(elanEvpnFlowUtils.evpnDeleteDmacFlowsToExternalMac(dmacFlowBuilder.build()));
});
return futures;
}, ElanConstants.JOB_MAX_RETRIES);
}
use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.Mac 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.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.Mac in project netvirt by opendaylight.
the class LocalUcastMacListener method getChildMod.
@Override
protected Map<InstanceIdentifier<LocalUcastMacs>, DataObjectModification<LocalUcastMacs>> getChildMod(final InstanceIdentifier<Node> parentIid, final DataObjectModification<Node> mod) {
Map<InstanceIdentifier<LocalUcastMacs>, DataObjectModification<LocalUcastMacs>> result = new HashMap<>();
DataObjectModification<HwvtepGlobalAugmentation> aug = mod.getModifiedAugmentation(HwvtepGlobalAugmentation.class);
if (aug != null && getModificationType(aug) != null) {
Collection<DataObjectModification<? extends DataObject>> children = aug.getModifiedChildren();
children.stream().filter(childMod -> getModificationType(childMod) != null).filter(childMod -> childMod.getDataType() == LocalUcastMacs.class).forEach(childMod -> {
LocalUcastMacs afterMac = (LocalUcastMacs) childMod.getDataAfter();
LocalUcastMacs mac = afterMac != null ? afterMac : (LocalUcastMacs) childMod.getDataBefore();
InstanceIdentifier<LocalUcastMacs> iid = parentIid.augmentation(HwvtepGlobalAugmentation.class).child(LocalUcastMacs.class, mac.getKey());
result.put(iid, (DataObjectModification<LocalUcastMacs>) childMod);
});
}
return result;
}
use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.Mac in project netvirt by opendaylight.
the class LocalUcastMacListener method added.
public void added(final InstanceIdentifier<LocalUcastMacs> identifier, final LocalUcastMacs macAdded) {
ResourceBatchingManager.getInstance().put(ResourceBatchingManager.ShardResource.CONFIG_TOPOLOGY, identifier, macAdded);
String hwvtepNodeId = identifier.firstKeyOf(Node.class).getNodeId().getValue();
String macAddress = macAdded.getMacEntryKey().getValue().toLowerCase(Locale.getDefault());
String elanName = getElanName(macAdded);
LOG.trace("LocalUcastMacs {} added to {}", macAddress, hwvtepNodeId);
ElanInstance elan = elanInstanceCache.get(elanName).orNull();
if (elan == null) {
LOG.warn("Could not find ELAN for mac {} being added", macAddress);
return;
}
jobCoordinator.enqueueJob(elanName + HwvtepHAUtil.L2GW_JOB_KEY, () -> {
L2GatewayDevice elanL2GwDevice = ElanL2GwCacheUtils.getL2GatewayDeviceFromCache(elanName, hwvtepNodeId);
if (elanL2GwDevice == null) {
LOG.warn("Could not find L2GatewayDevice for ELAN: {}, nodeID:{} from cache", elanName, hwvtepNodeId);
return null;
}
elanL2GwDevice.addUcastLocalMac(macAdded);
elanL2GatewayUtils.installL2GwUcastMacInElan(elan, elanL2GwDevice, macAddress.toLowerCase(), macAdded, null);
return null;
});
}
Aggregations