Search in sources :

Example 1 with Stateful

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

the class PcepStateUtils method showMessages.

private static void showMessages(final ShellTable table, final Messages messages) {
    if (messages == null) {
        return;
    }
    addHeader(table, "Messages");
    table.addRow().addContent("Last Sent Msg Timestamp", messages.getLastSentMsgTimestamp());
    table.addRow().addContent("Received Msg Count", messages.getReceivedMsgCount());
    table.addRow().addContent("Sent Msg Count", messages.getSentMsgCount());
    table.addRow().addContent("Unknown Msg Received", messages.getUnknownMsgReceived());
    final StatefulMessagesStatsAug statefulMessages = messages.getAugmentation(StatefulMessagesStatsAug.class);
    if (statefulMessages == null) {
        return;
    }
    addHeader(table, " Stateful Messages");
    table.addRow().addContent("Last Received RptMsg Timestamp", statefulMessages.getLastReceivedRptMsgTimestamp());
    table.addRow().addContent("Received RptMsg", statefulMessages.getReceivedRptMsgCount());
    table.addRow().addContent("Sent Init Msg", statefulMessages.getSentInitMsgCount());
    table.addRow().addContent("Sent Upd Msg", statefulMessages.getSentUpdMsgCount());
}
Also used : StatefulMessagesStatsAug(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stateful.stats.rev171113.StatefulMessagesStatsAug)

Example 2 with Stateful

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

the class PCEPObjectParserTest method testOpenObjectWithTLV.

@Test
public void testOpenObjectWithTLV() throws PCEPDeserializerException, IOException {
    try (SyncOptimizationsActivator a = new SyncOptimizationsActivator()) {
        a.start(this.ctx);
        final SyncOptimizationsOpenObjectParser parser = new SyncOptimizationsOpenObjectParser(this.ctx.getTlvHandlerRegistry(), this.ctx.getVendorInformationTlvRegistry());
        final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPOpenObject1.bin"));
        final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder builder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder();
        builder.setProcessingRule(false);
        builder.setIgnore(false);
        builder.setVersion(new ProtocolVersion((short) 1));
        builder.setKeepalive((short) 30);
        builder.setDeadTimer((short) 120);
        builder.setSessionId((short) 1);
        final Stateful tlv1 = new StatefulBuilder().setLspUpdateCapability(Boolean.TRUE).addAugmentation(Stateful1.class, new Stateful1Builder().build()).build();
        final Tlvs1Builder statBuilder = new Tlvs1Builder();
        statBuilder.setStateful(tlv1);
        final Tlvs3Builder syncOptBuilder = new Tlvs3Builder();
        syncOptBuilder.setLspDbVersion(new LspDbVersionBuilder().setLspDbVersionValue(new BigInteger(DB_VERSION)).build());
        syncOptBuilder.setSpeakerEntityId(new SpeakerEntityIdBuilder().setSpeakerEntityIdValue(SPEAKER_ID).build());
        builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder().addAugmentation(Tlvs1.class, statBuilder.build()).addAugmentation(Tlvs3.class, syncOptBuilder.build()).build());
        assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
        final ByteBuf buf = Unpooled.buffer();
        parser.serializeObject(builder.build(), buf);
        assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
    }
}
Also used : Stateful(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.stateful.capability.tlv.Stateful) ObjectHeaderImpl(org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl) SyncOptimizationsActivator(org.opendaylight.protocol.pcep.sync.optimizations.SyncOptimizationsActivator) StatefulBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.stateful.capability.tlv.StatefulBuilder) LspDbVersionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.lsp.db.version.tlv.LspDbVersionBuilder) Tlvs3Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs3Builder) ByteBuf(io.netty.buffer.ByteBuf) ProtocolVersion(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ProtocolVersion) Stateful1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Stateful1Builder) Tlvs1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Tlvs1Builder) SyncOptimizationsOpenObjectParser(org.opendaylight.protocol.pcep.sync.optimizations.SyncOptimizationsOpenObjectParser) Stateful1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Stateful1) SpeakerEntityIdBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.speaker.entity.id.tlv.SpeakerEntityIdBuilder) Tlvs1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Tlvs1) TlvsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.srp.object.srp.TlvsBuilder) BigInteger(java.math.BigInteger) Test(org.junit.Test)

Example 3 with Stateful

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

the class PCEPTlvParserTest method testStatefulTlv.

