use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported.route.object.rro.Subobject in project bgpcep by opendaylight.
the class TopologyProviderTest method testOnReportMessage.
@Test
public void testOnReportMessage() throws ExecutionException, InterruptedException {
listener.onSessionUp(session);
Pcrpt pcRptMsg = createSrPcRpt("1.1.1.1", "sr-path1", Uint32.ONE, true);
listener.onMessage(session, pcRptMsg);
readDataOperational(getDataBroker(), pathComputationClientIId, pcc -> {
// check sr-path
final Map<ReportedLspKey, ReportedLsp> reportedLsps = pcc.getReportedLsp();
assertNotNull(reportedLsps);
assertEquals(1, reportedLsps.size());
final ReportedLsp lsp = reportedLsps.values().iterator().next();
assertEquals("sr-path1", lsp.getName());
final Map<PathKey, Path> paths = lsp.getPath();
assertNotNull(paths);
final Path path = paths.values().iterator().next();
assertEquals(1, path.augmentation(Path1.class).getPathSetupType().getPst().intValue());
final List<Subobject> subobjects = path.getEro().nonnullSubobject();
assertEquals(1, subobjects.size());
assertEquals("1.1.1.1", ((IpNodeId) ((SrEroType) subobjects.get(0).getSubobjectType()).getNai()).getIpAddress().getIpv4AddressNoZone().getValue());
return pcc;
});
pcRptMsg = createSrPcRpt("1.1.1.3", "sr-path2", Uint32.TWO, false);
listener.onMessage(session, pcRptMsg);
readDataOperational(getDataBroker(), pathComputationClientIId, pcc -> {
// check second lsp sr-path
final Map<ReportedLspKey, ReportedLsp> reportedLsps = pcc.getReportedLsp();
assertNotNull(reportedLsps);
assertEquals(2, reportedLsps.size());
return pcc;
});
pcRptMsg = createSrPcRpt("1.1.1.2", "sr-path1", Uint32.ONE, true);
listener.onMessage(session, pcRptMsg);
readDataOperational(getDataBroker(), pathComputationClientIId, pcc -> {
// check updated sr-path
final Map<ReportedLspKey, ReportedLsp> reportedLsps = pcc.getReportedLsp();
assertNotNull(reportedLsps);
assertEquals(2, reportedLsps.size());
for (final ReportedLsp rlsp : reportedLsps.values()) {
if (rlsp.getName().equals("sr-path1")) {
final List<Subobject> subobjects = rlsp.nonnullPath().values().iterator().next().getEro().nonnullSubobject();
assertEquals(1, subobjects.size());
assertEquals("1.1.1.2", ((IpNodeId) ((SrEroType) subobjects.get(0).getSubobjectType()).getNai()).getIpAddress().getIpv4AddressNoZone().getValue());
}
}
return pcc;
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported.route.object.rro.Subobject in project bgpcep by opendaylight.
the class TopologyProviderTest method createSrEroObject.
private static Ero createSrEroObject(final String nai) {
final SrEroTypeBuilder srEroBuilder = new SrEroTypeBuilder().setCFlag(false).setMFlag(false).setNaiType(NaiType.Ipv4NodeId).setSid(Uint32.valueOf(123456)).setNai(new IpNodeIdBuilder().setIpAddress(new IpAddressNoZone(new Ipv4AddressNoZone(nai))).build());
final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(srEroBuilder.build()).setLoose(false);
final List<Subobject> subobjects = Lists.newArrayList(subobjBuilder.build());
return new EroBuilder().setProcessingRule(false).setIgnore(false).setSubobject(subobjects).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported.route.object.rro.Subobject in project bgpcep by opendaylight.
the class MessagesUtil method getEro.
public static Ero getEro(final List<PathDescription> pathDescriptions) {
/* Prepare ERO */
final EroBuilder eroBuilder = new EroBuilder().setIgnore(false).setProcessingRule(true);
final List<Subobject> eroSubs = new ArrayList<>();
/* Fulfill ERO sublist */
for (PathDescription path : pathDescriptions) {
Subobject sb = null;
if (path.getSid() == null) {
IpPrefix ipPref = null;
/* Prepare SubObject for IPv4 or IPv6 address */
if (path.getIpv4() != null) {
final Ipv4Prefix ipv4Pref = new Ipv4Prefix(path.getIpv4().getValue() + "/32");
ipPref = new IpPrefixBuilder().setIpPrefix(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix(ipv4Pref)).build();
}
if (path.getIpv6() != null) {
final Ipv6Prefix ipv6Pref = new Ipv6Prefix(path.getIpv6().getValue() + "/128");
ipPref = new IpPrefixBuilder().setIpPrefix(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix(ipv6Pref)).build();
}
if (ipPref != null) {
final IpPrefixCase ipPrefCase = new IpPrefixCaseBuilder().setIpPrefix(ipPref).build();
sb = new SubobjectBuilder().setSubobjectType(ipPrefCase).setLoose(false).build();
}
} else {
/* Prepare SubObject for Segment Routing */
SrEroType srEro = null;
if (path.getLocalIpv4() != null && path.getRemoteIpv4() != null) {
srEro = new SrEroTypeBuilder().setNaiType(NaiType.Ipv4Adjacency).setSid(path.getSid()).setCFlag(false).setMFlag(true).setNai(new IpAdjacencyBuilder().setLocalIpAddress(new IpAddressNoZone(new Ipv4AddressNoZone(path.getLocalIpv4().getValue()))).setRemoteIpAddress(new IpAddressNoZone(new Ipv4AddressNoZone(path.getRemoteIpv4().getValue()))).build()).build();
}
if (path.getLocalIpv6() != null && path.getRemoteIpv6() != null) {
srEro = new SrEroTypeBuilder().setNaiType(NaiType.Ipv6Adjacency).setSid(path.getSid()).setCFlag(false).setMFlag(true).setNai(new IpAdjacencyBuilder().setLocalIpAddress(new IpAddressNoZone(new Ipv6AddressNoZone(path.getLocalIpv6().getValue()))).setRemoteIpAddress(new IpAddressNoZone(new Ipv6AddressNoZone(path.getRemoteIpv6().getValue()))).build()).build();
}
if (srEro != null) {
sb = new SubobjectBuilder().setSubobjectType(srEro).setLoose(false).build();
}
}
/* Add corresponding SubObject to the ERO List */
if (sb != null) {
eroSubs.add(sb);
}
}
/* Set ERO sublist */
eroBuilder.setSubobject(eroSubs);
return eroBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported.route.object.rro.Subobject in project bgpcep by opendaylight.
the class AbstractEROPathKeySubobjectParser method serializeSubobject.
@Override
public final void serializeSubobject(final Subobject subobject, final ByteBuf buffer) {
final SubobjectType type = subobject.getSubobjectType();
checkArgument(type instanceof PathKeyCase, "Unknown subobject instance. Passed %s. Needed PathKey.", type.getClass());
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.path.key._case.PathKey pk = ((PathKeyCase) type).getPathKey();
final PathKey pathKey = pk.getPathKey();
checkArgument(pathKey != null, "PathKey is mandatory.");
final byte[] pceID = pk.getPceId().getValue();
checkArgument(pceID.length == PCE_ID_F_LENGTH || pceID.length == PCE128_ID_F_LENGTH, "PceId 32/128 Bit required.");
final ByteBuf body = Unpooled.buffer();
ByteBufUtils.write(body, pathKey.getValue());
body.writeBytes(pceID);
EROSubobjectUtil.formatSubobject(pceID.length == PCE_ID_F_LENGTH ? TYPE_32 : TYPE_128, subobject.getLoose(), body, buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported.route.object.rro.Subobject in project bgpcep by opendaylight.
the class AbstractEROPathKeySubobjectParser method parseSubobject.
@Override
public final Subobject parseSubobject(final ByteBuf buffer, final boolean loose) throws PCEPDeserializerException {
checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
checkContentLength(buffer.readableBytes());
return new SubobjectBuilder().setLoose(loose).setSubobjectType(new PathKeyCaseBuilder().setPathKey(new PathKeyBuilder().setPathKey(new PathKey(ByteBufUtils.readUint16(buffer))).setPceId(new PceId(readPceId(buffer))).build()).build()).build();
}
Aggregations