use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.initiation.Tlvs in project bgpcep by opendaylight.
the class Stateful07PCReportMessageParser method getValidReports.
protected Reports getValidReports(final List<Object> objects, final List<Message> errors) {
final ReportsBuilder builder = new ReportsBuilder();
boolean lspViaSR = false;
Object object = objects.remove(0);
if (object instanceof Srp) {
final Srp srp = (Srp) object;
final Tlvs tlvs = srp.getTlvs();
if (tlvs != null) {
lspViaSR = PSTUtil.isDefaultPST(tlvs.getPathSetupType());
}
builder.setSrp(srp);
if (objects.isEmpty()) {
object = null;
} else {
object = objects.remove(0);
}
}
if (validateLsp(object, lspViaSR, errors, builder)) {
if (!objects.isEmpty()) {
if (!validatePath(objects, errors, builder)) {
return null;
}
}
return builder.build();
}
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.initiation.Tlvs in project bgpcep by opendaylight.
the class PCCTunnelManagerImpl method returnDelegation.
private void returnDelegation(final Updates update, final PCCSession session) {
final PlspId plspId = update.getLsp().getPlspId();
final PCCTunnel tunnel = this.tunnels.get(plspId);
final long srpId = update.getSrp().getOperationId().getValue();
if (tunnel != null) {
// check if session really has a delegation
if (hasDelegation(tunnel, session)) {
// send report D=0
final Tlvs tlvs = buildTlvs(tunnel, plspId.getValue(), Optional.absent());
final Pcrpt pcrtp = createPcRtpMessage(new LspBuilder(update.getLsp()).setSync(true).setOperational(OperationalStatus.Up).setDelegate(false).setTlvs(tlvs).build(), Optional.of(createSrp(srpId)), tunnel.getLspState());
session.sendReport(pcrtp);
// start state timer
startStateTimeout(tunnel, plspId);
// if PCC's LSP, start re-delegation timer
if (tunnel.getType() == LspType.PCC_LSP) {
startRedelegationTimer(tunnel, plspId, session);
} else {
// if PCE-initiated LSP, revoke delegation instantly
setDelegation(plspId, null);
}
} else {
session.sendError(MsgBuilderUtil.createErrorMsg(PCEPErrors.UPDATE_REQ_FOR_NON_LSP, srpId));
}
} else {
session.sendError(MsgBuilderUtil.createErrorMsg(PCEPErrors.UNKNOWN_PLSP_ID, srpId));
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.initiation.Tlvs in project bgpcep by opendaylight.
the class PCCTunnelManagerImpl method startRedelegationTimer.
private void startRedelegationTimer(final PCCTunnel tunnel, final PlspId plspId, final PCCSession session) {
final Timeout newRedelegationTimeout = this.timer.newTimeout(timeout -> {
// remove delegation
PCCTunnelManagerImpl.this.setDelegation(plspId, null);
// delegate to another PCE
int index = session.getId();
for (int i = 1; i < PCCTunnelManagerImpl.this.sessions.size(); i++) {
index++;
if (index == PCCTunnelManagerImpl.this.sessions.size()) {
index = 0;
}
final PCCSession nextSession = PCCTunnelManagerImpl.this.sessions.get(index);
if (nextSession != null) {
tunnel.cancelTimeouts();
final Tlvs tlvs = buildTlvs(tunnel, plspId.getValue(), Optional.absent());
nextSession.sendReport(createPcRtpMessage(createLsp(plspId.getValue(), true, Optional.fromNullable(tlvs), true, false), NO_SRP, tunnel.getLspState()));
tunnel.setDelegationHolder(nextSession.getId());
break;
}
}
}, this.redelegationTimeout, TimeUnit.SECONDS);
tunnel.setRedelegationTimeout(newRedelegationTimeout);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.initiation.Tlvs in project bgpcep by opendaylight.
the class PCCTunnelManagerImpl method createLspAndSendReport.
private void createLspAndSendReport(final long plspId, final PCCTunnel tunnel, final PCCSession session, final Optional<Boolean> isSync, final Optional<Srp> srp) {
final boolean delegation = hasDelegation(tunnel, session);
if (delegation) {
tunnel.cancelTimeouts();
}
final String destinationAddress = getDestinationAddress(tunnel.getLspState().getEro().getSubobject(), this.address);
final Tlvs tlvs = createLspTlvs(plspId, true, destinationAddress, this.address, this.address, Optional.of(tunnel.getPathName()), this.syncOptimization.incrementLspDBVersion());
final boolean sync = isSync.isPresent() ? isSync.get() : this.syncOptimization.isSyncNeedIt();
final Lsp lsp = createLsp(plspId, sync, Optional.fromNullable(tlvs), delegation, false);
final Pcrpt pcrtp = createPcRtpMessage(lsp, srp, tunnel.getLspState());
session.sendReport(pcrtp);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.initiation.Tlvs in project bgpcep by opendaylight.
the class PCCTunnelManagerImpl method sendToAll.
private void sendToAll(final PCCTunnel tunnel, final PlspId plspId, final List<Subobject> subobjects, final Srp srp, final Path path, final Lsp lsp) {
for (final PCCSession session : this.sessions.values()) {
final boolean isDelegated = hasDelegation(tunnel, session);
final Tlvs tlvs = buildTlvs(tunnel, plspId.getValue(), Optional.of(subobjects));
final Pcrpt pcRpt = createPcRtpMessage(new LspBuilder(lsp).setPlspId(plspId).setOperational(OperationalStatus.Up).setDelegate(isDelegated).setSync(true).addAugmentation(Lsp1.class, new Lsp1Builder().setCreate(tunnel.getType() == LspType.PCE_LSP).build()).setTlvs(tlvs).build(), Optional.fromNullable(srp), path);
session.sendReport(pcRpt);
}
}
Aggregations