Search in sources :

Example 1 with PceIdList

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.monitoring.request.PceIdList in project bgpcep by opendaylight.

the class PCEPRequestMessageParser method getMonitoring.

protected MonitoringRequest getMonitoring(final Queue<Object> objects) {
    final MonitoringRequestBuilder builder = new MonitoringRequestBuilder();
    Object obj = objects.peek();
    if (obj instanceof Monitoring) {
        builder.setMonitoring((Monitoring) obj);
        objects.remove();
    } else {
        return null;
    }
    obj = objects.peek();
    if (obj instanceof PccIdReq) {
        builder.setPccIdReq((PccIdReq) obj);
        objects.remove();
        obj = objects.peek();
    }
    final List<PceIdList> pceIdList = new ArrayList<>();
    while (obj instanceof PceId) {
        pceIdList.add(new PceIdListBuilder().setPceId((PceId) obj).build());
        objects.remove();
        obj = objects.peek();
    }
    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.rev181109.pcreq.message.pcreq.message.MonitoringRequestBuilder) PceIdList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.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.rev181109.pce.id.object.PceId) PceIdListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.monitoring.request.PceIdListBuilder) PccIdReq(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcc.id.req.object.PccIdReq) VendorInformationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObject) Object(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object) Monitoring(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.object.Monitoring)

Example 2 with PceIdList

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.monitoring.request.PceIdList in project bgpcep by opendaylight.

the class PCEPValidatorTest method testMonReqMsg.

@Test
public void testMonReqMsg() throws PCEPDeserializerException, IOException {
    final PCEPMonitoringRequestMessageParser parser = new PCEPMonitoringRequestMessageParser(this.objectRegistry);
    final PcreqMessageBuilder builder = new PcreqMessageBuilder();
    final MonitoringRequestBuilder monReqBuilder = new MonitoringRequestBuilder().setMonitoring(this.monitoring).setPceIdList(Lists.newArrayList(new PceIdListBuilder().setPceId(this.pceId).build()));
    builder.setMonitoringRequest(monReqBuilder.build());
    final byte[] msgBytes = { 0x20, 0x08, 0x00, 0x18, /* monitoring object */
    0x13, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, /* pce-id object */
    0x19, 0x10, 0x00, 0x08, 0x7f, 0x00, 0x00, 0x02 };
    ByteBuf result = Unpooled.wrappedBuffer(msgBytes);
    assertEquals(new PcmonreqBuilder().setPcreqMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
    ByteBuf buf = Unpooled.buffer(result.readableBytes());
    parser.serializeMessage(new PcmonreqBuilder().setPcreqMessage(builder.build()).build(), buf);
    assertArrayEquals(result.array(), buf.array());
    result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCMonReq.bin"));
    final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.Requests> reqs2 = new ArrayList<>();
    final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.RequestsBuilder rBuilder1 = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.RequestsBuilder();
    rBuilder1.setRp(this.rpTrue);
    final P2pBuilder p2pBuilder = new P2pBuilder().setEndpointsObj(this.endpoints).setMetrics(Lists.newArrayList(this.metrics)).setIro(this.iro);
    rBuilder1.setSegmentComputation(new SegmentComputationBuilder().setP2p(p2pBuilder.build()).build());
    reqs2.add(rBuilder1.build());
    builder.setRequests(reqs2).setSvec(Lists.newArrayList(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.SvecBuilder().setSvec(this.svec).build()));
    monReqBuilder.setMonitoring(this.monitoring).setPccIdReq(this.pccIdReq);
    final PceIdList pceIdList = new PceIdListBuilder().setPceId(this.pceId).build();
    monReqBuilder.setPceIdList(Lists.newArrayList(pceIdList, pceIdList));
    builder.setMonitoringRequest(monReqBuilder.build());
    assertEquals(new PcmonreqBuilder().setPcreqMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
    buf = Unpooled.buffer(result.readableBytes());
    parser.serializeMessage(new PcmonreqBuilder().setPcreqMessage(builder.build()).build(), buf);
    assertArrayEquals(result.array(), buf.array());
}
Also used : Notifications(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf.message.pcntf.message.Notifications) Collections(java.util.Collections) PceIdListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.monitoring.request.PceIdListBuilder) ArrayList(java.util.ArrayList) PCEPMonitoringRequestMessageParser(org.opendaylight.protocol.pcep.parser.message.PCEPMonitoringRequestMessageParser) PcreqMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.PcreqMessageBuilder) ByteBuf(io.netty.buffer.ByteBuf) PceIdList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.monitoring.request.PceIdList) SvecBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.svec.object.SvecBuilder) SegmentComputationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.SegmentComputationBuilder) MonitoringRequestBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.MonitoringRequestBuilder) PcmonreqBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.PcmonreqBuilder) P2pBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.P2pBuilder) Test(org.junit.Test)

Example 3 with PceIdList

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.monitoring.request.PceIdList 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 4 with PceIdList

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.monitoring.request.PceIdList 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);
    for (final PceIdList pceId : monReq.nonnullPceIdList()) {
        serializeObject(pceId.getPceId(), out);
    }
}
Also used : PceIdList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.monitoring.request.PceIdList)

Aggregations

ArrayList (java.util.ArrayList)3 PceIdList (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.monitoring.request.PceIdList)3 MonitoringRequestBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.MonitoringRequestBuilder)2 PceIdListBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.monitoring.request.PceIdListBuilder)2 ByteBuf (io.netty.buffer.ByteBuf)1 Collections (java.util.Collections)1 Test (org.junit.Test)1 PCEPMonitoringRequestMessageParser (org.opendaylight.protocol.pcep.parser.message.PCEPMonitoringRequestMessageParser)1 PcmonreqBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.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 MonitoringRequestBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.MonitoringRequestBuilder)1 PceIdList (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.monitoring.request.PceIdList)1 PceIdListBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.monitoring.request.PceIdListBuilder)1 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object)1 Monitoring (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.object.Monitoring)1 PccIdReq (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcc.id.req.object.PccIdReq)1 PceId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pce.id.object.PceId)1 Notifications (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf.message.pcntf.message.Notifications)1