Search in sources :

Example 1 with EdgeLink

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

the class AbstractPathService method getPaths.

@Override
public Set<Path> getPaths(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 ImmutableSet.of();
    }
    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 edgeToEdgePaths(srcEdge, dstEdge, internalWeigher);
    }
    // Otherwise get all paths between the source and destination edge
    // devices.
    Topology topology = topologyService.currentTopology();
    Set<Path> paths = topologyService.getPaths(topology, srcDevice, dstDevice, internalWeigher);
    return edgeToEdgePaths(srcEdge, dstEdge, paths, internalWeigher);
}
Also used : DefaultPath(org.onosproject.net.DefaultPath) DefaultDisjointPath(org.onosproject.net.DefaultDisjointPath) Path(org.onosproject.net.Path) DisjointPath(org.onosproject.net.DisjointPath) DefaultEdgeLink(org.onosproject.net.DefaultEdgeLink) EdgeLink(org.onosproject.net.EdgeLink) DeviceId(org.onosproject.net.DeviceId)

Example 2 with EdgeLink

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

the class AbstractPathService method getDisjointPaths.

@Override
public Set<DisjointPath> getDisjointPaths(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 ImmutableSet.of();
    }
    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 edgeToEdgePathsDisjoint(srcEdge, dstEdge, internalWeigher);
    }
    // Otherwise get all paths between the source and destination edge
    // devices.
    Topology topology = topologyService.currentTopology();
    Set<DisjointPath> paths = topologyService.getDisjointPaths(topology, srcDevice, dstDevice, internalWeigher);
    return edgeToEdgePathsDisjoint(srcEdge, dstEdge, paths, internalWeigher);
}
Also used : DefaultEdgeLink(org.onosproject.net.DefaultEdgeLink) EdgeLink(org.onosproject.net.EdgeLink) DeviceId(org.onosproject.net.DeviceId) DefaultDisjointPath(org.onosproject.net.DefaultDisjointPath) DisjointPath(org.onosproject.net.DisjointPath)

Example 3 with EdgeLink

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

the class AbstractPathService method getDisjointPaths.

@Override
public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, LinkWeigher weigher, Map<Link, Object> riskProfile) {
    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 ImmutableSet.of();
    }
    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 edgeToEdgePathsDisjoint(srcEdge, dstEdge, internalWeigher);
    }
    // Otherwise get all paths between the source and destination edge
    // devices.
    Topology topology = topologyService.currentTopology();
    Set<DisjointPath> paths = topologyService.getDisjointPaths(topology, srcDevice, dstDevice, internalWeigher, riskProfile);
    return edgeToEdgePathsDisjoint(srcEdge, dstEdge, paths, internalWeigher);
}
Also used : DefaultEdgeLink(org.onosproject.net.DefaultEdgeLink) EdgeLink(org.onosproject.net.EdgeLink) DeviceId(org.onosproject.net.DeviceId) DefaultDisjointPath(org.onosproject.net.DefaultDisjointPath) DisjointPath(org.onosproject.net.DisjointPath)

Example 4 with EdgeLink

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

the class PointToPointIntentCompiler method pathAvailable.

/**
 * Checks suggested path availability.
 * It checks:
 * - single links availability;
 * - that first and last device of the path are coherent with ingress and egress devices;
 * - links contiguity.
 *
 * @param intent    Intent with suggested path to check
 * @return true if the suggested path is available
 */
