Search in sources :

Example 31 with Path

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

the class VirtualNetworkTopologyManagerTest method testGetPathsUsingNullWeight.

/**
 * Test getPaths() method using a null weight.
 */
@Test(expected = NullPointerException.class)
public void testGetPathsUsingNullWeight() {
    VirtualNetwork virtualNetwork = setupVirtualNetworkTopology();
    TopologyService topologyService = manager.get(virtualNetwork.id(), TopologyService.class);
    Topology topology = topologyService.currentTopology();
    VirtualDevice srcVirtualDevice = getVirtualDevice(virtualNetwork.id(), DID1);
    VirtualDevice dstVirtualDevice = getVirtualDevice(virtualNetwork.id(), DID2);
    // test the getPaths() method using a null weight.
    Set<Path> paths = topologyService.getPaths(topology, srcVirtualDevice.id(), dstVirtualDevice.id(), (LinkWeigher) null);
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) Path(org.onosproject.net.Path) DisjointPath(org.onosproject.net.DisjointPath) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) Topology(org.onosproject.net.topology.Topology) TopologyService(org.onosproject.net.topology.TopologyService) Test(org.junit.Test)

Example 32 with Path

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

the class DefaultVirtualFlowRuleProvider method generateRuleForMulti.

/**
 * Generate physical rules when a virtual flow rule can be handled with
 * multiple physical switches.
 *
 * @param networkId The virtual network identifier
 * @param ingressPoint The ingress point of the physical network
 * @param egressPoint The egress point of the physical network
 * @param commonSelector A common traffic selector between the virtual
 *                       and physical flow rules
 * @param commonTreatment A common traffic treatment between the virtual
 *                        and physical flow rules
 * @param flowRule The virtual flow rule to be translated
 * @return A set of flow rules for the physical network
 */
private Set<FlowRule> generateRuleForMulti(NetworkId networkId, ConnectPoint ingressPoint, ConnectPoint egressPoint, TrafficSelector commonSelector, TrafficTreatment commonTreatment, FlowRule flowRule) {
    Set<FlowRule> outRules = new HashSet<>();
    Path internalPath = internalRoutingAlgorithm.findPath(ingressPoint, egressPoint);
    checkNotNull(internalPath, "No path between " + ingressPoint.toString() + " " + egressPoint.toString());
    ConnectPoint outCp = internalPath.links().get(0).src();
    // ingress point of tunnel
    TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder(commonSelector);
    selectorBuilder.matchInPort(ingressPoint.port());
    TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder(commonTreatment);
    // TODO: add the logic to check host location
    treatmentBuilder.pushVlan().setVlanId(VlanId.vlanId(networkId.id().shortValue()));
    treatmentBuilder.setOutput(outCp.port());
    FlowRule.Builder ruleBuilder = DefaultFlowRule.builder().fromApp(vnService.getVirtualNetworkApplicationId(networkId)).forDevice(ingressPoint.deviceId()).withSelector(selectorBuilder.build()).withIdleTimeout(flowRule.timeout()).withTreatment(treatmentBuilder.build()).withPriority(flowRule.priority());
    FlowRule rule = ruleBuilder.build();
    frm.addIngressRule(flowRule, rule, networkId);
    outRules.add(rule);
    // routing inside tunnel
    ConnectPoint inCp = internalPath.links().get(0).dst();
    if (internalPath.links().size() > 1) {
        for (Link l : internalPath.links().subList(1, internalPath.links().size())) {
            outCp = l.src();
            selectorBuilder = DefaultTrafficSelector.builder(commonSelector).matchVlanId(VlanId.vlanId(networkId.id().shortValue())).matchInPort(inCp.port());
            treatmentBuilder = DefaultTrafficTreatment.builder(commonTreatment).setOutput(outCp.port());
            ruleBuilder = DefaultFlowRule.builder().fromApp(vnService.getVirtualNetworkApplicationId(networkId)).forDevice(inCp.deviceId()).withSelector(selectorBuilder.build()).withTreatment(treatmentBuilder.build()).withIdleTimeout(flowRule.timeout()).withPriority(flowRule.priority());
            outRules.add(ruleBuilder.build());
            inCp = l.dst();
        }
    }
    // egress point of tunnel
    selectorBuilder = DefaultTrafficSelector.builder(commonSelector).matchVlanId(VlanId.vlanId(networkId.id().shortValue())).matchInPort(inCp.port());
    treatmentBuilder = DefaultTrafficTreatment.builder(commonTreatment).popVlan().setOutput(egressPoint.port());
    ruleBuilder = DefaultFlowRule.builder().fromApp(appId).forDevice(egressPoint.deviceId()).withSelector(selectorBuilder.build()).withTreatment(treatmentBuilder.build()).withIdleTimeout(flowRule.timeout()).withPriority(flowRule.priority());
    outRules.add(ruleBuilder.build());
    return outRules;
}
Also used : Path(org.onosproject.net.Path) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint) Link(org.onosproject.net.Link) HashSet(java.util.HashSet)

