use of org.onosproject.ui.model.topo.UiHost in project onos by opennetworkinglab.
the class Topo2Jsonifier method json.
private ObjectNode json(String ridStr, UiHost host) {
ObjectNode node = objectNode().put("id", host.idAsString()).put("nodeType", HOST).put("layer", host.layer());
// TODO: complete host details
Host h = host.backingHost();
// h will be null, for example, after a HOST_REMOVED event
if (h != null) {
addIps(node, h);
addProps(node, h);
addGeoGridLocation(node, h);
node.put("configured", h.configured());
}
addMetaUi(node, ridStr, host.idAsString());
return node;
}
use of org.onosproject.ui.model.topo.UiHost in project onos by opennetworkinglab.
the class ModelCache method addOrUpdateHost.
// invoked from UiSharedTopologyModel host listener
void addOrUpdateHost(Host host) {
HostId id = host.id();
String memo = MEMO_UPDATED;
UiHost uiHost = uiTopology.findHost(id);
if (uiHost == null) {
uiHost = addNewHost(host);
memo = MEMO_ADDED;
}
updateHost(uiHost, host);
postEvent(HOST_ADDED_OR_UPDATED, uiHost, memo);
// Link event must be sent after the host event
UiEdgeLink uiEdgeLink = uiTopology.findEdgeLink(uiHost.edgeLinkId());
postEvent(LINK_ADDED_OR_UPDATED, uiEdgeLink, memo);
}
use of org.onosproject.ui.model.topo.UiHost in project onos by opennetworkinglab.
the class ModelCache method removeHost.
// invoked from UiSharedTopologyModel host listener
void removeHost(Host host) {
HostId id = host.id();
UiHost uiHost = uiTopology.findHost(id);
if (uiHost != null) {
UiEdgeLink edgeLink = uiTopology.findEdgeLink(uiHost.edgeLinkId());
uiTopology.remove(edgeLink);
postEvent(LINK_REMOVED, edgeLink, MEMO_REMOVED);
uiTopology.remove(uiHost);
postEvent(HOST_REMOVED, uiHost, MEMO_REMOVED);
} else {
log.warn(E_NO_ELEMENT, "host", id);
}
}
use of org.onosproject.ui.model.topo.UiHost 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.UiHost in project onos by opennetworkinglab.
the class ModelCache method moveHost.
// invoked from UiSharedTopologyModel host listener
void moveHost(Host host, Host prevHost) {
UiHost uiHost = uiTopology.findHost(prevHost.id());
if (uiHost != null) {
updateHost(uiHost, host);
postEvent(HOST_MOVED, uiHost, MEMO_MOVED);
} else {
log.warn(E_NO_ELEMENT, "host", prevHost.id());
}
}
Aggregations