Search in sources :

Example 1 with UiHost

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;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Host(org.onosproject.net.Host) UiHost(org.onosproject.ui.model.topo.UiHost)

Example 2 with UiHost

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);
}
Also used : UiEdgeLink(org.onosproject.ui.model.topo.UiEdgeLink) UiHost(org.onosproject.ui.model.topo.UiHost) HostId(org.onosproject.net.HostId)

Example 3 with UiHost

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);
    }
}
Also used : UiEdgeLink(org.onosproject.ui.model.topo.UiEdgeLink) UiHost(org.onosproject.ui.model.topo.UiHost) HostId(org.onosproject.net.HostId)

Example 4 with UiHost

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();
}
Also used : DeviceId(org.onosproject.net.DeviceId) UiRegion(org.onosproject.ui.model.topo.UiRegion) UiDevice(org.onosproject.ui.model.topo.UiDevice) UiHost(org.onosproject.ui.model.topo.UiHost) RegionId(org.onosproject.net.region.RegionId) HostId(org.onosproject.net.HostId) HashSet(java.util.HashSet)

Example 5 with UiHost

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());
    }
}
Also used : UiHost(org.onosproject.ui.model.topo.UiHost)

Aggregations

UiHost (org.onosproject.ui.model.topo.UiHost)10 HostId (org.onosproject.net.HostId)5 DeviceId (org.onosproject.net.DeviceId)3 Host (org.onosproject.net.Host)3 UiDevice (org.onosproject.ui.model.topo.UiDevice)3 UiEdgeLink (org.onosproject.ui.model.topo.UiEdgeLink)3 HashSet (java.util.HashSet)2 RegionId (org.onosproject.net.region.RegionId)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 DefaultEdgeLink.createEdgeLink (org.onosproject.net.DefaultEdgeLink.createEdgeLink)1 EdgeLink (org.onosproject.net.EdgeLink)1 UiLinkId (org.onosproject.ui.model.topo.UiLinkId)1 UiRegion (org.onosproject.ui.model.topo.UiRegion)1