use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.PcupdMessageBuilder in project bgpcep by opendaylight.
the class Stateful07TopologySessionListener method createUpdateMessageSync.
private SrpIdNumber createUpdateMessageSync(final PcupdMessageBuilder pcupdMessageBuilder) {
final UpdatesBuilder updBuilder = new UpdatesBuilder();
// LSP mandatory in Upd
final Lsp lsp = new LspBuilder().setPlspId(new PlspId(0L)).setSync(Boolean.TRUE).build();
// SRP Mandatory in Upd
final SrpBuilder srpBuilder = new SrpBuilder();
// not sue whether use 0 instead of nextRequest() or do not insert srp == SRP-ID-number = 0
srpBuilder.setOperationId(nextRequest());
final Srp srp = srpBuilder.build();
// ERO Mandatory in Upd
final PathBuilder pb = new PathBuilder();
pb.setEro(new EroBuilder().build());
updBuilder.setPath(pb.build());
updBuilder.setLsp(lsp).setSrp(srp).setPath(pb.build());
pcupdMessageBuilder.setUpdates(Collections.singletonList(updBuilder.build()));
return srp.getOperationId();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.PcupdMessageBuilder 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.pcep.ietf.stateful.rev171025.pcupd.message.PcupdMessageBuilder in project bgpcep by opendaylight.
the class Stateful07PCUpdateRequestMessageParser method validate.
@Override
protected 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("Pcup message cannot be empty.");
}
final List<Updates> updateRequests = Lists.newArrayList();
while (!objects.isEmpty()) {
final Updates upd = getValidUpdates(objects, errors);
if (upd != null) {
updateRequests.add(upd);
}
}
if (!objects.isEmpty()) {
throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
}
return new PcupdBuilder().setPcupdMessage(new PcupdMessageBuilder().setUpdates(updateRequests).build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.PcupdMessageBuilder in project bgpcep by opendaylight.
the class Stateful07TopologySessionListener method triggerResyncronization.
private ListenableFuture<OperationResult> triggerResyncronization(final TriggerSyncArgs input) {
LOG.trace("Trigger Resynchronization {}", input);
markAllLspAsStale();
updatePccState(PccSyncState.PcepTriggeredResync);
final PcupdMessageBuilder pcupdMessageBuilder = new PcupdMessageBuilder(MESSAGE_HEADER);
final SrpIdNumber srpIdNumber = createUpdateMessageSync(pcupdMessageBuilder);
final Message msg = new PcupdBuilder().setPcupdMessage(pcupdMessageBuilder.build()).build();
return sendMessage(msg, srpIdNumber, null);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.PcupdMessageBuilder in project bgpcep by opendaylight.
the class Stateful07TopologySessionListener method redelegate.
private ListenableFuture<OperationResult> redelegate(final Lsp reportedLsp, final Srp srp, final Lsp lsp, final UpdateLspArgs input) {
// the D bit that was reported decides the type of PCE message sent
requireNonNull(reportedLsp.isDelegate());
final Message msg;
if (reportedLsp.isDelegate()) {
// we already have delegation, send update
final UpdatesBuilder rb = new UpdatesBuilder();
rb.setSrp(srp);
rb.setLsp(lsp);
final PathBuilder pb = new PathBuilder();
pb.fieldsFrom(input.getArguments());
rb.setPath(pb.build());
final PcupdMessageBuilder ub = new PcupdMessageBuilder(MESSAGE_HEADER);
ub.setUpdates(Collections.singletonList(rb.build()));
msg = new PcupdBuilder().setPcupdMessage(ub.build()).build();
} else {
final Lsp1 lspCreateFlag = reportedLsp.getAugmentation(Lsp1.class);
// we only retake delegation for PCE initiated tunnels
if (lspCreateFlag != null && !lspCreateFlag.isCreate()) {
LOG.warn("Unable to retake delegation of PCC-initiated tunnel: {}", reportedLsp);
return OperationResults.createUnsent(PCEPErrors.UPDATE_REQ_FOR_NON_LSP).future();
}
// we want to revoke delegation, different type of message
// is sent because of specification by Siva
// this message is also sent, when input delegate bit is set to 0
// generating an error in PCC
final List<Requests> reqs = new ArrayList<>();
reqs.add(new RequestsBuilder().setSrp(srp).setLsp(lsp).build());
final PcinitiateMessageBuilder ib = new PcinitiateMessageBuilder();
ib.setRequests(reqs);
msg = new PcinitiateBuilder().setPcinitiateMessage(ib.build()).build();
}
return sendMessage(msg, srp.getOperationId(), input.getArguments().getMetadata());
}
Aggregations