Search in sources :

Example 31 with TablesKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.TablesKey in project bgpcep by opendaylight.

the class BmpRibInWriter method createTableInstance.

/**
 * Create new table instance.
 */
private static ImmutableMap.Builder<TablesKey, TableContext> createTableInstance(final Set<TablesKey> tableTypes, final YangInstanceIdentifier yangTableRootIId, final DOMDataTreeWriteTransaction tx, final RIBExtensionConsumerContext ribExtensions, final BindingCodecTree tree) {
    final ImmutableMap.Builder<TablesKey, TableContext> tb = ImmutableMap.builder();
    for (final TablesKey k : tableTypes) {
        final RIBSupport rs = ribExtensions.getRIBSupport(k);
        if (rs == null) {
            LOG.warn("No support for table type {}, skipping it", k);
            continue;
        }
        final TableContext ctx = new TableContext(rs, yangTableRootIId.node(TablesUtil.toYangTablesKey(k)).toOptimized(), tree);
        ctx.createTable(tx);
        tx.put(LogicalDatastoreType.OPERATIONAL, ctx.getTableId().node(BMP_ATTRIBUTES_QNAME).node(ATTRIBUTES_UPTODATE_FALSE.getIdentifier()), ATTRIBUTES_UPTODATE_FALSE);
        LOG.debug("Created table instance {}", ctx.getTableId());
        tb.put(k, ctx);
    }
    return tb;
}
Also used : TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey) RIBSupport(org.opendaylight.protocol.bgp.rib.spi.RIBSupport) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 32 with TablesKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.TablesKey in project bgpcep by opendaylight.

the class GlobalUtil method buildAfiSafi.

/**
 * Build Afi Safi containing State.
 *
 * @param ribState             containing RIb Operational State
 * @param tablesKey            table Key
 * @param bgpTableTypeRegistry BGP TableType Registry
 * @return Afi Safi Operational State
 */
public static AfiSafi buildAfiSafi(final BGPRibState ribState, final TablesKey tablesKey, final BGPTableTypeRegistryConsumer bgpTableTypeRegistry) {
    final Optional<Class<? extends AfiSafiType>> optAfiSafi = bgpTableTypeRegistry.getAfiSafiType(tablesKey);
    if (!optAfiSafi.isPresent()) {
        return null;
    }
    final State state = new StateBuilder().addAugmentation(GlobalAfiSafiStateAugmentation.class, new GlobalAfiSafiStateAugmentationBuilder().setTotalPaths(ribState.getPathCount(tablesKey)).setTotalPrefixes(ribState.getPrefixesCount(tablesKey)).build()).build();
    return new AfiSafiBuilder().setAfiSafiName(optAfiSafi.get()).setState(state).build();
}
Also used : GlobalAfiSafiStateAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.GlobalAfiSafiStateAugmentation) AfiSafiBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafiBuilder) GlobalAfiSafiStateAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.GlobalAfiSafiStateAugmentationBuilder) BGPRibState(org.opendaylight.protocol.bgp.rib.spi.state.BGPRibState) State(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.State) StateBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.StateBuilder) AfiSafiType(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType)

Example 33 with TablesKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.TablesKey in project bgpcep by opendaylight.

the class BmpRibInWriter method addRoutes.

private synchronized void addRoutes(final MpReachNlri nlri, final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes attributes) {
    final TablesKey key = new TablesKey(nlri.getAfi(), nlri.getSafi());
    final TableContext ctx = this.tables.get(key);
    if (ctx == null) {
        LOG.debug("No table for {}, not accepting NLRI {}", key, nlri);
        return;
    }
    final DOMDataWriteTransaction tx = this.chain.newWriteOnlyTransaction();
    ctx.writeRoutes(tx, nlri, attributes);
    LOG.trace("Write routes {}", nlri);
    tx.submit();
}
Also used : TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey) DOMDataWriteTransaction(org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction)

Example 34 with TablesKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.TablesKey in project bgpcep by opendaylight.

the class BGPPeer method addBgp4Support.

// try to add a support for old-school BGP-4, if peer did not advertise IPv4-Unicast MP capability
private synchronized void addBgp4Support() {
    final TablesKey key = new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
    if (!this.tables.contains(key)) {
        final HashSet<TablesKey> newSet = new HashSet<>(this.tables);
        newSet.add(key);
        this.tables = ImmutableSet.copyOf(newSet);
        createAdjRibOutListener(key, false);
    }
}
Also used : TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey) HashSet(java.util.HashSet)

Example 35 with TablesKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.TablesKey in project bgpcep by opendaylight.

the class AdjRibInWriter method createNewTableInstances.

/**
 * Create new table instances, potentially creating their empty entries
 */
private ImmutableMap<TablesKey, TableContext> createNewTableInstances(final YangInstanceIdentifier newPeerPath, final RIBSupportContextRegistry registry, final Set<TablesKey> tableTypes, final Map<TablesKey, SendReceive> addPathTablesType, final DOMDataWriteTransaction tx) {
    final Builder<TablesKey, TableContext> tb = ImmutableMap.builder();
    for (final TablesKey tableKey : tableTypes) {
        final RIBSupportContext rs = registry.getRIBSupportContext(tableKey);
        // TODO: Use returned value once Instance Identifier builder allows for it.
        final NodeIdentifierWithPredicates instanceIdentifierKey = RibSupportUtils.toYangTablesKey(tableKey);
        if (rs == null) {
            LOG.warn("No support for table type {}, skipping it", tableKey);
            continue;
        }
        installAdjRibsOutTables(newPeerPath, rs, instanceIdentifierKey, tableKey, addPathTablesType.get(tableKey), tx);
        installAdjRibInTables(newPeerPath, tableKey, rs, instanceIdentifierKey, tx, tb);
    }
    return tb.build();
}
Also used : TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey) RIBSupportContext(org.opendaylight.protocol.bgp.rib.impl.spi.RIBSupportContext) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates)

Aggregations

TablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey)40 TablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey)15 RIBSupport (org.opendaylight.protocol.bgp.rib.spi.RIBSupport)11 KeyedInstanceIdentifier (org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier)11 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)9 Before (org.junit.Before)8 Test (org.junit.Test)8 PathSelectionMode (org.opendaylight.protocol.bgp.mode.api.PathSelectionMode)8 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)8 ArrayList (java.util.ArrayList)7 CommitInfo (org.opendaylight.mdsal.common.api.CommitInfo)7 Peer (org.opendaylight.protocol.bgp.rib.spi.Peer)6 Identifier (org.opendaylight.yangtools.yang.binding.Identifier)6 DOMDataTreeWriteTransaction (org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction)5 RibId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.RibId)5 ChannelFuture (io.netty.channel.ChannelFuture)4 InetSocketAddress (java.net.InetSocketAddress)4 HashMap (java.util.HashMap)4 BGPRouteEntryExportParametersImpl (org.opendaylight.protocol.bgp.mode.impl.BGPRouteEntryExportParametersImpl)4 BGPRouteEntryExportParameters (org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters)4