Search in sources :

Example 21 with Pcrpt

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

the class PCEPValidatorTest method testRptMsg.

@Test
public void testRptMsg() throws IOException, PCEPDeserializerException {
    try (CrabbeInitiatedActivator a = new CrabbeInitiatedActivator();
        StatefulActivator b = new StatefulActivator()) {
        a.start(this.ctx);
        b.start(this.ctx);
        ByteBuf result = Unpooled.wrappedBuffer(PCRT1);
        final Stateful07PCReportMessageParser parser = new Stateful07PCReportMessageParser(this.ctx.getObjectHandlerRegistry());
        final PcrptMessageBuilder builder = new PcrptMessageBuilder();
        final List<Reports> reports = Lists.newArrayList();
        reports.add(new ReportsBuilder().setLsp(this.lsp).build());
        builder.setReports(reports);
        final Message parseResult = parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList());
        assertEquals(new PcrptBuilder().setPcrptMessage(builder.build()).build(), parseResult);
        ByteBuf buf = Unpooled.buffer(result.readableBytes());
        parser.serializeMessage(new PcrptBuilder().setPcrptMessage(builder.build()).build(), buf);
        assertArrayEquals(result.array(), buf.array());
        result = Unpooled.wrappedBuffer(PCRT2);
        final List<Reports> reports1 = Lists.newArrayList();
        reports1.add(new ReportsBuilder().setLsp(this.lsp).setPath(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.reports.PathBuilder().setEro(this.ero).setLspa(this.lspa).build()).build());
        builder.setReports(reports1);
        final ByteBuf input = result.slice(4, result.readableBytes() - 4);
        assertEquals(new PcrptBuilder().setPcrptMessage(builder.build()).build(), parser.parseMessage(input, Collections.emptyList()));
        buf = Unpooled.buffer(result.readableBytes());
        parser.serializeMessage(new PcrptBuilder().setPcrptMessage(builder.build()).build(), buf);
        assertArrayEquals(result.array(), buf.array());
        result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCRpt.3.bin"));
        final List<Reports> reports2 = Lists.newArrayList();
        final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.reports.PathBuilder pBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.reports.PathBuilder();
        pBuilder.setEro(this.ero);
        pBuilder.setLspa(this.lspa);
        pBuilder.setMetrics(Lists.newArrayList(this.metrics, this.metrics));
        pBuilder.setRro(this.rro);
        reports2.add(new ReportsBuilder().setSrp(this.srp).setLsp(this.lspSrp).setPath(pBuilder.build()).build());
        builder.setReports(reports2);
        assertEquals(new PcrptBuilder().setPcrptMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
        buf = Unpooled.buffer(result.readableBytes());
        parser.serializeMessage(new PcrptBuilder().setPcrptMessage(builder.build()).build(), buf);
        assertArrayEquals(result.array(), buf.array());
        result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCRpt.5.bin"));
        final List<Reports> reports3 = Lists.newArrayList();
        final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.reports.PathBuilder pBuilder1 = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.reports.PathBuilder();
        pBuilder1.setEro(this.ero);
        pBuilder1.setLspa(this.lspa);
        pBuilder1.setMetrics(Lists.newArrayList(this.metrics, this.metrics));
        pBuilder1.setRro(this.rro);
        reports3.add(new ReportsBuilder().setSrp(this.srp).setLsp(this.lspSrp).setPath(pBuilder.build()).build());
        reports3.add(new ReportsBuilder().setSrp(this.srp).setLsp(this.lspSrp).setPath(pBuilder1.build()).build());
        builder.setReports(reports3);
        assertEquals(new PcrptBuilder().setPcrptMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
        buf = Unpooled.buffer(result.readableBytes());
        parser.serializeMessage(new PcrptBuilder().setPcrptMessage(builder.build()).build(), buf);
        assertArrayEquals(result.array(), buf.array());
        result = Unpooled.wrappedBuffer(PCRT3);
        final List<Reports> reports4 = Lists.newArrayList();
        reports4.add(new ReportsBuilder().setLsp(this.lsp).setPath(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.reports.PathBuilder().setEro(this.ero).setLspa(this.lspa).setBandwidth(this.bandwidth).setReoptimizationBandwidth(this.reoptimizationBandwidth).build()).build());
        builder.setReports(reports4);
        final ByteBuf input2 = result.slice(4, result.readableBytes() - 4);
        assertEquals(new PcrptBuilder().setPcrptMessage(builder.build()).build(), parser.parseMessage(input2, Collections.emptyList()));
        buf = Unpooled.buffer(result.readableBytes());
        parser.serializeMessage(new PcrptBuilder().setPcrptMessage(builder.build()).build(), buf);
        assertArrayEquals(result.array(), buf.array());
    }
}
Also used : ReportsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.ReportsBuilder) Message(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message) Collections(java.util.Collections) PcrptBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PcrptBuilder) ByteBuf(io.netty.buffer.ByteBuf) Stateful07PCReportMessageParser(org.opendaylight.protocol.pcep.ietf.stateful07.Stateful07PCReportMessageParser) PathBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.pcupd.message.updates.PathBuilder) PcrptMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.PcrptMessageBuilder) CrabbeInitiatedActivator(org.opendaylight.protocol.pcep.ietf.initiated00.CrabbeInitiatedActivator) StatefulActivator(org.opendaylight.protocol.pcep.ietf.stateful07.StatefulActivator) Reports(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.Reports) Test(org.junit.Test)

