use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.isis.lan.identifier.IsIsRouterIdentifierBuilder 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()));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.isis.lan.identifier.IsIsRouterIdentifierBuilder in project bgpcep by opendaylight.
the class NodeNlriParser method serializeIsisPseudoNode.
private static IsisPseudonodeCase serializeIsisPseudoNode(final ContainerNode pseudoIsisNode) {
final IsIsRouterIdentifierBuilder isisRouterId = new IsIsRouterIdentifierBuilder();
if (pseudoIsisNode.findChildByArg(ISIS_ROUTER_NID).isPresent()) {
final ContainerNode isisRouterNid = (ContainerNode) pseudoIsisNode.findChildByArg(ISIS_ROUTER_NID).get();
if (isisRouterNid.findChildByArg(ISO_SYSTEM_NID).isPresent()) {
isisRouterId.setIsoSystemId(new IsoSystemIdentifier((byte[]) isisRouterNid.findChildByArg(ISO_SYSTEM_NID).get().body()));
}
}
final IsisPseudonodeBuilder nodeBuilder = new IsisPseudonodeBuilder();
nodeBuilder.setIsIsRouterIdentifier(isisRouterId.build());
if (pseudoIsisNode.findChildByArg(PSN_NID).isPresent()) {
nodeBuilder.setPsn((Uint8) pseudoIsisNode.findChildByArg(PSN_NID).get().body());
} else {
nodeBuilder.setPsn(Uint8.ZERO);
}
return new IsisPseudonodeCaseBuilder().setIsisPseudonode(nodeBuilder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.isis.lan.identifier.IsIsRouterIdentifierBuilder in project bgpcep by opendaylight.
the class UriBuilderTest method test.
@Test
public void test() {
final LinkstateRouteBuilder routeB = new LinkstateRouteBuilder().setProtocolId(ProtocolId.Direct).setIdentifier(new Identifier(Uint64.TEN)).setPathId(new PathId(Uint32.ZERO)).setRouteKey("key");
final UriBuilder a = new UriBuilder(routeB.build());
assertEquals("bgpls://Direct:10/", a.toString());
routeB.setRouteDistinguisher(DISTINGUISHER);
final UriBuilder b = new UriBuilder(routeB.build());
assertEquals("bgpls://1.2.3.4:258:Direct:10/", b.toString());
final UriBuilder c = new UriBuilder(b, "foo");
assertEquals("bgpls://1.2.3.4:258:Direct:10/type=foo", c.toString());
a.add("foo", 25L);
assertEquals("bgpls://Direct:10/&foo=25", a.toString());
final LinkCaseBuilder linkB = new LinkCaseBuilder();
linkB.setLinkDescriptors(new LinkDescriptorsBuilder().setIpv4InterfaceAddress(new Ipv4InterfaceIdentifier("127.0.0.1")).setIpv4NeighborAddress(new Ipv4InterfaceIdentifier("20.20.20.20")).setMultiTopologyId(new TopologyIdentifier(Uint16.valueOf(55))).setLinkLocalIdentifier(Uint32.ONE).setLinkRemoteIdentifier(Uint32.TWO).build());
final LocalNodeDescriptorsBuilder nodeB = new LocalNodeDescriptorsBuilder();
nodeB.setAsNumber(new AsNumber(Uint32.valueOf(12))).setDomainId(new DomainIdentifier(Uint32.valueOf(15))).setAreaId(new AreaIdentifier(Uint32.valueOf(17)));
nodeB.setCRouterIdentifier(new OspfNodeCaseBuilder().setOspfNode(new OspfNodeBuilder().setOspfRouterId(Uint32.valueOf(22)).build()).build());
linkB.setLocalNodeDescriptors(nodeB.build());
final RemoteNodeDescriptorsBuilder nodeR = new RemoteNodeDescriptorsBuilder();
nodeR.setCRouterIdentifier(new IsisPseudonodeCaseBuilder().setIsisPseudonode(new IsisPseudonodeBuilder().setIsIsRouterIdentifier(new IsIsRouterIdentifierBuilder().setIsoSystemId(new IsoSystemIdentifier(new byte[] { 1, 2, 3, 4, 5, 6 })).build()).setPsn(Uint8.TWO).build()).build());
linkB.setRemoteNodeDescriptors(nodeR.build());
c.add(linkB.build());
assertEquals("bgpls://1.2.3.4:258:Direct:10/type=foo&local-as=12&local-domain=15&local-area=17&" + "local-router=22&remote-router=0102.0304.0506.02&ipv4-iface=127.0.0.1&ipv4-neigh=20.20.20.20&m" + "t=55&local-id=1&remote-id=2", c.toString());
}
Aggregations