Search in sources :

Example 21 with Tables

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

the class GracefulCapabilityHandler method serializeCapability.

private ByteBuf serializeCapability(final GracefulRestartCapability grace) {
    final Map<TablesKey, Tables> tables = grace.getTables();
    final int tablesSize = tables != null ? tables.size() : 0;
    final ByteBuf bytes = Unpooled.buffer(HEADER_SIZE + PER_AFI_SAFI_SIZE * tablesSize);
    Uint16 time = grace.getRestartTime();
    if (time == null) {
        time = Uint16.ZERO;
    }
    final int timeval = time.toJava();
    Preconditions.checkArgument(timeval >= 0 && timeval <= MAX_RESTART_TIME, "Restart time is " + time);
    final GracefulRestartCapability.RestartFlags flags = grace.getRestartFlags();
    if (flags != null && flags.getRestartState()) {
        bytes.writeShort(RESTART_FLAG_STATE | timeval);
    } else {
        bytes.writeShort(timeval);
    }
    serializeTables(tables, bytes);
    return bytes;
}
Also used : RestartFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.GracefulRestartCapability.RestartFlags) TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.TablesKey) Uint16(org.opendaylight.yangtools.yang.common.Uint16) Tables(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.Tables) GracefulRestartCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.GracefulRestartCapability) ByteBuf(io.netty.buffer.ByteBuf)

Example 22 with Tables

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

the class LlGracefulCapabilityHandler method serializeCapability.

private ByteBuf serializeCapability(final LlGracefulRestartCapability cap) {
    final Map<TablesKey, Tables> tables = cap.getTables();
    if (tables == null || tables.isEmpty()) {
        return Unpooled.EMPTY_BUFFER;
    }
    final ByteBuf buffer = Unpooled.buffer(PER_TABLE_SIZE * tables.size());
    for (Tables table : tables.values()) {
        final Class<? extends AddressFamily> afi = table.getAfi();
        final Class<? extends SubsequentAddressFamily> safi = table.getSafi();
        final Integer afival = this.afiReg.numberForClass(afi);
        checkArgument(afival != null, "Unhandled address family %s", afi);
        buffer.writeShort(afival);
        final Integer safival = this.safiReg.numberForClass(safi);
        checkArgument(safival != null, "Unhandled subsequent address family %s", safi);
        buffer.writeByte(safival);
        if (table.getAfiFlags() != null && table.getAfiFlags().getForwardingState()) {
            buffer.writeByte(AFI_FLAG_FORWARDING_STATE);
        } else {
            buffer.writeByte(0);
        }
        final Uint24 staleTime = table.getLongLivedStaleTime();
        final int timeval = staleTime != null ? staleTime.getValue().intValue() : 0;
        checkArgument(timeval >= 0 && timeval <= MAX_STALE_TIME, "Restart time is %s", staleTime);
        buffer.writeMedium(timeval);
    }
    return buffer;
}
Also used : TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.ll.graceful.restart.capability.TablesKey) Tables(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.ll.graceful.restart.capability.Tables) Uint24(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.types.rev171204.Uint24) ByteBuf(io.netty.buffer.ByteBuf)

Example 23 with Tables

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

the class BGPPeer method onSessionUp.

