use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument in project bgpcep by opendaylight.
the class AbstractIPRibSupport method createRouteKey.
/**
* Prefix and Path Id are the route key.
*
* @param prefixes UnkeyedListEntryNode containing route
* @return Nid with Route Key
*/
private NodeIdentifierWithPredicates createRouteKey(final UnkeyedListEntryNode prefixes) {
final Optional<DataContainerChild<? extends PathArgument, ?>> maybePrefixLeaf = prefixes.getChild(routePrefixIdentifier());
final Optional<DataContainerChild<? extends PathArgument, ?>> maybePathIdLeaf = prefixes.getChild(routePathIdNid());
Preconditions.checkState(maybePrefixLeaf.isPresent());
final Object prefixValue = maybePrefixLeaf.get().getValue();
return PathIdUtil.createNidKey(routeQName(), routeKeyQName(), pathIdQName(), prefixValue, maybePathIdLeaf);
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument in project bgpcep by opendaylight.
the class AbstractIPRibSupport 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(this.nlriRoutesList);
if (maybeRoutes.isPresent()) {
final DataContainerChild<? extends PathArgument, ?> routes = maybeRoutes.get();
if (routes instanceof UnkeyedListNode) {
// Instance identifier to table/(choice routes)/(map of route)
// FIXME: cache on per-table basis (in TableContext, for example)
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.PathArgument in project bgpcep by opendaylight.
the class AbstractVpnRIBSupport 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(this.nlriRoutesListNid);
if (maybeRoutes.isPresent()) {
final DataContainerChild<? extends PathArgument, ?> routes = maybeRoutes.get();
if (routes instanceof UnkeyedListNode) {
final UnkeyedListNode routeListNode = (UnkeyedListNode) routes;
LOG.debug("{} routes are found", routeListNode.getSize());
final YangInstanceIdentifier base = routesPath.node(routesContainerIdentifier()).node(routeNid());
for (final UnkeyedListEntryNode e : routeListNode.getValue()) {
final NodeIdentifierWithPredicates key = createRouteKey(e);
LOG.debug("Route {} is processed.", key);
function.apply(tx, base, key, e, attributes);
}
} else {
LOG.warn("Routes {} are not a map", routes);
}
}
} else {
LOG.debug("Destination is null.");
}
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument in project bgpcep by opendaylight.
the class LinkstateNlriParser method serializeAdvertisedNodeDescriptor.
private static void serializeAdvertisedNodeDescriptor(final CLinkstateDestinationBuilder builder, final ChoiceNode objectType) {
// prefix node descriptors
final PrefixCaseBuilder prefixBuilder = new PrefixCaseBuilder();
prefixBuilder.setAdvertisingNodeDescriptors(NodeNlriParser.serializeAdvNodeDescriptors((ContainerNode) objectType.getChild(ADVERTISING_NODE_DESCRIPTORS_NID).get()));
// prefix descriptors
final Optional<DataContainerChild<? extends PathArgument, ?>> prefixDescriptors = objectType.getChild(PREFIX_DESCRIPTORS_NID);
if (prefixDescriptors.isPresent()) {
prefixBuilder.setPrefixDescriptors(AbstractPrefixNlriParser.serializePrefixDescriptors((ContainerNode) prefixDescriptors.get()));
}
builder.setObjectType(prefixBuilder.build());
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument in project bgpcep by opendaylight.
the class NodeNlriParser method serializeRouterId.
private static CRouterIdentifier serializeRouterId(final ContainerNode descriptorsData) {
CRouterIdentifier cRouterId = null;
final Optional<DataContainerChild<? extends PathArgument, ?>> maybeRouterId = descriptorsData.getChild(ROUTER_NID);
if (maybeRouterId.isPresent()) {
final ChoiceNode routerId = (ChoiceNode) maybeRouterId.get();
if (routerId.getChild(ISIS_NODE_NID).isPresent()) {
cRouterId = serializeIsisNode((ContainerNode) routerId.getChild(ISIS_NODE_NID).get());
} else if (routerId.getChild(ISIS_PSEUDONODE_NID).isPresent()) {
cRouterId = serializeIsisPseudoNode((ContainerNode) routerId.getChild(ISIS_PSEUDONODE_NID).get());
} else if (routerId.getChild(OSPF_NODE_NID).isPresent()) {
cRouterId = serializeOspfNode((ContainerNode) routerId.getChild(OSPF_NODE_NID).get());
} else if (routerId.getChild(OSPF_PSEUDONODE_NID).isPresent()) {
cRouterId = serializeOspfPseudoNode((ContainerNode) routerId.getChild(OSPF_PSEUDONODE_NID).get());
}
}
return cRouterId;
}
Aggregations