use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.PcrptBuilder in project bgpcep by opendaylight.
the class Stateful07PCReportMessageParser method validate.
@Override
public Message validate(final List<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
Preconditions.checkArgument(objects != null, "Passed list can't be null.");
if (objects.isEmpty()) {
throw new PCEPDeserializerException("Pcrpt message cannot be empty.");
}
final List<Reports> reports = Lists.newArrayList();
while (!objects.isEmpty()) {
final Reports report = getValidReports(objects, errors);
if (report != null) {
reports.add(report);
}
}
return new PcrptBuilder().setPcrptMessage(new PcrptMessageBuilder().setReports(reports).build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.PcrptBuilder in project bgpcep by opendaylight.
the class MsgBuilderUtil method createPcRtpMessage.
public static Pcrpt createPcRtpMessage(final Lsp lsp, final Optional<Srp> srp, final Path path) {
final PcrptBuilder rptBuilder = new PcrptBuilder();
final PcrptMessageBuilder msgBuilder = new PcrptMessageBuilder();
final ReportsBuilder reportBuilder = new ReportsBuilder();
reportBuilder.setLsp(lsp);
reportBuilder.setSrp(srp.orNull());
reportBuilder.setPath(path);
msgBuilder.setReports(Lists.newArrayList(reportBuilder.build()));
rptBuilder.setPcrptMessage(msgBuilder.build());
return rptBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.PcrptBuilder in project bgpcep by opendaylight.
the class PCEPTopologySessionListenerTest method testUnknownLsp.
@Test
public void testUnknownLsp() throws Exception {
final List<Reports> reports = Lists.newArrayList(new ReportsBuilder().setPath(new PathBuilder().setEro(new EroBuilder().build()).build()).setLsp(new LspBuilder().setPlspId(new PlspId(Uint32.valueOf(5))).setSync(FALSE).setRemove(FALSE).setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.lsp.TlvsBuilder().setLspIdentifiers(new LspIdentifiersBuilder().setLspId(new LspId(Uint32.ONE)).build()).setSymbolicPathName(new SymbolicPathNameBuilder().setPathName(new SymbolicPathName(new byte[] { 22, 34 })).build()).build()).build()).build());
final Pcrpt rptmsg = new PcrptBuilder().setPcrptMessage(new PcrptMessageBuilder().setReports(reports).build()).build();
listener.onSessionUp(session);
listener.onMessage(session, rptmsg);
readDataOperational(getDataBroker(), TOPO_IID, node -> {
assertFalse(node.nonnullNode().isEmpty());
return node;
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.PcrptBuilder in project bgpcep by opendaylight.
the class Stateful07TopologySessionListenerTest method testUnknownLsp.
@Test
public void testUnknownLsp() throws Exception {
final List<Reports> reports = Lists.newArrayList(new ReportsBuilder().setPath(new PathBuilder().setEro(new EroBuilder().build()).build()).setLsp(new LspBuilder().setPlspId(new PlspId(5L)).setSync(false).setRemove(false).setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.TlvsBuilder().setLspIdentifiers(new LspIdentifiersBuilder().setLspId(new LspId(1L)).build()).setSymbolicPathName(new SymbolicPathNameBuilder().setPathName(new SymbolicPathName(new byte[] { 22, 34 })).build()).build()).build()).build());
final Pcrpt rptmsg = new PcrptBuilder().setPcrptMessage(new PcrptMessageBuilder().setReports(reports).build()).build();
this.listener.onSessionUp(this.session);
this.listener.onMessage(this.session, rptmsg);
readDataOperational(getDataBroker(), TOPO_IID, node -> {
assertFalse(node.getNode().isEmpty());
return node;
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.PcrptBuilder in project bgpcep by opendaylight.
the class PCEPValidatorTest method testRptMsg.
@Test
public void testRptMsg() throws IOException, PCEPDeserializerException {
new InitiatedActivator().start(ctx);
new StatefulActivator().start(ctx);
ByteBuf result = Unpooled.wrappedBuffer(PCRT1);
final StatefulPCReportMessageParser parser = new StatefulPCReportMessageParser(this.ctx.getObjectHandlerRegistry());
final PcrptMessageBuilder builder = new PcrptMessageBuilder();
final List<Reports> reports = new ArrayList<>();
reports.add(new ReportsBuilder().setLsp(this.lsp).build());
builder.setReports(reports);
final Message parseResult = parser.parseMessage(result.slice(4, result.readableBytes() - 4), List.of());
assertEquals(new PcrptBuilder().setPcrptMessage(builder.build()).build(), parseResult);
ByteBuf buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcrptBuilder().setPcrptMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
result = Unpooled.wrappedBuffer(PCRT2);
builder.setReports(List.of(new ReportsBuilder().setLsp(this.lsp).setPath(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcrpt.message.pcrpt.message.reports.PathBuilder().setEro(this.ero).setLspa(this.lspa).build()).build()));
final ByteBuf input = result.slice(4, result.readableBytes() - 4);
assertEquals(new PcrptBuilder().setPcrptMessage(builder.build()).build(), parser.parseMessage(input, List.of()));
buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcrptBuilder().setPcrptMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCRpt.3.bin"));
final List<Reports> reports2 = new ArrayList<>();
final var pBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcrpt.message.pcrpt.message.reports.PathBuilder();
pBuilder.setEro(this.ero);
pBuilder.setLspa(this.lspa);
pBuilder.setMetrics(Lists.newArrayList(this.metrics, this.metrics));
pBuilder.setRro(this.rro);
reports2.add(new ReportsBuilder().setSrp(this.srp).setLsp(this.lspSrp).setPath(pBuilder.build()).build());
builder.setReports(reports2);
assertEquals(new PcrptBuilder().setPcrptMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), List.of()));
buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcrptBuilder().setPcrptMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCRpt.4.bin"));
assertEquals(new PcrptBuilder().setPcrptMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), List.of()));
result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCRpt.5.bin"));
final List<Reports> reports3 = new ArrayList<>();
final var pBuilder1 = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcrpt.message.pcrpt.message.reports.PathBuilder();
pBuilder1.setEro(this.ero);
pBuilder1.setLspa(this.lspa);
pBuilder1.setMetrics(Lists.newArrayList(this.metrics, this.metrics));
pBuilder1.setRro(this.rro);
reports3.add(new ReportsBuilder().setSrp(this.srp).setLsp(this.lspSrp).setPath(pBuilder.build()).build());
reports3.add(new ReportsBuilder().setSrp(this.srp).setLsp(this.lspSrp).setPath(pBuilder1.build()).build());
builder.setReports(reports3);
assertEquals(new PcrptBuilder().setPcrptMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), List.of()));
buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcrptBuilder().setPcrptMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
result = Unpooled.wrappedBuffer(PCRT3);
final List<Reports> reports4 = new ArrayList<>();
reports4.add(new ReportsBuilder().setLsp(this.lsp).setPath(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcrpt.message.pcrpt.message.reports.PathBuilder().setEro(this.ero).setLspa(this.lspa).setBandwidth(this.bandwidth).setReoptimizationBandwidth(this.reoptimizationBandwidth).build()).build());
builder.setReports(reports4);
final ByteBuf input2 = result.slice(4, result.readableBytes() - 4);
assertEquals(new PcrptBuilder().setPcrptMessage(builder.build()).build(), parser.parseMessage(input2, List.of()));
buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcrptBuilder().setPcrptMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
}
Aggregations