use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.PcinitiateBuilder in project bgpcep by opendaylight.
the class PCEPTopologySessionListener method removeLsp.
@Override
@SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH", justification = "SB does not grok TYPE_USE")
public synchronized ListenableFuture<OperationResult> removeLsp(final RemoveLspArgs input) {
checkArgument(input != null && input.getName() != null && input.getNode() != null, MISSING_XML_TAG);
LOG.trace("RemoveLspArgs {}", input);
// Make sure the LSP exists, we need it for PLSP-ID
final InstanceIdentifier<ReportedLsp> lsp = lspIdentifier(input.getName());
final ListenableFuture<Optional<ReportedLsp>> f = readOperationalData(lsp);
return f == null ? OperationResults.createUnsent(PCEPErrors.LSP_INTERNAL_ERROR).future() : Futures.transformAsync(f, rep -> {
final Lsp reportedLsp = validateReportedLsp(rep, input);
if (reportedLsp == null) {
return OperationResults.createUnsent(PCEPErrors.UNKNOWN_PLSP_ID).future();
}
final PcinitiateMessageBuilder ib = new PcinitiateMessageBuilder(MESSAGE_HEADER);
final Requests rb = buildRequest(rep, reportedLsp);
ib.setRequests(Collections.singletonList(rb));
return sendMessage(new PcinitiateBuilder().setPcinitiateMessage(ib.build()).build(), rb.getSrp().getOperationId(), null);
}, MoreExecutors.directExecutor());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.PcinitiateBuilder in project bgpcep by opendaylight.
the class PCEPTopologySessionListener method redelegate.
@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "https://github.com/spotbugs/spotbugs/issues/811")
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
final boolean isDelegate = requireNonNull(reportedLsp.getDelegate());
final Message msg;
if (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.augmentation(Lsp1.class);
// we only retake delegation for PCE initiated tunnels
if (lspCreateFlag != null && !lspCreateFlag.getCreate()) {
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());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.PcinitiateBuilder in project bgpcep by opendaylight.
the class CInitiated00PCInitiateMessageParser 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.");
final PcinitiateMessageBuilder builder = new PcinitiateMessageBuilder();
final List<Requests> reqs = Lists.newArrayList();
while (!objects.isEmpty()) {
reqs.add(this.getValidRequest(objects));
}
builder.setRequests(reqs);
return new PcinitiateBuilder().setPcinitiateMessage(builder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.PcinitiateBuilder 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());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.PcinitiateBuilder in project bgpcep by opendaylight.
the class Stateful07TopologySessionListener method removeLsp.
@Override
public synchronized ListenableFuture<OperationResult> removeLsp(@Nonnull final RemoveLspArgs input) {
Preconditions.checkArgument(input != null && input.getName() != null && input.getNode() != null, MISSING_XML_TAG);
LOG.trace("RemoveLspArgs {}", input);
// Make sure the LSP exists, we need it for PLSP-ID
final InstanceIdentifier<ReportedLsp> lsp = lspIdentifier(input.getName());
final ListenableFuture<Optional<ReportedLsp>> f = readOperationalData(lsp);
if (f == null) {
return OperationResults.createUnsent(PCEPErrors.LSP_INTERNAL_ERROR).future();
}
return Futures.transformAsync(f, rep -> {
final Lsp reportedLsp = validateReportedLsp(rep, input);
if (reportedLsp == null) {
return OperationResults.createUnsent(PCEPErrors.UNKNOWN_PLSP_ID).future();
}
final PcinitiateMessageBuilder ib = new PcinitiateMessageBuilder(MESSAGE_HEADER);
final Requests rb = buildRequest(rep, reportedLsp);
ib.setRequests(Collections.singletonList(rb));
return sendMessage(new PcinitiateBuilder().setPcinitiateMessage(ib.build()).build(), rb.getSrp().getOperationId(), null);
}, MoreExecutors.directExecutor());
}
Aggregations