Search in sources :

Example 6 with EdgeLink

use of org.onosproject.net.EdgeLink in project onos by opennetworkinglab.

the class ModelCache method addNewHost.

private UiHost addNewHost(Host h) {
    UiHost host = new UiHost(uiTopology, h);
    uiTopology.add(host);
    EdgeLink elink = synthesizeLink(h);
    UiLinkId elinkId = uiLinkId(elink);
    host.setEdgeLinkId(elinkId);
    // add synthesized edge link to the topology
    addNewEdgeLink(elinkId);
    return host;
}
Also used : DefaultEdgeLink.createEdgeLink(org.onosproject.net.DefaultEdgeLink.createEdgeLink) EdgeLink(org.onosproject.net.EdgeLink) UiEdgeLink(org.onosproject.ui.model.topo.UiEdgeLink) UiLinkId(org.onosproject.ui.model.topo.UiLinkId) UiHost(org.onosproject.ui.model.topo.UiHost)

Example 7 with EdgeLink

use of org.onosproject.net.EdgeLink in project onos by opennetworkinglab.

the class AbstractPathService method edgeToEdgePath.

// Produces a direct edge-to-edge path.
private Path edgeToEdgePath(EdgeLink srcLink, EdgeLink dstLink, Path path, LinkWeigher weigher) {
    List<Link> links = Lists.newArrayListWithCapacity(2);
    Weight cost = weigher.getInitialWeight();
    // add the infrastructure path only if it is not null.
    if (srcLink != NOT_HOST) {
        links.add(srcLink);
        cost = cost.merge(weigher.weight(new DefaultTopologyEdge(null, null, srcLink)));
    }
    if (path != null) {
        links.addAll(path.links());
        cost = cost.merge(path.weight());
    }
    if (dstLink != NOT_HOST) {
        links.add(dstLink);
        cost = cost.merge(weigher.weight(new DefaultTopologyEdge(null, null, dstLink)));
    }
    return new DefaultPath(PID, links, cost);
}
Also used : DefaultPath(org.onosproject.net.DefaultPath) Link(org.onosproject.net.Link) DefaultEdgeLink(org.onosproject.net.DefaultEdgeLink) EdgeLink(org.onosproject.net.EdgeLink) Weight(org.onlab.graph.Weight)

Example 8 with EdgeLink

use of org.onosproject.net.EdgeLink in project onos by opennetworkinglab.

the class AbstractPathService method getKShortestPaths.

@Override
public Stream<Path> getKShortestPaths(ElementId src, ElementId dst, LinkWeigher weigher) {
    checkNotNull(src, ELEMENT_ID_NULL);
    checkNotNull(dst, ELEMENT_ID_NULL);
    LinkWeigher internalWeigher = weigher != null ? weigher : DEFAULT_WEIGHER;
    // Get the source and destination edge locations
    EdgeLink srcEdge = getEdgeLink(src, true);
    EdgeLink dstEdge = getEdgeLink(dst, false);
    // If either edge is null, bail with no paths.
    if (srcEdge == null || dstEdge == null) {
        return Stream.empty();
    }
    DeviceId srcDevice = srcEdge != NOT_HOST ? srcEdge.dst().deviceId() : (DeviceId) src;
    DeviceId dstDevice = dstEdge != NOT_HOST ? dstEdge.src().deviceId() : (DeviceId) dst;
    // is just one path, so build it and return it.
    if (srcDevice.equals(dstDevice)) {
        return Stream.of(edgeToEdgePath(srcEdge, dstEdge, null, internalWeigher));
    }
    // Otherwise get all paths between the source and destination edge
    // devices.
    Topology topology = topologyService.currentTopology();
    return topologyService.getKShortestPaths(topology, srcDevice, dstDevice, internalWeigher).map(path -> edgeToEdgePath(srcEdge, dstEdge, path, internalWeigher));
}
Also used : DefaultEdgeLink(org.onosproject.net.DefaultEdgeLink) EdgeLink(org.onosproject.net.EdgeLink) DeviceId(org.onosproject.net.DeviceId)

