use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.RequestsBuilder in project bgpcep by opendaylight.
the class CInitiated00PCInitiateMessageParser method getValidRequest.
protected Requests getValidRequest(final List<Object> objects) {
final RequestsBuilder builder = new RequestsBuilder();
builder.setSrp((Srp) objects.get(0));
objects.remove(0);
builder.setLsp((Lsp) objects.get(0));
objects.remove(0);
final List<Metrics> metrics = Lists.newArrayList();
Object obj;
State state = State.INIT;
while (!objects.isEmpty() && !state.equals(State.END)) {
obj = objects.get(0);
state = insertObject(state, obj, builder, metrics);
if (!state.equals(State.END)) {
objects.remove(0);
}
}
builder.setMetrics(metrics);
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.RequestsBuilder in project bgpcep by opendaylight.
the class Stateful07TopologySessionListener method buildRequest.
private Requests buildRequest(final Optional<ReportedLsp> rep, final Lsp reportedLsp) {
// Build the request and send it
final RequestsBuilder rb = new RequestsBuilder();
final SrpBuilder srpBuilder = new SrpBuilder().addAugmentation(Srp1.class, new Srp1Builder().setRemove(Boolean.TRUE).build()).setOperationId(nextRequest()).setProcessingRule(Boolean.TRUE);
final Optional<PathSetupType> maybePST = getPST(rep);
if (maybePST.isPresent()) {
srpBuilder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.srp.object.srp.TlvsBuilder().setPathSetupType(maybePST.get()).build());
}
rb.setSrp(srpBuilder.build());
rb.setLsp(new LspBuilder().setRemove(Boolean.FALSE).setPlspId(reportedLsp.getPlspId()).setDelegate(reportedLsp.isDelegate()).build());
return rb.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.RequestsBuilder 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.types.rev181109.pcreq.message.pcreq.message.RequestsBuilder in project bgpcep by opendaylight.
the class PCCSessionListenerTest method createInitMsg.
private static PcinitiateMessage createInitMsg(final boolean remove, final boolean endpoint) {
// lsp with "unknown" plsp-id
final LspBuilder lspBuilder = new LspBuilder().setAdministrative(true).setDelegate(true).setIgnore(false).setOperational(OperationalStatus.Up).setPlspId(new PlspId(999L)).setProcessingRule(false).setRemove(remove).setSync(true);
final List<Requests> requests = Lists.newArrayList();
final RequestsBuilder reqBuilder = new RequestsBuilder().setLsp(lspBuilder.build()).setSrp(new SrpBuilder(MsgBuilderUtil.createSrp(123)).addAugmentation(Srp1.class, new Srp1Builder().setRemove(remove).build()).build());
if (endpoint) {
reqBuilder.setEndpointsObj(new EndpointsObjBuilder().build());
}
requests.add(reqBuilder.build());
final PcinitiateMessageBuilder initBuilder = new PcinitiateMessageBuilder().setRequests(requests);
return new PcinitiateBuilder().setPcinitiateMessage(initBuilder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.RequestsBuilder in project bgpcep by opendaylight.
the class PCEPRequestMessageParser method getRequests.
protected List<Requests> getRequests(final Queue<Object> objects, final List<Message> errors) {
final List<Requests> requests = new ArrayList<>();
for (Object obj = objects.peek(); obj != null; obj = objects.peek()) {
if (!(obj instanceof Rp)) {
// if RP obj is missing return error only
errors.add(createErrorMsg(PCEPErrors.RP_MISSING, Optional.empty()));
return null;
}
final RequestsBuilder rBuilder = new RequestsBuilder();
final Rp rpObj = (Rp) obj;
objects.remove();
if (rpObj.getProcessingRule()) {
rBuilder.setRp(rpObj);
} else {
errors.add(createErrorMsg(PCEPErrors.P_FLAG_NOT_SET, Optional.empty()));
}
final List<VendorInformationObject> vendorInfo = addVendorInformationObjects(objects);
if (!vendorInfo.isEmpty()) {
rBuilder.setVendorInformationObject(vendorInfo);
}
// expansion
if (rpObj.getPathKey()) {
// FIXME: this can fail on malformed messages (i.e. objects.isEmpty()), add an explicit check/error
obj = objects.element();
if (obj instanceof PathKey) {
// FIXME: shouldn't we be also removing the object?
rBuilder.setPathKeyExpansion(new PathKeyExpansionBuilder().setPathKey((PathKey) obj).build());
}
}
obj = objects.peek();
if (!(obj instanceof EndpointsObj)) {
errors.add(createErrorMsg(PCEPErrors.END_POINTS_MISSING, Optional.of(rpObj)));
return null;
}
if (!rpObj.getP2mp()) {
// p2p
// FIXME: explicit check for empty/type?
final EndpointsObj ep = (EndpointsObj) objects.remove();
final P2pBuilder p2pBuilder = new P2pBuilder();
if (!ep.getProcessingRule()) {
errors.add(createErrorMsg(PCEPErrors.P_FLAG_NOT_SET, Optional.of(rpObj)));
} else {
p2pBuilder.setEndpointsObj(ep);
}
final SegmentComputation segm = getP2PSegmentComputation(p2pBuilder, objects, errors, rpObj);
if (segm != null) {
rBuilder.setSegmentComputation(segm);
}
} else {
// p2mp
final SegmentComputation segm = getP2MPSegmentComputation(objects, errors, rpObj);
if (segm != null) {
rBuilder.setSegmentComputation(segm);
}
}
requests.add(rBuilder.build());
}
return requests;
}
Aggregations