use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntry in project netvirt by opendaylight.
the class EvpnMacVrfUtils method addEvpnDmacFlow.
public void addEvpnDmacFlow(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 solution
String nexthopIP = macVrfEntry.getRoutePaths().get(0).getNexthopAddress();
IpAddress ipAddress = new IpAddress(new Ipv4Address(nexthopIP));
Long elanTag = getElanTagByMacvrfiid(instanceIdentifier);
if (elanTag == null) {
return;
}
String dstMacAddress = macVrfEntry.getMac();
long vni = macVrfEntry.getL2vni();
jobCoordinator.enqueueJob(dstMacAddress, () -> {
List<ListenableFuture<Void>> futures = new ArrayList<>();
dpnInterfaceLists.forEach(dpnInterfaces -> {
BigInteger dpId = dpnInterfaces.getDpId();
LOG.info("ADD: Build DMAC flow with dpId {}, nexthopIP {}, elanTag {}," + "vni {}, dstMacAddress {}, elanName {} ", dpId, nexthopIP, elanTag, vni, dstMacAddress, elanName);
ElanEvpnFlowUtils.EvpnDmacFlowBuilder dmacFlowBuilder = new ElanEvpnFlowUtils.EvpnDmacFlowBuilder();
dmacFlowBuilder.setDpId(dpId).setNexthopIP(ipAddress.toString()).setElanTag(elanTag).setVni(vni).setDstMacAddress(dstMacAddress).setElanName(elanName);
Flow flow = elanEvpnFlowUtils.evpnBuildDmacFlowForExternalRemoteMac(dmacFlowBuilder.build());
futures.add(mdsalManager.installFlow(dpId, flow));
});
return futures;
}, ElanConstants.JOB_MAX_RETRIES);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntry 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.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntry in project netvirt by opendaylight.
the class EvpnMacVrfUtils method updateEvpnDmacFlows.
public void updateEvpnDmacFlows(final ElanInstance elanInstance, final boolean install) {
String rd = evpnUtils.getEvpnRd(elanInstance);
if (rd == null) {
return;
}
final InstanceIdentifier<VrfTables> iid = InstanceIdentifier.create(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd));
evpnUtils.asyncReadAndExecute(LogicalDatastoreType.CONFIGURATION, iid, new StringBuilder(elanInstance.getElanInstanceName()).append(":").append(rd).toString(), (vrfTablesOptional) -> {
if (!vrfTablesOptional.isPresent()) {
return null;
}
List<MacVrfEntry> macVrfEntries = vrfTablesOptional.get().getMacVrfEntry();
if (macVrfEntries == null || macVrfEntries.isEmpty()) {
return null;
}
for (MacVrfEntry macVrfEntry : macVrfEntries) {
InstanceIdentifier<MacVrfEntry> macVrfEntryIid = getMacVrfEntryIid(rd, macVrfEntry);
if (install) {
addEvpnDmacFlowOnAttach(macVrfEntryIid, macVrfEntry, elanInstance);
} else {
removeEvpnDmacFlowOnDetach(macVrfEntryIid, macVrfEntry, elanInstance);
}
}
return null;
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntry 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.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntry in project netvirt by opendaylight.
the class EvpnMacVrfUtils method getElanNameByMacvrfiid.
public String getElanNameByMacvrfiid(InstanceIdentifier<MacVrfEntry> instanceIdentifier) {
try (ReadOnlyTransaction tx = dataBroker.newReadOnlyTransaction()) {
String rd = instanceIdentifier.firstKeyOf(VrfTables.class).getRouteDistinguisher();
String elanName = null;
InstanceIdentifier<EvpnRdToNetwork> iidEvpnRdToNet = InstanceIdentifier.builder(EvpnRdToNetworks.class).child(EvpnRdToNetwork.class, new EvpnRdToNetworkKey(rd)).build();
try {
Optional<EvpnRdToNetwork> evpnRdToNetwork = tx.read(LogicalDatastoreType.CONFIGURATION, iidEvpnRdToNet).checkedGet();
if (evpnRdToNetwork.isPresent()) {
elanName = evpnRdToNetwork.get().getNetworkId();
}
} catch (ReadFailedException e) {
LOG.error("getElanName: unable to read elanName, exception ", e);
}
return elanName;
}
}
Aggregations