Search in sources :

Example 1 with SRLinkWeigher

use of org.onosproject.segmentrouting.SRLinkWeigher in project trellis-control by opennetworkinglab.

the class DefaultL2TunnelHandler method getPath.

/**
 * Returns the path betwwen two connect points.
 *
 * @param srcCp source connect point
 * @param dstCp destination connect point
 * @return the path
 */
private List<Link> getPath(ConnectPoint srcCp, ConnectPoint dstCp) {
    // use SRLinkWeigher to avoid pair links, and also
    // avoid going from the spine to the leaf and to the
    // spine again, we need to have the leaf as CP1 here.
    LinkWeigher srLw = new SRLinkWeigher(srManager, srcCp.deviceId(), new HashSet<Link>());
    Set<Path> paths = srManager.topologyService.getPaths(srManager.topologyService.currentTopology(), srcCp.deviceId(), dstCp.deviceId(), srLw);
    log.debug("Paths obtained from topology service {}", paths);
    // We randomly pick a path.
    if (paths.isEmpty()) {
        return null;
    }
    int size = paths.size();
    int index = RandomUtils.nextInt(0, size);
    List<Link> result = Iterables.get(paths, index).links();
    log.debug("Randomly picked a path {}", result);
    return result;
}
Also used : Path(org.onosproject.net.Path) SRLinkWeigher(org.onosproject.segmentrouting.SRLinkWeigher) LinkWeigher(org.onosproject.net.topology.LinkWeigher) SRLinkWeigher(org.onosproject.segmentrouting.SRLinkWeigher) Link(org.onosproject.net.Link) DefaultLink(org.onosproject.net.DefaultLink) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 2 with SRLinkWeigher

use of org.onosproject.segmentrouting.SRLinkWeigher in project trellis-control by opennetworkinglab.

the class McastUtils method getPaths.

/**
 * Gets path from src to dst computed using the custom link weigher.
 *
 * @param src source device ID
 * @param dst destination device ID
 * @param linksToEnforce links to be enforced
 * @return list of paths from src to dst
 */
List<Path> getPaths(DeviceId src, DeviceId dst, Set<Link> linksToEnforce) {
    final Topology currentTopology = topologyService.currentTopology();
    final LinkWeigher linkWeigher = new SRLinkWeigher(srManager, src, linksToEnforce);
    List<Path> allPaths = Lists.newArrayList(topologyService.getPaths(currentTopology, src, dst, linkWeigher));
    log.trace("{} path(s) found from {} to {}", allPaths.size(), src, dst);
    return allPaths;
}
Also used : Path(org.onosproject.net.Path) SRLinkWeigher(org.onosproject.segmentrouting.SRLinkWeigher) LinkWeigher(org.onosproject.net.topology.LinkWeigher) Topology(org.onosproject.net.topology.Topology) SRLinkWeigher(org.onosproject.segmentrouting.SRLinkWeigher)

Aggregations

Path (org.onosproject.net.Path)2 LinkWeigher (org.onosproject.net.topology.LinkWeigher)2 SRLinkWeigher (org.onosproject.segmentrouting.SRLinkWeigher)2 ConnectPoint (org.onosproject.net.ConnectPoint)1 DefaultLink (org.onosproject.net.DefaultLink)1 Link (org.onosproject.net.Link)1 Topology (org.onosproject.net.topology.Topology)1