Search in sources :

Example 51 with VrfEntry

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry in project netvirt by opendaylight.

the class FibEntriesListener method remove.

@Override
protected void remove(InstanceIdentifier<VrfEntry> identifier, VrfEntry del) {
    LOG.trace("Remove Fib event - Key : {}, value : {} ", identifier, del);
    final VrfTablesKey key = identifier.firstKeyOf(VrfTables.class, VrfTablesKey.class);
    String rd = key.getRouteDistinguisher();
    List<RoutePaths> routePaths = del.getRoutePaths();
    removeLabelFromVpnInstance(rd, routePaths);
}
Also used : VrfTablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey) RoutePaths(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentrybase.RoutePaths)

Example 52 with VrfEntry

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry 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);
}
Also used : MacVrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntry) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) VrfTables(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables) FibEntries(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.FibEntries) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap)

Example 53 with VrfEntry

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry in project netvirt by opendaylight.

the class BgpUtil method removeVrfEntry.

public void removeVrfEntry(String rd, VrfEntry vrfEntry) {
    LOG.debug("removeVrfEntry : vrf {} prefix {}", rd, vrfEntry.getDestPrefix());
    InstanceIdentifier<VrfEntry> vrfEntryId = InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd)).child(VrfEntry.class, new VrfEntryKey(vrfEntry.getDestPrefix())).build();
    delete(vrfEntryId);
}
Also used : VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) VrfTablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey) FibEntries(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.FibEntries) VrfEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntryKey)

Example 54 with VrfEntry

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry in project netvirt by opendaylight.

the class FibDSWriter method addFibEntryToDS.

public synchronized void addFibEntryToDS(String rd, String prefix, List<String> nextHopList, VrfEntry.EncapType encapType, int label, long l3vni, String gatewayMacAddress, RouteOrigin origin) {
    if (rd == null || rd.isEmpty()) {
        LOG.error("Prefix {} not associated with vpn", prefix);
        return;
    }
    Preconditions.checkNotNull(nextHopList, "NextHopList can't be null");
    for (String nextHop : nextHopList) {
        if (nextHop == null || nextHop.isEmpty()) {
            LOG.error("nextHop list contains null element");
            return;
        }
        LOG.debug("Created vrfEntry for {} nexthop {} label {}", prefix, nextHop, label);
    }
    // Looking for existing prefix in MDSAL database
    InstanceIdentifier<VrfEntry> vrfEntryId = InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd)).child(VrfEntry.class, new VrfEntryKey(prefix)).build();
    VrfEntryBuilder vrfEntryBuilder = new VrfEntryBuilder().setDestPrefix(prefix).setOrigin(origin.getValue());
    buildVpnEncapSpecificInfo(vrfEntryBuilder, encapType, label, l3vni, gatewayMacAddress, nextHopList);
    bgpUtil.update(vrfEntryId, vrfEntryBuilder.build());
}
Also used : MacVrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntry) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) VrfTablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey) FibEntries(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.FibEntries) MacVrfEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntryKey) VrfEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntryKey) MacVrfEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntryBuilder) VrfEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntryBuilder)

Example 55 with VrfEntry

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry in project netvirt by opendaylight.

the class FibDSWriter method removeFibEntryFromDS.

public synchronized void removeFibEntryFromDS(String rd, String prefix) {
    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 {}", prefix, rd);
    InstanceIdentifierBuilder<VrfEntry> idBuilder = InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd)).child(VrfEntry.class, new VrfEntryKey(prefix));
    InstanceIdentifier<VrfEntry> vrfEntryId = idBuilder.build();
    bgpUtil.delete(vrfEntryId);
}
Also used : MacVrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntry) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) VrfTablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey) VrfTables(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables) MacVrfEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntryKey) VrfEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntryKey)

Aggregations

VrfEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry)48 VrfTablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey)39 BigInteger (java.math.BigInteger)34 ArrayList (java.util.ArrayList)33 VpnInstanceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry)26 VrfTables (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables)23 FibEntries (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.FibEntries)22 VrfEntryKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntryKey)22 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)19 RoutePaths (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentrybase.RoutePaths)17 Routes (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes)17 Prefixes (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes)16 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)15 ExecutionException (java.util.concurrent.ExecutionException)14 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)14 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)14 RouteOrigin (org.opendaylight.netvirt.fibmanager.api.RouteOrigin)12 Optional (com.google.common.base.Optional)11 Collections (java.util.Collections)11 List (java.util.List)11