Search in sources :

Example 6 with LspDbVersion

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.lsp.db.version.tlv.LspDbVersion in project bgpcep by opendaylight.

the class PCEPObjectParserTest method testLspObjectWithTLV.

@Test
public void testLspObjectWithTLV() throws IOException, PCEPDeserializerException {
    try (StatefulActivator a = new StatefulActivator();
        SyncOptimizationsActivator a2 = new SyncOptimizationsActivator()) {
        a.start(this.ctx);
        a2.start(this.ctx);
        final SyncOptimizationsLspObjectParser parser = new SyncOptimizationsLspObjectParser(this.ctx.getTlvHandlerRegistry(), this.ctx.getVendorInformationTlvRegistry());
        final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPLspObject1WithTLV.bin"));
        final LspBuilder builder = new LspBuilder();
        builder.setProcessingRule(true);
        builder.setIgnore(true);
        builder.setAdministrative(true);
        builder.setDelegate(false);
        builder.setRemove(true);
        builder.setSync(false);
        builder.addAugmentation(Lsp1.class, new Lsp1Builder().setCreate(false).build());
        builder.setOperational(OperationalStatus.GoingDown);
        builder.setPlspId(new PlspId(0x12345L));
        final LspErrorCode tlv1 = new LspErrorCodeBuilder().setErrorCode(627610883L).build();
        final SymbolicPathName tlv2 = new SymbolicPathNameBuilder().setPathName(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.SymbolicPathName("Med".getBytes())).build();
        final LspDbVersion lspDbVersion = new LspDbVersionBuilder().setLspDbVersionValue(new BigInteger(DB_VERSION)).build();
        builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.TlvsBuilder().setLspErrorCode(tlv1).setSymbolicPathName(tlv2).addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs1.class, new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs1Builder().setLspDbVersion(lspDbVersion).build()).build());
        assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
        final ByteBuf buf = Unpooled.buffer();
        parser.serializeObject(builder.build(), buf);
        assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
    }
}
Also used : ObjectHeaderImpl(org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl) LspErrorCode(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.error.code.tlv.LspErrorCode) SymbolicPathNameBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.symbolic.path.name.tlv.SymbolicPathNameBuilder) SyncOptimizationsActivator(org.opendaylight.protocol.pcep.sync.optimizations.SyncOptimizationsActivator) LspDbVersionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.lsp.db.version.tlv.LspDbVersionBuilder) ByteBuf(io.netty.buffer.ByteBuf) SymbolicPathName(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.symbolic.path.name.tlv.SymbolicPathName) PlspId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PlspId) StatefulActivator(org.opendaylight.protocol.pcep.ietf.stateful07.StatefulActivator) LspErrorCodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.error.code.tlv.LspErrorCodeBuilder) SyncOptimizationsLspObjectParser(org.opendaylight.protocol.pcep.sync.optimizations.SyncOptimizationsLspObjectParser) LspDbVersion(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.lsp.db.version.tlv.LspDbVersion) LspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.LspBuilder) BigInteger(java.math.BigInteger) Lsp1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Lsp1Builder) Test(org.junit.Test)

Example 7 with LspDbVersion

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.lsp.db.version.tlv.LspDbVersion in project bgpcep by opendaylight.

the class LspDbVersionTlvParser method serializeTlv.

@Override
public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
    Preconditions.checkArgument(tlv instanceof LspDbVersion, "Tlv object is not instance of LspDbVersion.");
    final ByteBuf body = Unpooled.buffer();
    writeUnsignedLong(((LspDbVersion) tlv).getLspDbVersionValue(), body);
    TlvUtil.formatTlv(TYPE, body, buffer);
}
Also used : LspDbVersion(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.lsp.db.version.tlv.LspDbVersion) ByteBuf(io.netty.buffer.ByteBuf)

Example 8 with LspDbVersion

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.lsp.db.version.tlv.LspDbVersion in project bgpcep by opendaylight.

the class StateSynchronizationAvoidanceProcedureTest method testStateSynchronizationSkipped.

@Test
public void testStateSynchronizationSkipped() throws Exception {
    // session up - sync skipped (LSP-DBs match)
    final LspDbVersion lspDbVersion = new LspDbVersionBuilder().setLspDbVersionValue(BigInteger.ONE).build();
    final PCEPSession session = getPCEPSession(getOpen(lspDbVersion), getOpen(lspDbVersion));
    this.listener.onSessionUp(session);
    // check node - synchronized
    readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
        assertEquals(PccSyncState.Synchronized, pcc.getStateSync());
        return pcc;
    });
}
Also used : PCEPSession(org.opendaylight.protocol.pcep.PCEPSession) LspDbVersion(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.lsp.db.version.tlv.LspDbVersion) LspDbVersionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.lsp.db.version.tlv.LspDbVersionBuilder) Test(org.junit.Test)

Example 9 with LspDbVersion

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.lsp.db.version.tlv.LspDbVersion in project bgpcep by opendaylight.

the class SyncOptimizationsOpenObjectParser method addTlv.

