use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables in project netvirt by opendaylight.
the class VpnUtil method removeVrfEntriesByOrigin.
/**
* Remove from MDSAL all those VrfEntries in a VPN that have an specific RouteOrigin.
*
* @param broker dataBroker service reference
* @param rd Route Distinguisher
* @param origin Origin of the Routes to be removed (see {@link RouteOrigin})
*/
public static void removeVrfEntriesByOrigin(DataBroker broker, String rd, RouteOrigin origin) {
InstanceIdentifier<VrfTables> vpnVrfTableIid = InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd)).build();
Optional<VrfTables> vrfTablesOpc = read(broker, LogicalDatastoreType.CONFIGURATION, vpnVrfTableIid);
if (vrfTablesOpc.isPresent()) {
VrfTables vrfTables = vrfTablesOpc.get();
WriteTransaction tx = broker.newWriteOnlyTransaction();
for (VrfEntry vrfEntry : vrfTables.getVrfEntry()) {
if (origin == RouteOrigin.value(vrfEntry.getOrigin())) {
tx.delete(LogicalDatastoreType.CONFIGURATION, vpnVrfTableIid.child(VrfEntry.class, vrfEntry.getKey()));
}
}
tx.submit();
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables in project netvirt by opendaylight.
the class BgpConfigurationManager method createStaleFibMap.
/*
* BGP restart scenario, ODL-BGP manager was/is running.
* On re-sync notification, Get a copy of FIB database.
*/
public void createStaleFibMap() {
totalStaledCount = 0;
try {
staledFibEntriesMap.clear();
InstanceIdentifier<FibEntries> id = InstanceIdentifier.create(FibEntries.class);
Optional<FibEntries> fibEntries = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, id);
if (fibEntries.isPresent()) {
List<VrfTables> staleVrfTables = fibEntries.get().getVrfTables();
for (VrfTables vrfTable : staleVrfTables) {
Map<String, Long> staleFibEntMap = new HashMap<>();
for (VrfEntry vrfEntry : vrfTable.getVrfEntry()) {
if (RouteOrigin.value(vrfEntry.getOrigin()) != RouteOrigin.BGP) {
// Stale marking and cleanup is only meant for the routes learned through BGP.
continue;
}
if (Thread.interrupted()) {
break;
}
totalStaledCount++;
// Create MAP from staleVrfTables.
vrfEntry.getRoutePaths().forEach(routePath -> staleFibEntMap.put(appendNextHopToPrefix(vrfEntry.getDestPrefix(), routePath.getNexthopAddress()), routePath.getLabel()));
}
staledFibEntriesMap.put(vrfTable.getRouteDistinguisher(), staleFibEntMap);
}
} else {
LOG.error("createStaleFibMap:: FIBentries.class is not present");
}
} catch (ReadFailedException e) {
LOG.error("createStaleFibMap:: error ", e);
}
LOG.error("created {} staled entries ", totalStaledCount);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables in project netvirt by opendaylight.
the class FibDSWriter method removeVrfFromDS.
public synchronized void removeVrfFromDS(String rd) {
LOG.debug("Removing vrf table for rd {}", rd);
InstanceIdentifierBuilder<VrfTables> idBuilder = InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd));
InstanceIdentifier<VrfTables> vrfTableId = idBuilder.build();
bgpUtil.delete(vrfTableId);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables in project netvirt by opendaylight.
the class FibUtil method removeVrfTable.
public void removeVrfTable(String rd, WriteTransaction writeConfigTxn) {
LOG.debug("Removing vrf table for rd {}", rd);
InstanceIdentifier.InstanceIdentifierBuilder<VrfTables> idBuilder = InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd));
InstanceIdentifier<VrfTables> vrfTableId = idBuilder.build();
if (writeConfigTxn != null) {
writeConfigTxn.delete(LogicalDatastoreType.CONFIGURATION, vrfTableId);
} else {
Optional<VrfTables> ifStateOptional = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, vrfTableId);
if (ifStateOptional.isPresent()) {
MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, vrfTableId);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables in project netvirt by opendaylight.
the class VrfEntryListener method cleanUpExternalRoutesOnDpn.
public void cleanUpExternalRoutesOnDpn(final BigInteger dpnId, final long vpnId, final String rd, final String localNextHopIp, final String remoteNextHopIp) {
LOG.trace("cleanUpExternalRoutesOnDpn : cleanup remote routes on dpn {} for vpn {}, rd {}, " + " localNexthopIp {} , remoteNexhtHopIp {}", dpnId, vpnId, rd, localNextHopIp, remoteNextHopIp);
InstanceIdentifier<VrfTables> id = buildVrfId(rd);
final VpnInstanceOpDataEntry vpnInstance = fibUtil.getVpnInstance(rd);
List<SubTransaction> txnObjects = new ArrayList<>();
final Optional<VrfTables> vrfTable = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, id);
if (vrfTable.isPresent()) {
jobCoordinator.enqueueJob(FibUtil.getJobKeyForVpnIdDpnId(vpnId, dpnId), () -> {
List<ListenableFuture<Void>> futures = new ArrayList<>();
synchronized (vpnInstance.getVpnInstanceName().intern()) {
WriteTransaction writeCfgTxn = dataBroker.newWriteOnlyTransaction();
vrfTable.get().getVrfEntry().stream().filter(vrfEntry -> RouteOrigin.value(vrfEntry.getOrigin()) == RouteOrigin.BGP).forEach(bgpRouteVrfEntryHandler.getConsumerForDeletingRemoteFib(dpnId, vpnId, remoteNextHopIp, vrfTable, writeCfgTxn, txnObjects));
futures.add(writeCfgTxn.submit());
}
return futures;
});
}
}
Aggregations