Search in sources :

Example 21 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 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 22 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 NeighborUtil method buildAfiSafiState.

private static org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.State buildAfiSafiState(@Nonnull final BGPAfiSafiState neighbor, @Nonnull final TablesKey tablesKey, final boolean afiSafiSupported) {
    final NeighborAfiSafiStateAugmentationBuilder builder = new NeighborAfiSafiStateAugmentationBuilder();
    builder.setActive(afiSafiSupported);
    if (afiSafiSupported) {
        builder.setPrefixes(new PrefixesBuilder().setInstalled(neighbor.getPrefixesInstalledCount(tablesKey)).setReceived(neighbor.getPrefixesReceivedCount(tablesKey)).setSent(neighbor.getPrefixesSentCount(tablesKey)).build());
    }
    return new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.StateBuilder().addAugmentation(NeighborAfiSafiStateAugmentation.class, builder.build()).build();
}
Also used : AfiSafi(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi) StateBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.StateBuilder) NeighborAfiSafiStateAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborAfiSafiStateAugmentationBuilder) PrefixesBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.operational.rev151009.bgp.neighbor.prefix.counters_state.PrefixesBuilder) NeighborAfiSafiStateAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborAfiSafiStateAugmentation)

Example 23 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 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 24 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 BmpRibInWriter method checkEndOfRib.

/**
 * For each received Update message, the upd sync variable needs to be updated to true, for particular AFI/SAFI
 * combination. Currently we only assume Unicast SAFI. From the Update message we have to extract the AFI. Each
 * Update message can contain BGP Object with one type of AFI. If the object is BGP Link, BGP Node or a BGPPrefix
 * the AFI is Linkstate. In case of BGPRoute, the AFI depends on the IP Address of the prefix.
 *
 * @param msg received Update message
 */
private boolean checkEndOfRib(final UpdateMessage msg) {
    TablesKey type = new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
    boolean isEOR = false;
    if (msg.getNlri() == null && msg.getWithdrawnRoutes() == null) {
        if (msg.getAttributes() != null) {
            if (msg.getAttributes().getAugmentation(Attributes1.class) != null) {
                final Attributes1 pa = msg.getAttributes().getAugmentation(Attributes1.class);
                if (pa.getMpReachNlri() != null) {
                    type = new TablesKey(pa.getMpReachNlri().getAfi(), pa.getMpReachNlri().getSafi());
                }
            } else if (msg.getAttributes().getAugmentation(Attributes2.class) != null) {
                final Attributes2 pa = msg.getAttributes().getAugmentation(Attributes2.class);
                if (pa.getMpUnreachNlri() != null) {
                    type = new TablesKey(pa.getMpUnreachNlri().getAfi(), pa.getMpUnreachNlri().getSafi());
                }
                if (pa.getMpUnreachNlri().getWithdrawnRoutes() == null) {
                    // EOR message contains only MPUnreach attribute and no NLRI
                    isEOR = true;
                }
            }
        } else {
            // true for empty Update Message
            isEOR = true;
        }
    }
    if (isEOR) {
        markTableUptodated(type);
        LOG.debug("BMP Synchronization finished for table {} ", type);
    }
    return isEOR;
}
Also used : TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey) Attributes2(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes2) Attributes1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1)

Example 25 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 BmpRibInWriter method removeRoutes.

private synchronized void removeRoutes(final MpUnreachNlri nlri) {
    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;
    }
    LOG.trace("Removing routes {}", nlri);
    final DOMDataWriteTransaction tx = this.chain.newWriteOnlyTransaction();
    ctx.removeRoutes(tx, 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)

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