Search in sources :

Example 21 with Prefixes

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.operational.rev151009.bgp.neighbor.prefix.counters_state.Prefixes in project bgpcep by opendaylight.

the class GenericConditionPolicyHandler method createPrefixes.

private static List<IpPrefix> createPrefixes(final Prefix prefixContainer) {
    final IpPrefix prefix = prefixContainer.getIpPrefix();
    if (prefixContainer.getMasklengthRange().equals(EXACT)) {
        return Collections.singletonList(prefix);
    }
    final String[] range = prefixContainer.getMasklengthRange().split("\\..");
    boolean ipv4 = false;
    final String prefixString;
    if (prefix.getIpv4Prefix() != null) {
        prefixString = prefix.getIpv4Prefix().getValue();
        ipv4 = true;
    } else {
        prefixString = prefix.getIpv6Prefix().getValue();
    }
    int from = Integer.parseInt(range[0]);
    final List<IpPrefix> prefixes = new ArrayList<>();
    while (from <= Integer.parseInt(range[1])) {
        final String prefixVal = StringUtils.replacePattern(prefixString, "[/][0-9]+", "/" + Integer.toString(from));
        if (ipv4) {
            prefixes.add(new IpPrefix(new Ipv4Prefix(prefixVal)));
        } else {
            prefixes.add(new IpPrefix(new Ipv6Prefix(prefixVal)));
        }
        from++;
    }
    return prefixes;
}
Also used : IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) ArrayList(java.util.ArrayList) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) Ipv6Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix)

Example 22 with Prefixes

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.operational.rev151009.bgp.neighbor.prefix.counters_state.Prefixes in project bgpcep by opendaylight.

the class BmpRibInWriter method prefixesToMpReach.

/**
 * Creates MPReach for the prefixes to be handled in the same way as linkstate routes.
 *
 * @param message Update message containing prefixes in NLRI
 * @return MpReachNlri with prefixes from the nlri field
 */
private static MpReachNlri prefixesToMpReach(final UpdateMessage message) {
    final List<Ipv4Prefixes> prefixes = message.getNlri().stream().map(n -> new Ipv4PrefixesBuilder().setPrefix(n.getPrefix()).setPathId(n.getPathId()).build()).collect(Collectors.toList());
    final MpReachNlriBuilder b = new MpReachNlriBuilder().setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new DestinationIpv4CaseBuilder().setDestinationIpv4(new DestinationIpv4Builder().setIpv4Prefixes(prefixes).build()).build()).build());
    if (message.getAttributes() != null) {
        b.setCNextHop(message.getAttributes().getCNextHop());
    }
    return b.build();
}
Also used : BMP_ATTRIBUTES_QNAME(org.opendaylight.protocol.bmp.impl.app.TablesUtil.BMP_ATTRIBUTES_QNAME) AdvertizedRoutesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.mp.reach.nlri.AdvertizedRoutesBuilder) BindingCodecTree(org.opendaylight.mdsal.binding.dom.codec.api.BindingCodecTree) WithdrawnRoutesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.mp.unreach.nlri.WithdrawnRoutesBuilder) Attributes1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1) LoggerFactory(org.slf4j.LoggerFactory) MpReachNlriBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlriBuilder) UpdateMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.UpdateMessage) MpUnreachNlriBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpUnreachNlriBuilder) ArrayList(java.util.ArrayList) DestinationIpv4Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.ipv4.prefixes.DestinationIpv4Builder) DestinationIpv4CaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationIpv4CaseBuilder) Map(java.util.Map) UnicastSubsequentAddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) Nonnull(javax.annotation.Nonnull) DOMTransactionChain(org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain) LeafNode(org.opendaylight.yangtools.yang.data.api.schema.LeafNode) Logger(org.slf4j.Logger) ImmutableMap(com.google.common.collect.ImmutableMap) RIBSupport(org.opendaylight.protocol.bgp.rib.spi.RIBSupport) TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) Set(java.util.Set) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates) Ipv4PrefixesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.ipv4.prefixes.destination.ipv4.Ipv4PrefixesBuilder) Collectors(java.util.stream.Collectors) MpUnreachNlri(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpUnreachNlri) QName(org.opendaylight.yangtools.yang.common.QName) Ipv4Prefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.ipv4.prefixes.destination.ipv4.Ipv4Prefixes) Ipv4AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily) List(java.util.List) MpReachNlri(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlri) ImmutableNodes(org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes) Attributes2(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes2) DOMDataWriteTransaction(org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction) InstanceIdentifierBuilder(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.InstanceIdentifierBuilder) RIBExtensionConsumerContext(org.opendaylight.protocol.bgp.rib.spi.RIBExtensionConsumerContext) MpReachNlriBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlriBuilder) AdvertizedRoutesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.mp.reach.nlri.AdvertizedRoutesBuilder) Ipv4PrefixesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.ipv4.prefixes.destination.ipv4.Ipv4PrefixesBuilder) DestinationIpv4CaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationIpv4CaseBuilder) Ipv4Prefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.ipv4.prefixes.destination.ipv4.Ipv4Prefixes) DestinationIpv4Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.ipv4.prefixes.DestinationIpv4Builder) UnicastSubsequentAddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily)

