Search in sources :

Example 6 with DisjointPath

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

the class ProtectedTransportIntentCompiler method createFreshProtectedPaths.

/**
 * Creates new protected paths.
 *
 * @param intent    original intention
 * @param did1      identifier of first device
 * @param did2      identifier of second device
 * @return compilation result
 * @throws IntentCompilationException when there's no satisfying path.
 */
private List<Intent> createFreshProtectedPaths(ProtectedTransportIntent intent, DeviceId did1, DeviceId did2) {
    DisjointPath disjointPath = getDisjointPath(intent, did1, did2);
    if (disjointPath == null || disjointPath.backup() == null) {
        log.error("Unable to find disjoint path between {}, {}", did1, did2);
        throw new IntentCompilationException("Unable to find disjoint paths.");
    }
    Path primary = disjointPath.primary();
    Path secondary = disjointPath.backup();
    String fingerprint = intent.key().toString();
    // pick and allocate Vlan to use as S-tag
    Pair<VlanId, VlanId> vlans = allocateEach(intent, primary, secondary, VlanId.class);
    VlanId primaryVlan = vlans.getLeft();
    VlanId secondaryVlan = vlans.getRight();
    // Build edge Intents for head/tail
    // resource for head/tail
    Collection<NetworkResource> oneResources = new ArrayList<>();
    Collection<NetworkResource> twoResources = new ArrayList<>();
    List<TransportEndpointDescription> onePaths = new ArrayList<>();
    onePaths.add(TransportEndpointDescription.builder().withOutput(vlanPort(primary.src(), primaryVlan)).build());
    onePaths.add(TransportEndpointDescription.builder().withOutput(vlanPort(secondary.src(), secondaryVlan)).build());
    List<TransportEndpointDescription> twoPaths = new ArrayList<>();
    twoPaths.add(TransportEndpointDescription.builder().withOutput(vlanPort(primary.dst(), primaryVlan)).build());
    twoPaths.add(TransportEndpointDescription.builder().withOutput(vlanPort(secondary.dst(), secondaryVlan)).build());
    ProtectionEndpointIntent oneIntent = ProtectionEndpointIntent.builder().key(intent.key()).appId(intent.appId()).priority(intent.priority()).resources(oneResources).deviceId(did1).description(buildDescription(onePaths, did2, fingerprint)).build();
    ProtectionEndpointIntent twoIntent = ProtectionEndpointIntent.builder().key(intent.key()).appId(intent.appId()).resources(twoResources).deviceId(did2).description(buildDescription(twoPaths, did1, fingerprint)).build();
    // Build transit intent for primary/secondary path
    Collection<NetworkResource> resources1 = ImmutableList.of(marker("protection1"));
    Collection<NetworkResource> resources2 = ImmutableList.of(marker("protection2"));
    ImmutableList<Intent> result = ImmutableList.<Intent>builder().addAll(createTransitIntent(intent, primary, primaryVlan, resources1)).addAll(createTransitIntent(intent, secondary, secondaryVlan, resources2)).add(oneIntent).add(twoIntent).build();
    log.trace("createFreshProtectedPaths result: {}", result);
    return result;
}
Also used : DefaultPath(org.onosproject.net.DefaultPath) Path(org.onosproject.net.Path) DisjointPath(org.onosproject.net.DisjointPath) ArrayList(java.util.ArrayList) ProtectionEndpointIntent(org.onosproject.net.intent.ProtectionEndpointIntent) ProtectedTransportIntent(org.onosproject.net.intent.ProtectedTransportIntent) Intent(org.onosproject.net.intent.Intent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) ProtectionEndpointIntent(org.onosproject.net.intent.ProtectionEndpointIntent) NetworkResource(org.onosproject.net.NetworkResource) TransportEndpointDescription(org.onosproject.net.behaviour.protection.TransportEndpointDescription) IntentCompilationException(org.onosproject.net.intent.IntentCompilationException) DisjointPath(org.onosproject.net.DisjointPath) VlanId(org.onlab.packet.VlanId)

Example 7 with DisjointPath

use of org.onosproject.net.DisjointPath 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 8 with DisjointPath

use of org.onosproject.net.DisjointPath 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 9 with DisjointPath

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

the class PathPainterTopovMessageHandler method buildDisjointPaths.

private ImmutableSet.Builder<Link> buildDisjointPaths(ImmutableSet.Builder<Link> pathBuilder) {
    paths.forEach(path -> {
        DisjointPath dp = (DisjointPath) path;
        pathBuilder.addAll(dp.primary().links());
        pathBuilder.addAll(dp.backup().links());
    });
    return pathBuilder;
}
Also used : DisjointPath(org.onosproject.net.DisjointPath)

Example 10 with DisjointPath

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

the class VirtualNetworkPathManagerTest method testGetPathsOnEmptyVnet.

/**
 * Tests getPaths(), getDisjointPaths()
 * on an empty virtual network.
 */
@Test
public void testGetPathsOnEmptyVnet() {
    VirtualNetwork vnet = setupEmptyVnet();
    PathService pathService = manager.get(vnet.id(), PathService.class);
    Set<Path> paths = pathService.getPaths(DID1, DID3);
    assertEquals("incorrect path count", 0, paths.size());
    Set<DisjointPath> disjointPaths = pathService.getDisjointPaths(DID1, DID3);
    assertEquals("incorrect path count", 0, disjointPaths.size());
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) Path(org.onosproject.net.Path) DisjointPath(org.onosproject.net.DisjointPath) PathService(org.onosproject.net.topology.PathService) DisjointPath(org.onosproject.net.DisjointPath) Test(org.junit.Test)

Aggregations

DisjointPath (org.onosproject.net.DisjointPath)19 Test (org.junit.Test)7 VirtualNetwork (org.onosproject.incubator.net.virtual.VirtualNetwork)7 Path (org.onosproject.net.Path)7 DefaultDisjointPath (org.onosproject.net.DefaultDisjointPath)6 VirtualDevice (org.onosproject.incubator.net.virtual.VirtualDevice)5 Topology (org.onosproject.net.topology.Topology)5 TopologyService (org.onosproject.net.topology.TopologyService)5 DefaultPath (org.onosproject.net.DefaultPath)4 DeviceId (org.onosproject.net.DeviceId)4 EdgeLink (org.onosproject.net.EdgeLink)3 Link (org.onosproject.net.Link)3 ImmutableSet (com.google.common.collect.ImmutableSet)2 ArrayList (java.util.ArrayList)2 GraphPathSearch (org.onlab.graph.GraphPathSearch)2 DefaultEdgeLink (org.onosproject.net.DefaultEdgeLink)2 Intent (org.onosproject.net.intent.Intent)2 LinkCollectionIntent (org.onosproject.net.intent.LinkCollectionIntent)2 DefaultTopologyVertex (org.onosproject.net.topology.DefaultTopologyVertex)2 LinkWeigher (org.onosproject.net.topology.LinkWeigher)2