Example 22 with Pcrpt

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

the class PCCTunnelManagerImpl method returnDelegation.

private void returnDelegation(final Updates update, final PCCSession session) {
    final PlspId plspId = update.getLsp().getPlspId();
    final PCCTunnel tunnel = this.tunnels.get(plspId);
    final long srpId = update.getSrp().getOperationId().getValue();
    if (tunnel != null) {
        // check if session really has a delegation
        if (hasDelegation(tunnel, session)) {
            // send report D=0
            final Tlvs tlvs = buildTlvs(tunnel, plspId.getValue(), Optional.absent());
            final Pcrpt pcrtp = createPcRtpMessage(new LspBuilder(update.getLsp()).setSync(true).setOperational(OperationalStatus.Up).setDelegate(false).setTlvs(tlvs).build(), Optional.of(createSrp(srpId)), tunnel.getLspState());
            session.sendReport(pcrtp);
            // start state timer
            startStateTimeout(tunnel, plspId);
            // if PCC's LSP, start re-delegation timer
            if (tunnel.getType() == LspType.PCC_LSP) {
                startRedelegationTimer(tunnel, plspId, session);
            } else {
                // if PCE-initiated LSP, revoke delegation instantly
                setDelegation(plspId, null);
            }
        } else {
            session.sendError(MsgBuilderUtil.createErrorMsg(PCEPErrors.UPDATE_REQ_FOR_NON_LSP, srpId));
        }
    } else {
        session.sendError(MsgBuilderUtil.createErrorMsg(PCEPErrors.UNKNOWN_PLSP_ID, srpId));
    }
}
Also used : Tlvs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.Tlvs) MsgBuilderUtil.createLspTlvs(org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil.createLspTlvs) Pcrpt(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Pcrpt) LspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.LspBuilder) PlspId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PlspId)

Example 23 with Pcrpt

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

the class PCCTunnelManagerImpl method createLspAndSendReport.

