Search in sources :

Example 1 with PcinitiateBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.PcinitiateBuilder in project bgpcep by opendaylight.

the class PCEPValidatorTest method testPcinitMsg.

@Test
public void testPcinitMsg() throws IOException, PCEPDeserializerException {
    try (CrabbeInitiatedActivator a = new CrabbeInitiatedActivator()) {
        a.start(this.ctx);
        final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/Pcinit.bin"));
        final CInitiated00PCInitiateMessageParser parser = new CInitiated00PCInitiateMessageParser(this.ctx.getObjectHandlerRegistry());
        final PcinitiateMessageBuilder builder = new PcinitiateMessageBuilder();
        final RequestsBuilder rBuilder = new RequestsBuilder();
        final List<Requests> reqs = Lists.newArrayList();
        rBuilder.setSrp(this.srp);
        rBuilder.setLsp(this.lspSrp);
        rBuilder.setEro(this.ero);
        rBuilder.setLspa(this.lspa);
        rBuilder.setMetrics(Lists.newArrayList(this.metrics));
        rBuilder.setIro(this.iro);
        reqs.add(rBuilder.build());
        builder.setRequests(reqs);
        assertEquals(new PcinitiateBuilder().setPcinitiateMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
        final ByteBuf buf = Unpooled.buffer(result.readableBytes());
        parser.serializeMessage(new PcinitiateBuilder().setPcinitiateMessage(builder.build()).build(), buf);
        assertArrayEquals(result.array(), buf.array());
    }
}
Also used : PcinitiateMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.PcinitiateMessageBuilder) CInitiated00PCInitiateMessageParser(org.opendaylight.protocol.pcep.ietf.initiated00.CInitiated00PCInitiateMessageParser) PcinitiateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.PcinitiateBuilder) RequestsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.RequestsBuilder) ByteBuf(io.netty.buffer.ByteBuf) Requests(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.Requests) CrabbeInitiatedActivator(org.opendaylight.protocol.pcep.ietf.initiated00.CrabbeInitiatedActivator) Test(org.junit.Test)

Example 2 with PcinitiateBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.PcinitiateBuilder in project bgpcep by opendaylight.

the class CInitiated00PCInitiateMessageParser method validate.

@Override
protected Message validate(final List<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
    Preconditions.checkArgument(objects != null, "Passed list can't be null.");
    final PcinitiateMessageBuilder builder = new PcinitiateMessageBuilder();
    final List<Requests> reqs = Lists.newArrayList();
    while (!objects.isEmpty()) {
        reqs.add(this.getValidRequest(objects));
    }
    builder.setRequests(reqs);
    return new PcinitiateBuilder().setPcinitiateMessage(builder.build()).build();
}
Also used : PcinitiateMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.PcinitiateMessageBuilder) PcinitiateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.PcinitiateBuilder) Requests(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.Requests)

Example 3 with PcinitiateBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.PcinitiateBuilder in project bgpcep by opendaylight.

the class Stateful07TopologySessionListener method redelegate.

private ListenableFuture<OperationResult> redelegate(final Lsp reportedLsp, final Srp srp, final Lsp lsp, final UpdateLspArgs input) {
    // the D bit that was reported decides the type of PCE message sent
    requireNonNull(reportedLsp.isDelegate());
    final Message msg;
    if (reportedLsp.isDelegate()) {
        // we already have delegation, send update
        final UpdatesBuilder rb = new UpdatesBuilder();
        rb.setSrp(srp);
        rb.setLsp(lsp);
        final PathBuilder pb = new PathBuilder();
        pb.fieldsFrom(input.getArguments());
        rb.setPath(pb.build());
        final PcupdMessageBuilder ub = new PcupdMessageBuilder(MESSAGE_HEADER);
        ub.setUpdates(Collections.singletonList(rb.build()));
        msg = new PcupdBuilder().setPcupdMessage(ub.build()).build();
    } else {
        final Lsp1 lspCreateFlag = reportedLsp.getAugmentation(Lsp1.class);
        // we only retake delegation for PCE initiated tunnels
        if (lspCreateFlag != null && !lspCreateFlag.isCreate()) {
            LOG.warn("Unable to retake delegation of PCC-initiated tunnel: {}", reportedLsp);
            return OperationResults.createUnsent(PCEPErrors.UPDATE_REQ_FOR_NON_LSP).future();
        }
        // we want to revoke delegation, different type of message
        // is sent because of specification by Siva
        // this message is also sent, when input delegate bit is set to 0
        // generating an error in PCC
        final List<Requests> reqs = new ArrayList<>();
        reqs.add(new RequestsBuilder().setSrp(srp).setLsp(lsp).build());
        final PcinitiateMessageBuilder ib = new PcinitiateMessageBuilder();
        ib.setRequests(reqs);
        msg = new PcinitiateBuilder().setPcinitiateMessage(ib.build()).build();
    }
    return sendMessage(msg, srp.getOperationId(), input.getArguments().getMetadata());
}
Also used : PcinitiateMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.PcinitiateMessageBuilder) PathBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.pcupd.message.updates.PathBuilder) PcinitiateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.PcinitiateBuilder) PcrptMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PcrptMessage) PcerrMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcerrMessage) Message(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message) PcupdMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.PcupdMessageBuilder) ArrayList(java.util.ArrayList) RequestsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.RequestsBuilder) UpdatesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.pcupd.message.UpdatesBuilder) Lsp1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Lsp1) PcupdBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PcupdBuilder) Requests(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.Requests)