Example 23 with Prefixes

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.operational.rev151009.bgp.neighbor.prefix.counters_state.Prefixes in project bgpcep by opendaylight.

the class BmpRibInWriter method prefixesToMpUnreach.

/**
 * Create MPUnreach for the prefixes to be handled in the same way as linkstate routes.
 *
 * @param message Update message containing withdrawn routes
 * @return MpUnreachNlri with prefixes from the withdrawn routes field
 */
private static MpUnreachNlri prefixesToMpUnreach(final UpdateMessage message) {
    final List<Ipv4Prefixes> prefixes = new ArrayList<>();
    message.getWithdrawnRoutes().forEach(w -> prefixes.add(new Ipv4PrefixesBuilder().setPrefix(w.getPrefix()).setPathId(w.getPathId()).build()));
    return new MpUnreachNlriBuilder().setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv4CaseBuilder().setDestinationIpv4(new DestinationIpv4Builder().setIpv4Prefixes(prefixes).build()).build()).build()).build();
}
Also used : Ipv4Prefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.ipv4.prefixes.destination.ipv4.Ipv4Prefixes) Ipv4AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily) ArrayList(java.util.ArrayList) MpUnreachNlriBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpUnreachNlriBuilder) DestinationIpv4Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.ipv4.prefixes.DestinationIpv4Builder) WithdrawnRoutesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.mp.unreach.nlri.WithdrawnRoutesBuilder) Ipv4PrefixesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.ipv4.prefixes.destination.ipv4.Ipv4PrefixesBuilder) DestinationIpv4CaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationIpv4CaseBuilder)

Example 24 with Prefixes

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.operational.rev151009.bgp.neighbor.prefix.counters_state.Prefixes in project bgpcep by opendaylight.

the class GlobalStateCliUtils method displayRibOperationalState.

static void displayRibOperationalState(@NonNull final String ribId, @NonNull final Global global, @NonNull final PrintStream stream) {
    final State globalState = global.getState();
    final ShellTable table = new ShellTable();
    table.column("Attribute").alignLeft();
    table.column("Value").alignLeft();
    addHeader(table, "RIB state");
    table.addRow().addContent("Router Id", ribId);
    table.addRow().addContent("As", globalState.getAs());
    table.addRow().addContent("Total Paths", globalState.getTotalPaths());
    table.addRow().addContent("Total Prefixes", globalState.getTotalPrefixes());
    global.getAfiSafis().getAfiSafi().forEach(afiSafi -> displayAfiSafi(afiSafi, table));
    table.print(stream);
}
Also used : ShellTable(org.apache.karaf.shell.table.ShellTable) State(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.State)

Example 25 with Prefixes

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.operational.rev151009.bgp.neighbor.prefix.counters_state.Prefixes in project bgpcep by opendaylight.

the class GlobalStateCliUtils method displayAfiSafi.

private static void displayAfiSafi(final AfiSafi afiSafi, final ShellTable table) {
    final GlobalAfiSafiStateAugmentation state = afiSafi.getState().getAugmentation(GlobalAfiSafiStateAugmentation.class);
    addHeader(table, "AFI/SAFI state");
    table.addRow().addContent("Family", afiSafi.getAfiSafiName().getSimpleName());
    if (state == null) {
        return;
    }
    table.addRow().addContent("Total Paths", state.getTotalPaths());
    table.addRow().addContent("Total Prefixes", state.getTotalPrefixes());
}
Also used : GlobalAfiSafiStateAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.GlobalAfiSafiStateAugmentation)

Aggregations

ArrayList (java.util.ArrayList)21 Prefixes (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes)14 BigInteger (java.math.BigInteger)13 List (java.util.List)9 Routes (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes)8 Logger (org.slf4j.Logger)8 LoggerFactory (org.slf4j.LoggerFactory)8 Collections (java.util.Collections)7 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)7 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)7 DestinationIpv4Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.ipv4.prefixes.DestinationIpv4Builder)7 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)7 Optional (com.google.common.base.Optional)6 Inject (javax.inject.Inject)6 Singleton (javax.inject.Singleton)6 Test (org.junit.Test)6 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)6 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)6 MDSALUtil (org.opendaylight.genius.mdsalutil.MDSALUtil)6 NwConstants (org.opendaylight.genius.mdsalutil.NwConstants)6