Search in sources :

Example 6 with TablesKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey in project bgpcep by opendaylight.

the class BaseAbstractRouteEntry method addPathToDataStore.

@SuppressWarnings("unchecked")
private void addPathToDataStore(final RouteEntryDependenciesContainer entryDep, final Identifier routeKey, final WriteTransaction tx) {
    final RIBSupport ribSup = entryDep.getRibSupport();
    Identifier newRouteKey = ribSup.createNewRouteKey(this.bestPath.getPathId(), routeKey);
    if (newRouteKey == null) {
        newRouteKey = routeKey;
    }
    final Route route = createRoute(ribSup, newRouteKey, this.bestPath.getPathId(), this.bestPath);
    LOG.trace("Selected best route {}", route);
    final KeyedInstanceIdentifier<Tables, TablesKey> locRibTarget = entryDep.getLocRibTableTarget();
    final InstanceIdentifier routeTarget = ribSup.createRouteIdentifier(locRibTarget, newRouteKey);
    LOG.debug("Write route to LocRib {}", route);
    tx.put(LogicalDatastoreType.OPERATIONAL, routeTarget, route);
    fillAdjRibsOut(this.bestPath.getAttributes(), route, newRouteKey, this.bestPath.getPeerId(), entryDep, tx);
}
Also used : InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) Identifier(org.opendaylight.yangtools.yang.binding.Identifier) TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey) RIBSupport(org.opendaylight.protocol.bgp.rib.spi.RIBSupport) Tables(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.Tables) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) Route(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.Route)

Example 7 with TablesKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey in project bgpcep by opendaylight.

the class AddPathAbstractRouteEntry method initializeBestPaths.

@Override
public void initializeBestPaths(final RouteEntryDependenciesContainer entryDependencies, final RouteEntryInfo entryInfo, final WriteTransaction tx) {
    if (this.bestPath != null) {
        final Peer toPeer = entryInfo.getToPeer();
        final TablesKey localTk = entryDependencies.getLocalTablesKey();
        final boolean destPeerSupAddPath = toPeer.supportsAddPathSupported(localTk);
        for (final AddPathBestPath path : this.bestPath) {
            if (!filterRoutes(path.getPeerId(), toPeer, localTk)) {
                continue;
            }
            writeRoutePath(entryInfo, destPeerSupAddPath, path, localTk, entryDependencies, tx);
        }
    }
}
Also used : TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey) Peer(org.opendaylight.protocol.bgp.rib.spi.Peer)

Example 8 with TablesKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey in project bgpcep by opendaylight.

the class AddPathAbstractRouteEntry method fillAdjRibsOut.

@SuppressWarnings("unchecked")
private void fillAdjRibsOut(final boolean isFirstBestPath, final Attributes attributes, final Route routeNonAddPath, final Route routeAddPath, final Identifier routeKeyAddNonPath, final Identifier routeKeyAddPath, final PeerId fromPeerId, final TablesKey localTK, final RouteEntryDependenciesContainer routeEntryDep, final WriteTransaction tx) {
    /*
         * We need to keep track of routers and populate adj-ribs-out, too. If we do not, we need to
         * expose from which client a particular route was learned from in the local RIB, and have
         * the listener perform filtering.
         *
         * We walk the policy set in order to minimize the amount of work we do for multiple peers:
         * if we have two eBGP peers, for example, there is no reason why we should perform the translation
         * multiple times.
         */
    final RIBSupport ribSupport = routeEntryDep.getRibSupport();
    for (final Peer toPeer : this.peerTracker.getPeers()) {
        if (!filterRoutes(fromPeerId, toPeer, localTK)) {
            continue;
        }
        final boolean destPeerSupAddPath = toPeer.supportsAddPathSupported(localTK);
        if (toPeer.getPeerId().getValue().equals("bgp://127.0.0.5")) {
            LOG.debug("Write route {} to peer AdjRibsOut {}", toPeer.getPeerId());
        }
        if (peersSupportsAddPathOrIsFirstBestPath(destPeerSupAddPath, isFirstBestPath)) {
            Optional<Attributes> effAttrib = Optional.empty();
            final Peer fromPeer = this.peerTracker.getPeer(fromPeerId);
            if (fromPeer != null && attributes != null) {
                final BGPRouteEntryExportParameters baseExp = new BGPRouteEntryExportParametersImpl(fromPeer, toPeer);
                effAttrib = routeEntryDep.getRoutingPolicies().applyExportPolicies(baseExp, attributes);
            }
            Route newRoute = null;
            InstanceIdentifier ribOutRoute = null;
            if (destPeerSupAddPath) {
                newRoute = routeAddPath;
                ribOutRoute = ribSupport.createRouteIdentifier(toPeer.getRibOutIId(localTK), routeKeyAddPath);
            } else if (!this.oldNonAddPathBestPathTheSame) {
                ribOutRoute = ribSupport.createRouteIdentifier(toPeer.getRibOutIId(localTK), routeKeyAddNonPath);
                newRoute = routeNonAddPath;
            }
            if (effAttrib.isPresent() && newRoute != null) {
                LOG.debug("Write route {} to peer AdjRibsOut {}", newRoute, toPeer.getPeerId());
                tx.put(LogicalDatastoreType.OPERATIONAL, ribOutRoute, newRoute);
                tx.put(LogicalDatastoreType.OPERATIONAL, ribOutRoute.child(Attributes.class), effAttrib.get());
            } else if (ribOutRoute != null) {
                LOG.trace("Removing {} from transaction for peer {}", ribOutRoute, toPeer.getPeerId());
                tx.delete(LogicalDatastoreType.OPERATIONAL, ribOutRoute);
            }
        }
    }
}
Also used : RIBSupport(org.opendaylight.protocol.bgp.rib.spi.RIBSupport) Peer(org.opendaylight.protocol.bgp.rib.spi.Peer) Attributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) BGPRouteEntryExportParametersImpl(org.opendaylight.protocol.bgp.mode.impl.BGPRouteEntryExportParametersImpl) BGPRouteEntryExportParameters(org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters) Route(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.Route)

