use of org.onosproject.ui.model.topo.UiRegion in project onos by opennetworkinglab.
the class ModelCache method loadRegions.
private void loadRegions() {
for (Region r : services.region().getRegions()) {
UiRegion region = addNewRegion(r);
updateRegion(region);
}
}
use of org.onosproject.ui.model.topo.UiRegion in project onos by opennetworkinglab.
the class ModelCache method addOrUpdateRegion.
// invoked from UiSharedTopologyModel region listener
void addOrUpdateRegion(Region region) {
RegionId id = region.id();
String memo = MEMO_UPDATED;
UiRegion uiRegion = uiTopology.findRegion(id);
if (uiRegion == null) {
uiRegion = addNewRegion(region);
memo = MEMO_ADDED;
}
updateRegion(uiRegion);
postEvent(REGION_ADDED_OR_UPDATED, uiRegion, memo);
}
use of org.onosproject.ui.model.topo.UiRegion in project onos by opennetworkinglab.
the class ModelCache method refresh.
/**
* Refreshes the internal state.
*/
public void refresh() {
// fix up internal linkages to ensure they are correct
// make sure regions reflect layout containment hierarchy
fixupContainmentHierarchy(uiTopology.nullRegion());
uiTopology.allRegions().forEach(this::fixupContainmentHierarchy);
// make sure devices and hosts are in the correct region
Set<UiDevice> allDevices = uiTopology.allDevices();
Set<UiHost> allHosts = uiTopology.allHosts();
services.region().getRegions().forEach(r -> {
RegionId rid = r.id();
UiRegion region = uiTopology.findRegion(rid);
if (region != null) {
reconcileDevicesAndHostsWithRegion(allDevices, allHosts, rid, region);
} else {
log.warn("No UiRegion in topology for ID {}", rid);
}
});
// what is left over, must belong to the null-region
Set<DeviceId> leftOver = new HashSet<>(allDevices.size());
allDevices.forEach(d -> leftOver.add(d.id()));
uiTopology.nullRegion().reconcileDevices(leftOver);
Set<HostId> leftOverHosts = new HashSet<>(allHosts.size());
allHosts.forEach(h -> leftOverHosts.add(h.id()));
uiTopology.nullRegion().reconcileHosts(leftOverHosts);
// now that we have correct region hierarchy, and devices are in their
// respective regions, we can compute synthetic links for each region.
uiTopology.computeSynthLinks();
}
use of org.onosproject.ui.model.topo.UiRegion in project onos by opennetworkinglab.
the class Topo2Jsonifier method jsonClosedRegion.
private ObjectNode jsonClosedRegion(String ridStr, UiRegion region) {
ObjectNode node = objectNode().put("id", region.idAsString()).put("name", region.name()).put("nodeType", REGION).put("nDevs", region.deviceCount()).put("nHosts", region.hostCount());
// TODO: device and host counts should take into account any nested
// subregions. i.e. should be the sum of all devices/hosts in
// all descendant subregions.
Region r = region.backingRegion();
if (r != null) {
// add data injected via network configuration script
addGeoGridLocation(node, r);
addProps(node, r);
}
// this may contain location data, as dragged by user
// (which should take precedence, over configured data)
addMetaUi(node, ridStr, region.idAsString());
return node;
}
use of org.onosproject.ui.model.topo.UiRegion in project onos by opennetworkinglab.
the class UiTopoSession method event.
@Override
public void event(UiModelEvent event) {
// they are created
if (event.type() == UiModelEvent.Type.DEVICE_ADDED_OR_UPDATED && event.memo().equals("added")) {
UiRegion uiRegion = sharedModel.getRegion(currentLayout.regionId());
uiRegion.newDeviceAdded(DeviceId.deviceId(event.subject().idAsString()));
} else if (event.type() == UiModelEvent.Type.DEVICE_REMOVED) {
UiRegion uiRegion = sharedModel.getRegion(currentLayout.regionId());
uiRegion.deviceRemoved(DeviceId.deviceId(event.subject().idAsString()));
}
webSocket.sendMessage(TOPO2_UI_MODEL_EVENT, t2json.jsonEvent(event));
}
Aggregations