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);
}
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;
}
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);
}
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));
}
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);
}
Aggregations