Search in sources :

Example 1 with LspDbVersion

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

the class PCEPObjectParserTest method testLspObjectWithTLV.

@Test
public void testLspObjectWithTLV() throws IOException, PCEPDeserializerException {
    new StatefulActivator().start(ctx);
    new SyncOptimizationsActivator().start(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().setProcessingRule(true).setIgnore(true).setAdministrative(true).setDelegate(false).setRemove(true).setSync(false).addAugmentation(new Lsp1Builder().setCreate(false).build()).setOperational(OperationalStatus.GoingDown).setPlspId(new PlspId(Uint32.valueOf(0x12345)));
    final LspErrorCode tlv1 = new LspErrorCodeBuilder().setErrorCode(Uint32.valueOf(627610883)).build();
    final SymbolicPathName tlv2 = new SymbolicPathNameBuilder().setPathName(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.SymbolicPathName("Med".getBytes())).build();
    final LspDbVersion lspDbVersion = new LspDbVersionBuilder().setLspDbVersionValue(DB_VERSION).build();
    builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.lsp.TlvsBuilder().setLspErrorCode(tlv1).setSymbolicPathName(tlv2).addAugmentation(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev200720.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.rev200720.lsp.error.code.tlv.LspErrorCode) SymbolicPathNameBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.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.rev200720.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.rev200720.symbolic.path.name.tlv.SymbolicPathName) PlspId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.PlspId) StatefulActivator(org.opendaylight.protocol.pcep.ietf.stateful.StatefulActivator) LspErrorCodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.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.rev200720.lsp.db.version.tlv.LspDbVersion) LspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.LspBuilder) Lsp1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.Lsp1Builder) Test(org.junit.Test)

Example 2 with LspDbVersion

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev200720.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) {
    checkArgument(tlv instanceof LspDbVersion, "Tlv object is not instance of LspDbVersion.");
    final ByteBuf body = Unpooled.buffer();
    writeOrZero(body, ((LspDbVersion) tlv).getLspDbVersionValue());
    TlvUtil.formatTlv(TYPE, body, buffer);
}
Also used : LspDbVersion(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev200720.lsp.db.version.tlv.LspDbVersion) ByteBuf(io.netty.buffer.ByteBuf)

Example 3 with LspDbVersion

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

the class SyncOptimizationsLspObjectParser method addTlv.

@Override
public void addTlv(final TlvsBuilder tbuilder, final Tlv tlv) {
    super.addTlv(tbuilder, tlv);
    final Tlvs1Builder syncOptTlvsBuilder = new Tlvs1Builder();
    if (tbuilder.augmentation(Tlvs1.class) != null) {
        final Tlvs1 t = tbuilder.augmentation(Tlvs1.class);
        if (t.getLspDbVersion() != null) {
            syncOptTlvsBuilder.setLspDbVersion(t.getLspDbVersion());
        }
    }
    if (tlv instanceof LspDbVersion) {
        syncOptTlvsBuilder.setLspDbVersion((LspDbVersion) tlv);
    }
    tbuilder.addAugmentation(syncOptTlvsBuilder.build());
}
Also used : LspDbVersion(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev200720.lsp.db.version.tlv.LspDbVersion) Tlvs1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev200720.Tlvs1Builder) Tlvs1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev200720.Tlvs1)

Example 4 with LspDbVersion

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

the class PCEPTopologySessionListener method manageNextReport.

