Search in sources :

Example 1 with PathSetupType

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.setup.type.tlv.PathSetupType in project bgpcep by opendaylight.

the class SrTlvParserTest method testPathSetupTypeTlvParser.

@Test
public void testPathSetupTypeTlvParser() throws PCEPDeserializerException {
    final SrPathSetupTypeTlvParser parser = new SrPathSetupTypeTlvParser();
    final PathSetupType pstTlv = new PathSetupTypeBuilder().setPst((short) 1).build();
    assertEquals(pstTlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(SR_TE_PST_BYTES, 4))));
    final ByteBuf buff = Unpooled.buffer();
    parser.serializeTlv(pstTlv, buff);
    assertArrayEquals(SR_TE_PST_BYTES, ByteArray.getAllBytes(buff));
}
Also used : PathSetupTypeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.setup.type.tlv.PathSetupTypeBuilder) PathSetupType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.setup.type.tlv.PathSetupType) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 2 with PathSetupType

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.setup.type.tlv.PathSetupType in project bgpcep by opendaylight.

the class PCEPTlvParserTest method testUnsupportedPSTSerializer.

@Test(expected = IllegalArgumentException.class)
public void testUnsupportedPSTSerializer() {
    final PathSetupTypeTlvParser parser = new PathSetupTypeTlvParser();
    final PathSetupType pstTlv = new PathSetupTypeBuilder().setPst((short) 1).build();
    final ByteBuf buff = Unpooled.buffer();
    parser.serializeTlv(pstTlv, buff);
}
Also used : PathSetupTypeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.setup.type.tlv.PathSetupTypeBuilder) PathSetupType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.setup.type.tlv.PathSetupType) ByteBuf(io.netty.buffer.ByteBuf) PathSetupTypeTlvParser(org.opendaylight.protocol.pcep.parser.tlv.PathSetupTypeTlvParser) Test(org.junit.Test)

Example 3 with PathSetupType

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.setup.type.tlv.PathSetupType in project bgpcep by opendaylight.

the class PCEPTlvParserTest method testPathSetupTypeTlvParser.

@Test
public void testPathSetupTypeTlvParser() throws PCEPDeserializerException {
    final PathSetupTypeTlvParser parser = new PathSetupTypeTlvParser();
    final PathSetupType pstTlv = new PathSetupTypeBuilder().setPst((short) 0).build();
    assertEquals(pstTlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(PST_TLV_BYTES, 4))));
    final ByteBuf buff = Unpooled.buffer();
    parser.serializeTlv(pstTlv, buff);
    assertArrayEquals(PST_TLV_BYTES, ByteArray.getAllBytes(buff));
}
Also used : PathSetupTypeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.setup.type.tlv.PathSetupTypeBuilder) PathSetupType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.setup.type.tlv.PathSetupType) ByteBuf(io.netty.buffer.ByteBuf) PathSetupTypeTlvParser(org.opendaylight.protocol.pcep.parser.tlv.PathSetupTypeTlvParser) Test(org.junit.Test)

Example 4 with PathSetupType

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.setup.type.tlv.PathSetupType in project bgpcep by opendaylight.

the class PathSetupTypeTlvParser method serializeTlv.

@Override
public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
    Preconditions.checkArgument(tlv instanceof PathSetupType, "PathSetupType is mandatory.");
    final PathSetupType pstTlv = (PathSetupType) tlv;
    Preconditions.checkArgument(checkPST(pstTlv.getPst()), UNSUPPORTED_PST);
    final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
    body.writeZero(OFFSET);
    writeUnsignedByte(pstTlv.getPst(), body);
    TlvUtil.formatTlv(TYPE, body, buffer);
}
Also used : PathSetupType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.setup.type.tlv.PathSetupType) ByteBuf(io.netty.buffer.ByteBuf)

Example 5 with PathSetupType

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.setup.type.tlv.PathSetupType in project bgpcep by opendaylight.

the class Stateful07TopologySessionListener method buildRequest.

private Requests buildRequest(final Optional<ReportedLsp> rep, final Lsp reportedLsp) {
    // Build the request and send it
    final RequestsBuilder rb = new RequestsBuilder();
    final SrpBuilder srpBuilder = new SrpBuilder().addAugmentation(Srp1.class, new Srp1Builder().setRemove(Boolean.TRUE).build()).setOperationId(nextRequest()).setProcessingRule(Boolean.TRUE);
    final Optional<PathSetupType> maybePST = getPST(rep);
    if (maybePST.isPresent()) {
        srpBuilder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.srp.object.srp.TlvsBuilder().setPathSetupType(maybePST.get()).build());
    }
    rb.setSrp(srpBuilder.build());
    rb.setLsp(new LspBuilder().setRemove(Boolean.FALSE).setPlspId(reportedLsp.getPlspId()).setDelegate(reportedLsp.isDelegate()).build());
    return rb.build();
}
Also used : SrpBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.srp.object.SrpBuilder) Preconditions(com.google.common.base.Preconditions) Collections(java.util.Collections) PathSetupType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.setup.type.tlv.PathSetupType) ReportedLspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.ReportedLspBuilder) LspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.LspBuilder) 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)

Aggregations

PathSetupType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.setup.type.tlv.PathSetupType)6 ByteBuf (io.netty.buffer.ByteBuf)4 Test (org.junit.Test)3 PathSetupTypeBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.setup.type.tlv.PathSetupTypeBuilder)3 Preconditions (com.google.common.base.Preconditions)2 Collections (java.util.Collections)2 PathSetupTypeTlvParser (org.opendaylight.protocol.pcep.parser.tlv.PathSetupTypeTlvParser)2 Srp1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Srp1Builder)1 RequestsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.RequestsBuilder)1 Path1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Path1Builder)1 StatefulTlv1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.StatefulTlv1)1 LspBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.LspBuilder)1 PathBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.pcupd.message.updates.PathBuilder)1 SrpBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.srp.object.SrpBuilder)1 LspId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.LspId)1 ReportedLspBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.ReportedLspBuilder)1