private void createLspAndSendReport(final long plspId, final PCCTunnel tunnel, final PCCSession session, final Optional<Boolean> isSync, final Optional<Srp> srp) {
    final boolean delegation = hasDelegation(tunnel, session);
    if (delegation) {
        tunnel.cancelTimeouts();
    }
    final String destinationAddress = getDestinationAddress(tunnel.getLspState().getEro().getSubobject(), this.address);
    final Tlvs tlvs = createLspTlvs(plspId, true, destinationAddress, this.address, this.address, Optional.of(tunnel.getPathName()), this.syncOptimization.incrementLspDBVersion());
    final boolean sync = isSync.isPresent() ? isSync.get() : this.syncOptimization.isSyncNeedIt();
    final Lsp lsp = createLsp(plspId, sync, Optional.fromNullable(tlvs), delegation, false);
    final Pcrpt pcrtp = createPcRtpMessage(lsp, srp, tunnel.getLspState());
    session.sendReport(pcrtp);
}
Also used : Tlvs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.Tlvs) MsgBuilderUtil.createLspTlvs(org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil.createLspTlvs) Pcrpt(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Pcrpt) MsgBuilderUtil.createLsp(org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil.createLsp) Lsp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.Lsp)

Example 24 with Pcrpt

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

the class PCCTunnelManagerImpl method sendToAll.

private void sendToAll(final PCCTunnel tunnel, final PlspId plspId, final List<Subobject> subobjects, final Srp srp, final Path path, final Lsp lsp) {
    for (final PCCSession session : this.sessions.values()) {
        final boolean isDelegated = hasDelegation(tunnel, session);
        final Tlvs tlvs = buildTlvs(tunnel, plspId.getValue(), Optional.of(subobjects));
        final Pcrpt pcRpt = createPcRtpMessage(new LspBuilder(lsp).setPlspId(plspId).setOperational(OperationalStatus.Up).setDelegate(isDelegated).setSync(true).addAugmentation(Lsp1.class, new Lsp1Builder().setCreate(tunnel.getType() == LspType.PCE_LSP).build()).setTlvs(tlvs).build(), Optional.fromNullable(srp), path);
        session.sendReport(pcRpt);
    }
}
Also used : PCCSession(org.opendaylight.protocol.pcep.pcc.mock.api.PCCSession) Tlvs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.Tlvs) MsgBuilderUtil.createLspTlvs(org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil.createLspTlvs) Pcrpt(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Pcrpt) LspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.LspBuilder) Lsp1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Lsp1Builder) Lsp1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Lsp1)

Example 25 with Pcrpt

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

the class PCCMockCommon method checkSequequenceDBVersionSync.

protected static void checkSequequenceDBVersionSync(final TestingSessionListener pceSessionListener, final BigInteger expectedDbVersion) {
    for (final Message msg : pceSessionListener.messages()) {
        final List<Reports> pcrt = ((Pcrpt) msg).getPcrptMessage().getReports();
        for (final Reports report : pcrt) {
            final Lsp lsp = report.getLsp();
            if (lsp.getPlspId().getValue() == 0) {
                assertEquals(false, lsp.isSync());
            } else {
                assertEquals(true, lsp.isSync());
            }
            final BigInteger actuaLspDBVersion = lsp.getTlvs().getAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs1.class).getLspDbVersion().getLspDbVersionValue();
            assertEquals(expectedDbVersion, actuaLspDBVersion);
        }
    }
}
Also used : Message(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message) Lsp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.Lsp) Reports(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.Reports) BigInteger(java.math.BigInteger)

Aggregations

Pcrpt (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Pcrpt)21 Test (org.junit.Test)17 LspBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.LspBuilder)12 MsgBuilderUtil.createLspTlvs (org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil.createLspTlvs)11 Tlvs (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.Tlvs)11 PlspId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PlspId)8 Pcinitiate (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Pcinitiate)7 Requests (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.Requests)7 Collections (java.util.Collections)5 LspDbVersionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.lsp.db.version.tlv.LspDbVersionBuilder)5 Reports (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.Reports)5 PCEPSession (org.opendaylight.protocol.pcep.PCEPSession)4 PcrptBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PcrptBuilder)4 PcrptMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.PcrptMessageBuilder)4 LspDbVersion (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.lsp.db.version.tlv.LspDbVersion)3 ReportsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.ReportsBuilder)3 ReportedLsp (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.ReportedLsp)3 ByteBuf (io.netty.buffer.ByteBuf)2 SymbolicPathName (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.SymbolicPathName)2 LspIdentifiersBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.LspIdentifiersBuilder)2