Example 9 with TablesKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey in project bgpcep by opendaylight.

the class AbstractRIBTestSetup method mockRib.

public void mockRib() throws Exception {
    final RIBExtensionProviderContext context = new SimpleRIBExtensionProviderContext();
    final ModuleInfoBackedContext strategy = createClassLoadingStrategy();
    final SchemaContext schemaContext = strategy.tryToCreateSchemaContext().get();
    this.codecFactory = createCodecFactory(strategy, schemaContext);
    final List<BgpTableType> localTables = new ArrayList<>();
    localTables.add(new BgpTableTypeImpl(AFI, SAFI));
    this.a1 = new RIBActivator();
    this.a1.startRIBExtensionProvider(context);
    final CodecsRegistryImpl codecsRegistry = CodecsRegistryImpl.create(this.codecFactory, GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy());
    mockedMethods();
    doReturn(mock(ClusterSingletonServiceRegistration.class)).when(this.clusterSingletonServiceProvider).registerClusterSingletonService(any(ClusterSingletonService.class));
    this.rib = new RIBImpl(new RibId("test"), new AsNumber(5L), RIB_ID, context, this.dispatcher, codecsRegistry, this.dom, getDataBroker(), this.policies, this.peerTracker, localTables, Collections.singletonMap(new TablesKey(AFI, SAFI), BasePathSelectionModeFactory.createBestPathSelectionStrategy(this.peerTracker)));
    this.rib.onGlobalContextUpdated(schemaContext);
    this.ribSupport = getRib().getRibSupportContext().getRIBSupport(KEY);
}
Also used : BgpTableType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.BgpTableType) TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey) RIBActivator(org.opendaylight.protocol.bgp.inet.RIBActivator) ArrayList(java.util.ArrayList) AsNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber) ModuleInfoBackedContext(org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext) SimpleRIBExtensionProviderContext(org.opendaylight.protocol.bgp.rib.spi.SimpleRIBExtensionProviderContext) RibId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.RibId) SimpleRIBExtensionProviderContext(org.opendaylight.protocol.bgp.rib.spi.SimpleRIBExtensionProviderContext) RIBExtensionProviderContext(org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderContext) ClusterSingletonServiceRegistration(org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration) ClusterSingletonService(org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService) SchemaContext(org.opendaylight.yangtools.yang.model.api.SchemaContext) BgpTableTypeImpl(org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl)

Example 10 with TablesKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey in project bgpcep by opendaylight.

the class BgpPeerRpcTest method setUp.

@Before
public void setUp() throws InterruptedException, ExecutionException {
    MockitoAnnotations.initMocks(this);
    this.rpc = new BgpPeerRpc(this.peerRpcs, this.session, Collections.singleton(new TablesKey(Ipv4AddressFamily.class, SubsequentAddressFamily.class)));
    final ChannelOutputLimiter limiter = new ChannelOutputLimiter(this.session);
    Mockito.doReturn(limiter).when(this.session).getLimiter();
    Mockito.doReturn(this.future).when(this.session).writeAndFlush(Mockito.any(Notification.class));
    Mockito.doReturn(true).when(this.future).isDone();
    Mockito.doReturn(null).when(this.future).get();
    Mockito.doReturn(true).when(this.future).isSuccess();
}
Also used : TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey) Ipv4AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily) SubsequentAddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.SubsequentAddressFamily) Notification(org.opendaylight.yangtools.yang.binding.Notification) Before(org.junit.Before)

Aggregations

TablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey)35 RIBSupport (org.opendaylight.protocol.bgp.rib.spi.RIBSupport)10 KeyedInstanceIdentifier (org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier)10 Tables (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.Tables)9 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)9 Before (org.junit.Before)7 RibId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.RibId)7 PathSelectionMode (org.opendaylight.protocol.bgp.mode.api.PathSelectionMode)6 Peer (org.opendaylight.protocol.bgp.rib.spi.Peer)6 Identifier (org.opendaylight.yangtools.yang.binding.Identifier)6 DOMDataWriteTransaction (org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction)5 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes)5 Route (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.Route)5 BgpId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpId)5 BGPRouteEntryExportParametersImpl (org.opendaylight.protocol.bgp.mode.impl.BGPRouteEntryExportParametersImpl)4 BGPRouteEntryExportParameters (org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters)4 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)4 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder)4 Nlri (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.update.message.Nlri)4 ChannelFuture (io.netty.channel.ChannelFuture)3