use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.srp.object.Srp in project bgpcep by opendaylight.
the class PCCTunnelManagerImpl method sendEndOfSynchronization.
private void sendEndOfSynchronization(final PCCSession session, final Optional<SrpIdNumber> operationId) {
Srp srp = null;
if (operationId.isPresent()) {
srp = new SrpBuilder().setOperationId(operationId.get()).build();
}
Optional<Tlvs> tlv = Optional.empty();
if (this.syncOptimization.isSyncAvoidanceEnabled()) {
tlv = createLspTlvsEndofSync(this.syncOptimization.incrementLspDBVersion().get());
}
final Pcrpt pcrtp = createPcRtpMessage(createLsp(Uint32.ZERO, false, tlv, true, false), Optional.ofNullable(srp), createPath(Collections.emptyList()));
session.sendReport(pcrtp);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.srp.object.Srp in project bgpcep by opendaylight.
the class PCCTunnelManagerImpl method reportAllKnownLsp.
private void reportAllKnownLsp(final Optional<SrpIdNumber> operationId, final PCCSession session) {
Srp srp = null;
if (operationId.isPresent()) {
srp = new SrpBuilder().setOperationId(operationId.get()).build();
}
for (final Entry<PlspId, PCCTunnel> entry : this.tunnels.entrySet()) {
final PCCTunnel tunnel = entry.getValue();
final Uint32 plspId = entry.getKey().getValue();
createLspAndSendReport(plspId, tunnel, session, Optional.empty(), Optional.ofNullable(srp));
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.srp.object.Srp in project bgpcep by opendaylight.
the class PCEPTopologySessionListener method manageNextReport.
@Holding("this")
private boolean manageNextReport(final Reports report, final MessageContext ctx) {
final Lsp lsp = report.getLsp();
final PlspId plspid = lsp.getPlspId();
final Srp srp = report.getSrp();
if (!lsp.getSync() && (plspid == null || plspid.getValue().toJava() == 0)) {
purgeStaleLsps(ctx);
if (isTriggeredSyncInProcess()) {
if (srp == null) {
return false;
}
final SrpIdNumber id = srp.getOperationId();
if (id.getValue().toJava() == 0) {
return false;
}
final PCEPRequest req = removeRequest(id);
ctx.resolveRequest(req);
}
stateSynchronizationAchieved(ctx);
return true;
}
final ReportedLspBuilder rlb = new ReportedLspBuilder();
boolean solicited = false;
solicited = isSolicited(srp, lsp, ctx, rlb);
// if remove flag is set in SRP object, remove the tunnel immediately
if (solicited) {
final Srp1 initiatedSrp = srp.augmentation(Srp1.class);
if (initiatedSrp != null && initiatedSrp.getRemove()) {
super.removeLsp(ctx, plspid);
return false;
}
}
rlb.setPath(BindingMap.of(buildPath(report, srp, lsp)));
String name = lookupLspName(plspid);
if (lsp.getTlvs() != null && lsp.getTlvs().getSymbolicPathName() != null) {
name = StandardCharsets.UTF_8.decode(ByteBuffer.wrap(lsp.getTlvs().getSymbolicPathName().getPathName().getValue())).toString();
}
// get LspDB from LSP and write it to pcc's node
final LspDbVersion lspDbVersion = geLspDbVersionTlv(lsp);
if (lspDbVersion != null) {
updatePccNode(ctx, new PathComputationClientBuilder().addAugmentation(new PathComputationClient1Builder().setLspDbVersion(lspDbVersion).build()).build());
}
updateLsp(ctx, plspid, name, rlb, solicited, lsp.getRemove());
unmarkStaleLsp(plspid);
LOG.debug("LSP {} updated", lsp);
return true;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.srp.object.Srp in project bgpcep by opendaylight.
the class PCEPTopologySessionListener method buildPath.
private static Path buildPath(final Reports report, final Srp srp, final Lsp lsp) {
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.reported.lsp.PathBuilder pb = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.reported.lsp.PathBuilder();
if (report.getPath() != null) {
pb.fieldsFrom(report.getPath());
}
// LSP is mandatory (if there is none, parser will throw an exception)
// this is to ensure a path will be created at any rate
final Path1Builder p1Builder = new Path1Builder();
p1Builder.setLsp(report.getLsp());
final PathSetupType pst;
if (srp != null && srp.getTlvs() != null && srp.getTlvs().getPathSetupType() != null) {
pst = srp.getTlvs().getPathSetupType();
p1Builder.setPathSetupType(pst);
} else {
pst = null;
}
pb.addAugmentation(p1Builder.build());
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.lsp.Tlvs tlvs = report.getLsp().getTlvs();
if (tlvs != null) {
if (tlvs.getLspIdentifiers() != null) {
pb.setLspId(tlvs.getLspIdentifiers().getLspId());
} else if (!PSTUtil.isDefaultPST(pst)) {
pb.setLspId(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId(lsp.getPlspId().getValue()));
}
}
return pb.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.srp.object.Srp 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());
}
Aggregations