Search in sources :

Example 16 with 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 createUpdateMessageSync.

private SrpIdNumber createUpdateMessageSync(final PcupdMessageBuilder pcupdMessageBuilder) {
    final UpdatesBuilder updBuilder = new UpdatesBuilder();
    // LSP mandatory in Upd
    final Lsp lsp = new LspBuilder().setPlspId(PLSPID_ZERO).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();
}
Also used : Srp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.srp.object.Srp) PathBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.updates.PathBuilder) SrpBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.srp.object.SrpBuilder) Lsp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.Lsp) ReportedLsp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.ReportedLsp) ReportedLspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.ReportedLspBuilder) LspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.LspBuilder) EroBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.EroBuilder) UpdatesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.UpdatesBuilder)

Example 17 with 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 PCEPTriggeredReSynchronizationProcedureTest method getSyncMsg.

private static Pcrpt getSyncMsg() {
    final SrpBuilder srpBuilder = new SrpBuilder();
    // not sue whether use 0 instead of nextRequest() or do not insert srp == SRP-ID-number = 0
    srpBuilder.setOperationId(new SrpIdNumber(Uint32.ONE));
    return MsgBuilderUtil.createPcRtpMessage(createLsp(Uint32.ZERO, false, Optional.of(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.lsp.TlvsBuilder().addAugmentation(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev200720.Tlvs1Builder().setLspDbVersion(new LspDbVersionBuilder().setLspDbVersionValue(Uint64.valueOf(3L)).build()).build()).build()), true, false), Optional.of(srpBuilder.build()), createPath(Collections.emptyList()));
}
Also used : SrpBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.srp.object.SrpBuilder) Collections(java.util.Collections) LspDbVersionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev200720.lsp.db.version.tlv.LspDbVersionBuilder) SrpIdNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.SrpIdNumber)

Example 18 with 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 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;
}
Also used : Srp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.srp.object.Srp) Tlvs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.srp.object.srp.Tlvs) ReportsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.ReportsBuilder) Object(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object)

Example 19 with 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 Stateful07SrpObjectParser method parseObject.

@Override
public Srp parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
    Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
    if (bytes.readableBytes() < MIN_SIZE) {
        throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + bytes.readableBytes() + "; Expected: >=" + MIN_SIZE + ".");
    }
    final SrpBuilder builder = new SrpBuilder();
    builder.setIgnore(header.isIgnore());
    builder.setProcessingRule(header.isProcessingRule());
    parseFlags(builder, bytes);
    builder.setOperationId(new SrpIdNumber(bytes.readUnsignedInt()));
    final TlvsBuilder tlvsBuilder = new TlvsBuilder();
    parseTlvs(tlvsBuilder, bytes.slice());
    builder.setTlvs(tlvsBuilder.build());
    return builder.build();
}
Also used : SrpBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.srp.object.SrpBuilder) TlvsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.srp.object.srp.TlvsBuilder) SrpIdNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.SrpIdNumber) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)

Example 20 with 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 Stateful07ErrorMessageParser method validate.

@Override
protected PcerrMessage 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("Error message is empty.");
    }
    final List<Rps> requestParameters = new ArrayList<>();
    final List<Srps> srps = new ArrayList<>();
    final List<Errors> errorObjects = new ArrayList<>();
    final PcerrMessageBuilder b = new PcerrMessageBuilder();
    Object obj = objects.get(0);
    State state = State.INIT;
    if (obj instanceof ErrorObject) {
        final ErrorObject o = (ErrorObject) obj;
        errorObjects.add(new ErrorsBuilder().setErrorObject(o).build());
        state = State.ERROR_IN;
    } else if (obj instanceof Rp) {
        final Rp o = (Rp) obj;
        if (o.isProcessingRule()) {
            errors.add(createErrorMsg(PCEPErrors.P_FLAG_NOT_SET, Optional.absent()));
            return null;
        }
        requestParameters.add(new RpsBuilder().setRp(o).build());
        state = State.RP_IN;
    } else if (obj instanceof Srp) {
        final Srp s = (Srp) obj;
        srps.add(new SrpsBuilder().setSrp(s).build());
        state = State.SRP_IN;
    }
    if (!state.equals(State.INIT)) {
        objects.remove(0);
    }
    while (!objects.isEmpty() && !state.equals(State.END)) {
        obj = objects.get(0);
        if (obj instanceof UnknownObject) {
            return new PcerrBuilder().setPcerrMessage(b.setErrors(((UnknownObject) obj).getErrors()).build()).build();
        }
        state = insertObject(state, obj, errorObjects, requestParameters, srps, b);
        if (!state.equals(State.END)) {
            objects.remove(0);
        }
    }
    if (errorObjects.isEmpty()) {
        throw new PCEPDeserializerException("At least one PCEPErrorObject is mandatory.");
    }
    if (!objects.isEmpty()) {
        throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
    }
    if (!requestParameters.isEmpty()) {
        b.setErrorType(new RequestCaseBuilder().setRequest(new RequestBuilder().setRps(requestParameters).build()).build());
    }
    if (!srps.isEmpty()) {
        b.setErrorType(new StatefulCaseBuilder().setStateful(new StatefulBuilder().setSrps(srps).build()).build());
    }
    return new PcerrBuilder().setPcerrMessage(b.setErrors(errorObjects).build()).build();
}
Also used : PcerrBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcerrBuilder) RequestBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.error.type.request._case.RequestBuilder) Srps(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcerr.pcerr.message.error.type.stateful._case.stateful.Srps) ErrorObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcep.error.object.ErrorObject) ArrayList(java.util.ArrayList) ErrorsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.ErrorsBuilder) StatefulBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcerr.pcerr.message.error.type.stateful._case.StatefulBuilder) UnknownObject(org.opendaylight.protocol.pcep.spi.UnknownObject) StatefulCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcerr.pcerr.message.error.type.StatefulCaseBuilder) Srp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.srp.object.Srp) PCEPErrors(org.opendaylight.protocol.pcep.spi.PCEPErrors) Errors(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.Errors) Rps(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.error.type.request._case.request.Rps) SrpsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcerr.pcerr.message.error.type.stateful._case.stateful.SrpsBuilder) RequestCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.error.type.RequestCaseBuilder) ErrorObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcep.error.object.ErrorObject) UnknownObject(org.opendaylight.protocol.pcep.spi.UnknownObject) Object(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object) RpsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.error.type.request._case.request.RpsBuilder) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException) PcerrMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.PcerrMessageBuilder) Rp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.Rp)

Aggregations

Srp (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.srp.object.Srp)13 SrpBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.srp.object.SrpBuilder)8 Srp (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.srp.object.Srp)7 SrpIdNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.SrpIdNumber)7 ArrayList (java.util.ArrayList)6 Lsp (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.Lsp)6 PlspId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.PlspId)5 UpdatesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.UpdatesBuilder)5 PathBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.updates.PathBuilder)5 ByteBuf (io.netty.buffer.ByteBuf)4 MsgBuilderUtil.createLspTlvs (org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil.createLspTlvs)4 MsgBuilderUtil.createSrp (org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil.createSrp)4 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)4 SrpIdNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.SrpIdNumber)4 ErrorsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.ErrorsBuilder)4 Collections (java.util.Collections)3 MsgBuilderUtil.createLsp (org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil.createLsp)3 LspBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.LspBuilder)3 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object)3 Test (org.junit.Test)2