Example 4 with PcinitiateBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.PcinitiateBuilder in project bgpcep by opendaylight.

the class Stateful07TopologySessionListener method removeLsp.

@Override
public synchronized ListenableFuture<OperationResult> removeLsp(@Nonnull final RemoveLspArgs input) {
    Preconditions.checkArgument(input != null && input.getName() != null && input.getNode() != null, MISSING_XML_TAG);
    LOG.trace("RemoveLspArgs {}", input);
    // Make sure the LSP exists, we need it for PLSP-ID
    final InstanceIdentifier<ReportedLsp> lsp = lspIdentifier(input.getName());
    final ListenableFuture<Optional<ReportedLsp>> f = readOperationalData(lsp);
    if (f == null) {
        return OperationResults.createUnsent(PCEPErrors.LSP_INTERNAL_ERROR).future();
    }
    return Futures.transformAsync(f, rep -> {
        final Lsp reportedLsp = validateReportedLsp(rep, input);
        if (reportedLsp == null) {
            return OperationResults.createUnsent(PCEPErrors.UNKNOWN_PLSP_ID).future();
        }
        final PcinitiateMessageBuilder ib = new PcinitiateMessageBuilder(MESSAGE_HEADER);
        final Requests rb = buildRequest(rep, reportedLsp);
        ib.setRequests(Collections.singletonList(rb));
        return sendMessage(new PcinitiateBuilder().setPcinitiateMessage(ib.build()).build(), rb.getSrp().getOperationId(), null);
    }, MoreExecutors.directExecutor());
}
Also used : PcinitiateMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.PcinitiateMessageBuilder) ReportedLsp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.ReportedLsp) PcinitiateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.PcinitiateBuilder) Optional(com.google.common.base.Optional) 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) Requests(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.Requests)

Example 5 with PcinitiateBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.PcinitiateBuilder in project bgpcep by opendaylight.

the class PCCSessionListenerTest method createInitMsg.

private static PcinitiateMessage createInitMsg(final boolean remove, final boolean endpoint) {
    // lsp with "unknown" plsp-id
    final LspBuilder lspBuilder = new LspBuilder().setAdministrative(true).setDelegate(true).setIgnore(false).setOperational(OperationalStatus.Up).setPlspId(new PlspId(999L)).setProcessingRule(false).setRemove(remove).setSync(true);
    final List<Requests> requests = Lists.newArrayList();
    final RequestsBuilder reqBuilder = new RequestsBuilder().setLsp(lspBuilder.build()).setSrp(new SrpBuilder(MsgBuilderUtil.createSrp(123)).addAugmentation(Srp1.class, new Srp1Builder().setRemove(remove).build()).build());
    if (endpoint) {
        reqBuilder.setEndpointsObj(new EndpointsObjBuilder().build());
    }
    requests.add(reqBuilder.build());
    final PcinitiateMessageBuilder initBuilder = new PcinitiateMessageBuilder().setRequests(requests);
    return new PcinitiateBuilder().setPcinitiateMessage(initBuilder.build()).build();
}
Also used : PcinitiateMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.PcinitiateMessageBuilder) SrpBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.srp.object.SrpBuilder) PcinitiateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.PcinitiateBuilder) LspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.LspBuilder) RequestsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.RequestsBuilder) Srp1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Srp1Builder) Requests(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.Requests) EndpointsObjBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.object.EndpointsObjBuilder) PlspId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PlspId)

Aggregations

PcinitiateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.PcinitiateBuilder)5 PcinitiateMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.PcinitiateMessageBuilder)5 Requests (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.Requests)5 RequestsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.RequestsBuilder)3 Optional (com.google.common.base.Optional)1 ByteBuf (io.netty.buffer.ByteBuf)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 CInitiated00PCInitiateMessageParser (org.opendaylight.protocol.pcep.ietf.initiated00.CInitiated00PCInitiateMessageParser)1 CrabbeInitiatedActivator (org.opendaylight.protocol.pcep.ietf.initiated00.CrabbeInitiatedActivator)1 Lsp1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Lsp1)1 Srp1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Srp1Builder)1 PcrptMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PcrptMessage)1 PcupdBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PcupdBuilder)1 PlspId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PlspId)1 Lsp (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.Lsp)1 LspBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.LspBuilder)1 PcupdMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.PcupdMessageBuilder)1 UpdatesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.pcupd.message.UpdatesBuilder)1 PathBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.pcupd.message.updates.PathBuilder)1