use of org.onosproject.net.HostId in project onos by opennetworkinglab.
the class UiTopologyTest method mockTopology.
@Test
public void mockTopology() {
host = new DefaultHost(PID, HID, MAC_ADDRESS, VID, LOC, IPSET);
uiHost = new UiHost(topo, host);
deviceLink = new UiDeviceLink(topo, DX1_DY2);
edgeLink = DefaultEdgeLink.createEdgeLink(CP, true);
linkId = UiLinkId.uiLinkId(edgeLink);
uiEdgeLink = new UiEdgeLink(topo, linkId);
mem1 = clusterMember(MID, 001);
region1 = region();
dev1 = device();
Set<DeviceId> deviceIds = new HashSet<>();
Set<HostId> hostIds = new HashSet<>();
topo.add(uiHost);
topo.add(mem1);
topo.add(region1);
topo.add(dev1);
topo.add(deviceLink);
topo.add(uiEdgeLink);
assertTrue(topo.allRegions().contains(region1));
assertTrue(topo.allClusterMembers().contains(mem1));
assertTrue(topo.findClusterMember(NodeId.nodeId("id1")).equals(mem1));
assertTrue(topo.findRegion(R1).equals(region1));
assertTrue(topo.findDevice(DID).equals(dev1));
assertTrue(topo.findHost(HID).equals(uiHost));
assertTrue(topo.findDeviceLink(DX1_DY2).equals(deviceLink));
deviceIds.add(DID);
assertTrue(topo.deviceSet(deviceIds).contains(dev1));
hostIds.add(HID);
assertTrue(topo.hostSet(hostIds).contains(uiHost));
topo.clear();
assertThat(topo.allClusterMembers(), is(empty()));
assertThat(topo.allDeviceLinks(), is(empty()));
assertThat(topo.allDevices(), is(empty()));
assertThat(topo.allHosts(), is(empty()));
assertThat(topo.allRegions(), is(empty()));
}
use of org.onosproject.net.HostId in project onos by opennetworkinglab.
the class IntentMonitorAndRerouteManager method applyPath.
@Override
public boolean applyPath(Route route) {
checkNotNull(route, "Route to apply must be not null");
checkNotNull(route.appId(), "Application id must be not null");
checkNotNull(route.key(), "Intent key to apply must be not null");
checkNotNull(route.paths(), "New path must be not null");
checkArgument(route.paths().size() >= 1);
ApplicationId appId = route.appId();
Key key = route.key();
// check if the app and the intent key are monitored
if (!monitoredIntents.containsKey(appId)) {
return false;
}
if (!monitoredIntents.get(appId).containsKey(key)) {
return false;
}
// TODO: now we manage only the unsplittable routing
Path currentPath = route.paths().stream().max(Comparator.comparing(Path::weight)).get();
// in this case remove them from the list
if (currentPath.path().get(0) instanceof HostId) {
currentPath.path().remove(0);
}
if (currentPath.path().get(currentPath.path().size() - 1) instanceof HostId) {
currentPath.path().remove(currentPath.path().size() - 1);
}
List<Link> links = createPathFromDeviceList(currentPath.path());
// Generate the new Link collection intent, if not possible it will return the old intent
ConnectivityIntent intent = generateLinkCollectionIntent(links, key, appId);
storeMonitoredIntent(intent);
intentService.submit(intent);
return true;
}
use of org.onosproject.net.HostId in project onos by opennetworkinglab.
the class PathManagerTest method edgeToEdgeDirect.
@Test
public void edgeToEdgeDirect() {
HostId src = hid("12:34:56:78:90:ab/1");
HostId dst = hid("12:34:56:78:90:ef/1");
fakeHostMgr.hosts.put(src, host("12:34:56:78:90:ab/1", "edge"));
fakeHostMgr.hosts.put(dst, host("12:34:56:78:90:ef/1", "edge"));
Set<Path> paths = service.getPaths(src, dst);
validatePaths(paths, 1, 2, src, dst);
validatePaths(service.getKShortestPaths(src, dst).collect(Collectors.toSet()), 1, 2, src, dst);
}
use of org.onosproject.net.HostId in project onos by opennetworkinglab.
the class PathManagerTest method edgeToInfra.
@Test
public void edgeToInfra() {
HostId src = hid("12:34:56:78:90:ab/1");
DeviceId dst = did("dst");
fakeTopoMgr.paths.add(createPath("edge", "middle", "dst"));
fakeHostMgr.hosts.put(src, host("12:34:56:78:90:ab/1", "edge"));
Set<Path> paths = service.getPaths(src, dst);
validatePaths(paths, 1, 3, src, dst);
}
use of org.onosproject.net.HostId in project onos by opennetworkinglab.
the class PathManagerTest method edgeToEdge.
@Test
public void edgeToEdge() {
HostId src = hid("12:34:56:78:90:ab/1");
HostId dst = hid("12:34:56:78:90:ef/1");
fakeTopoMgr.paths.add(createPath("srcEdge", "middle", "dstEdge"));
fakeHostMgr.hosts.put(src, host("12:34:56:78:90:ab/1", "srcEdge"));
fakeHostMgr.hosts.put(dst, host("12:34:56:78:90:ef/1", "dstEdge"));
Set<Path> paths = service.getPaths(src, dst);
validatePaths(paths, 1, 4, src, dst);
validatePaths(service.getKShortestPaths(src, dst).collect(Collectors.toSet()), 1, 4, src, dst);
}
Aggregations