Search in sources :

Example 26 with PceId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PceId in project bgpcep by opendaylight.

the class PCEPXROSubobjectParserTest method testXROPathKey32Subobject.

@Test
public void testXROPathKey32Subobject() throws PCEPDeserializerException {
    final XROPathKey32SubobjectParser parser = new XROPathKey32SubobjectParser();
    final SubobjectBuilder subs = new SubobjectBuilder();
    subs.setMandatory(true);
    final PathKeyBuilder pBuilder = new PathKeyBuilder();
    pBuilder.setPceId(new PceId(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x50, (byte) 0x00 }));
    pBuilder.setPathKey(new PathKey(4660));
    subs.setSubobjectType(new PathKeyCaseBuilder().setPathKey(pBuilder.build()).build());
    assertEquals(subs.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(pathKey32Bytes, 2)), true));
    final ByteBuf buff = Unpooled.buffer();
    parser.serializeSubobject(subs.build(), buff);
    assertArrayEquals(pathKey32Bytes, ByteArray.getAllBytes(buff));
    try {
        parser.parseSubobject(null, true);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
    try {
        parser.parseSubobject(Unpooled.EMPTY_BUFFER, true);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
}
Also used : PathKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PathKey) PathKeyCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.PathKeyCaseBuilder) XROPathKey32SubobjectParser(org.opendaylight.protocol.pcep.parser.subobject.XROPathKey32SubobjectParser) PceId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PceId) PathKeyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.path.key._case.PathKeyBuilder) ByteBuf(io.netty.buffer.ByteBuf) SubobjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.xro.SubobjectBuilder) Test(org.junit.Test)

Example 27 with PceId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PceId in project bgpcep by opendaylight.

the class Util method validateMonitoringMetrics.

public static MetricPce validateMonitoringMetrics(final List<Object> objects) throws PCEPDeserializerException {
    final MetricPceBuilder metricPceBuilder = new MetricPceBuilder();
    if (!(objects.get(0) instanceof PceId)) {
        throw new PCEPDeserializerException("metric-pce-list must start with PCE-ID object.");
    }
    metricPceBuilder.setPceId((PceId) (objects.get(0)));
    objects.remove(0);
    State state = State.START;
    while (!objects.isEmpty() && !state.equals(State.END)) {
        final Object obj = objects.get(0);
        state = insertObject(metricPceBuilder, state, obj);
        if (!state.equals(State.END)) {
            objects.remove(0);
        }
    }
    return metricPceBuilder.build();
}
Also used : PceId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pce.id.object.PceId) Object(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object) MetricPceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.metrics.MetricPceBuilder) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)

Example 28 with PceId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PceId in project bgpcep by opendaylight.

the class PCEPReplyMessageParser method handleEro.

private Result handleEro(final Ero ero, final List<Object> objects) {
    objects.remove(0);
    final SuccessBuilder builder = new SuccessBuilder();
    final List<Paths> paths = new ArrayList<>();
    final PathsBuilder pBuilder = new PathsBuilder();
    pBuilder.setEro(ero);
    while (!objects.isEmpty() && !(objects.get(0) instanceof PceId)) {
        final List<VendorInformationObject> vendorInfoObjects = addVendorInformationObjects(objects);
        if (!vendorInfoObjects.isEmpty()) {
            builder.setVendorInformationObject(vendorInfoObjects);
        }
        this.parsePath(pBuilder, objects);
        paths.add(pBuilder.build());
    }
    builder.setPaths(paths);
    return new SuccessCaseBuilder().setSuccess(builder.build()).build();
}
Also used : SuccessBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.success._case.SuccessBuilder) SuccessCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.SuccessCaseBuilder) ArrayList(java.util.ArrayList) PceId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pce.id.object.PceId) VendorInformationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.objects.VendorInformationObject) Paths(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.success._case.success.Paths) PathsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.success._case.success.PathsBuilder)

Example 29 with PceId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PceId in project bgpcep by opendaylight.

the class PCEPReplyMessageParser method handleNoPath.

private Result handleNoPath(final NoPath noPath, final List<Object> objects) {
    objects.remove(0);
    final FailureCaseBuilder builder = new FailureCaseBuilder();
    builder.setNoPath(noPath);
    while (!objects.isEmpty() && !(objects.get(0) instanceof PceId)) {
        this.parseAttributes(builder, objects);
    }
    return builder.build();
}
Also used : FailureCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.FailureCaseBuilder) PceId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pce.id.object.PceId)

Example 30 with PceId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PceId 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)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)22 PceId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PceId)22 PathKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PathKey)21 Test (org.junit.Test)14 PathKeyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.path.key._case.PathKeyBuilder)13 PathKeyCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.PathKeyCaseBuilder)11 PathKeyCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.PathKeyCaseBuilder)8 PathKeyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.path.key._case.PathKeyBuilder)8 PceId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pce.id.object.PceId)6 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)5 SubobjectBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.xro.SubobjectBuilder)4 SubobjectContainerBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.list.SubobjectContainerBuilder)4 PathKeyCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.PathKeyCase)4 ArrayList (java.util.ArrayList)3 SubobjectBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.SubobjectBuilder)3 SubobjectBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.rro.SubobjectBuilder)3 PathKeyCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.PathKeyCase)3 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)2 EROPathKey32SubobjectParser (org.opendaylight.protocol.rsvp.parser.impl.subobject.ero.EROPathKey32SubobjectParser)2 XROPathKey32SubobjectParser (org.opendaylight.protocol.rsvp.parser.impl.subobject.xro.XROPathKey32SubobjectParser)2