Search in sources :

Example 11 with NodeIdentifierWithPredicates

use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates in project bgpcep by opendaylight.

the class VpnIpv6RIBSupportTest method testRoutePath.

@Test
public void testRoutePath() {
    final NodeIdentifierWithPredicates prefixNii = createRouteNIWP(ROUTES);
    assertEquals(getRoutePath().node(prefixNii), RIB_SUPPORT.routePath(getTablePath().node(Routes.QNAME), prefixNii));
}
Also used : NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates) AbstractRIBSupportTest(org.opendaylight.protocol.bgp.rib.spi.AbstractRIBSupportTest) Test(org.junit.Test)

Example 12 with NodeIdentifierWithPredicates

use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates in project bgpcep by opendaylight.

the class AbstractLabeledUnicastRIBSupport method createRouteKey.

private NodeIdentifierWithPredicates createRouteKey(final UnkeyedListEntryNode labeledUnicast) {
    final ByteBuf buffer = Unpooled.buffer();
    final CLabeledUnicastDestination dest = extractCLabeledUnicastDestination(labeledUnicast);
    LUNlriParser.serializeNlri(Collections.singletonList(dest), false, buffer);
    final String routeKeyValue = ByteArray.encodeBase64(buffer);
    final Optional<DataContainerChild<? extends PathArgument, ?>> maybePathIdLeaf = labeledUnicast.getChild(routePathIdNid());
    final NodeIdentifierWithPredicates routeKey = PathIdUtil.createNidKey(routeQName(), routeKeyQName(), pathIdQName(), routeKeyValue, maybePathIdLeaf);
    return routeKey;
}
Also used : CLabeledUnicastDestination(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.labeled.unicast.destination.CLabeledUnicastDestination) DataContainerChild(org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild) PathArgument(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument) ByteBuf(io.netty.buffer.ByteBuf) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates)

Example 13 with NodeIdentifierWithPredicates

use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates in project bgpcep by opendaylight.

the class AbstractLabeledUnicastRIBSupport method processDestination.

@Override
protected void processDestination(final DOMDataWriteTransaction tx, final YangInstanceIdentifier routesPath, final ContainerNode destination, final ContainerNode attributes, final ApplyRoute function) {
    if (destination != null) {
        final Optional<DataContainerChild<? extends PathArgument, ?>> maybeRoutes = destination.getChild(NLRI_ROUTES_LIST);
        if (maybeRoutes.isPresent()) {
            final DataContainerChild<? extends PathArgument, ?> routes = maybeRoutes.get();
            if (routes instanceof UnkeyedListNode) {
                final YangInstanceIdentifier base = routesPath.node(routesContainerIdentifier()).node(routeNid());
                for (final UnkeyedListEntryNode e : ((UnkeyedListNode) routes).getValue()) {
                    final NodeIdentifierWithPredicates routeKey = createRouteKey(e);
                    function.apply(tx, base, routeKey, e, attributes);
                }
            } else {
                LOG.warn("Routes {} are not a map", routes);
            }
        }
    }
}
Also used : DataContainerChild(org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild) UnkeyedListEntryNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode) PathArgument(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) UnkeyedListNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode)

Example 14 with NodeIdentifierWithPredicates

use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates in project bgpcep by opendaylight.

the class AbstractVpnRIBSupport method createRouteKey.

