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

The following examples show how to use org.onosproject.net.device.DeviceEvent#subject() . 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: 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 4
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 5
Source File: HostLocationProvider.java    From onos with Apache License 2.0 5 votes vote down vote up
private void handleEvent(DeviceEvent event) {
    Device device = event.subject();
    switch (event.type()) {
        case DEVICE_ADDED:
            break;
        case DEVICE_AVAILABILITY_CHANGED:
            if (hostRemovalEnabled && !deviceService.isAvailable(device.id())) {
                processDeviceDown(device.id());
            }
            break;
        case DEVICE_SUSPENDED:
        case DEVICE_UPDATED:
            // Nothing to do?
            break;
        case DEVICE_REMOVED:
            if (hostRemovalEnabled) {
                processDeviceDown(device.id());
            }
            break;
        case PORT_ADDED:
            break;
        case PORT_UPDATED:
            if (hostRemovalEnabled && !event.port().isEnabled()) {
                processPortDown(new ConnectPoint(device.id(), event.port().number()));
            }
            break;
        case PORT_REMOVED:
            if (hostRemovalEnabled) {
                processPortDown(new ConnectPoint(device.id(), event.port().number()));
            }
            break;
        default:
            break;
    }
}
 
Example 6
Source File: OpticalDeviceServiceView.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Transform Port instance on the event to Optical specific port, if it is well-formed.
 *
 * @param event original event to transform
 * @return transformed {@link DeviceEvent}
 */
public DeviceEvent augment(DeviceEvent event) {
    final Port port = augment(event.port());
    if (port == event.port()) {
        // If the Port not changed, pass through
        return event;
    }
    return new DeviceEvent(event.type(), event.subject(), port, event.time());
}
 
Example 7
Source File: FlowRuleDriverProvider.java    From onos with Apache License 2.0 5 votes vote down vote up
private void handleEvent(DeviceEvent event) {
    Device device = event.subject();
    boolean isRelevant = mastershipService.isLocalMaster(device.id()) &&
            deviceService.isAvailable(device.id());

    if (isRelevant) {
        pollDeviceFlowEntries(device);
    }
}
 
Example 8
Source File: GroupDriverProvider.java    From onos with Apache License 2.0 5 votes vote down vote up
private void handleEvent(DeviceEvent event) {
    Device device = event.subject();
    boolean isRelevant = mastershipService.isLocalMaster(device.id()) &&
            deviceService.isAvailable(device.id());

    if (isRelevant) {
        pollDeviceGroups(device.id());
    }
}
 
Example 9
Source File: MeterDriverProvider.java    From onos with Apache License 2.0 5 votes vote down vote up
private void handleEvent(DeviceEvent event) {
    Device device = event.subject();
    boolean isRelevant = mastershipService.isLocalMaster(device.id()) &&
            deviceService.isAvailable(device.id());

    if (isRelevant) {
        pollDeviceMeters(device.id());
    }
}
 
Example 10
Source File: TopologyHandler.java    From onos with Apache License 2.0 4 votes vote down vote up
private boolean isValid(DeviceEvent deviceEvent) {
    Device device = deviceEvent.subject();
    // We don't process the event if the device is available
    return !srManager.deviceService.isAvailable(device.id());
}
 
Example 11
Source File: FlowRuleDriverProvider.java    From onos with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isRelevant(DeviceEvent event) {
    Device device = event.subject();
    return POSITIVE_DEVICE_EVENT.contains(event.type()) &&
           device.is(FlowRuleProgrammable.class);
}
 
Example 12
Source File: GroupDriverProvider.java    From onos with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isRelevant(DeviceEvent event) {
    Device device = event.subject();
    return POSITIVE_DEVICE_EVENT.contains(event.type()) &&
            device.is(GroupProgrammable.class);
}
 
Example 13
Source File: MeterDriverProvider.java    From onos with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isRelevant(DeviceEvent event) {
    Device device = event.subject();
    return POSITIVE_DEVICE_EVENT.contains(event.type()) &&
            device.is(MeterProgrammable.class);
}