Search in sources :

Example 1 with UnkeyedListNode

use of org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode in project bgpcep by opendaylight.

the class AbstractFlowspecNlriParser method extractFlowspec.

public final List<Flowspec> extractFlowspec(final DataContainerNode<?> route) {
    requireNonNull(route, "Cannot extract flowspec from null route.");
    final List<Flowspec> fsList = new ArrayList<>();
    final Optional<DataContainerChild<? extends PathArgument, ?>> flowspecs = route.getChild(FLOWSPEC_NID);
    if (flowspecs.isPresent()) {
        for (final UnkeyedListEntryNode flowspec : ((UnkeyedListNode) flowspecs.get()).getValue()) {
            final FlowspecBuilder fsBuilder = new FlowspecBuilder();
            final Optional<DataContainerChild<?, ?>> flowspecType = flowspec.getChild(FLOWSPEC_TYPE_NID);
            if (flowspecType.isPresent()) {
                final ChoiceNode fsType = (ChoiceNode) flowspecType.get();
                processFlowspecType(fsType, fsBuilder);
            }
            fsList.add(fsBuilder.build());
        }
    }
    return fsList;
}
Also used : FlowspecBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.FlowspecBuilder) DataContainerChild(org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild) ArrayList(java.util.ArrayList) Flowspec(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.Flowspec) UnkeyedListEntryNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode) ChoiceNode(org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode) PathArgument(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument) UnkeyedListNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode)

Example 2 with UnkeyedListNode

use of org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode 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 3 with UnkeyedListNode

use of org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode in project bgpcep by opendaylight.

the class AbstractLabeledUnicastRIBSupport method extractLabel.

public static List<LabelStack> extractLabel(final DataContainerNode<? extends PathArgument> route, final NodeIdentifier labelStackNid, final NodeIdentifier labelValueNid) {
    final List<LabelStack> labels = new ArrayList<>();
    final Optional<DataContainerChild<? extends PathArgument, ?>> labelStacks = route.getChild(labelStackNid);
    if (labelStacks.isPresent()) {
        for (final UnkeyedListEntryNode label : ((UnkeyedListNode) labelStacks.get()).getValue()) {
            final Optional<DataContainerChild<? extends PathArgument, ?>> labelStack = label.getChild(labelValueNid);
            if (labelStack.isPresent()) {
                final LabelStackBuilder labelStackbuilder = new LabelStackBuilder();
                labelStackbuilder.setLabelValue(new MplsLabel((Long) labelStack.get().getValue()));
                labels.add(labelStackbuilder.build());
            }
        }
    }
    return labels;
}
Also used : LabelStackBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.labeled.unicast.LabelStackBuilder) LabelStack(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.labeled.unicast.LabelStack) DataContainerChild(org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild) ArrayList(java.util.ArrayList) UnkeyedListEntryNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode) MplsLabel(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.MplsLabel) PathArgument(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument) UnkeyedListNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode)

Example 4 with UnkeyedListNode

use of org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode in project controller by opendaylight.

the class SerializationUtilsTest method createNormalizedNode.

