Search in sources :

Example 1 with Requests

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.Requests in project bgpcep by opendaylight.

the class PCEPRequestMessageParser method serializeRequest.

protected void serializeRequest(final PcreqMessage msg, final ByteBuf buffer) {
    for (final Requests req : msg.getRequests()) {
        serializeObject(req.getRp(), buffer);
        serializeVendorInformationObjects(req.getVendorInformationObject(), buffer);
        if (req.getPathKeyExpansion() != null) {
            serializeObject(req.getPathKeyExpansion().getPathKey(), buffer);
        }
        if (req.getSegmentComputation() != null) {
            final SegmentComputation sc = req.getSegmentComputation();
            if (sc.getP2p() != null) {
                serializeP2P(buffer, sc.getP2p());
            }
        }
    }
}
Also used : Requests(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.Requests) SegmentComputation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.requests.SegmentComputation)

Example 2 with Requests

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.Requests in project bgpcep by opendaylight.

the class PCEPRequestMessageParser method getRequests.

protected List<Requests> getRequests(final List<Object> objects, final List<Message> errors) {
    final List<Requests> requests = new ArrayList<>();
    while (!objects.isEmpty()) {
        final RequestsBuilder rBuilder = new RequestsBuilder();
        Rp rpObj = null;
        if (!(objects.get(0) instanceof Rp)) {
            // if RP obj is missing return error only
            errors.add(createErrorMsg(PCEPErrors.RP_MISSING, Optional.absent()));
            return null;
        }
        rpObj = (Rp) objects.get(0);
        objects.remove(0);
        if (!rpObj.isProcessingRule()) {
            errors.add(createErrorMsg(PCEPErrors.P_FLAG_NOT_SET, Optional.absent()));
        } else {
            rBuilder.setRp(rpObj);
        }
        final List<VendorInformationObject> vendorInfo = addVendorInformationObjects(objects);
        if (!vendorInfo.isEmpty()) {
            rBuilder.setVendorInformationObject(vendorInfo);
        }
        // expansion
        if (rpObj.isPathKey() && objects.get(0) instanceof PathKey) {
            rBuilder.setPathKeyExpansion(new PathKeyExpansionBuilder().setPathKey((PathKey) objects.get(0)).build());
        }
        final P2pBuilder p2pBuilder = new P2pBuilder();
        if (!objects.isEmpty() && objects.get(0) instanceof EndpointsObj) {
            final EndpointsObj ep = (EndpointsObj) objects.get(0);
            objects.remove(0);
            if (!ep.isProcessingRule()) {
                errors.add(createErrorMsg(PCEPErrors.P_FLAG_NOT_SET, Optional.of(rpObj)));
            } else {
                p2pBuilder.setEndpointsObj(ep);
            }
        } else {
            errors.add(createErrorMsg(PCEPErrors.END_POINTS_MISSING, Optional.of(rpObj)));
            return null;
        }
        // p2p
        if (!rpObj.isP2mp()) {
            final SegmentComputation segm = getSegmentComputation(p2pBuilder, objects, errors, rpObj);
            if (segm != null) {
                rBuilder.setSegmentComputation(segm);
            }
        }
        requests.add(rBuilder.build());
    }
    return requests;
}
Also used : PathKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.key.object.PathKey) ArrayList(java.util.ArrayList) VendorInformationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.objects.VendorInformationObject) PathKeyExpansionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.requests.PathKeyExpansionBuilder) RequestsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.RequestsBuilder) P2pBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.requests.segment.computation.P2pBuilder) EndpointsObj(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.object.EndpointsObj) Requests(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.Requests) Rp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.Rp) SegmentComputation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.requests.SegmentComputation)

Example 3 with Requests

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.Requests in project bgpcep by opendaylight.

the class PCEPRequestMessageParser method validate.

@Override
protected Message 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("Pcrep message cannot be empty.");
    }
    final PcreqMessageBuilder mBuilder = new PcreqMessageBuilder();
    mBuilder.setMonitoringRequest(getMonitoring(objects));
    final List<Svec> svecs = getSvecs(objects);
    if (!svecs.isEmpty()) {
        mBuilder.setSvec(svecs);
    }
    final List<Requests> requests = getRequests(objects, errors);
    if (requests != null) {
        mBuilder.setRequests(requests);
    } else {
        errors.add(createErrorMsg(PCEPErrors.RP_MISSING, Optional.absent()));
    }
    if (!objects.isEmpty()) {
        throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
    }
    return new PcreqBuilder().setPcreqMessage(mBuilder.build()).build();
}
Also used : Svec(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.Svec) PcreqBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcreqBuilder) PcreqMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.PcreqMessageBuilder) Requests(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.Requests) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)

