use of org.onosproject.net.device.DeviceEvent.Type.PORT_UPDATED in project onos by opennetworkinglab.
the class EdgeManager method processDeviceEvent.
// Processes a device event by adding or removing its end-points in our cache.
private void processDeviceEvent(DeviceEvent event) {
// FIXME handle the case where a device is suspended, this may or may not come up
DeviceEvent.Type type = event.type();
DeviceId id = event.subject().id();
if (type == DEVICE_ADDED || type == DEVICE_AVAILABILITY_CHANGED && deviceService.isAvailable(id)) {
// When device is added or becomes available, add all its ports
deviceService.getPorts(event.subject().id()).forEach(p -> addEdgePort(new ConnectPoint(id, p.number())));
} else if (type == DEVICE_REMOVED || type == DEVICE_AVAILABILITY_CHANGED && !deviceService.isAvailable(id)) {
// When device is removed or becomes unavailable, remove all its ports.
// Note: cannot rely on Device subsystem, ports may be gone.
Optional.ofNullable(connectionPoints.remove(id)).orElse(ImmutableSet.of()).forEach(point -> post(new EdgePortEvent(EDGE_PORT_REMOVED, point)));
} else if (type == DeviceEvent.Type.PORT_ADDED || type == PORT_UPDATED && event.port().isEnabled()) {
addEdgePort(new ConnectPoint(id, event.port().number()));
} else if (type == DeviceEvent.Type.PORT_REMOVED || type == PORT_UPDATED && !event.port().isEnabled()) {
removeEdgePort(new ConnectPoint(id, event.port().number()));
}
}
Aggregations