Example 33 with Path

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

the class AbstractPathServiceTest method checkPaths.

private void checkPaths(Collection<Path> paths) {
    assertThat(paths, notNullValue());
    assertThat(paths, hasSize(1));
    Path path = paths.iterator().next();
    checkPathValues(path);
}
Also used : DefaultPath(org.onosproject.net.DefaultPath) DefaultDisjointPath(org.onosproject.net.DefaultDisjointPath) Path(org.onosproject.net.Path) DisjointPath(org.onosproject.net.DisjointPath)

Example 34 with Path

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

the class AbstractPathServiceTest method testSelfPaths.

/**
 * Tests paths from a host.
 */
@Test
public void testSelfPaths() {
    HostId host = hid("12:34:56:78:90:ab/1");
    Set<Path> paths = service.getPaths(host, host, new TestWeigher());
    assertThat(paths, hasSize(1));
    Path path = paths.iterator().next();
    assertThat(path, not(nullValue()));
    assertThat(path.links(), hasSize(2));
    Link link1 = path.links().get(0);
    Link link2 = path.links().get(1);
    assertThat(link1.src(), is(link2.dst()));
    assertThat(link2.src(), is(link1.dst()));
    assertThat(link1.src().hostId(), is(host));
    assertThat(link2.dst().hostId(), is(host));
}
Also used : DefaultPath(org.onosproject.net.DefaultPath) DefaultDisjointPath(org.onosproject.net.DefaultDisjointPath) Path(org.onosproject.net.Path) DisjointPath(org.onosproject.net.DisjointPath) HostId(org.onosproject.net.HostId) Link(org.onosproject.net.Link) DefaultLink(org.onosproject.net.DefaultLink) Test(org.junit.Test)

Example 35 with Path

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

the class AbstractPathServiceTest method checkDisjointPaths.

private void checkDisjointPaths(Set<DisjointPath> paths) {
    assertThat(paths, notNullValue());
    assertThat(paths, hasSize(1));
    Path path = paths.iterator().next();
    checkPathValues(path);
}
Also used : DefaultPath(org.onosproject.net.DefaultPath) DefaultDisjointPath(org.onosproject.net.DefaultDisjointPath) Path(org.onosproject.net.Path) DisjointPath(org.onosproject.net.DisjointPath)

Aggregations

Path (org.onosproject.net.Path)60 DeviceId (org.onosproject.net.DeviceId)27 DefaultPath (org.onosproject.net.DefaultPath)24 Link (org.onosproject.net.Link)23 DisjointPath (org.onosproject.net.DisjointPath)22 ConnectPoint (org.onosproject.net.ConnectPoint)18 Test (org.junit.Test)16 ImmutableSet (com.google.common.collect.ImmutableSet)12 ArrayList (java.util.ArrayList)11 List (java.util.List)11 Set (java.util.Set)11 Collectors (java.util.stream.Collectors)10 DefaultLink (org.onosproject.net.DefaultLink)10 Intent (org.onosproject.net.intent.Intent)10 Collections (java.util.Collections)9 Topology (org.onosproject.net.topology.Topology)8 Logger (org.slf4j.Logger)8 Stream (java.util.stream.Stream)7 ScalarWeight (org.onlab.graph.ScalarWeight)7 HostId (org.onosproject.net.HostId)7