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));
}
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;
}
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);
}
}
}
}
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));
}
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());
}
}
Aggregations