private boolean pathAvailable(PointToPointIntent intent) {
    // Check links availability
    List<Link> suggestedPath = intent.suggestedPath();
    for (Link link : suggestedPath) {
        if (!(link instanceof EdgeLink) && !linkService.getLinks(link.src()).contains(link)) {
            return false;
        }
    }
    // Check that first and last device of the path are intent ingress and egress devices
    if (!suggestedPath.get(0).src().deviceId().equals(intent.filteredIngressPoint().connectPoint().deviceId())) {
        return false;
    }
    if (!suggestedPath.get(suggestedPath.size() - 1).dst().deviceId().equals(intent.filteredEgressPoint().connectPoint().deviceId())) {
        return false;
    }
    // Check contiguity
    List<Pair<Link, Link>> linkPairs = IntStream.range(0, suggestedPath.size() - 1).mapToObj(i -> Pair.of(suggestedPath.get(i), suggestedPath.get(i + 1))).collect(Collectors.toList());
    for (Pair<Link, Link> linkPair : linkPairs) {
        if (!linkPair.getKey().dst().deviceId().equals(linkPair.getValue().src().deviceId())) {
            return false;
        }
    }
    return true;
}
Also used : DefaultEdgeLink.createEdgeLink(org.onosproject.net.DefaultEdgeLink.createEdgeLink) ListIterator(java.util.ListIterator) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) PortNumber(org.onosproject.net.PortNumber) TimeoutException(java.util.concurrent.TimeoutException) Link(org.onosproject.net.Link) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) ByteBuffer(java.nio.ByteBuffer) ConnectPoint(org.onosproject.net.ConnectPoint) Pair(org.apache.commons.lang3.tuple.Pair) Port(org.onosproject.net.Port) GroupListener(org.onosproject.net.group.GroupListener) Arrays.asList(java.util.Arrays.asList) PathNotFoundException(org.onosproject.net.intent.impl.PathNotFoundException) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) ImmutableSet(com.google.common.collect.ImmutableSet) Deactivate(org.osgi.service.component.annotations.Deactivate) Set(java.util.Set) Collectors(java.util.stream.Collectors) List(java.util.List) Stream(java.util.stream.Stream) FlowRule(org.onosproject.net.flow.FlowRule) GroupBuckets(org.onosproject.net.group.GroupBuckets) LinkService(org.onosproject.net.link.LinkService) Path(org.onosproject.net.Path) DeviceId(org.onosproject.net.DeviceId) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupDescription(org.onosproject.net.group.GroupDescription) IntStream(java.util.stream.IntStream) IntentCompilationException(org.onosproject.net.intent.IntentCompilationException) CompletableFuture(java.util.concurrent.CompletableFuture) GroupBucket(org.onosproject.net.group.GroupBucket) GroupKey(org.onosproject.net.group.GroupKey) Group(org.onosproject.net.group.Group) ArrayList(java.util.ArrayList) Component(org.osgi.service.component.annotations.Component) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) DefaultPath(org.onosproject.net.DefaultPath) Intent(org.onosproject.net.intent.Intent) Activate(org.osgi.service.component.annotations.Activate) EdgeLink(org.onosproject.net.EdgeLink) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) IntentId(org.onosproject.net.intent.IntentId) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) PathIntent(org.onosproject.net.intent.PathIntent) Instructions(org.onosproject.net.flow.instructions.Instructions) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) Instruction(org.onosproject.net.flow.instructions.Instruction) GroupService(org.onosproject.net.group.GroupService) ProtectionConstraint(org.onosproject.net.intent.constraint.ProtectionConstraint) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) ProviderId(org.onosproject.net.provider.ProviderId) DefaultGroupBucket(org.onosproject.net.group.DefaultGroupBucket) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) ScalarWeight(org.onlab.graph.ScalarWeight) Reference(org.osgi.service.component.annotations.Reference) Collections(java.util.Collections) DisjointPath(org.onosproject.net.DisjointPath) DefaultEdgeLink.createEdgeLink(org.onosproject.net.DefaultEdgeLink.createEdgeLink) EdgeLink(org.onosproject.net.EdgeLink) DefaultEdgeLink.createEdgeLink(org.onosproject.net.DefaultEdgeLink.createEdgeLink) Link(org.onosproject.net.Link) EdgeLink(org.onosproject.net.EdgeLink) Pair(org.apache.commons.lang3.tuple.Pair)

Example 5 with EdgeLink

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

the class ModelCache method updateHost.

private void updateHost(UiHost uiHost, Host h) {
    UiEdgeLink existing = uiTopology.findEdgeLink(uiHost.edgeLinkId());
    // TODO: review - do we need EdgeLink now that we are creating from id only?
    EdgeLink currentElink = synthesizeLink(h);
    UiLinkId currentElinkId = uiLinkId(currentElink);
    if (existing != null) {
        if (!currentElinkId.equals(existing.id())) {
            // edge link has changed
            insertNewUiEdgeLink(currentElinkId);
            uiHost.setEdgeLinkId(currentElinkId);
            uiTopology.remove(existing);
        }
    } else {
        // no previously existing edge link
        insertNewUiEdgeLink(currentElinkId);
        uiHost.setEdgeLinkId(currentElinkId);
    }
    HostLocation hloc = h.location();
    uiHost.setLocation(hloc.deviceId(), hloc.port());
}
Also used : UiEdgeLink(org.onosproject.ui.model.topo.UiEdgeLink) 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) HostLocation(org.onosproject.net.HostLocation)

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