Search in sources :

Example 6 with UiHost

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

Example 7 with UiHost

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

Example 8 with UiHost

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

Example 9 with UiHost

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

Example 10 with UiHost

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);
}
Also used : DeviceId(org.onosproject.net.DeviceId) 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)

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