Search in sources :

Example 26 with NodeIdentifier

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.NodeIdentifier in project bgpcep by opendaylight.

the class LinkstateNlriParserTest method testNodeNlri.

@Test
public void testNodeNlri() throws BGPParsingException {
    setUp(this.nodeNlri);
    // test BA form
    assertNull(this.dest.getRouteDistinguisher());
    assertEquals(ProtocolId.IsisLevel2, this.dest.getProtocolId());
    assertEquals(Uint64.ONE, this.dest.getIdentifier().getValue());
    final NodeCase nCase = (NodeCase) this.dest.getObjectType();
    final NodeDescriptors nodeD = nCase.getNodeDescriptors();
    assertEquals(new AsNumber(Uint32.valueOf(72)), nodeD.getAsNumber());
    assertEquals(new DomainIdentifier(Uint32.valueOf(0x28282828L)), nodeD.getDomainId());
    assertEquals(new IsisPseudonodeCaseBuilder().setIsisPseudonode(new IsisPseudonodeBuilder().setPsn(Uint8.valueOf(5)).setIsIsRouterIdentifier(new IsIsRouterIdentifierBuilder().setIsoSystemId(new IsoSystemIdentifier(new byte[] { 0, 0, 0, 0, 0, (byte) 0x39 })).build()).build()).build(), nodeD.getCRouterIdentifier());
    final ByteBuf buffer = Unpooled.buffer();
    this.registry.serializeNlriType(this.dest, buffer);
    assertArrayEquals(this.nodeNlri, ByteArray.readAllBytes(buffer));
    // test BI form
    final DataContainerNodeBuilder<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<Uint64> identifier = new ImmutableLeafNodeBuilder<>();
    identifier.withNodeIdentifier(LinkstateNlriParser.IDENTIFIER_NID);
    identifier.withValue(Uint64.ONE);
    linkstateBI.addChild(identifier.build());
    final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> objectType = Builders.choiceBuilder();
    objectType.withNodeIdentifier(LinkstateNlriParser.OBJECT_TYPE_NID);
    final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> nodeDescriptors = Builders.containerBuilder();
    nodeDescriptors.withNodeIdentifier(LinkstateNlriParser.NODE_DESCRIPTORS_NID);
    final ImmutableLeafNodeBuilder<Uint32> asNumber = new ImmutableLeafNodeBuilder<>();
    asNumber.withNodeIdentifier(NodeNlriParser.AS_NUMBER_NID);
    asNumber.withValue(Uint32.valueOf(72));
    nodeDescriptors.addChild(asNumber.build());
    final ImmutableLeafNodeBuilder<Uint32> areaID = new ImmutableLeafNodeBuilder<>();
    areaID.withNodeIdentifier(NodeNlriParser.AREA_NID);
    areaID.withValue(Uint32.valueOf(2697513L));
    nodeDescriptors.addChild(areaID.build());
    final ImmutableLeafNodeBuilder<Uint32> domainID = new ImmutableLeafNodeBuilder<>();
    domainID.withNodeIdentifier(NodeNlriParser.DOMAIN_NID);
    domainID.withValue(Uint32.valueOf(0x28282828L));
    nodeDescriptors.addChild(domainID.build());
    final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> crouterId = Builders.choiceBuilder();
    crouterId.withNodeIdentifier(C_ROUTER_ID_NID);
    final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> isisNode = Builders.containerBuilder();
    isisNode.withNodeIdentifier(NodeNlriParser.ISIS_PSEUDONODE_NID);
    final ImmutableLeafNodeBuilder<byte[]> isoSystemID = new ImmutableLeafNodeBuilder<>();
    isoSystemID.withNodeIdentifier(NodeNlriParser.ISO_SYSTEM_NID);
    isoSystemID.withValue(new byte[] { 0, 0, 0, 0, 0, (byte) 0x39 });
    final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> isisPseudoRouter = Builders.containerBuilder();
    isisPseudoRouter.withNodeIdentifier(NodeNlriParser.ISIS_ROUTER_NID);
    isisPseudoRouter.addChild(isoSystemID.build());
    isisNode.addChild(isisPseudoRouter.build());
    isisNode.addChild(Builders.leafBuilder().withNodeIdentifier(NodeNlriParser.PSN_NID).withValue(Uint8.valueOf(5)).build());
    crouterId.addChild(isisNode.build());
    nodeDescriptors.addChild(crouterId.build());
    objectType.addChild(nodeDescriptors.build());
    linkstateBI.addChild(objectType.build());
    assertEquals(this.dest, LinkstateNlriParser.extractLinkstateDestination(linkstateBI.build()));
}
Also used : IsisPseudonodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.node.identifier.c.router.identifier.isis.pseudonode._case.IsisPseudonodeBuilder) UnkeyedListEntryNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode) LocalNodeDescriptors(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.link._case.LocalNodeDescriptors) RemoteNodeDescriptors(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.link._case.RemoteNodeDescriptors) AdvertisingNodeDescriptors(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.prefix._case.AdvertisingNodeDescriptors) NodeDescriptors(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.node._case.NodeDescriptors) IsoSystemIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.IsoSystemIdentifier) ByteBuf(io.netty.buffer.ByteBuf) AsNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber) IsisPseudonodeCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.node.identifier.c.router.identifier.IsisPseudonodeCaseBuilder) NodeCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.NodeCase) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) ChoiceNode(org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) ImmutableLeafNodeBuilder(org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder) IsIsRouterIdentifierBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.isis.lan.identifier.IsIsRouterIdentifierBuilder) Uint32(org.opendaylight.yangtools.yang.common.Uint32) DomainIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.DomainIdentifier) Uint64(org.opendaylight.yangtools.yang.common.Uint64) Test(org.junit.Test)

