Search in sources :

Example 1 with Tlvs2Builder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Tlvs2Builder in project bgpcep by opendaylight.

the class PCEPObjectParserTest method testLspaObject.

@Test
public void testLspaObject() throws IOException, PCEPDeserializerException {
    final Stateful07LspaObjectParser parser = new Stateful07LspaObjectParser(this.tlvRegistry, this.viTlvRegistry);
    final LspaBuilder builder = new LspaBuilder();
    final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPLspaObject3RandVals.bin"));
    final SymbolicPathName tlv = new SymbolicPathNameBuilder().setPathName(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.SymbolicPathName(new byte[] { (byte) 0x4d, (byte) 0x65, (byte) 0x64, (byte) 0x20, (byte) 0x74, (byte) 0x65, (byte) 0x73, (byte) 0x74, (byte) 0x20, (byte) 0x6f, (byte) 0x66, (byte) 0x20, (byte) 0x73, (byte) 0x79, (byte) 0x6d, (byte) 0x62, (byte) 0x6f, (byte) 0x6c, (byte) 0x69, (byte) 0x63, (byte) 0x20, (byte) 0x6e, (byte) 0x61, (byte) 0x6d, (byte) 0x65 })).build();
    builder.setIgnore(false);
    builder.setProcessingRule(false);
    builder.setExcludeAny(new AttributeFilter(0x20A1FEE3L));
    builder.setIncludeAny(new AttributeFilter(0x1A025CC7L));
    builder.setIncludeAll(new AttributeFilter(0x2BB66532L));
    builder.setHoldPriority((short) 0x02);
    builder.setSetupPriority((short) 0x03);
    builder.setLocalProtectionDesired(true);
    builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lspa.object.lspa.TlvsBuilder().addAugmentation(Tlvs2.class, new Tlvs2Builder().setSymbolicPathName(tlv).build()).build());
    // Tlvs container does not contain toString
    final Object o = parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4));
    assertEquals(tlv, ((Lspa) o).getTlvs().getAugmentation(Tlvs2.class).getSymbolicPathName());
    // assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), ByteArray.cutBytes(result,
    // 4)));
    final ByteBuf buf = Unpooled.buffer();
    parser.serializeObject(builder.build(), buf);
    assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
}
Also used : LspaBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lspa.object.LspaBuilder) ObjectHeaderImpl(org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl) SymbolicPathNameBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.symbolic.path.name.tlv.SymbolicPathNameBuilder) Tlvs2Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Tlvs2Builder) ByteBuf(io.netty.buffer.ByteBuf) Stateful07LspaObjectParser(org.opendaylight.protocol.pcep.ietf.stateful07.Stateful07LspaObjectParser) AttributeFilter(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.AttributeFilter) SymbolicPathName(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.symbolic.path.name.tlv.SymbolicPathName) Test(org.junit.Test)

Example 2 with Tlvs2Builder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Tlvs2Builder in project bgpcep by opendaylight.

the class Stateful07LspaObjectParser method addTlv.

@Override
public void addTlv(final TlvsBuilder tbuilder, final Tlv tlv) {
    super.addTlv(tbuilder, tlv);
    final Tlvs2Builder nameBuilder = new Tlvs2Builder();
    if (tbuilder.getAugmentation(Tlvs2.class) != null) {
        final Tlvs2 t = tbuilder.getAugmentation(Tlvs2.class);
        if (t.getSymbolicPathName() != null) {
            nameBuilder.setSymbolicPathName(t.getSymbolicPathName());
        }
    }
    if (tlv instanceof SymbolicPathName) {
        nameBuilder.setSymbolicPathName((SymbolicPathName) tlv);
    }
    tbuilder.addAugmentation(Tlvs2.class, nameBuilder.build());
}
Also used : SymbolicPathName(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.symbolic.path.name.tlv.SymbolicPathName) Tlvs2Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Tlvs2Builder) Tlvs2(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Tlvs2)

Aggregations

Tlvs2Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Tlvs2Builder)2 SymbolicPathName (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.symbolic.path.name.tlv.SymbolicPathName)2 ByteBuf (io.netty.buffer.ByteBuf)1 Test (org.junit.Test)1 Stateful07LspaObjectParser (org.opendaylight.protocol.pcep.ietf.stateful07.Stateful07LspaObjectParser)1 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)1 Tlvs2 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Tlvs2)1 SymbolicPathNameBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.symbolic.path.name.tlv.SymbolicPathNameBuilder)1 LspaBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lspa.object.LspaBuilder)1 AttributeFilter (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.AttributeFilter)1