@Override
public void addTlv(final TlvsBuilder tbuilder, final Tlv tlv) {
    super.addTlv(tbuilder, tlv);
    final Tlvs3Builder syncOptTlvsBuilder = new Tlvs3Builder();
    if (tbuilder.getAugmentation(Tlvs3.class) != null) {
        final Tlvs3 t = tbuilder.getAugmentation(Tlvs3.class);
        if (t.getLspDbVersion() != null) {
            syncOptTlvsBuilder.setLspDbVersion(t.getLspDbVersion());
        }
        if (t.getSpeakerEntityId() != null) {
            syncOptTlvsBuilder.setSpeakerEntityId(t.getSpeakerEntityId());
        }
    }
    if (tlv instanceof LspDbVersion) {
        syncOptTlvsBuilder.setLspDbVersion((LspDbVersion) tlv);
    }
    if (tlv instanceof SpeakerEntityId) {
        syncOptTlvsBuilder.setSpeakerEntityId((SpeakerEntityId) tlv);
    }
    tbuilder.addAugmentation(Tlvs3.class, syncOptTlvsBuilder.build());
}
Also used : LspDbVersion(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.lsp.db.version.tlv.LspDbVersion) SpeakerEntityId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.speaker.entity.id.tlv.SpeakerEntityId) Tlvs3Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs3Builder) Tlvs3(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs3)

Example 10 with LspDbVersion

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.lsp.db.version.tlv.LspDbVersion in project bgpcep by opendaylight.

the class Stateful07TopologySessionListener method manageNextReport.

private boolean manageNextReport(final Reports report, final MessageContext ctx) {
    final Lsp lsp = report.getLsp();
    final PlspId plspid = lsp.getPlspId();
    final Srp srp = report.getSrp();
    if (!lsp.isSync() && (plspid == null || plspid.getValue() == 0)) {
        purgeStaleLsps(ctx);
        if (isTriggeredSyncInProcess()) {
            if (srp == null) {
                return false;
            }
            final SrpIdNumber id = srp.getOperationId();
            if (id.getValue() == 0) {
                return false;
            }
            final PCEPRequest req = removeRequest(id);
            ctx.resolveRequest(req);
        }
        stateSynchronizationAchieved(ctx);
        return true;
    }
    final ReportedLspBuilder rlb = new ReportedLspBuilder();
    boolean solicited = false;
    solicited = isSolicited(srp, lsp, ctx, rlb);
    // if remove flag is set in SRP object, remove the tunnel immediately
    if (solicited && srp.getAugmentation(Srp1.class) != null) {
        final Srp1 initiatedSrp = srp.getAugmentation(Srp1.class);
        if (initiatedSrp.isRemove()) {
            super.removeLsp(ctx, plspid);
            return false;
        }
    }
    rlb.setPath(Collections.singletonList(buildPath(report, srp, lsp)));
    String name = lookupLspName(plspid);
    if (lsp.getTlvs() != null && lsp.getTlvs().getSymbolicPathName() != null) {
        name = StandardCharsets.UTF_8.decode(ByteBuffer.wrap(lsp.getTlvs().getSymbolicPathName().getPathName().getValue())).toString();
    }
    // get LspDB from LSP and write it to pcc's node
    final LspDbVersion lspDbVersion = geLspDbVersionTlv(lsp);
    if (lspDbVersion != null) {
        updatePccNode(ctx, new PathComputationClientBuilder().addAugmentation(PathComputationClient1.class, new PathComputationClient1Builder().setLspDbVersion(lspDbVersion).build()).build());
    }
    updateLsp(ctx, plspid, name, rlb, solicited, lsp.isRemove());
    unmarkStaleLsp(plspid);
    LOG.debug("LSP {} updated", lsp);
    return true;
}
Also used : Srp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.srp.object.Srp) Srp1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Srp1) ReportedLsp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.ReportedLsp) Lsp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.Lsp) SrpIdNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.SrpIdNumber) ReportedLspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.ReportedLspBuilder) LspDbVersion(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.lsp.db.version.tlv.LspDbVersion) PathComputationClientBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.PathComputationClientBuilder) PathComputationClient1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.PathComputationClient1Builder) PlspId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PlspId)

Aggregations

LspDbVersion (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.lsp.db.version.tlv.LspDbVersion)11 LspDbVersionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.lsp.db.version.tlv.LspDbVersionBuilder)6 Test (org.junit.Test)5 PCEPSession (org.opendaylight.protocol.pcep.PCEPSession)4 Tlvs3Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs3Builder)3 Pcrpt (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Pcrpt)3 PlspId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PlspId)3 ByteBuf (io.netty.buffer.ByteBuf)2 Tlvs3 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs3)2 LspBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.LspBuilder)2 SymbolicPathNameBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.symbolic.path.name.tlv.SymbolicPathNameBuilder)2 Optional (com.google.common.base.Optional)1 BigInteger (java.math.BigInteger)1 Collections (java.util.Collections)1 ExecutionException (java.util.concurrent.ExecutionException)1 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)1 StatefulActivator (org.opendaylight.protocol.pcep.ietf.stateful07.StatefulActivator)1 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)1 SyncOptimizationsActivator (org.opendaylight.protocol.pcep.sync.optimizations.SyncOptimizationsActivator)1 SyncOptimizationsLspObjectParser (org.opendaylight.protocol.pcep.sync.optimizations.SyncOptimizationsLspObjectParser)1