Example 27 with NodeIdentifier

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.NodeIdentifier in project bgpcep by opendaylight.

the class NodeNlriParser method parseObjectType.

@Override
protected ObjectType parseObjectType(final ByteBuf buffer) {
    final NodeCaseBuilder builder = new NodeCaseBuilder();
    builder.setNodeDescriptors(new NodeDescriptorsBuilder((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.NodeIdentifier) SimpleNlriTypeRegistry.getInstance().parseTlv(buffer)).build());
    return builder.build();
}
Also used : IsisNodeCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.node.identifier.c.router.identifier.IsisNodeCaseBuilder) NodeCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.NodeCaseBuilder) OspfNodeCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.node.identifier.c.router.identifier.OspfNodeCaseBuilder) AdvertisingNodeDescriptorsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.prefix._case.AdvertisingNodeDescriptorsBuilder) LocalNodeDescriptorsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.link._case.LocalNodeDescriptorsBuilder) RemoteNodeDescriptorsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.link._case.RemoteNodeDescriptorsBuilder) NodeDescriptorsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.node._case.NodeDescriptorsBuilder)

Example 28 with NodeIdentifier

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.NodeIdentifier in project bgpcep by opendaylight.

the class AbstractPrefixNlriParser method parseObjectType.

@Override
protected final ObjectType parseObjectType(final ByteBuf buffer) {
    final NodeIdentifier oType = SimpleNlriTypeRegistry.getInstance().parseTlv(buffer);
    final PrefixCaseBuilder builder = new PrefixCaseBuilder();
    builder.setAdvertisingNodeDescriptors(new AdvertisingNodeDescriptorsBuilder(oType).build());
    builder.setPrefixDescriptors(parsePrefixDescriptor(buffer));
    return builder.build();
}
Also used : AdvertisingNodeDescriptorsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.prefix._case.AdvertisingNodeDescriptorsBuilder) PrefixCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.PrefixCaseBuilder) NodeIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.NodeIdentifier)

Example 29 with NodeIdentifier

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.NodeIdentifier in project bgpcep by opendaylight.

the class AbstractNodeDescriptorTlvCodec method parseNodeDescriptor.

