Search in sources :

Example 11 with Ero

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.Ero in project bgpcep by opendaylight.

the class MessagesUtil method createPcRepMessage.

public static Pcrep createPcRepMessage(final Rp rp, final P2p p2p, final ConstrainedPath cpath) {
    /* Prepare Path Object with ERO and Object from the Request */
    final ArrayList<Paths> paths = new ArrayList<>();
    PathsBuilder pathBuilder = buildPath(cpath);
    if (p2p.getLspa() != null) {
        pathBuilder.setLspa(p2p.getLspa());
    }
    if (p2p.getIro() != null) {
        pathBuilder.setIro(p2p.getIro());
    }
    if (p2p.getXro() != null) {
        pathBuilder.setXro(p2p.getXro());
    }
    paths.add(pathBuilder.build());
    /* Prepare Reply with Path Object */
    final RepliesBuilder replyBuilder = new RepliesBuilder().setRp(rp).setResult(new SuccessCaseBuilder().setSuccess(new SuccessBuilder().setPaths(paths).build()).build());
    /* Prepare PcRep Message */
    final PcrepMessageBuilder msgBuilder = new PcrepMessageBuilder().setReplies(Lists.newArrayList(replyBuilder.build()));
    return new PcrepBuilder().setPcrepMessage(msgBuilder.build()).build();
}
Also used : RepliesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.RepliesBuilder) SuccessBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.result.success._case.SuccessBuilder) SuccessCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.result.SuccessCaseBuilder) PcrepMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.PcrepMessageBuilder) ArrayList(java.util.ArrayList) PcrepBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.PcrepBuilder) Paths(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.result.success._case.success.Paths) PathsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.result.success._case.success.PathsBuilder)

Example 12 with Ero

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.Ero in project bgpcep by opendaylight.

the class PCCTunnelManagerImplTest method createRequests.

private static Requests createRequests(final long plspId, final Optional<Boolean> remove, final Optional<Boolean> delegate) {
    final LspBuilder lsp = new LspBuilder().setTlvs(new TlvsBuilder().setSymbolicPathName(new SymbolicPathNameBuilder().setPathName(new SymbolicPathName(SYMBOLIC_NAME)).build()).build()).setPlspId(new PlspId(Uint32.valueOf(plspId)));
    if (delegate.isPresent()) {
        lsp.setDelegate(Boolean.TRUE);
    }
    final SrpBuilder srpBuilder = new SrpBuilder();
    if (remove.isPresent()) {
        srpBuilder.addAugmentation(new Srp1Builder().setRemove(Boolean.TRUE).build());
    }
    return new RequestsBuilder().setEro(ERO).setLsp(lsp.build()).setSrp(srpBuilder.setOperationId(new SrpIdNumber(Uint32.ZERO)).build()).build();
}
Also used : TlvsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.lsp.TlvsBuilder) SrpBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.srp.object.SrpBuilder) SymbolicPathNameBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.symbolic.path.name.tlv.SymbolicPathNameBuilder) SrpIdNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.SrpIdNumber) LspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.LspBuilder) SymbolicPathName(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.SymbolicPathName) Srp1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.Srp1Builder) RequestsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.pcinitiate.message.pcinitiate.message.RequestsBuilder) PlspId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.PlspId)

Example 13 with Ero

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.Ero in project bgpcep by opendaylight.

the class PathComputationImpl method computeEro.

@Override
public Ero computeEro(final EndpointsObj endpoints, final Bandwidth bandwidth, final ClassType classType, final List<Metrics> metrics, final boolean segmentRouting) {
    VertexKey source = getSourceVertexKey(endpoints);
    VertexKey destination = getDestinationVertexKey(endpoints);
    if (source == null) {
        return null;
    }
    if (destination == null) {
        return null;
    }
    /* Create new Constraints Object from the request */
    PathConstraints cts = getConstraints(endpoints, bandwidth, classType, metrics, segmentRouting);
    /* Determine Path Computation Algorithm according to parameters */
    AlgorithmType algoType;
    if (cts.getTeMetric() == null && cts.getDelay() == null && cts.getBandwidth() == null) {
        algoType = AlgorithmType.Spf;
    } else if (cts.getDelay() == null) {
        algoType = AlgorithmType.Cspf;
    } else {
        algoType = AlgorithmType.Samcra;
    }
    PathComputationAlgorithm algo = algoProvider.getPathComputationAlgorithm(tedGraph, algoType);
    if (algo == null) {
        return null;
    }
    /*
         * Request Path Computation for given source, destination and
         * constraints
         */
    final ConstrainedPath cpath = algo.computeP2pPath(source, destination, cts);
    LOG.info("Computed ERO: {}", cpath.getPathDescription());
    /* Check if we got a valid Path and return appropriate ERO */
    if (cpath.getStatus() == ComputationStatus.Completed) {
        return MessagesUtil.getEro(cpath.getPathDescription());
    } else {
        return null;
    }
}
Also used : AlgorithmType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.AlgorithmType) ConstrainedPath(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.ConstrainedPath) VertexKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.VertexKey) PathComputationAlgorithm(org.opendaylight.algo.PathComputationAlgorithm) PathConstraints(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.PathConstraints)

