Search in sources :

Example 31 with Pcrpt

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

the class PCEPValidatorTest method testRptMsg.

@Test
public void testRptMsg() throws IOException, PCEPDeserializerException {
    new InitiatedActivator().start(ctx);
    new StatefulActivator().start(ctx);
    ByteBuf result = Unpooled.wrappedBuffer(PCRT1);
    final StatefulPCReportMessageParser parser = new StatefulPCReportMessageParser(this.ctx.getObjectHandlerRegistry());
    final PcrptMessageBuilder builder = new PcrptMessageBuilder();
    final List<Reports> reports = new ArrayList<>();
    reports.add(new ReportsBuilder().setLsp(this.lsp).build());
    builder.setReports(reports);
    final Message parseResult = parser.parseMessage(result.slice(4, result.readableBytes() - 4), List.of());
    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);
    builder.setReports(List.of(new ReportsBuilder().setLsp(this.lsp).setPath(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcrpt.message.pcrpt.message.reports.PathBuilder().setEro(this.ero).setLspa(this.lspa).build()).build()));
    final ByteBuf input = result.slice(4, result.readableBytes() - 4);
    assertEquals(new PcrptBuilder().setPcrptMessage(builder.build()).build(), parser.parseMessage(input, List.of()));
    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 = new ArrayList<>();
    final var pBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.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), List.of()));
    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.4.bin"));
    assertEquals(new PcrptBuilder().setPcrptMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), List.of()));
    result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCRpt.5.bin"));
    final List<Reports> reports3 = new ArrayList<>();
    final var pBuilder1 = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.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), List.of()));
    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 = new ArrayList<>();
    reports4.add(new ReportsBuilder().setLsp(this.lsp).setPath(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.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, List.of()));
    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.rev200720.pcrpt.message.pcrpt.message.ReportsBuilder) Message(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message) Collections(java.util.Collections) PcrptBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.PcrptBuilder) ArrayList(java.util.ArrayList) ByteBuf(io.netty.buffer.ByteBuf) PathBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.updates.PathBuilder) StatefulPCReportMessageParser(org.opendaylight.protocol.pcep.ietf.stateful.StatefulPCReportMessageParser) PcrptMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcrpt.message.PcrptMessageBuilder) StatefulActivator(org.opendaylight.protocol.pcep.ietf.stateful.StatefulActivator) Reports(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcrpt.message.pcrpt.message.Reports) InitiatedActivator(org.opendaylight.protocol.pcep.ietf.initiated.InitiatedActivator) Test(org.junit.Test)

Example 32 with Pcrpt

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

the class TopologyProviderTest method testOnReportMessage.