private NodeIdentifierWithPredicates createRouteKey(final UnkeyedListEntryNode l3vpn) {
    final ByteBuf buffer = Unpooled.buffer();
    final VpnDestination dests = new VpnDestinationBuilder().setPrefix(extractPrefix(l3vpn, this.prefixTypeNid)).setRouteDistinguisher(extractRouteDistinguisher(l3vpn)).build();
    final ByteBuf nlriByteBuf = Unpooled.buffer();
    for (final VpnDestination dest : Collections.singletonList(dests)) {
        final IpPrefix prefix = dest.getPrefix();
        LOG.debug("Serializing Nlri: VpnDestination={}, IpPrefix={}", dest, prefix);
        AbstractVpnNlriParser.serializeLengtField(prefix, null, nlriByteBuf);
        RouteDistinguisherUtil.serializeRouteDistinquisher(dest.getRouteDistinguisher(), nlriByteBuf);
        Preconditions.checkArgument(prefix.getIpv6Prefix() != null || prefix.getIpv4Prefix() != null, "Ipv6 or Ipv4 prefix is missing.");
        LUNlriParser.serializePrefixField(prefix, nlriByteBuf);
    }
    buffer.writeBytes(nlriByteBuf);
    return new NodeIdentifierWithPredicates(routeQName(), this.routeKey, ByteArray.encodeBase64(buffer));
}
Also used : IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) VpnDestination(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.rev171207.l3vpn.ip.destination.type.VpnDestination) ByteBuf(io.netty.buffer.ByteBuf) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates) VpnDestinationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.rev171207.l3vpn.ip.destination.type.VpnDestinationBuilder)

Example 15 with NodeIdentifierWithPredicates

use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates in project bgpcep by opendaylight.

the class RIBImpl method startLocRib.

private synchronized void startLocRib(final TablesKey key) {
    LOG.debug("Creating LocRib table for {}", key);
    // create locRibWriter for each table
    final DOMDataWriteTransaction tx = this.domChain.newWriteOnlyTransaction();
    final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> table = ImmutableNodes.mapEntryBuilder();
    table.withNodeIdentifier(RibSupportUtils.toYangTablesKey(key));
    table.withChild(EMPTY_TABLE_ATTRIBUTES);
    final NodeIdentifierWithPredicates tableKey = RibSupportUtils.toYangTablesKey(key);
    final InstanceIdentifierBuilder tableId = YangInstanceIdentifier.builder(this.yangRibId.node(LocRib.QNAME).node(Tables.QNAME));
    tableId.nodeWithKey(tableKey.getNodeType(), tableKey.getKeyValues());
    for (final Entry<QName, Object> e : tableKey.getKeyValues().entrySet()) {
        table.withChild(ImmutableNodes.leafNode(e.getKey(), e.getValue()));
    }
    final RIBSupportContext supportContext = this.ribContextRegistry.getRIBSupportContext(key);
    if (supportContext != null) {
        final ChoiceNode routes = supportContext.getRibSupport().emptyRoutes();
        table.withChild(routes);
        tx.put(LogicalDatastoreType.OPERATIONAL, tableId.build(), table.build());
        try {
            tx.submit().checkedGet();
        } catch (final TransactionCommitFailedException e1) {
            LOG.error("Failed to initiate LocRIB for key {}", key, e1);
        }
    } else {
        LOG.warn("There's no registered RIB Context for {}", key.getAfi());
    }
}
Also used : TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) InstanceIdentifierBuilder(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.InstanceIdentifierBuilder) QName(org.opendaylight.yangtools.yang.common.QName) RIBSupportContext(org.opendaylight.protocol.bgp.rib.impl.spi.RIBSupportContext) ChoiceNode(org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates) MapEntryNode(org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode) DOMDataWriteTransaction(org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction)

Aggregations

NodeIdentifierWithPredicates (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates)97 Test (org.junit.Test)52 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)49 ArrayList (java.util.ArrayList)37 Flowspec (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.Flowspec)34 FlowspecBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.FlowspecBuilder)34 NumericOperand (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.NumericOperand)20 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)20 QName (org.opendaylight.yangtools.yang.common.QName)15 DestinationFlowspecBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.ipv4.DestinationFlowspecBuilder)12 PathArgument (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument)11 AbstractRIBSupportTest (org.opendaylight.protocol.bgp.rib.spi.AbstractRIBSupportTest)10 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)10 DOMDataWriteTransaction (org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction)9 DataContainerChild (org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild)7 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)6 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)6 BitmaskOperand (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.BitmaskOperand)6 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)5 DestinationFlowspecBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.ipv6.DestinationFlowspecBuilder)5