Example 14 with Ero

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.Ero in project bgpcep by opendaylight.

the class AbstractTopologySessionListener method makeBeforeBreak.

private static Map<PathKey, Path> makeBeforeBreak(final ReportedLspBuilder rlb, final ReportedLsp previous, final String name, final boolean remove) {
    // just one path should be reported
    final Path path = Iterables.getOnlyElement(rlb.getPath().values());
    final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId reportedLspId = path.getLspId();
    final List<Path> updatedPaths;
    // remove existing tunnel's paths now, as explicit path remove will not come
    if (!remove && reportedLspId.getValue().toJava() == 0) {
        updatedPaths = new ArrayList<>();
        LOG.debug("Remove previous paths {} to this lsp name {}", previous.getPath(), name);
    } else {
        // check previous report for existing paths
        final Collection<Path> prev = previous.nonnullPath().values();
        updatedPaths = new ArrayList<>(prev);
        LOG.debug("Found previous paths {} to this lsp name {}", updatedPaths, name);
        for (final Path prevPath : prev) {
            // we found reported path in previous reports
            if (prevPath.getLspId().getValue().toJava() == 0 || prevPath.getLspId().equals(reportedLspId)) {
                LOG.debug("Match on lsp-id {}", prevPath.getLspId().getValue());
                // path that was reported previously and does have the same lsp-id, path will be updated
                final boolean r = updatedPaths.remove(prevPath);
                LOG.trace("Request removed? {}", r);
            }
        }
    }
    // if the path does not exist in previous report, add it to path list, it's a new ERO
    // only one path will be added
    // lspId is 0 means confirmation message that shouldn't be added (because we have no means of deleting it later)
    LOG.trace("Adding new path {} to {}", path, updatedPaths);
    updatedPaths.add(path);
    if (remove) {
        if (reportedLspId.getValue().toJava() == 0) {
            // if lsp-id also 0, remove all paths
            LOG.debug("Removing all paths.");
            updatedPaths.clear();
        } else {
            // path is marked to be removed
            LOG.debug("Removing path {} from {}", path, updatedPaths);
            final boolean r = updatedPaths.remove(path);
            LOG.trace("Request removed? {}", r);
        }
    }
    LOG.debug("Setting new paths {} to lsp {}", updatedPaths, name);
    return Maps.uniqueIndex(updatedPaths, Path::key);
}
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)

Example 15 with Ero

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.Ero in project bgpcep by opendaylight.

the class PCEPTopologySessionListener method createUpdateMessageSync.

private SrpIdNumber createUpdateMessageSync(final PcupdMessageBuilder pcupdMessageBuilder) {
    final UpdatesBuilder updBuilder = new UpdatesBuilder();
    // LSP mandatory in Upd
    final Lsp lsp = new LspBuilder().setPlspId(PLSPID_ZERO).setSync(Boolean.TRUE).build();
    // SRP Mandatory in Upd
    final SrpBuilder srpBuilder = new SrpBuilder();
    // not sue whether use 0 instead of nextRequest() or do not insert srp == SRP-ID-number = 0
    srpBuilder.setOperationId(nextRequest());
    final Srp srp = srpBuilder.build();
    // ERO Mandatory in Upd
    final PathBuilder pb = new PathBuilder();
    pb.setEro(new EroBuilder().build());
    updBuilder.setPath(pb.build());
    updBuilder.setLsp(lsp).setSrp(srp).setPath(pb.build());
    pcupdMessageBuilder.setUpdates(Collections.singletonList(updBuilder.build()));
    return srp.getOperationId();
}
Also used : Srp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.srp.object.Srp) PathBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.updates.PathBuilder) SrpBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.srp.object.SrpBuilder) 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) ReportedLspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.ReportedLspBuilder) LspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.LspBuilder) EroBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.EroBuilder) UpdatesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.UpdatesBuilder)

Aggregations

ArrayList (java.util.ArrayList)16 Ero (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.Ero)8 ByteBuf (io.netty.buffer.ByteBuf)7 Test (org.junit.Test)7 EroBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.EroBuilder)7 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object)5 Subobject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.Subobject)5 SubobjectBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.SubobjectBuilder)5 Ipv4AddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone)4 LspBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.LspBuilder)4 ArrayDeque (java.util.ArrayDeque)2 InitiatedActivator (org.opendaylight.protocol.pcep.ietf.initiated.InitiatedActivator)2 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)2 RSVPParsingException (org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException)2 BitArray (org.opendaylight.protocol.util.BitArray)2 IpAddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone)2 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)2 Ipv6AddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6AddressNoZone)2 SrRange (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.prefix.state.SrRange)2 SrRangeBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.prefix.state.SrRangeBuilder)2