private static NormalizedNode<?, ?> createNormalizedNode() {
    final LeafSetNode<Object> leafSetNode = Builders.leafSetBuilder().withNodeIdentifier(id("leafSetNode")).withChild(createLeafSetEntry("leafSetNode", "leafSetValue1")).withChild(createLeafSetEntry("leafSetNode", "leafSetValue2")).build();
    final LeafSetNode<Object> orderedLeafSetNode = Builders.orderedLeafSetBuilder().withNodeIdentifier(id("orderedLeafSetNode")).withChild(createLeafSetEntry("orderedLeafSetNode", "value1")).withChild(createLeafSetEntry("orderedLeafSetNode", "value2")).build();
    final LeafNode<Boolean> booleanLeaf = createLeaf("booleanLeaf", true);
    final LeafNode<Byte> byteLeaf = createLeaf("byteLeaf", (byte) 0);
    final LeafNode<Short> shortLeaf = createLeaf("shortLeaf", (short) 55);
    final LeafNode<Integer> intLeaf = createLeaf("intLeaf", 11);
    final LeafNode<Long> longLeaf = createLeaf("longLeaf", 151515L);
    final LeafNode<String> stringLeaf = createLeaf("stringLeaf", "stringValue");
    final LeafNode<String> longStringLeaf = createLeaf("longStringLeaf", getLongString());
    final LeafNode<QName> qNameLeaf = createLeaf("stringLeaf", QName.create("base", "qName"));
    final LeafNode<YangInstanceIdentifier> idLeaf = createLeaf("stringLeaf", YangInstanceIdentifier.EMPTY);
    final MapEntryNode entry1 = Builders.mapEntryBuilder().withNodeIdentifier(listId("mapNode", "key", "key1")).withChild(stringLeaf).build();
    final MapEntryNode entry2 = Builders.mapEntryBuilder().withNodeIdentifier(listId("mapNode", "key", "key2")).withChild(stringLeaf).build();
    final MapNode mapNode = Builders.mapBuilder().withNodeIdentifier(id("mapNode")).withChild(entry1).withChild(entry2).build();
    final OrderedMapNode orderedMapNode = Builders.orderedMapBuilder().withNodeIdentifier(id("orderedMapNode")).withChild(entry2).withChild(entry1).build();
    final UnkeyedListEntryNode unkeyedListEntry1 = Builders.unkeyedListEntryBuilder().withNodeIdentifier(id("unkeyedList")).withChild(stringLeaf).build();
    final UnkeyedListEntryNode unkeyedListEntry2 = Builders.unkeyedListEntryBuilder().withNodeIdentifier(id("unkeyedList")).withChild(stringLeaf).build();
    final UnkeyedListNode unkeyedListNode = Builders.unkeyedListBuilder().withNodeIdentifier(id("unkeyedList")).withChild(unkeyedListEntry1).withChild(unkeyedListEntry2).build();
    final ImmutableSet<QName> childNames = ImmutableSet.of(QName.create(CONTAINER_Q_NAME, "aug1"), QName.create(CONTAINER_Q_NAME, "aug1"));
    final AugmentationNode augmentationNode = Builders.augmentationBuilder().withNodeIdentifier(new YangInstanceIdentifier.AugmentationIdentifier(childNames)).withChild(createLeaf("aug1", "aug1Value")).withChild(createLeaf("aug2", "aug2Value")).build();
    final ChoiceNode choiceNode = Builders.choiceBuilder().withNodeIdentifier(id("choiceNode")).withChild(createLeaf("choiceLeaf", 12)).build();
    return Builders.containerBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(CONTAINER_Q_NAME)).withChild(booleanLeaf).withChild(byteLeaf).withChild(shortLeaf).withChild(intLeaf).withChild(longLeaf).withChild(stringLeaf).withChild(longStringLeaf).withChild(qNameLeaf).withChild(idLeaf).withChild(mapNode).withChild(orderedMapNode).withChild(unkeyedListNode).withChild(leafSetNode).withChild(orderedLeafSetNode).withChild(augmentationNode).withChild(choiceNode).build();
}
Also used : UnkeyedListEntryNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode) OrderedMapNode(org.opendaylight.yangtools.yang.data.api.schema.OrderedMapNode) MapNode(org.opendaylight.yangtools.yang.data.api.schema.MapNode) OrderedMapNode(org.opendaylight.yangtools.yang.data.api.schema.OrderedMapNode) ChoiceNode(org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) UnkeyedListNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode) QName(org.opendaylight.yangtools.yang.common.QName) MapEntryNode(org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) AugmentationNode(org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode)

Example 5 with UnkeyedListNode

use of org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode in project bgpcep by opendaylight.

the class EvpnRibSupport 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)

Aggregations

UnkeyedListEntryNode (org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode)8 UnkeyedListNode (org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode)8 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)6 PathArgument (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument)6 DataContainerChild (org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild)6 NodeIdentifierWithPredicates (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates)5 ArrayList (java.util.ArrayList)2 ChoiceNode (org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Flowspec (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.Flowspec)1 FlowspecBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.FlowspecBuilder)1 LabelStack (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.labeled.unicast.LabelStack)1 LabelStackBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.labeled.unicast.LabelStackBuilder)1 MplsLabel (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.MplsLabel)1 QName (org.opendaylight.yangtools.yang.common.QName)1 AugmentationNode (org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode)1 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)1 MapNode (org.opendaylight.yangtools.yang.data.api.schema.MapNode)1 OrderedMapNode (org.opendaylight.yangtools.yang.data.api.schema.OrderedMapNode)1