use of org.onosproject.ui.model.topo.UiDevice in project onos by opennetworkinglab.
the class ModelCache method addOrUpdateDevice.
// invoked from UiSharedTopologyModel device listener
void addOrUpdateDevice(Device device) {
DeviceId id = device.id();
String memo = MEMO_UPDATED;
UiDevice uiDevice = uiTopology.findDevice(id);
if (uiDevice == null) {
uiDevice = addNewDevice(device);
memo = MEMO_ADDED;
} else {
updateDevice(uiDevice);
}
postEvent(DEVICE_ADDED_OR_UPDATED, uiDevice, memo);
}
use of org.onosproject.ui.model.topo.UiDevice 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.UiDevice 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