use of org.onosproject.ui.model.topo.UiHost in project onos by opennetworkinglab.
the class ModelCache method addNewHost.
private UiHost addNewHost(Host h) {
UiHost host = new UiHost(uiTopology, h);
uiTopology.add(host);
EdgeLink elink = synthesizeLink(h);
UiLinkId elinkId = uiLinkId(elink);
host.setEdgeLinkId(elinkId);
// add synthesized edge link to the topology
addNewEdgeLink(elinkId);
return host;
}
use of org.onosproject.ui.model.topo.UiHost in project onos by opennetworkinglab.
the class ModelCacheTest method assertLocation.
private void assertLocation(HostId hid, DeviceId expDev, int expPort) {
UiHost h = cache.accessHost(hid);
assertEquals("unex device", expDev, h.locationDevice());
assertEquals("unex port", portNumber(expPort), h.locationPort());
}
use of org.onosproject.ui.model.topo.UiHost in project onos by opennetworkinglab.
the class ModelCache method loadHosts.
private void loadHosts() {
for (Host h : services.host().getHosts()) {
UiHost host = addNewHost(h);
updateHost(host, h);
}
}
use of org.onosproject.ui.model.topo.UiHost in project onos by opennetworkinglab.
the class ModelCache method reconcileDevicesAndHostsWithRegion.
private void reconcileDevicesAndHostsWithRegion(Set<UiDevice> allDevices, Set<UiHost> allHosts, RegionId rid, UiRegion region) {
Set<DeviceId> deviceIds = services.region().getRegionDevices(rid);
Set<HostId> hostIds = new HashSet<>();
region.reconcileDevices(deviceIds);
deviceIds.forEach(devId -> {
UiDevice dev = uiTopology.findDevice(devId);
if (dev != null) {
dev.setRegionId(rid);
allDevices.remove(dev);
} else {
log.warn("Region device ID {} but no UiDevice in topology", devId);
}
Set<Host> hosts = services.host().getConnectedHosts(devId);
for (Host h : hosts) {
HostId hid = h.id();
hostIds.add(hid);
UiHost host = uiTopology.findHost(hid);
if (host != null) {
host.setRegionId(rid);
allHosts.remove(host);
} else {
log.warn("Region host ID {} but no UiHost in topology", hid);
}
}
});
region.reconcileHosts(hostIds);
}
use of org.onosproject.ui.model.topo.UiHost in project onos by opennetworkinglab.
the class ModelCache method updateRegion.
private void updateRegion(UiRegion region) {
RegionId rid = region.id();
Set<DeviceId> deviceIds = services.region().getRegionDevices(rid);
Set<HostId> hostIds = services.region().getRegionHosts(rid);
// Make sure device objects refer to their region
deviceIds.forEach(d -> {
UiDevice dev = uiTopology.findDevice(d);
if (dev != null) {
dev.setRegionId(rid);
} else {
// if we don't have the UiDevice in the topology, what can we do?
log.warn("Region device {}, but we don't have UiDevice in topology", d);
}
});
hostIds.forEach(d -> {
UiHost host = uiTopology.findHost(d);
if (host != null) {
host.setRegionId(rid);
} else {
// if we don't have the UiDevice in the topology, what can we do?
log.warn("Region host {}, but we don't have UiHost in topology", d);
}
});
// Make sure the region object refers to the devices
region.reconcileDevices(deviceIds);
region.reconcileHosts(hostIds);
fixupContainmentHierarchy(region);
}
Aggregations