@Override
public synchronized void onSessionUp(final BGPSession session) {
    this.currentSession = session;
    this.sessionUp = true;
    this.ribOutChain = this.rib.createPeerDOMChain(new DOMTransactionChainListener() {

        @Override
        public void onTransactionChainSuccessful(final DOMTransactionChain chain) {
            LOG.debug("RibOut transaction chain {} successful.", chain);
        }

        @Override
        public void onTransactionChainFailed(final DOMTransactionChain chain, final DOMDataTreeTransaction transaction, final Throwable cause) {
            onRibOutChainFailed(cause);
        }
    });
    if (this.currentSession instanceof BGPSessionStateProvider) {
        ((BGPSessionStateProvider) this.currentSession).registerMessagesCounter(this);
    }
    final GracefulRestartCapability advertisedGracefulRestartCapability = session.getAdvertisedGracefulRestartCapability();
    final var advertisedTables = advertisedGracefulRestartCapability.getTables();
    final var advertisedLLTables = session.getAdvertisedLlGracefulRestartCapability().getTables();
    final List<AddressFamilies> addPathTablesType = session.getAdvertisedAddPathTableTypes();
    final Set<BgpTableType> advertizedTableTypes = session.getAdvertisedTableTypes();
    LOG.info("Session with peer {} went up with tables {} and Add Path tables {}", getName(), advertizedTableTypes, addPathTablesType);
    final Set<TablesKey> setTables = advertizedTableTypes.stream().map(t -> new TablesKey(t.getAfi(), t.getSafi())).collect(Collectors.toSet());
    this.tables = ImmutableSet.copyOf(setTables);
    this.addPathTableMaps = mapTableTypesFamilies(addPathTablesType);
    final boolean restartingLocally = isLocalRestarting();
    if (!restartingLocally) {
        addBgp4Support();
    }
    if (!isRestartingGracefully()) {
        this.peerId = RouterIds.createPeerId(session.getBgpId());
        final KeyedInstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.bgp.rib.rib.Peer, PeerKey> peerIId = getInstanceIdentifier().child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.bgp.rib.rib.Peer.class, new PeerKey(this.peerId));
        this.peerPath = createPeerPath(this.peerId);
        this.peerRibOutIId = peerPath.node(ADJRIBOUT_NID);
        this.trackerRegistration = this.rib.getPeerTracker().registerPeer(this);
        createEffRibInWriter();
        registerPrefixesCounters(this.effRibInWriter, this.effRibInWriter);
        this.effRibInWriter.init();
        this.ribWriter = this.ribWriter.transform(this.peerId, this.peerPath, this.rib.getRibSupportContext(), this.tables, this.addPathTableMaps);
        if (this.rpcRegistry != null) {
            this.rpcRegistration = this.rpcRegistry.registerRpcImplementation(BgpPeerRpcService.class, new BgpPeerRpc(this, session, this.tables), ImmutableSet.of(this.rib.getInstanceIdentifier().child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.bgp.rib.rib.Peer.class, new PeerKey(this.peerId))));
        }
    } else {
        final Set<TablesKey> forwardingTables;
        if (advertisedTables == null) {
            forwardingTables = Collections.emptySet();
        } else {
            forwardingTables = advertisedTables.values().stream().filter(table -> table.getAfiFlags() != null).filter(table -> table.getAfiFlags().getForwardingState()).map(table -> new TablesKey(table.getAfi(), table.getSafi())).collect(Collectors.toSet());
        }
        this.ribWriter.clearTables(Sets.difference(this.tables, forwardingTables));
        if (restartingLocally) {
            this.effRibInWriter.close();
            this.peerRestartStopwatch = Stopwatch.createStarted();
            handleSelectionReferralTimer();
            this.missingEOT.addAll(this.tables);
        }
    }
    if (advertisedTables == null || advertisedTables.isEmpty()) {
        setAdvertizedGracefulRestartTableTypes(Collections.emptyList());
    } else {
        setAdvertizedGracefulRestartTableTypes(advertisedTables.values().stream().map(t -> new TablesKey(t.getAfi(), t.getSafi())).collect(Collectors.toList()));
    }
    setAfiSafiGracefulRestartState(advertisedGracefulRestartCapability.getRestartTime().toJava(), false, restartingLocally);
    final Map<TablesKey, Integer> llTablesReceived;
    if (advertisedLLTables != null) {
        llTablesReceived = new HashMap<>();
        for (var table : advertisedLLTables.values()) {
            llTablesReceived.put(new TablesKey(table.getAfi(), table.getSafi()), table.getLongLivedStaleTime().getValue().intValue());
        }
    } else {
        llTablesReceived = Collections.emptyMap();
    }
    setAdvertizedLlGracefulRestartTableTypes(llTablesReceived);
    if (!llTablesReceived.isEmpty()) {
        llgrSupport = true;
    // FIXME: propagate preserved tables
    } else {
        // FIXME: clear preserved tables
        llgrSupport = false;
    }
    if (!restartingLocally) {
        if (!setTables.contains(IPV4_UCAST_TABLE_KEY)) {
            createAdjRibOutListener(IPV4_UCAST_TABLE_KEY, false);
        }
        for (final TablesKey key : getAfiSafisAdvertized()) {
            createAdjRibOutListener(key, true);
        }
    }
    // SpotBugs does not grok Optional.ifPresent() and thinks we are using unsynchronized access
    final Optional<RevisedErrorHandlingSupport> errorHandling = this.bgpPeer.getErrorHandling();
    if (errorHandling.isPresent()) {
        this.currentSession.addDecoderConstraint(RevisedErrorHandlingSupport.class, errorHandling.get());
    }
}
Also used : AddressFamilies(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.add.path.capability.AddressFamilies) LoadingCache(com.google.common.cache.LoadingCache) RevisedErrorHandlingSupport(org.opendaylight.protocol.bgp.parser.spi.RevisedErrorHandlingSupport) BgpAddPathTableType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.BgpAddPathTableType) LoggerFactory(org.slf4j.LoggerFactory) PeerKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.bgp.rib.rib.PeerKey) Attributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes) MpReachNlriBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.MpReachNlriBuilder) BgpPeerRpcService(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.peer.rpc.rev180329.BgpPeerRpcService) Update(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update) MpReachNlri(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.MpReachNlri) Ipv4AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv4AddressFamily) LocalPreferenceAttributeParser(org.opendaylight.protocol.bgp.parser.impl.message.update.LocalPreferenceAttributeParser) GracefulRestartUtil(org.opendaylight.protocol.bgp.rib.impl.config.GracefulRestartUtil) Notification(org.opendaylight.yangtools.yang.binding.Notification) Nlri(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.update.message.Nlri) RouteRefresh(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.RouteRefresh) WithdrawnRoutesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.mp.unreach.nlri.WithdrawnRoutesBuilder) ObjectRegistration(org.opendaylight.yangtools.concepts.ObjectRegistration) Map(java.util.Map) SendReceive(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.SendReceive) AdvertizedRoutesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.mp.reach.nlri.AdvertizedRoutesBuilder) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) DestinationIpv4Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.prefixes.DestinationIpv4Builder) BgpPeer(org.opendaylight.protocol.bgp.rib.impl.config.BgpPeer) TABLES_NID(org.opendaylight.protocol.bgp.rib.spi.RIBNodeIdentifiers.TABLES_NID) CommitInfo(org.opendaylight.mdsal.common.api.CommitInfo) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) BgpParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.BgpParameters) Set(java.util.Set) TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey) BGPDocumentedException(org.opendaylight.protocol.bgp.parser.BGPDocumentedException) BGPSessionPreferences(org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences) Collectors(java.util.stream.Collectors) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder) Sets(com.google.common.collect.Sets) DestinationIpv4CaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationIpv4CaseBuilder) CacheLoader(com.google.common.cache.CacheLoader) Objects(java.util.Objects) MpUnreachNlri(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.MpUnreachNlri) List(java.util.List) DOMDataTreeTransaction(org.opendaylight.mdsal.dom.api.DOMDataTreeTransaction) GuardedBy(org.checkerframework.checker.lock.qual.GuardedBy) ADJRIBOUT_NID(org.opendaylight.protocol.bgp.rib.spi.RIBNodeIdentifiers.ADJRIBOUT_NID) DOMTransactionChain(org.opendaylight.mdsal.dom.api.DOMTransactionChain) BGPSessionStateProvider(org.opendaylight.protocol.bgp.rib.impl.state.BGPSessionStateProvider) BGPTerminationReason(org.opendaylight.protocol.bgp.rib.spi.BGPTerminationReason) Optional(java.util.Optional) CacheBuilder(com.google.common.cache.CacheBuilder) MpUnreachNlriBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.MpUnreachNlriBuilder) Registration(org.opendaylight.yangtools.concepts.Registration) NonNull(org.eclipse.jdt.annotation.NonNull) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) IpAddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone) BgpTableType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.BgpTableType) RIB(org.opendaylight.protocol.bgp.rib.impl.spi.RIB) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) DOMTransactionChainListener(org.opendaylight.mdsal.dom.api.DOMTransactionChainListener) Stopwatch(com.google.common.base.Stopwatch) GracefulRestartCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.GracefulRestartCapability) ClusterIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.ClusterIdentifier) RouterIds(org.opendaylight.protocol.bgp.rib.spi.RouterIds) HashMap(java.util.HashMap) BGPError(org.opendaylight.protocol.bgp.parser.BGPError) Ipv4PrefixesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.prefixes.destination.ipv4.Ipv4PrefixesBuilder) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Ipv4Prefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.prefixes.destination.ipv4.Ipv4Prefixes) BGPSessionState(org.opendaylight.protocol.bgp.rib.spi.state.BGPSessionState) AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.AddressFamily) RouteTarget(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.RouteTarget) SubsequentAddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.SubsequentAddressFamily) MessageUtil(org.opendaylight.protocol.bgp.parser.spi.MessageUtil) Objects.requireNonNull(java.util.Objects.requireNonNull) BGPSessionListener(org.opendaylight.protocol.bgp.rib.spi.BGPSessionListener) BGPTransportState(org.opendaylight.protocol.bgp.rib.spi.state.BGPTransportState) Logger(org.slf4j.Logger) RIBSupport(org.opendaylight.protocol.bgp.rib.spi.RIBSupport) PeerRole(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerRole) MoreObjects(com.google.common.base.MoreObjects) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates) TimeUnit(java.util.concurrent.TimeUnit) Ipv4Util(org.opendaylight.protocol.util.Ipv4Util) Futures(com.google.common.util.concurrent.Futures) Holding(org.checkerframework.checker.lock.qual.Holding) RpcProviderService(org.opendaylight.mdsal.binding.api.RpcProviderService) AsNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) BGPTableTypeRegistryConsumer(org.opendaylight.protocol.bgp.openconfig.spi.BGPTableTypeRegistryConsumer) BGPTimersState(org.opendaylight.protocol.bgp.rib.spi.state.BGPTimersState) Collections(java.util.Collections) UnicastSubsequentAddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.UnicastSubsequentAddressFamily) FluentFuture(com.google.common.util.concurrent.FluentFuture) BGPSession(org.opendaylight.protocol.bgp.rib.spi.BGPSession) RevisedErrorHandlingSupport(org.opendaylight.protocol.bgp.parser.spi.RevisedErrorHandlingSupport) Collections(java.util.Collections) AddressFamilies(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.add.path.capability.AddressFamilies) DOMDataTreeTransaction(org.opendaylight.mdsal.dom.api.DOMDataTreeTransaction) BGPSessionStateProvider(org.opendaylight.protocol.bgp.rib.impl.state.BGPSessionStateProvider) DOMTransactionChainListener(org.opendaylight.mdsal.dom.api.DOMTransactionChainListener) BgpTableType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.BgpTableType) TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey) BgpPeer(org.opendaylight.protocol.bgp.rib.impl.config.BgpPeer) DOMTransactionChain(org.opendaylight.mdsal.dom.api.DOMTransactionChain) PeerKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.bgp.rib.rib.PeerKey) BgpPeerRpcService(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.peer.rpc.rev180329.BgpPeerRpcService) GracefulRestartCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.GracefulRestartCapability)