@Holding("this")
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.getSync() && (plspid == null || plspid.getValue().toJava() == 0)) {
        purgeStaleLsps(ctx);
        if (isTriggeredSyncInProcess()) {
            if (srp == null) {
                return false;
            }
            final SrpIdNumber id = srp.getOperationId();
            if (id.getValue().toJava() == 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) {
        final Srp1 initiatedSrp = srp.augmentation(Srp1.class);
        if (initiatedSrp != null && initiatedSrp.getRemove()) {
            super.removeLsp(ctx, plspid);
            return false;
        }
    }
    rlb.setPath(BindingMap.of(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(new PathComputationClient1Builder().setLspDbVersion(lspDbVersion).build()).build());
    }
    updateLsp(ctx, plspid, name, rlb, solicited, lsp.getRemove());
    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.rev200720.srp.object.Srp) Srp1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.Srp1) Lsp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.Lsp) ReportedLsp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.ReportedLsp) SrpIdNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.SrpIdNumber) ReportedLspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.ReportedLspBuilder) LspDbVersion(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev200720.lsp.db.version.tlv.LspDbVersion) PathComputationClientBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.PathComputationClientBuilder) PathComputationClient1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev200720.PathComputationClient1Builder) PlspId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.PlspId) Holding(org.checkerframework.checker.lock.qual.Holding)

Example 5 with LspDbVersion

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

the class PCETriggeredInitialSyncProcedureTest method testPcepTriggeredInitialSyncPerformed.

/**
 * Test Triggered Initial Sync procedure.
 */
@Test
public void testPcepTriggeredInitialSyncPerformed() throws Exception {
    final PCEPTopologySessionListener listener = getSessionListener();
    // session up - expect triggered sync (LSP-DBs do not match)
    final LspDbVersion localDbVersion = new LspDbVersionBuilder().setLspDbVersionValue(Uint64.ONE).build();
    final LspDbVersion localDbVersion2 = new LspDbVersionBuilder().setLspDbVersionValue(Uint64.TWO).build();
    final PCEPSession session = getPCEPSession(getOpen(localDbVersion, false), getOpen(localDbVersion2, false));
    listener.onSessionUp(session);
    readDataOperational(getDataBroker(), pathComputationClientIId, pcc -> {
        // check node - not synchronized and TriggeredInitialSync state
        assertEquals(PccSyncState.TriggeredInitialSync, pcc.getStateSync());
        return pcc;
    });
    // sync rpt + LSP-DB
    final Pcrpt syncMsg = getsyncMsg();
    listener.onMessage(session, syncMsg);
    readDataOperational(getDataBroker(), pathComputationClientIId, pcc -> {
        // check node - synchronized
        assertEquals(PccSyncState.Synchronized, pcc.getStateSync());
        // check reported LSP is empty, LSP state from previous session was purged
        assertNull(pcc.getReportedLsp());
        return pcc;
    });
    // report LSP + LSP-DB version number
    final Pcrpt pcRpt = getPcrpt();
    listener.onMessage(session, pcRpt);
    readDataOperational(getDataBroker(), pathComputationClientIId, pcc -> {
        assertFalse(pcc.nonnullReportedLsp().isEmpty());
        return pcc;
    });
}
Also used : PCEPSession(org.opendaylight.protocol.pcep.PCEPSession) Pcrpt(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.Pcrpt) LspDbVersion(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev200720.lsp.db.version.tlv.LspDbVersion) LspDbVersionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev200720.lsp.db.version.tlv.LspDbVersionBuilder) Test(org.junit.Test)

Aggregations

LspDbVersion (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev200720.lsp.db.version.tlv.LspDbVersion)9 Test (org.junit.Test)5 LspDbVersionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev200720.lsp.db.version.tlv.LspDbVersionBuilder)5 PCEPSession (org.opendaylight.protocol.pcep.PCEPSession)4 Pcrpt (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.Pcrpt)3 PlspId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.PlspId)3 ByteBuf (io.netty.buffer.ByteBuf)2 LspDbVersion (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.lsp.db.version.tlv.LspDbVersion)2 LspBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.LspBuilder)2 SymbolicPathNameBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.symbolic.path.name.tlv.SymbolicPathNameBuilder)2 Optional (com.google.common.base.Optional)1 Collections (java.util.Collections)1 ExecutionException (java.util.concurrent.ExecutionException)1 Holding (org.checkerframework.checker.lock.qual.Holding)1 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)1 StatefulActivator (org.opendaylight.protocol.pcep.ietf.stateful.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 PathComputationClient1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.PathComputationClient1Builder)1