Search in sources :

Example 26 with UnkeyedListEntryNode

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

the class LinkstateNlriParserTest method testPrefixNlri.

@Test
public void testPrefixNlri() throws BGPParsingException {
    setUp(this.prefixNlri);
    // test BA form
    assertNull(this.dest.getDistinguisher());
    assertEquals(ProtocolId.IsisLevel2, this.dest.getProtocolId());
    assertEquals(BigInteger.ONE, this.dest.getIdentifier().getValue());
    final PrefixCase pCase = ((PrefixCase) this.dest.getObjectType());
    final AdvertisingNodeDescriptors local = pCase.getAdvertisingNodeDescriptors();
    assertEquals(new AsNumber(72L), local.getAsNumber());
    assertEquals(new DomainIdentifier(0x28282828L), local.getDomainId());
    assertEquals(new IsisNodeCaseBuilder().setIsisNode(new IsisNodeBuilder().setIsoSystemId(new IsoSystemIdentifier(new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x42 })).build()).build(), local.getCRouterIdentifier());
    final PrefixDescriptors pd = pCase.getPrefixDescriptors();
    assertEquals(OspfRouteType.External1, pd.getOspfRouteType());
    assertEquals(new TopologyIdentifier(15), pd.getMultiTopologyId());
    assertEquals(new Ipv4Prefix("255.255.0.0/16"), pd.getIpReachabilityInformation().getIpv4Prefix());
    final ByteBuf buffer = Unpooled.buffer();
    this.registry.serializeNlriType(this.dest, buffer);
    assertArrayEquals(this.prefixNlri, ByteArray.readAllBytes(buffer));
    // test BI form
    final DataContainerNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, UnkeyedListEntryNode> linkstateBI = ImmutableUnkeyedListEntryNodeBuilder.create();
    linkstateBI.withNodeIdentifier(C_LINKSTATE_NID);
    final ImmutableLeafNodeBuilder<String> protocolId = new ImmutableLeafNodeBuilder<>();
    protocolId.withNodeIdentifier(LinkstateNlriParser.PROTOCOL_ID_NID);
    protocolId.withValue("isis-level2");
    linkstateBI.addChild(protocolId.build());
    final ImmutableLeafNodeBuilder<BigInteger> identifier = new ImmutableLeafNodeBuilder<>();
    identifier.withNodeIdentifier(LinkstateNlriParser.IDENTIFIER_NID);
    identifier.withValue(BigInteger.ONE);
    linkstateBI.addChild(identifier.build());
    final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> objectType = Builders.choiceBuilder();
    objectType.withNodeIdentifier(LinkstateNlriParser.OBJECT_TYPE_NID);
    // advertising node descriptors
    final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> advertisingNodeDescriptors = Builders.containerBuilder();
    advertisingNodeDescriptors.withNodeIdentifier(LinkstateNlriParser.ADVERTISING_NODE_DESCRIPTORS_NID);
    final ImmutableLeafNodeBuilder<Long> asNumber = new ImmutableLeafNodeBuilder<>();
    asNumber.withNodeIdentifier(NodeNlriParser.AS_NUMBER_NID);
    asNumber.withValue(72L);
    advertisingNodeDescriptors.addChild(asNumber.build());
    final ImmutableLeafNodeBuilder<Long> domainID = new ImmutableLeafNodeBuilder<>();
    domainID.withNodeIdentifier(NodeNlriParser.DOMAIN_NID);
    domainID.withValue(673720360L);
    advertisingNodeDescriptors.addChild(domainID.build());
    final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> crouterId = Builders.choiceBuilder();
    crouterId.withNodeIdentifier(C_ROUTER_ID_NID);
    final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> isisNode = Builders.containerBuilder();
    isisNode.withNodeIdentifier(NodeNlriParser.ISIS_NODE_NID);
    final ImmutableLeafNodeBuilder<byte[]> isoSystemID = new ImmutableLeafNodeBuilder<>();
    isoSystemID.withNodeIdentifier(NodeNlriParser.ISO_SYSTEM_NID);
    isoSystemID.withValue(new byte[] { 0, 0, 0, 0, 0, (byte) 0x42 });
    isisNode.addChild(isoSystemID.build());
    crouterId.addChild(isisNode.build());
    advertisingNodeDescriptors.addChild(crouterId.build());
    // prefix descriptors
    final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> prefixDescriptors = Builders.containerBuilder();
    prefixDescriptors.withNodeIdentifier(LinkstateNlriParser.PREFIX_DESCRIPTORS_NID);
    prefixDescriptors.addChild(asNumber.build());
    prefixDescriptors.addChild(domainID.build());
    final ImmutableLeafNodeBuilder<Integer> multiTopologyId = new ImmutableLeafNodeBuilder<>();
    multiTopologyId.withNodeIdentifier(TlvUtil.MULTI_TOPOLOGY_NID);
    multiTopologyId.withValue(15);
    prefixDescriptors.addChild(multiTopologyId.build());
    final ImmutableLeafNodeBuilder<String> ipReachabilityInformation = new ImmutableLeafNodeBuilder<>();
    ipReachabilityInformation.withNodeIdentifier(IP_REACH_NID);
    ipReachabilityInformation.withValue("255.255.0.0/16");
    prefixDescriptors.addChild(ipReachabilityInformation.build());
    final ImmutableLeafNodeBuilder<String> ospfRouteType = new ImmutableLeafNodeBuilder<>();
    ospfRouteType.withNodeIdentifier(OSPF_ROUTE_NID);
    ospfRouteType.withValue("external1");
    prefixDescriptors.addChild(ospfRouteType.build());
    objectType.addChild(advertisingNodeDescriptors.build());
    objectType.addChild(prefixDescriptors.build());
    linkstateBI.addChild(objectType.build());
    assertEquals(this.dest, LinkstateNlriParser.extractLinkstateDestination(linkstateBI.build()));
}
Also used : PrefixDescriptors(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.object.type.prefix._case.PrefixDescriptors) UnkeyedListEntryNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode) ByteBuf(io.netty.buffer.ByteBuf) IsisNodeCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.node.identifier.c.router.identifier.IsisNodeCaseBuilder) AdvertisingNodeDescriptors(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.object.type.prefix._case.AdvertisingNodeDescriptors) ChoiceNode(org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) DomainIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.DomainIdentifier) TopologyIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.TopologyIdentifier) PrefixCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.object.type.PrefixCase) IsoSystemIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.IsoSystemIdentifier) AsNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber) BigInteger(java.math.BigInteger) IsisNodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.node.identifier.c.router.identifier.isis.node._case.IsisNodeBuilder) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) BigInteger(java.math.BigInteger) ImmutableLeafNodeBuilder(org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder) Test(org.junit.Test)

Example 27 with UnkeyedListEntryNode

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

the class LinkstateRIBSupport method processRoute.

private void processRoute(final Optional<DataContainerChild<? extends PathArgument, ?>> maybeRoutes, final YangInstanceIdentifier routesPath, final ContainerNode attributes, final ApplyRoute function, final DOMDataWriteTransaction tx) {
    if (maybeRoutes.isPresent()) {
        final DataContainerChild<? extends PathArgument, ?> routes = maybeRoutes.get();
        if (routes instanceof UnkeyedListNode) {
            final YangInstanceIdentifier base = routesPath.node(routesContainerIdentifier()).node(this.route);
            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 : UnkeyedListEntryNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode) 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)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