Example 24 with Tables

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

the class BgpPeer method getBgpCapabilities.

@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "https://github.com/spotbugs/spotbugs/issues/811")
private static List<OptionalCapabilities> getBgpCapabilities(final AfiSafis afiSafis, final RIB rib, final BGPTableTypeRegistryConsumer tableTypeRegistry) {
    final List<OptionalCapabilities> caps = new ArrayList<>();
    caps.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().setAs4BytesCapability(new As4BytesCapabilityBuilder().setAsNumber(rib.getLocalAs()).build()).build()).build());
    caps.add(new OptionalCapabilitiesBuilder().setCParameters(BgpExtendedMessageUtil.EXTENDED_MESSAGE_CAPABILITY).build());
    caps.add(new OptionalCapabilitiesBuilder().setCParameters(MultiprotocolCapabilitiesUtil.RR_CAPABILITY).build());
    final Collection<AfiSafi> afiSafi = OpenConfigMappingUtil.getAfiSafiWithDefault(afiSafis, false).values();
    final List<AddressFamilies> addPathCapability = OpenConfigMappingUtil.toAddPathCapability(afiSafi, tableTypeRegistry);
    if (!addPathCapability.isEmpty()) {
        caps.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(new CParameters1Builder().setAddPathCapability(new AddPathCapabilityBuilder().setAddressFamilies(addPathCapability).build()).build()).build()).build());
    }
    final List<BgpTableType> tableTypes = OpenConfigMappingUtil.toTableTypes(afiSafi, tableTypeRegistry);
    for (final BgpTableType tableType : tableTypes) {
        if (!rib.getLocalTables().contains(tableType)) {
            LOG.info("RIB instance does not list {} in its local tables. Incoming data will be dropped.", tableType);
        }
        caps.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(new CParameters1Builder().setMultiprotocolCapability(new MultiprotocolCapabilityBuilder(tableType).build()).build()).build()).build());
    }
    return caps;
}
Also used : BgpTableType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.BgpTableType) OptionalCapabilitiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.OptionalCapabilitiesBuilder) MultiprotocolCapabilityBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.MultiprotocolCapabilityBuilder) AfiSafi(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi) ArrayList(java.util.ArrayList) OptionalCapabilities(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.OptionalCapabilities) As4BytesCapabilityBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.c.parameters.As4BytesCapabilityBuilder) CParametersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.CParametersBuilder) CParameters1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.CParameters1Builder) AddressFamilies(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.add.path.capability.AddressFamilies) AddPathCapabilityBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.AddPathCapabilityBuilder) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 25 with Tables

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