Example 9 with EdgeLink

use of org.onosproject.net.EdgeLink in project onos by opennetworkinglab.

the class PointToPointIntentCompiler method filterInvalidSubIntents.

/**
 * Deletes intents from the given list if the ports or links the intent
 * relies on are no longer viable. The failover flow rule intent is never
 * deleted -- only its contents are updated.
 *
 * @param oldInstallables  list of intents to examine
 * @return                 list of reusable installable intents
 */
private List<Intent> filterInvalidSubIntents(List<Intent> oldInstallables, PointToPointIntent pointIntent) {
    List<Intent> intentList = new ArrayList<>();
    intentList.addAll(oldInstallables);
    Iterator<Intent> iterator = intentList.iterator();
    while (iterator.hasNext()) {
        Intent intent = iterator.next();
        intent.resources().forEach(resource -> {
            if (resource instanceof Link) {
                Link link = (Link) resource;
                if (link.state() == Link.State.INACTIVE) {
                    setPathsToRemove(intent);
                } else if (link instanceof EdgeLink) {
                    ConnectPoint connectPoint = (link.src().elementId() instanceof DeviceId) ? link.src() : link.dst();
                    Port port = deviceService.getPort(connectPoint.deviceId(), connectPoint.port());
                    if (port == null || !port.isEnabled()) {
                        setPathsToRemove(intent);
                    }
                } else {
                    Port port1 = deviceService.getPort(link.src().deviceId(), link.src().port());
                    Port port2 = deviceService.getPort(link.dst().deviceId(), link.dst().port());
                    if (port1 == null || !port1.isEnabled() || port2 == null || !port2.isEnabled()) {
                        setPathsToRemove(intent);
                    }
                }
            }
        });
    }
    removeAndUpdateIntents(intentList, pointIntent);
    return intentList;
}
Also used : DefaultEdgeLink.createEdgeLink(org.onosproject.net.DefaultEdgeLink.createEdgeLink) EdgeLink(org.onosproject.net.EdgeLink) DeviceId(org.onosproject.net.DeviceId) Port(org.onosproject.net.Port) ArrayList(java.util.ArrayList) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) Intent(org.onosproject.net.intent.Intent) PathIntent(org.onosproject.net.intent.PathIntent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) ConnectPoint(org.onosproject.net.ConnectPoint) DefaultEdgeLink.createEdgeLink(org.onosproject.net.DefaultEdgeLink.createEdgeLink) Link(org.onosproject.net.Link) EdgeLink(org.onosproject.net.EdgeLink)

Aggregations

EdgeLink (org.onosproject.net.EdgeLink)9 DeviceId (org.onosproject.net.DeviceId)6 DefaultEdgeLink (org.onosproject.net.DefaultEdgeLink)5 DefaultEdgeLink.createEdgeLink (org.onosproject.net.DefaultEdgeLink.createEdgeLink)4 DisjointPath (org.onosproject.net.DisjointPath)4 DefaultDisjointPath (org.onosproject.net.DefaultDisjointPath)3 DefaultPath (org.onosproject.net.DefaultPath)3 Link (org.onosproject.net.Link)3 ArrayList (java.util.ArrayList)2 ConnectPoint (org.onosproject.net.ConnectPoint)2 Path (org.onosproject.net.Path)2 Port (org.onosproject.net.Port)2 UiEdgeLink (org.onosproject.ui.model.topo.UiEdgeLink)2 UiLinkId (org.onosproject.ui.model.topo.UiLinkId)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 ByteBuffer (java.nio.ByteBuffer)1 Arrays.asList (java.util.Arrays.asList)1 Collections (java.util.Collections)1 Iterator (java.util.Iterator)1 List (java.util.List)1