Example 4 with Requests

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.Requests in project bgpcep by opendaylight.

the class PCCTunnelManagerImplTest method createRequests.

private static Requests createRequests(final long plspId, final Optional<Boolean> remove, final Optional<Boolean> delegate) {
    final RequestsBuilder reqBuilder = new RequestsBuilder();
    reqBuilder.setEro(ERO);
    final LspBuilder lsp = new LspBuilder().setTlvs(new TlvsBuilder().setSymbolicPathName(new SymbolicPathNameBuilder().setPathName(new SymbolicPathName(SYMBOLIC_NAME)).build()).build()).setPlspId(new PlspId(plspId));
    if (delegate.isPresent()) {
        lsp.setDelegate(Boolean.TRUE);
    }
    reqBuilder.setLsp(lsp.build());
    final SrpBuilder srpBuilder = new SrpBuilder();
    if (remove.isPresent()) {
        srpBuilder.addAugmentation(Srp1.class, new Srp1Builder().setRemove(Boolean.TRUE).build());
    }
    reqBuilder.setSrp(srpBuilder.setOperationId(new SrpIdNumber(0L)).build());
    return reqBuilder.build();
}
Also used : TlvsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.TlvsBuilder) SrpBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.srp.object.SrpBuilder) SymbolicPathNameBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.symbolic.path.name.tlv.SymbolicPathNameBuilder) SrpIdNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.SrpIdNumber) LspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.LspBuilder) SymbolicPathName(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.SymbolicPathName) RequestsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.RequestsBuilder) Srp1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Srp1Builder) PlspId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PlspId)

Example 5 with Requests

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.Requests in project bgpcep by opendaylight.

the class PCCTunnelManagerImpl method takeDelegation.

protected void takeDelegation(final Requests request, final PCCSession session) {
    final PlspId plspId = request.getLsp().getPlspId();
    final PCCTunnel tunnel = this.tunnels.get(plspId);
    final long srpId = request.getSrp().getOperationId().getValue();
    if (tunnel != null) {
        // check if tunnel has no delegation
        if ((tunnel.getType() == LspType.PCE_LSP) && ((tunnel.getDelegationHolder() == -1) || (tunnel.getDelegationHolder() == session.getId()))) {
            // set delegation
            tunnel.cancelTimeouts();
            setDelegation(plspId, session);
            // send report
            final Tlvs tlvs = buildTlvs(tunnel, plspId.getValue(), Optional.absent());
            session.sendReport(createPcRtpMessage(new LspBuilder(request.getLsp()).setSync(true).setOperational(OperationalStatus.Up).setDelegate(true).setTlvs(tlvs).build(), Optional.of(createSrp(srpId)), tunnel.getLspState()));
        } else {
            session.sendError(MsgBuilderUtil.createErrorMsg(PCEPErrors.LSP_NOT_PCE_INITIATED, srpId));
        }
    } else {
        session.sendError(MsgBuilderUtil.createErrorMsg(PCEPErrors.UNKNOWN_PLSP_ID, srpId));
    }
}
Also used : Tlvs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.Tlvs) MsgBuilderUtil.createLspTlvs(org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil.createLspTlvs) LspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.LspBuilder) PlspId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PlspId)

Aggregations

Requests (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.Requests)13 LspBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.LspBuilder)12 Test (org.junit.Test)9 PlspId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PlspId)9 MsgBuilderUtil.createLspTlvs (org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil.createLspTlvs)8 Pcinitiate (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Pcinitiate)8 Tlvs (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.Tlvs)8 Pcrpt (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Pcrpt)7 RequestsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.RequestsBuilder)6 PcinitiateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.PcinitiateBuilder)5 PcinitiateMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.PcinitiateMessageBuilder)5 ByteBuf (io.netty.buffer.ByteBuf)4 Srp1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Srp1Builder)4 SrpBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.srp.object.SrpBuilder)4 ArrayList (java.util.ArrayList)3 Collections (java.util.Collections)3 PcreqMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.PcreqMessageBuilder)3 Requests (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.Requests)3 UnknownHostException (java.net.UnknownHostException)2 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)2