the class AdjRibsInWriterTest method testTransform.

@Test
public void testTransform() {
    this.writer = AdjRibInWriter.create(YangInstanceIdentifier.of(Rib.QNAME), PeerRole.Ebgp, this.ptc);
    assertNotNull(this.writer);
    final YangInstanceIdentifier peerPath = YangInstanceIdentifier.builder().node(RIB_NID).node(Peer.QNAME).nodeWithKey(Peer.QNAME, RIBQNames.PEER_ID_QNAME, this.peerIp).build();
    this.writer.transform(new PeerId(this.peerIp), peerPath, this.registry, this.tableTypes, ADD_PATH_TABLE_MAPS);
    verifyPeerSkeletonInsertedCorrectly(peerPath);
    // verify supported tables were inserted for ipv4
    verify(this.tx).put(eq(LogicalDatastoreType.OPERATIONAL), eq(peerPath.node(SupportedTables.QNAME).node(RibSupportUtils.toYangKey(SupportedTables.QNAME, K4))), any(NormalizedNode.class));
    verifyUptodateSetToFalse(peerPath);
}
Also used : NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) PeerId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerId) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)12 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)10 ArrayList (java.util.ArrayList)9 Table (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table)9 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)9 FlowKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey)7 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)6 ByteBuf (io.netty.buffer.ByteBuf)6 Map (java.util.Map)6 ExecutionException (java.util.concurrent.ExecutionException)6 TablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey)6 KeyedInstanceIdentifier (org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier)6 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)6 HashMap (java.util.HashMap)5 RIBSupport (org.opendaylight.protocol.bgp.rib.spi.RIBSupport)5 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)5 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)5 BigInteger (java.math.BigInteger)4 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)4 ItemSyncBox (org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox)4