@Test
public void testStatefulTlv() throws PCEPDeserializerException {
    final Stateful07StatefulCapabilityTlvParser parser = new Stateful07StatefulCapabilityTlvParser();
    final Stateful tlv = new StatefulBuilder().setLspUpdateCapability(Boolean.TRUE).build();
    assertEquals(tlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(statefulBytes, 4))));
    final ByteBuf buff = Unpooled.buffer();
    parser.serializeTlv(tlv, buff);
    assertArrayEquals(statefulBytes, ByteArray.getAllBytes(buff));
}
Also used : Stateful(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.stateful.capability.tlv.Stateful) Stateful07StatefulCapabilityTlvParser(org.opendaylight.protocol.pcep.ietf.stateful07.Stateful07StatefulCapabilityTlvParser) StatefulBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.stateful.capability.tlv.StatefulBuilder) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 4 with Stateful

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

the class PCEPValidatorTest method testOpenMsg.

@Test
public void testOpenMsg() throws IOException, PCEPDeserializerException {
    try (StatefulActivator a = new StatefulActivator()) {
        a.start(this.ctx);
        final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPOpenMessage1.bin"));
        final PCEPOpenMessageParser parser = new PCEPOpenMessageParser(this.ctx.getObjectHandlerRegistry());
        final OpenMessageBuilder builder = new OpenMessageBuilder();
        final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder b = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder();
        b.setProcessingRule(false);
        b.setIgnore(false);
        b.setVersion(new ProtocolVersion((short) 1));
        b.setKeepalive((short) 30);
        b.setDeadTimer((short) 120);
        b.setSessionId((short) 1);
        final Stateful tlv1 = new StatefulBuilder().setLspUpdateCapability(Boolean.TRUE).build();
        b.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder().addAugmentation(Tlvs1.class, new Tlvs1Builder().setStateful(tlv1).build()).build());
        builder.setOpen(b.build());
        assertEquals(new OpenBuilder().setOpenMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
        final ByteBuf buf = Unpooled.buffer(result.readableBytes());
        parser.serializeMessage(new OpenBuilder().setOpenMessage(builder.build()).build(), buf);
        assertArrayEquals(result.array(), buf.array());
    }
}
Also used : Stateful(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.stateful.capability.tlv.Stateful) Collections(java.util.Collections) StatefulBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.stateful.capability.tlv.StatefulBuilder) ByteBuf(io.netty.buffer.ByteBuf) ProtocolVersion(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ProtocolVersion) Tlvs1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Tlvs1Builder) OpenMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.message.OpenMessageBuilder) StatefulActivator(org.opendaylight.protocol.pcep.ietf.stateful07.StatefulActivator) OpenBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.OpenBuilder) PCEPOpenMessageParser(org.opendaylight.protocol.pcep.parser.message.PCEPOpenMessageParser) Subobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.include.route.object.iro.Subobject) Test(org.junit.Test)

Example 5 with Stateful

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

the class Stateful07StatefulCapabilityTlvParser method parseTlv.

@Override
public Stateful parseTlv(final ByteBuf buffer) throws PCEPDeserializerException {
    if (buffer == null) {
        return null;
    }
    if (buffer.readableBytes() < FLAGS_F_LENGTH / Byte.SIZE) {
        throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; Expected: >= " + FLAGS_F_LENGTH / Byte.SIZE + ".");
    }
    final StatefulBuilder sb = new StatefulBuilder();
    parseFlags(sb, buffer);
    return sb.build();
}
Also used : StatefulBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.stateful.capability.tlv.StatefulBuilder) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)

Aggregations

Stateful (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.stateful.capability.tlv.Stateful)7 StatefulBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.stateful.capability.tlv.StatefulBuilder)5 ByteBuf (io.netty.buffer.ByteBuf)4 Test (org.junit.Test)4 Stateful1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Stateful1)4 Tlvs1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Tlvs1)3 Tlvs1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Tlvs1Builder)3 BitArray (org.opendaylight.protocol.util.BitArray)2 ProtocolVersion (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ProtocolVersion)2 BigInteger (java.math.BigInteger)1 InetAddress (java.net.InetAddress)1 Collections (java.util.Collections)1 Stateful07StatefulCapabilityTlvParser (org.opendaylight.protocol.pcep.ietf.stateful07.Stateful07StatefulCapabilityTlvParser)1 StatefulActivator (org.opendaylight.protocol.pcep.ietf.stateful07.StatefulActivator)1 PCEPOpenMessageParser (org.opendaylight.protocol.pcep.parser.message.PCEPOpenMessageParser)1 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)1 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)1 SyncOptimizationsActivator (org.opendaylight.protocol.pcep.sync.optimizations.SyncOptimizationsActivator)1 SyncOptimizationsCapabilityTlvParser (org.opendaylight.protocol.pcep.sync.optimizations.SyncOptimizationsCapabilityTlvParser)1 SyncOptimizationsOpenObjectParser (org.opendaylight.protocol.pcep.sync.optimizations.SyncOptimizationsOpenObjectParser)1