Search in sources :

Example 6 with UiDevice

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

Example 7 with UiDevice

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);
}
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 8 with UiDevice

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);
}
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

UiDevice (org.onosproject.ui.model.topo.UiDevice)8 DeviceId (org.onosproject.net.DeviceId)5 HostId (org.onosproject.net.HostId)3 UiHost (org.onosproject.ui.model.topo.UiHost)3 HashSet (java.util.HashSet)2 Device (org.onosproject.net.Device)2 RegionId (org.onosproject.net.region.RegionId)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 Test (org.junit.Test)1 Host (org.onosproject.net.Host)1 UiRegion (org.onosproject.ui.model.topo.UiRegion)1