protected static NodeIdentifier parseNodeDescriptor(final ByteBuf value, final Map<QName, Object> parsedSubTlvs) {
    parsedSubTlvs.putAll(SimpleNlriTypeRegistry.getInstance().parseSubTlvs(value));
    final AsNumber asNumber = (AsNumber) parsedSubTlvs.get(AsNumTlvParser.AS_NUMBER_QNAME);
    final DomainIdentifier domainId = (DomainIdentifier) parsedSubTlvs.get(DomainIdTlvParser.DOMAIN_ID_QNAME);
    final AreaIdentifier areaId = (AreaIdentifier) parsedSubTlvs.get(AreaIdTlvParser.AREA_ID_QNAME);
    final CRouterIdentifier routerId = (CRouterIdentifier) parsedSubTlvs.get(CRouterIdentifier.QNAME);
    return new NodeIdentifier() {

        @Override
        public Class<NodeIdentifier> implementedInterface() {
            return NodeIdentifier.class;
        }

        @Override
        public AsNumber getAsNumber() {
            return asNumber;
        }

        @Override
        public DomainIdentifier getDomainId() {
            return domainId;
        }

        @Override
        public AreaIdentifier getAreaId() {
            return areaId;
        }

        @Override
        public CRouterIdentifier getCRouterIdentifier() {
            return routerId;
        }
    };
}
Also used : CRouterIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.node.identifier.CRouterIdentifier) AreaIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.AreaIdentifier) NodeIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.NodeIdentifier) AsNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber) DomainIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.DomainIdentifier)

Example 30 with NodeIdentifier

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.NodeIdentifier in project bgpcep by opendaylight.

the class AbstractRIBTestSetup method ipv4Input.

public Collection<DataTreeCandidate> ipv4Input(final YangInstanceIdentifier target, final ModificationType type, final Ipv4Prefix... prefix) {
    final Collection<DataTreeCandidate> col = new HashSet<>();
    final DataTreeCandidate candidate = mock(DataTreeCandidate.class);
    final DataTreeCandidateNode rootNode = mock(DataTreeCandidateNode.class);
    doReturn(rootNode).when(candidate).getRootNode();
    doReturn(type).when(rootNode).getModificationType();
    doCallRealMethod().when(rootNode).toString();
    doReturn(target).when(candidate).getRootPath();
    doCallRealMethod().when(candidate).toString();
    final Collection<DataTreeCandidateNode> children = new HashSet<>();
    for (final Ipv4Prefix p : prefix) {
        final NodeIdentifierWithPredicates routekey = NodeIdentifierWithPredicates.of(Ipv4Route.QNAME, PREFIX_QNAME, p);
        final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> b = ImmutableNodes.mapEntryBuilder();
        b.withNodeIdentifier(routekey);
        b.addChild(Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(PREFIX_QNAME)).withValue(p).build());
        final DataTreeCandidateNode child = mock(DataTreeCandidateNode.class);
        doReturn(createIdentifier(p)).when(child).getIdentifier();
        doReturn(java.util.Optional.of(b.build())).when(child).getDataAfter();
        doReturn(type).when(child).getModificationType();
        children.add(child);
    }
    doReturn(children).when(rootNode).getChildNodes();
    col.add(candidate);
    return col;
}
Also used : DataTreeCandidate(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate) DataTreeCandidateNode(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates) MapEntryNode(org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) HashSet(java.util.HashSet)

Aggregations

NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)18 Test (org.junit.Test)13 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)10 UnkeyedListEntryNode (org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode)8 ByteBuf (io.netty.buffer.ByteBuf)7 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)6 AsNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber)5 ArrayList (java.util.ArrayList)4 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)4 ChoiceNode (org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode)4 ImmutableLeafNodeBuilder (org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder)4 IfTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel)3 ParentRefs (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs)3 TunnelTypeVxlan (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan)3 NodeIdentifier (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.interfaces._interface.NodeIdentifier)3 Esi (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.esi.Esi)3 DomainIdentifier (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.DomainIdentifier)3 CRouterIdentifier (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.node.identifier.CRouterIdentifier)3 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)3 Before (org.junit.Before)2