Search in sources :

Example 1 with MonitoringRequest

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.MonitoringRequest in project bgpcep by opendaylight.

the class PCEPMonitoringRequestMessageParser 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("Pcmonreq message cannot be empty.");
    }
    final MonitoringRequest monReq = getMonitoring(objects);
    if (monReq == null) {
        errors.add(createErrorMsg(PCEPErrors.MONITORING_OBJECT_MISSING, Optional.absent()));
    }
    final PcreqMessageBuilder mBuilder = new PcreqMessageBuilder();
    mBuilder.setMonitoringRequest(monReq);
    final List<Svec> svecs = getSvecs(objects);
    if (!svecs.isEmpty()) {
        mBuilder.setSvec(svecs);
    }
    final List<Requests> requests = getRequests(objects, errors);
    if (requests != null && !requests.isEmpty()) {
        mBuilder.setRequests(requests);
    }
    if (!objects.isEmpty()) {
        throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
    }
    return new PcmonreqBuilder().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) PcmonreqBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcmonreqBuilder) PcreqMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.PcreqMessageBuilder) MonitoringRequest(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.MonitoringRequest) 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 2 with MonitoringRequest

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.MonitoringRequest in project bgpcep by opendaylight.

the class PCEPRequestMessageParser method getMonitoring.

protected MonitoringRequest getMonitoring(final List<Object> objects) {
    final MonitoringRequestBuilder builder = new MonitoringRequestBuilder();
    if (!objects.isEmpty() && objects.get(0) instanceof Monitoring) {
        builder.setMonitoring((Monitoring) objects.get(0));
        objects.remove(0);
    } else {
        return null;
    }
    if (!objects.isEmpty() && objects.get(0) instanceof PccIdReq) {
        builder.setPccIdReq((PccIdReq) objects.get(0));
        objects.remove(0);
    }
    final List<PceIdList> pceIdList = new ArrayList<>();
    while (!objects.isEmpty() && objects.get(0) instanceof PceId) {
        pceIdList.add(new PceIdListBuilder().setPceId((PceId) objects.get(0)).build());
        objects.remove(0);
    }
    if (!pceIdList.isEmpty()) {
        builder.setPceIdList(pceIdList);
    }
    return builder.build();
}
Also used : MonitoringRequestBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.MonitoringRequestBuilder) PceIdList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.monitoring.request.PceIdList) ArrayList(java.util.ArrayList) PceId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pce.id.object.PceId) PceIdListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.monitoring.request.PceIdListBuilder) PccIdReq(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcc.id.req.object.PccIdReq) Monitoring(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.object.Monitoring)

Example 3 with MonitoringRequest

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.MonitoringRequest in project bgpcep by opendaylight.

the class PCEPRequestMessageParser method serializeMonitoringRequest.

protected void serializeMonitoringRequest(final MonitoringRequest monReq, final ByteBuf out) {
    serializeObject(monReq.getMonitoring(), out);
    serializeObject(monReq.getPccIdReq(), out);
    if (monReq.getPceIdList() != null) {
        for (final PceIdList pceId : monReq.getPceIdList()) {
            serializeObject(pceId.getPceId(), out);
        }
    }
}
Also used : PceIdList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.monitoring.request.PceIdList)

Aggregations

PceIdList (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.monitoring.request.PceIdList)2 ArrayList (java.util.ArrayList)1 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)1 PcmonreqBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcmonreqBuilder)1 Monitoring (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.object.Monitoring)1 PccIdReq (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcc.id.req.object.PccIdReq)1 PceId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pce.id.object.PceId)1 PcreqMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.PcreqMessageBuilder)1 MonitoringRequest (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.MonitoringRequest)1 MonitoringRequestBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.MonitoringRequestBuilder)1 Requests (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.Requests)1 Svec (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.Svec)1 PceIdListBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.monitoring.request.PceIdListBuilder)1