@Test
public void testOnReportMessage() throws ExecutionException, InterruptedException {
    listener.onSessionUp(session);
    Pcrpt pcRptMsg = createSrPcRpt("1.1.1.1", "sr-path1", Uint32.ONE, true);
    listener.onMessage(session, pcRptMsg);
    readDataOperational(getDataBroker(), pathComputationClientIId, pcc -> {
        // check sr-path
        final Map<ReportedLspKey, ReportedLsp> reportedLsps = pcc.getReportedLsp();
        assertNotNull(reportedLsps);
        assertEquals(1, reportedLsps.size());
        final ReportedLsp lsp = reportedLsps.values().iterator().next();
        assertEquals("sr-path1", lsp.getName());
        final Map<PathKey, Path> paths = lsp.getPath();
        assertNotNull(paths);
        final Path path = paths.values().iterator().next();
        assertEquals(1, path.augmentation(Path1.class).getPathSetupType().getPst().intValue());
        final List<Subobject> subobjects = path.getEro().nonnullSubobject();
        assertEquals(1, subobjects.size());
        assertEquals("1.1.1.1", ((IpNodeId) ((SrEroType) subobjects.get(0).getSubobjectType()).getNai()).getIpAddress().getIpv4AddressNoZone().getValue());
        return pcc;
    });
    pcRptMsg = createSrPcRpt("1.1.1.3", "sr-path2", Uint32.TWO, false);
    listener.onMessage(session, pcRptMsg);
    readDataOperational(getDataBroker(), pathComputationClientIId, pcc -> {
        // check second lsp sr-path
        final Map<ReportedLspKey, ReportedLsp> reportedLsps = pcc.getReportedLsp();
        assertNotNull(reportedLsps);
        assertEquals(2, reportedLsps.size());
        return pcc;
    });
    pcRptMsg = createSrPcRpt("1.1.1.2", "sr-path1", Uint32.ONE, true);
    listener.onMessage(session, pcRptMsg);
    readDataOperational(getDataBroker(), pathComputationClientIId, pcc -> {
        // check updated sr-path
        final Map<ReportedLspKey, ReportedLsp> reportedLsps = pcc.getReportedLsp();
        assertNotNull(reportedLsps);
        assertEquals(2, reportedLsps.size());
        for (final ReportedLsp rlsp : reportedLsps.values()) {
            if (rlsp.getName().equals("sr-path1")) {
                final List<Subobject> subobjects = rlsp.nonnullPath().values().iterator().next().getEro().nonnullSubobject();
                assertEquals(1, subobjects.size());
                assertEquals("1.1.1.2", ((IpNodeId) ((SrEroType) subobjects.get(0).getSubobjectType()).getNai()).getIpAddress().getIpv4AddressNoZone().getValue());
            }
        }
        return pcc;
    });
}
Also used : Path(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.reported.lsp.Path) PathKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.reported.lsp.PathKey) ReportedLsp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.ReportedLsp) Subobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.Subobject) Pcrpt(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.Pcrpt) ReportedLspKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.ReportedLspKey) SrEroType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.network.topology.topology.node.path.computation.client.reported.lsp.path.ero.subobject.subobject.type.SrEroType) AbstractPCEPSessionTest(org.opendaylight.bgpcep.pcep.topology.provider.AbstractPCEPSessionTest) Test(org.junit.Test)

Example 33 with Pcrpt

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

the class PCCMockCommon method checkSequequenceDBVersionSync.

protected static void checkSequequenceDBVersionSync(final TestingSessionListener pceSessionListener, final Uint64 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().toJava() == 0) {
                assertEquals(false, lsp.getSync());
            } else {
                assertEquals(true, lsp.getSync());
            }
            final Uint64 actuaLspDBVersion = lsp.getTlvs().augmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev200720.Tlvs1.class).getLspDbVersion().getLspDbVersionValue();
            assertEquals(expectedDbVersion, actuaLspDBVersion);
        }
    }
}
Also used : Message(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message) Lsp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.Lsp) Reports(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcrpt.message.pcrpt.message.Reports) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 34 with Pcrpt

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.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 Uint32 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.empty());
            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.rev200720.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.rev200720.Pcrpt) LspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.LspBuilder) Uint32(org.opendaylight.yangtools.yang.common.Uint32) PlspId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.PlspId)

Example 35 with Pcrpt

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.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(new Lsp1Builder().setCreate(tunnel.getType() == LspType.PCE_LSP).build()).setTlvs(tlvs).build(), Optional.ofNullable(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.rev200720.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.rev200720.Pcrpt) 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)

Aggregations

Test (org.junit.Test)25 Pcrpt (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.Pcrpt)21 MsgBuilderUtil.createLspTlvs (org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil.createLspTlvs)19 LspBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.LspBuilder)12 Tlvs (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.lsp.Tlvs)11 Pcrpt (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Pcrpt)10 LspBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.LspBuilder)8 Tlvs (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.Tlvs)8 PlspId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.PlspId)8 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)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 Pcinitiate (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.Pcinitiate)7 Requests (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.pcinitiate.message.pcinitiate.message.Requests)7 Collections (java.util.Collections)6 LspDbVersionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev200720.lsp.db.version.tlv.LspDbVersionBuilder)5 PlspId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PlspId)5 Reports (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcrpt.message.pcrpt.message.Reports)5 PCEPSession (org.opendaylight.protocol.pcep.PCEPSession)4 Reports (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.Reports)4