use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey 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.fibentries.VrfTablesKey in project netvirt by opendaylight.
the class VpnInterfaceManager method importSubnetRouteForNewVpn.
public synchronized void importSubnetRouteForNewVpn(String rd, String prefix, String nextHop, int label, SubnetRoute route, WriteTransaction writeConfigTxn) {
RouteOrigin origin = RouteOrigin.SELF_IMPORTED;
VrfEntry vrfEntry = FibHelper.getVrfEntryBuilder(prefix, label, nextHop, origin, null).addAugmentation(SubnetRoute.class, route).build();
List<VrfEntry> vrfEntryList = Collections.singletonList(vrfEntry);
InstanceIdentifierBuilder<VrfTables> idBuilder = InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd));
InstanceIdentifier<VrfTables> vrfTableId = idBuilder.build();
VrfTables vrfTableNew = new VrfTablesBuilder().setRouteDistinguisher(rd).setVrfEntry(vrfEntryList).build();
if (writeConfigTxn != null) {
writeConfigTxn.merge(LogicalDatastoreType.CONFIGURATION, vrfTableId, vrfTableNew, true);
} else {
VpnUtil.syncUpdate(dataBroker, LogicalDatastoreType.CONFIGURATION, vrfTableId, vrfTableNew);
}
LOG.info("SUBNETROUTE: importSubnetRouteForNewVpn: Created vrfEntry for rd {} prefix {} nexthop {} label {}" + " and elantag {}", rd, prefix, nextHop, label, route.getElantag());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey in project netvirt by opendaylight.
the class FibEntriesListener method add.
@Override
protected void add(InstanceIdentifier<VrfEntry> identifier, VrfEntry add) {
LOG.trace("Add Vrf Entry event - Key : {}, value : {}", identifier, add);
final VrfTablesKey key = identifier.firstKeyOf(VrfTables.class, VrfTablesKey.class);
String rd = key.getRouteDistinguisher();
addLabelToVpnInstance(rd, add.getRoutePaths());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey in project netvirt by opendaylight.
the class FibDSWriter method removeOrUpdateFibEntryFromDS.
public synchronized void removeOrUpdateFibEntryFromDS(String rd, String prefix, String nextHop) {
if (rd == null || rd.isEmpty()) {
LOG.error("Prefix {} not associated with vpn", prefix);
return;
}
LOG.debug("Removing fib entry with destination prefix {} from vrf table for rd {} and nextHop {}", prefix, rd, nextHop);
try {
InstanceIdentifier<VrfEntry> vrfEntryId = InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd)).child(VrfEntry.class, new VrfEntryKey(prefix)).build();
Optional<VrfEntry> existingVrfEntry = singleTxDB.syncReadOptional(LogicalDatastoreType.CONFIGURATION, vrfEntryId);
List<RoutePaths> routePaths = existingVrfEntry.toJavaUtil().map(VrfEntry::getRoutePaths).orElse(Collections.emptyList());
if (routePaths.size() == 1) {
if (routePaths.get(0).getNexthopAddress().equals(nextHop)) {
bgpUtil.delete(vrfEntryId);
}
} else {
routePaths.stream().map(RoutePaths::getNexthopAddress).filter(nextHopAddress -> nextHopAddress.equals(nextHop)).findFirst().ifPresent(nh -> {
InstanceIdentifier<RoutePaths> routePathId = FibHelper.buildRoutePathId(rd, prefix, nextHop);
bgpUtil.delete(routePathId);
});
}
} catch (ReadFailedException e) {
LOG.error("Error while reading vrfEntry for rd {}, prefix {}", rd, prefix);
return;
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey in project netvirt by opendaylight.
the class FibDSWriter method removeVrfSubFamilyFromDS.
public synchronized void removeVrfSubFamilyFromDS(String rd, AddressFamily addressFamily) {
if (rd == null) {
return;
}
LOG.debug("removeVrfSubFamilyFromDS : addressFamily {} from vrf rd {}", addressFamily, rd);
InstanceIdentifier<VrfTables> id = InstanceIdentifier.create(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd));
try {
VrfTables vrfTable = singleTxDB.syncRead(LogicalDatastoreType.CONFIGURATION, id);
if (vrfTable != null) {
List<VrfEntry> vrfEntries = vrfTable.getVrfEntry();
if (vrfEntries == null) {
LOG.error("removeVrfSubFamilyFromDS : VrfEntry not found for rd {}", rd);
return;
}
for (VrfEntry vrfEntry : vrfEntries) {
boolean found = false;
if (vrfEntry.getEncapType() != null) {
if (!vrfEntry.getEncapType().equals(EncapType.Mplsgre) && addressFamily == AddressFamily.L2VPN) {
found = true;
} else if (vrfEntry.getEncapType().equals(EncapType.Mplsgre)) {
if (addressFamily == AddressFamily.IPV4 && FibHelper.isIpv4Prefix(vrfEntry.getDestPrefix())) {
found = true;
} else if (addressFamily == AddressFamily.IPV6 && FibHelper.isIpv6Prefix(vrfEntry.getDestPrefix())) {
found = true;
}
}
}
if (found == false) {
continue;
}
bgpUtil.removeVrfEntry(rd, vrfEntry);
}
}
} catch (ReadFailedException rfe) {
LOG.error("removeVrfSubFamilyFromDS : Internal Error rd {}", rd, rfe);
}
return;
}
Aggregations