Java Code Examples for org.onosproject.net.device.DeviceEvent#type()

The following examples show how to use org.onosproject.net.device.DeviceEvent#type() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Ovs.java    From onos with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isCompleted(WorkflowContext context, Event event) throws WorkflowException {
    if (!(event instanceof DeviceEvent)) {
        return false;
    }
    DeviceEvent deviceEvent = (DeviceEvent) event;
    Device device = deviceEvent.subject();
    switch (deviceEvent.type()) {
        case DEVICE_ADDED:
        case DEVICE_AVAILABILITY_CHANGED:
        case DEVICE_UPDATED:
            return context.getService(DeviceService.class).isAvailable(device.id());
        default:
            return false;
    }
}
 
Example 2
Source File: Ovs.java    From onos with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isCompleted(WorkflowContext context, Event event) throws WorkflowException {
    if (!(event instanceof DeviceEvent)) {
        return false;
    }
    DeviceEvent deviceEvent = (DeviceEvent) event;
    Device device = deviceEvent.subject();
    switch (deviceEvent.type()) {
        case DEVICE_ADDED:
        case DEVICE_AVAILABILITY_CHANGED:
        case DEVICE_UPDATED:
            return context.getService(DeviceService.class).isAvailable(device.id());
        default:
            return false;
    }
}
 
Example 3
Source File: RoadmManager.java    From onos with Apache License 2.0 6 votes vote down vote up
@Override
public void event(DeviceEvent deviceEvent) {
    Device device = deviceEvent.subject();

    switch (deviceEvent.type()) {
        case DEVICE_ADDED:
        case DEVICE_UPDATED:
            initDevice(device.id());
            break;
        case PORT_ADDED:
        case PORT_UPDATED:
            //FIXME
            // As roadm application is a optional tool for now.
            // The target power initialization will be enhanced later,
            // hopefully using an formal optical subsystem.
            // setInitialTargetPortPower(device.id(), deviceEvent.port().number());
            break;
        default:
            break;

    }
}
 
Example 4
Source File: Ipv6RoutingComponent.java    From onos-p4-tutorial with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isRelevant(DeviceEvent event) {
    switch (event.type()) {
        case DEVICE_AVAILABILITY_CHANGED:
        case DEVICE_ADDED:
            break;
        default:
            return false;
    }
    // Process device event if this controller instance is the master
    // for the device and the device is available.
    DeviceId deviceId = event.subject().id();
    return mastershipService.isLocalMaster(deviceId) &&
            deviceService.isAvailable(event.subject().id());
}
 
Example 5
Source File: Ovs.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isCompleted(WorkflowContext context, Event event) throws WorkflowException {
    if (!(event instanceof DeviceEvent)) {
        return false;
    }
    DeviceEvent deviceEvent = (DeviceEvent) event;
    switch (deviceEvent.type()) {
        case DEVICE_REMOVED:
            log.trace("GOT DEVICE REMOVED EVENT FOR DEVICE {}", event.subject());
            return !isNext(context);
        default:
            return false;
    }
}
 
Example 6
Source File: NetconfDeviceProvider.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isRelevant(DeviceEvent event) {
    if (event.type() != DeviceEvent.Type.DEVICE_ADDED &&
            event.type() != DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED) {
        return false;
    }
    return (SCHEME_NAME.equalsIgnoreCase(event.subject().annotations().value(AnnotationKeys.PROTOCOL)) ||
            (SCHEME_NAME.equalsIgnoreCase(event.subject().id().uri().getScheme()))) &&
            mastershipService.isLocalMaster(event.subject().id());
}
 
Example 7
Source File: Ovs.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isCompleted(WorkflowContext context, Event event) throws WorkflowException {
    if (!(event instanceof DeviceEvent)) {
        return false;
    }
    DeviceEvent deviceEvent = (DeviceEvent) event;
    switch (deviceEvent.type()) {
        case DEVICE_REMOVED:
            return !isNext(context);
        default:
            return false;
    }
}
 
Example 8
Source File: StatsPoller.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isRelevant(DeviceEvent event) {
    switch (event.type()) {
        case DEVICE_ADDED:
        case DEVICE_UPDATED:
        case DEVICE_AVAILABILITY_CHANGED:
        case DEVICE_REMOVED:
        case DEVICE_SUSPENDED:
            return true;
        default:
            return false;
    }
}
 
