Search in sources :

Example 1 with ReportsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcrpt.message.pcrpt.message.ReportsBuilder in project bgpcep by opendaylight.

the class Stateful07PCReportMessageParser method validateLsp.

private static boolean validateLsp(final Object object, final boolean lspViaSR, final List<Message> errors, final ReportsBuilder builder) {
    if (object instanceof Lsp) {
        final Lsp lsp = (Lsp) object;
        final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.Tlvs tlvs = lsp.getTlvs();
        if (!lspViaSR && lsp.getPlspId().getValue() != 0 && (tlvs == null || tlvs.getLspIdentifiers() == null)) {
            final Message errorMsg = createErrorMsg(PCEPErrors.LSP_IDENTIFIERS_TLV_MISSING, Optional.absent());
            errors.add(errorMsg);
            return false;
        }
        builder.setLsp(lsp);
        return true;
    }
    errors.add(createErrorMsg(PCEPErrors.LSP_MISSING, Optional.absent()));
    return false;
}
Also used : Message(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message) Preconditions(com.google.common.base.Preconditions) Lsp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.Lsp)

Example 2 with ReportsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcrpt.message.pcrpt.message.ReportsBuilder in project bgpcep by opendaylight.

the class Stateful07PCReportMessageParser method validatePath.

private static boolean validatePath(final List<Object> objects, final List<Message> errors, final ReportsBuilder builder) {
    final PathBuilder pBuilder = new PathBuilder();
    Object object = objects.remove(0);
    if (object instanceof Ero) {
        pBuilder.setEro((Ero) object);
    } else {
        errors.add(createErrorMsg(PCEPErrors.ERO_MISSING, Optional.absent()));
        return false;
    }
    parsePath(objects, pBuilder);
    builder.setPath(pBuilder.build());
    return true;
}
Also used : PathBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.reports.PathBuilder) Ero(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Ero) Object(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object)

Example 3 with ReportsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcrpt.message.pcrpt.message.ReportsBuilder in project bgpcep by opendaylight.

the class MsgBuilderUtil method createPcRtpMessage.

public static Pcrpt createPcRtpMessage(final Lsp lsp, final Optional<Srp> srp, final Path path) {
    final PcrptBuilder rptBuilder = new PcrptBuilder();
    final PcrptMessageBuilder msgBuilder = new PcrptMessageBuilder();
    final ReportsBuilder reportBuilder = new ReportsBuilder();
    reportBuilder.setLsp(lsp);
    reportBuilder.setSrp(srp.orNull());
    reportBuilder.setPath(path);
    msgBuilder.setReports(Lists.newArrayList(reportBuilder.build()));
    rptBuilder.setPcrptMessage(msgBuilder.build());
    return rptBuilder.build();
}
Also used : ReportsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.ReportsBuilder) PcrptBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PcrptBuilder) PcrptMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.PcrptMessageBuilder)

Example 4 with ReportsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcrpt.message.pcrpt.message.ReportsBuilder in project bgpcep by opendaylight.

the class PcRptMessageCodec method getValidReports.

@Override
protected Reports getValidReports(final Queue<Object> objects, final List<Message> errors) {
    final Optional<Object> find = Iterables.tryFind(objects, Predicates.instanceOf(BandwidthUsage.class));
    final Object object;
    if (find.isPresent()) {
        object = find.get();
        objects.remove(object);
    } else {
        object = null;
    }
    final Reports validReports = super.getValidReports(objects, errors);
    if (object != null && validReports != null) {
        final Path path = validReports.getPath();
        if (path != null) {
            return new ReportsBuilder(validReports).setPath(new PathBuilder(path).setBandwidth(setBandwidthUsage(path.getBandwidth(), (BandwidthUsage) object)).build()).build();
        }
    }
    return validReports;
}
Also used : Path(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcrpt.message.pcrpt.message.reports.Path) PathBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcrpt.message.pcrpt.message.reports.PathBuilder) ReportsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcrpt.message.pcrpt.message.ReportsBuilder) BandwidthUsage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.auto.bandwidth.rev181109.bandwidth.usage.object.BandwidthUsage) Reports(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcrpt.message.pcrpt.message.Reports) Object(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object)

Example 5 with ReportsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcrpt.message.pcrpt.message.ReportsBuilder in project bgpcep by opendaylight.

the class StatefulPCReportMessageParser method validateLsp.

private static boolean validateLsp(final Object object, final boolean lspViaSR, final List<Message> errors, final ReportsBuilder builder) {
    if (object instanceof Lsp) {
        final Lsp lsp = (Lsp) object;
        final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.lsp.Tlvs tlvs = lsp.getTlvs();
        if (!lspViaSR && lsp.getPlspId().getValue().toJava() != 0 && (tlvs == null || tlvs.getLspIdentifiers() == null)) {
            final Message errorMsg = createErrorMsg(PCEPErrors.LSP_IDENTIFIERS_TLV_MISSING, Optional.empty());
            errors.add(errorMsg);
            return false;
        }
        builder.setLsp(lsp);
        return true;
    }
    errors.add(createErrorMsg(PCEPErrors.LSP_MISSING, Optional.empty()));
    return false;
}
Also used : Message(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message) Lsp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.Lsp)

Aggregations

ReportsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.ReportsBuilder)4 ReportsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcrpt.message.pcrpt.message.ReportsBuilder)4 Test (org.junit.Test)3 PathBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.reports.PathBuilder)3 Reports (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcrpt.message.pcrpt.message.Reports)3 PathBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcrpt.message.pcrpt.message.reports.PathBuilder)3 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object)3 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object)3 PcrptBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PcrptBuilder)2 PcrptMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.PcrptMessageBuilder)2 Reports (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.Reports)2 PcrptBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.PcrptBuilder)2 PcrptMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcrpt.message.PcrptMessageBuilder)2 Message (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message)2 LspId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId)2 Preconditions (com.google.common.base.Preconditions)1 ByteBuf (io.netty.buffer.ByteBuf)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 InitiatedActivator (org.opendaylight.protocol.pcep.ietf.initiated.InitiatedActivator)1