Search in sources :

Example 6 with UnkeyedListEntryNode

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

the class EvpnNlriParserTest method testExtractEvpnDestination.

@Test
public void testExtractEvpnDestination() throws BGPParsingException {
    final DataContainerNodeAttrBuilder<NodeIdentifier, UnkeyedListEntryNode> evpnBI = ImmutableUnkeyedListEntryNodeBuilder.create();
    evpnBI.withNodeIdentifier(EVPN_NID);
    evpnBI.withChild(createMACIpAdvChoice());
    evpnBI.withChild(createValueBuilder(RD_MODEL, RD_NID).build());
    final EvpnDestination destResult = EvpnNlriParser.extractEvpnDestination(evpnBI.build());
    final EvpnDestination expected = new EvpnDestinationBuilder().setRouteDistinguisher(RD).setEvpnChoice(MACIpAdvRParserTest.createdExpectedResult()).build();
    assertEquals(expected, destResult);
}
Also used : NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) UnkeyedListEntryNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode) EvpnDestination(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.destination.EvpnDestination) EvpnDestinationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.destination.EvpnDestinationBuilder) Test(org.junit.Test)

Example 7 with UnkeyedListEntryNode

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

the class AbstractFlowspecNlriParser method createDscpsLengths.

private static List<Dscps> createDscpsLengths(final UnkeyedListNode dscpLengthsData) {
    final List<Dscps> dscpsLengths = new ArrayList<>();
    for (final UnkeyedListEntryNode node : dscpLengthsData.getValue()) {
        final DscpsBuilder dscpsLengthsBuilder = new DscpsBuilder();
        final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(OP_NID);
        if (opValue.isPresent()) {
            dscpsLengthsBuilder.setOp(NumericOneByteOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue()));
        }
        final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(VALUE_NID);
        if (valueNode.isPresent()) {
            dscpsLengthsBuilder.setValue(new Dscp((Short) valueNode.get().getValue()));
        }
        dscpsLengths.add(dscpsLengthsBuilder.build());
    }
    return dscpsLengths;
}
Also used : Dscps(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.dscp._case.Dscps) DscpsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.dscp._case.DscpsBuilder) Set(java.util.Set) DataContainerChild(org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild) ArrayList(java.util.ArrayList) UnkeyedListEntryNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode) PathArgument(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument) Dscp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.Dscp)

Example 8 with UnkeyedListEntryNode

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

the class AbstractFlowspecNlriParser method createSourcePorts.

private static List<SourcePorts> createSourcePorts(final UnkeyedListNode sourcePortsData) {
    final List<SourcePorts> sourcePorts = new ArrayList<>();
    for (final UnkeyedListEntryNode node : sourcePortsData.getValue()) {
        final SourcePortsBuilder sourcePortsBuilder = new SourcePortsBuilder();
        final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(OP_NID);
        if (opValue.isPresent()) {
            sourcePortsBuilder.setOp(NumericTwoByteOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue()));
        }
        final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(VALUE_NID);
        if (valueNode.isPresent()) {
            sourcePortsBuilder.setValue((Integer) valueNode.get().getValue());
        }
        sourcePorts.add(sourcePortsBuilder.build());
    }
    return sourcePorts;
}
Also used : Set(java.util.Set) SourcePortsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.source.port._case.SourcePortsBuilder) DataContainerChild(org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild) ArrayList(java.util.ArrayList) UnkeyedListEntryNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode) PathArgument(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument) SourcePorts(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.source.port._case.SourcePorts)

Example 9 with UnkeyedListEntryNode

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

the class AbstractFlowspecNlriParser method createDestinationPorts.

private static List<DestinationPorts> createDestinationPorts(final UnkeyedListNode destinationPortsData) {
    final List<DestinationPorts> destinationPorts = new ArrayList<>();
    for (final UnkeyedListEntryNode node : destinationPortsData.getValue()) {
        final DestinationPortsBuilder destPortsBuilder = new DestinationPortsBuilder();
        final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(OP_NID);
        if (opValue.isPresent()) {
            destPortsBuilder.setOp(NumericTwoByteOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue()));
        }
        final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(VALUE_NID);
        if (valueNode.isPresent()) {
            destPortsBuilder.setValue((Integer) valueNode.get().getValue());
        }
        destinationPorts.add(destPortsBuilder.build());
    }
    return destinationPorts;
}
Also used : DestinationPorts(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.destination.port._case.DestinationPorts) Set(java.util.Set) DataContainerChild(org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild) ArrayList(java.util.ArrayList) DestinationPortsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.destination.port._case.DestinationPortsBuilder) UnkeyedListEntryNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode) PathArgument(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument)

Example 10 with UnkeyedListEntryNode

use of org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode 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)

Aggregations

UnkeyedListEntryNode (org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode)27 PathArgument (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument)18 DataContainerChild (org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild)18 ArrayList (java.util.ArrayList)14 Set (java.util.Set)12 UnkeyedListNode (org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode)8 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)7 Test (org.junit.Test)6 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)6 ChoiceNode (org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode)6 NodeIdentifierWithPredicates (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates)5 BigInteger (java.math.BigInteger)4 ImmutableLeafNodeBuilder (org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder)4 ByteBuf (io.netty.buffer.ByteBuf)3 AsNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber)3 DomainIdentifier (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.DomainIdentifier)3 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)3 EvpnDestination (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.destination.EvpnDestination)2 EvpnDestinationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.destination.EvpnDestinationBuilder)2 DestinationPorts (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.destination.port._case.DestinationPorts)2