use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.reported.lsp.PathBuilder in project bgpcep by opendaylight.
the class Stateful07PCReportMessageParser method validatePath.
private static boolean validatePath(final List<Object> objects, final List<Message> errors, final ReportsBuilder builder) {
final PathBuilder pBuilder = new PathBuilder();
Object object = objects.remove(0);
if (object instanceof Ero) {
pBuilder.setEro((Ero) object);
} else {
errors.add(createErrorMsg(PCEPErrors.ERO_MISSING, Optional.absent()));
return false;
}
parsePath(objects, pBuilder);
builder.setPath(pBuilder.build());
return true;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.reported.lsp.PathBuilder 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.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.reported.lsp.PathBuilder in project bgpcep by opendaylight.
the class PCEPValidatorTest method testUpdMsg.
@Test
public void testUpdMsg() throws IOException, PCEPDeserializerException {
try (CrabbeInitiatedActivator a = new CrabbeInitiatedActivator()) {
a.start(this.ctx);
ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCUpd.2.bin"));
final Stateful07PCUpdateRequestMessageParser parser = new Stateful07PCUpdateRequestMessageParser(this.ctx.getObjectHandlerRegistry());
final PcupdMessageBuilder builder = new PcupdMessageBuilder();
final List<Updates> updates = Lists.newArrayList();
final PathBuilder pBuilder = new PathBuilder();
pBuilder.setEro(this.ero);
pBuilder.setLspa(this.lspa);
updates.add(new UpdatesBuilder().setSrp(this.srp).setLsp(this.lspSrp).setPath(pBuilder.build()).build());
builder.setUpdates(updates);
assertEquals(new PcupdBuilder().setPcupdMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
ByteBuf buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcupdBuilder().setPcupdMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCUpd.5.bin"));
final List<Updates> updates1 = Lists.newArrayList();
final PathBuilder pBuilder1 = new PathBuilder();
pBuilder1.setEro(this.ero);
pBuilder1.setLspa(this.lspa);
updates1.add(new UpdatesBuilder().setSrp(this.srp).setLsp(this.lspSrp).setPath(pBuilder.build()).build());
updates1.add(new UpdatesBuilder().setSrp(this.srp).setLsp(this.lspSrp).setPath(pBuilder1.build()).build());
builder.setUpdates(updates1);
assertEquals(new PcupdBuilder().setPcupdMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcupdBuilder().setPcupdMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.reported.lsp.PathBuilder in project bgpcep by opendaylight.
the class Stateful07PCReportMessageParser method parsePath.
private static void parsePath(final List<Object> objects, final PathBuilder builder) {
final List<Metrics> pathMetrics = Lists.newArrayList();
Object obj;
State state = State.INIT;
while (!objects.isEmpty() && !state.equals(State.END)) {
obj = objects.get(0);
state = insertObject(state, obj, builder, pathMetrics);
if (!state.equals(State.END)) {
objects.remove(0);
}
}
if (!pathMetrics.isEmpty()) {
builder.setMetrics(pathMetrics);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.reported.lsp.PathBuilder in project bgpcep by opendaylight.
the class Stateful07PCUpdateRequestMessageParser method parsePath.
private static void parsePath(final List<Object> objects, final PathBuilder pBuilder) {
final List<Metrics> pathMetrics = Lists.newArrayList();
Object obj;
State state = State.INIT;
while (!objects.isEmpty() && !state.equals(State.END)) {
obj = objects.get(0);
state = insertObject(state, obj, pBuilder, pathMetrics);
if (!state.equals(State.END)) {
objects.remove(0);
}
}
if (!pathMetrics.isEmpty()) {
pBuilder.setMetrics(pathMetrics);
}
}
Aggregations