use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.IgpNodeAttributes1 in project bgpcep by opendaylight.
the class LinkstateTopologyBuilderTest method testOspfLinkstateTopologyBuilder.
@Test
public void testOspfLinkstateTopologyBuilder() throws TransactionCommitFailedException, ReadFailedException {
// create node
updateLinkstateRoute(createLinkstateNodeRoute(ProtocolId.Ospf, "node1", NODE_1_AS, ROUTER_1_ID));
readDataOperational(getDataBroker(), this.linkstateTopoBuilder.getInstanceIdentifier(), topology -> {
assertEquals(1, topology.getNode().size());
final Node node1 = topology.getNode().get(0);
assertEquals(NODE_1_OSPF_ID, node1.getNodeId().getValue());
final IgpNodeAttributes igpNode1 = node1.getAugmentation(Node1.class).getIgpNodeAttributes();
assertEquals(ROUTER_1_ID, igpNode1.getRouterId().get(0).getIpv4Address().getValue());
assertEquals("node1", igpNode1.getName().getValue());
assertNull(igpNode1.getAugmentation(IgpNodeAttributes1.class));
assertEquals(ROUTER_1_ID, igpNode1.getAugmentation(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.IgpNodeAttributes1.class).getOspfNodeAttributes().getTed().getTeRouterIdIpv4().getValue());
return topology;
});
// update node with prefix
updateLinkstateRoute(createLinkstatePrefixRoute(ProtocolId.Ospf, NODE_1_AS, NODE_1_PREFIX, 500L, ROUTER_1_ID));
readDataOperational(getDataBroker(), this.linkstateTopoBuilder.getInstanceIdentifier(), topology -> {
final IgpNodeAttributes igpNode2 = topology.getNode().get(0).getAugmentation(Node1.class).getIgpNodeAttributes();
assertEquals(1, igpNode2.getPrefix().size());
final Prefix prefix = igpNode2.getPrefix().get(0);
assertEquals(NODE_1_PREFIX, prefix.getPrefix().getIpv4Prefix().getValue());
assertEquals(500L, prefix.getMetric().longValue());
return topology;
});
// create link
updateLinkstateRoute(createLinkstateLinkRoute(ProtocolId.Ospf, NODE_1_AS, NODE_2_AS, "link1"));
readDataOperational(getDataBroker(), this.linkstateTopoBuilder.getInstanceIdentifier(), topology -> {
assertEquals(1, topology.getLink().size());
final Link link1 = topology.getLink().get(0);
assertEquals(2, topology.getNode().size());
assertEquals(1, topology.getNode().get(0).getTerminationPoint().size());
assertEquals(1, topology.getNode().get(1).getTerminationPoint().size());
assertEquals("bgpls://Ospf:1/type=link&local-as=1&local-router=0000.0102.0304&remote-as=2&mt=1", link1.getLinkId().getValue());
assertEquals(NODE_1_OSPF_ID, link1.getSource().getSourceNode().getValue());
assertEquals(NODE_2_OSPF_ID, link1.getDestination().getDestNode().getValue());
final IgpLinkAttributes igpLink1 = link1.getAugmentation(Link1.class).getIgpLinkAttributes();
assertEquals("link1", igpLink1.getName());
assertNull(igpLink1.getAugmentation(IgpLinkAttributes1.class));
assertEquals((short) 1, igpLink1.getAugmentation(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.IgpLinkAttributes1.class).getOspfLinkAttributes().getMultiTopologyId().shortValue());
assertEquals(2, igpLink1.getAugmentation(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.IgpLinkAttributes1.class).getOspfLinkAttributes().getTed().getSrlg().getSrlgValues().size());
return topology;
});
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.IgpNodeAttributes1 in project bgpcep by opendaylight.
the class LinkstateTopologyBuilderTest method testIsisLinkstateTopologyBuilder.
@Test
public void testIsisLinkstateTopologyBuilder() throws TransactionCommitFailedException, ReadFailedException {
// create node
updateLinkstateRoute(createLinkstateNodeRoute(ProtocolId.IsisLevel2, "node1", NODE_1_AS, ROUTER_1_ID));
readDataOperational(getDataBroker(), this.linkstateTopoBuilder.getInstanceIdentifier(), topology -> {
assertEquals(1, topology.getNode().size());
final Node node1 = topology.getNode().get(0);
assertEquals(NODE_1_ISIS_ID, node1.getNodeId().getValue());
final IgpNodeAttributes igpNode1 = node1.getAugmentation(Node1.class).getIgpNodeAttributes();
assertEquals(ROUTER_1_ID, igpNode1.getRouterId().get(0).getIpv4Address().getValue());
assertEquals("node1", igpNode1.getName().getValue());
final IgpNodeAttributes1 igpNodeAttributes1 = igpNode1.getAugmentation(IgpNodeAttributes1.class);
assertEquals("0000.0102.0304", igpNodeAttributes1.getIsisNodeAttributes().getIso().getIsoSystemId().getValue());
assertEquals(ROUTER_1_ID, igpNodeAttributes1.getIsisNodeAttributes().getTed().getTeRouterIdIpv4().getValue());
assertEquals("47.0000.0000.0000.0000.0102.0304", igpNodeAttributes1.getIsisNodeAttributes().getNet().get(0).getValue());
assertNull(igpNode1.getAugmentation(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.IgpNodeAttributes1.class));
return topology;
});
// create link
updateLinkstateRoute(createLinkstateLinkRoute(ProtocolId.IsisLevel2, NODE_1_AS, NODE_2_AS, "link1"));
readDataOperational(getDataBroker(), this.linkstateTopoBuilder.getInstanceIdentifier(), topology -> {
assertEquals(1, topology.getLink().size());
final Link link1 = topology.getLink().get(0);
assertEquals(2, topology.getNode().size());
assertEquals(1, topology.getNode().get(0).getTerminationPoint().size());
assertEquals(1, topology.getNode().get(1).getTerminationPoint().size());
assertEquals("bgpls://IsisLevel2:1/type=link&local-as=1&local-router=0000.0102.0304&remote-as" + "=2&mt=1", link1.getLinkId().getValue());
assertEquals(NODE_1_ISIS_ID, link1.getSource().getSourceNode().getValue());
assertEquals(NODE_2_ISIS_ID, link1.getDestination().getDestNode().getValue());
final IgpLinkAttributes igpLink1 = link1.getAugmentation(Link1.class).getIgpLinkAttributes();
assertEquals("link1", igpLink1.getName());
assertEquals((short) 1, igpLink1.getAugmentation(IgpLinkAttributes1.class).getIsisLinkAttributes().getMultiTopologyId().shortValue());
assertNull(igpLink1.getAugmentation(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.IgpLinkAttributes1.class));
return topology;
});
// update node
updateLinkstateRoute(createLinkstateNodeRoute(ProtocolId.IsisLevel2, "updated-node", NODE_1_AS, ROUTER_2_ID));
readDataOperational(getDataBroker(), this.linkstateTopoBuilder.getInstanceIdentifier(), topology -> {
assertEquals(1, topology.getNode().size());
final IgpNodeAttributes igpNode2 = topology.getNode().get(0).getAugmentation(Node1.class).getIgpNodeAttributes();
assertEquals(ROUTER_2_ID, igpNode2.getRouterId().get(0).getIpv4Address().getValue());
assertEquals("updated-node", igpNode2.getName().getValue());
return topology;
});
// remove
final WriteTransaction wTx = getDataBroker().newWriteOnlyTransaction();
wTx.delete(LogicalDatastoreType.OPERATIONAL, this.linkstateRouteIID);
wTx.submit();
readDataOperational(getDataBroker(), this.linkstateTopoBuilder.getInstanceIdentifier(), topology -> {
assertEquals(0, topology.getNode().size());
assertEquals(0, topology.getLink().size());
return topology;
});
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.IgpNodeAttributes1 in project bgpcep by opendaylight.
the class ProtocolUtil method ospfNodeAttributes.
private static org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.IgpNodeAttributes1 ospfNodeAttributes(final NodeIdentifier node, final NodeAttributes na) {
final org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.ospf.node.attributes.ospf.node.attributes.TedBuilder tb = new org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.ospf.node.attributes.ospf.node.attributes.TedBuilder();
final OspfNodeAttributesBuilder ab = new OspfNodeAttributesBuilder();
if (na != null) {
if (na.getIpv4RouterId() != null) {
tb.setTeRouterIdIpv4(na.getIpv4RouterId());
}
if (na.getIpv6RouterId() != null) {
tb.setTeRouterIdIpv6(na.getIpv6RouterId());
}
if (na.getTopologyIdentifier() != null) {
ab.setMultiTopologyId(nodeMultiTopology(na.getTopologyIdentifier()));
}
final CRouterIdentifier ri = node.getCRouterIdentifier();
if (ri instanceof OspfPseudonodeCase) {
final OspfPseudonode pn = ((OspfPseudonodeCase) ri).getOspfPseudonode();
ab.setRouterType(new PseudonodeBuilder().setPseudonode(Boolean.TRUE).build());
ab.setDrInterfaceId(pn.getLanInterface().getValue());
} else if (ri instanceof OspfNodeCase && na.getNodeFlags() != null) {
// TODO: what should we do with in.getOspfRouterId()?
final NodeFlagBits nf = na.getNodeFlags();
if (nf.isAbr() != null) {
ab.setRouterType(new AbrBuilder().setAbr(nf.isAbr()).build());
} else if (nf.isExternal() != null) {
ab.setRouterType(new InternalBuilder().setInternal(!nf.isExternal()).build());
}
}
}
ab.setTed(tb.build());
return new org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.IgpNodeAttributes1Builder().setOspfNodeAttributes(ab.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.IgpNodeAttributes1 in project bgpcep by opendaylight.
the class ProtocolUtil method isisNodeAttributes.
private static org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.IgpNodeAttributes1 isisNodeAttributes(final NodeIdentifier node, final NodeAttributes na) {
final org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.isis.node.attributes.isis.node.attributes.TedBuilder tb = new org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.isis.node.attributes.isis.node.attributes.TedBuilder();
final IsisNodeAttributesBuilder ab = new IsisNodeAttributesBuilder();
if (na != null) {
if (na.getIpv4RouterId() != null) {
tb.setTeRouterIdIpv4(na.getIpv4RouterId());
}
if (na.getIpv6RouterId() != null) {
tb.setTeRouterIdIpv6(na.getIpv6RouterId());
}
if (na.getTopologyIdentifier() != null) {
ab.setMultiTopologyId(nodeMultiTopology(na.getTopologyIdentifier()));
}
}
final CRouterIdentifier ri = node.getCRouterIdentifier();
if (ri instanceof IsisPseudonodeCase) {
final IsisPseudonode pn = ((IsisPseudonodeCase) ri).getIsisPseudonode();
final IsoBuilder b = new IsoBuilder();
final String systemId = UriBuilder.isoId(pn.getIsIsRouterIdentifier().getIsoSystemId());
b.setIsoSystemId(new IsoSystemId(systemId));
b.setIsoPseudonodeId(new IsoPseudonodeId(BaseEncoding.base16().encode(new byte[] { pn.getPsn().byteValue() })));
ab.setIso(b.build());
if (na != null) {
ab.setNet(toIsoNetIds(na.getIsisAreaId(), systemId));
}
} else if (ri instanceof IsisNodeCase) {
final IsisNode in = ((IsisNodeCase) ri).getIsisNode();
final String systemId = UriBuilder.isoId(in.getIsoSystemId());
ab.setIso(new IsoBuilder().setIsoSystemId(new IsoSystemId(systemId)).build());
if (na != null) {
ab.setNet(toIsoNetIds(na.getIsisAreaId(), systemId));
}
}
ab.setTed(tb.build());
return new org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.IgpNodeAttributes1Builder().setIsisNodeAttributes(ab.build()).build();
}
Aggregations