use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.sr.subobject.nai.IpNodeId in project bgpcep by opendaylight.
the class AbstractSrSubobjectParser method serializeNai.
private static void serializeNai(final Nai nai, final SidType sidType, final ByteBuf buffer) {
switch(sidType) {
case Ipv4NodeId:
writeIpv4Address(((IpNodeId) nai).getIpAddress().getIpv4Address(), buffer);
break;
case Ipv6NodeId:
writeIpv6Address(((IpNodeId) nai).getIpAddress().getIpv6Address(), buffer);
break;
case Ipv4Adjacency:
writeIpv4Address(((IpAdjacency) nai).getLocalIpAddress().getIpv4Address(), buffer);
writeIpv4Address(((IpAdjacency) nai).getRemoteIpAddress().getIpv4Address(), buffer);
break;
case Ipv6Adjacency:
writeIpv6Address(((IpAdjacency) nai).getLocalIpAddress().getIpv6Address(), buffer);
writeIpv6Address(((IpAdjacency) nai).getRemoteIpAddress().getIpv6Address(), buffer);
break;
case Unnumbered:
final UnnumberedAdjacency unnumbered = (UnnumberedAdjacency) nai;
ByteBufWriteUtil.writeUnsignedInt(unnumbered.getLocalNodeId(), buffer);
ByteBufWriteUtil.writeUnsignedInt(unnumbered.getLocalInterfaceId(), buffer);
ByteBufWriteUtil.writeUnsignedInt(unnumbered.getRemoteNodeId(), buffer);
ByteBufWriteUtil.writeUnsignedInt(unnumbered.getRemoteInterfaceId(), buffer);
break;
default:
break;
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.sr.subobject.nai.IpNodeId in project bgpcep by opendaylight.
the class TopologyProviderTest method testOnReportMessage.
@Test
public void testOnReportMessage() throws ReadFailedException {
this.listener.onSessionUp(this.session);
Pcrpt pcRptMsg = createSrPcRpt("1.1.1.1", "sr-path1", 1L, true);
this.listener.onMessage(this.session, pcRptMsg);
readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
// check sr-path
final List<ReportedLsp> reportedLsps = pcc.getReportedLsp();
assertNotNull(reportedLsps);
assertEquals(1, reportedLsps.size());
final ReportedLsp lsp = reportedLsps.get(0);
assertEquals("sr-path1", lsp.getName());
assertEquals(1, lsp.getPath().get(0).getAugmentation(Path1.class).getPathSetupType().getPst().intValue());
final List<Subobject> subobjects = lsp.getPath().get(0).getEro().getSubobject();
assertEquals(1, subobjects.size());
assertEquals("1.1.1.1", ((IpNodeId) ((SrEroType) subobjects.get(0).getSubobjectType()).getNai()).getIpAddress().getIpv4Address().getValue());
return pcc;
});
pcRptMsg = createSrPcRpt("1.1.1.3", "sr-path2", 2L, false);
this.listener.onMessage(this.session, pcRptMsg);
readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
// check second lsp sr-path
final List<ReportedLsp> reportedLsps = pcc.getReportedLsp();
assertNotNull(reportedLsps);
assertEquals(2, reportedLsps.size());
return pcc;
});
pcRptMsg = createSrPcRpt("1.1.1.2", "sr-path1", 1L, true);
this.listener.onMessage(this.session, pcRptMsg);
readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
// check updated sr-path
final List<ReportedLsp> reportedLsps = pcc.getReportedLsp();
assertNotNull(reportedLsps);
assertEquals(2, reportedLsps.size());
for (final ReportedLsp rlsp : reportedLsps) {
if (rlsp.getName().equals("sr-path1")) {
final List<Subobject> subobjects = rlsp.getPath().get(0).getEro().getSubobject();
assertEquals(1, subobjects.size());
assertEquals("1.1.1.2", ((IpNodeId) ((SrEroType) subobjects.get(0).getSubobjectType()).getNai()).getIpAddress().getIpv4Address().getValue());
}
}
return pcc;
});
}
Aggregations