Example 9
Source File: Srv6Component.java    From onos-p4-tutorial with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isRelevant(DeviceEvent event) {
    switch (event.type()) {
        case DEVICE_ADDED:
        case DEVICE_AVAILABILITY_CHANGED:
            break;
        default:
            // Ignore other events.
            return false;
    }
    // Process only if this controller instance is the master.
    final DeviceId deviceId = event.subject().id();
    return mastershipService.isLocalMaster(deviceId);
}
 
Example 10
Source File: NdpReplyComponent.java    From ngsdn-tutorial with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isRelevant(DeviceEvent event) {
    switch (event.type()) {
        case DEVICE_ADDED:
        case DEVICE_AVAILABILITY_CHANGED:
            break;
        default:
            // Ignore other events.
            return false;
    }
    // Process only if this controller instance is the master.
    final DeviceId deviceId = event.subject().id();
    return mastershipService.isLocalMaster(deviceId);
}
 
Example 11
Source File: L2BridgingComponent.java    From onos-p4-tutorial with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isRelevant(DeviceEvent event) {
    switch (event.type()) {
        case DEVICE_ADDED:
        case DEVICE_AVAILABILITY_CHANGED:
            break;
        default:
            // Ignore other events.
            return false;
    }
    // Process only if this controller instance is the master.
    final DeviceId deviceId = event.subject().id();
    return mastershipService.isLocalMaster(deviceId);
}
 
Example 12
Source File: EventHistoryManager.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isRelevant(DeviceEvent event) {
    if (excludeStatsEvent) {
        return event.type() != DeviceEvent.Type.PORT_STATS_UPDATED;
    } else {
        return true;
    }
}
 
Example 13
Source File: Ipv6RoutingComponent.java    From onos-p4-tutorial with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isRelevant(DeviceEvent event) {
    switch (event.type()) {
        case DEVICE_AVAILABILITY_CHANGED:
        case DEVICE_ADDED:
            break;
        default:
            return false;
    }
    // Process device event if this controller instance is the master
    // for the device and the device is available.
    DeviceId deviceId = event.subject().id();
    return mastershipService.isLocalMaster(deviceId) &&
            deviceService.isAvailable(event.subject().id());
}
 
Example 14
Source File: Ovs.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isCompleted(WorkflowContext context, Event event) throws WorkflowException {
    if (!(event instanceof DeviceEvent)) {
        return false;
    }
    DeviceEvent deviceEvent = (DeviceEvent) event;
    switch (deviceEvent.type()) {
        case DEVICE_REMOVED:
            return !isNext(context);
        default:
            return false;
    }
}
 
Example 15
Source File: ScalableGatewayManager.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public void event(DeviceEvent deviceEvent) {
    if (deviceEvent.type() == DeviceEvent.Type.DEVICE_SUSPENDED ||
            deviceEvent.type() == DeviceEvent.Type.DEVICE_REMOVED) {
        DeviceId deviceId = deviceEvent.subject().id();
        deleteGatewayNode(getGatewayNode(deviceId));
        log.warn("Gateway with device ID {} is disconnected", deviceId);
    }
}
 
Example 16
Source File: L2BridgingComponent.java    From ngsdn-tutorial with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isRelevant(DeviceEvent event) {
    switch (event.type()) {
        case DEVICE_ADDED:
        case DEVICE_AVAILABILITY_CHANGED:
            break;
        default:
            // Ignore other events.
            return false;
    }
    // Process only if this controller instance is the master.
    final DeviceId deviceId = event.subject().id();
    return mastershipService.isLocalMaster(deviceId);
}
 
Example 17
Source File: Ovs.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isCompleted(WorkflowContext context, Event event) throws WorkflowException {
    if (!(event instanceof DeviceEvent)) {
        return false;
    }
    DeviceEvent deviceEvent = (DeviceEvent) event;
    switch (deviceEvent.type()) {
        case PORT_ADDED:
            return !isNext(context);
        default:
            return false;
    }
}
 
Example 18
Source File: XconnectManager.java    From onos with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isRelevant(DeviceEvent event) {
    return event.type() == DeviceEvent.Type.DEVICE_ADDED ||
            event.type() == DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED ||
            event.type() == DeviceEvent.Type.DEVICE_UPDATED;
}
 
Example 19
Source File: OvsdbDeviceProvider.java    From onos with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isRelevant(DeviceEvent event) {
    DeviceId deviceId = event.subject().id();
    return event.type() == DeviceEvent.Type.DEVICE_ADDED &&
            isRelevant(deviceId) && mastershipService.isLocalMaster(deviceId);
}
 
Example 20
Source File: PacketManager.java    From onos with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isRelevant(DeviceEvent event) {
    return event.type() == DeviceEvent.Type.DEVICE_ADDED ||
            event.type() == DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED;
}