Search in sources :

Example 1 with DeviceTaskException

use of org.onosproject.provider.general.device.impl.DeviceTaskExecutor.DeviceTaskException in project onos by opennetworkinglab.

the class GeneralDeviceProvider method handleConnectionSetup.

private void handleConnectionSetup(DeviceId deviceId) {
    assertConfig(deviceId);
    // Bind pipeconf (if any and if device is capable).
    bindPipeconfIfRequired(deviceId);
    // Get handshaker.
    final DeviceHandshaker handshaker = handshakerOrFail(deviceId);
    if (handshaker.hasConnection() || handshakersWithListeners.containsKey(deviceId)) {
        throw new DeviceTaskException("connection already exists");
    }
    // Add device agent listener.
    handshakersWithListeners.put(deviceId, handshaker);
    handshaker.addDeviceAgentListener(id(), deviceAgentListener);
    // Start connection via handshaker.
    if (!handshaker.connect()) {
        // Failed! Remove listeners.
        handshaker.removeDeviceAgentListener(id());
        handshakersWithListeners.remove(deviceId);
        // Clean up connection state leftovers.
        handshaker.disconnect();
        throw new DeviceTaskException("connection failed");
    }
    createOrUpdateDevice(deviceId, false);
// From here we expect a CHANNEL_OPEN event to update availability.
}
Also used : DeviceHandshaker(org.onosproject.net.device.DeviceHandshaker) DeviceTaskException(org.onosproject.provider.general.device.impl.DeviceTaskExecutor.DeviceTaskException)

Example 2 with DeviceTaskException

use of org.onosproject.provider.general.device.impl.DeviceTaskExecutor.DeviceTaskException in project onos by opennetworkinglab.

the class GeneralDeviceProvider method bindPipeconfIfRequired.

private void bindPipeconfIfRequired(DeviceId deviceId) {
    if (pipeconfService.getPipeconf(deviceId).isPresent() || !isPipelineProgrammable(deviceId)) {
        // Device has already a pipeconf or is not programmable.
        return;
    }
    // Get pipeconf from netcfg or driver (default one).
    final PiPipelineProgrammable pipelineProg = getBehaviour(deviceId, PiPipelineProgrammable.class);
    final PiPipeconfId pipeconfId = getPipeconfId(deviceId, pipelineProg);
    if (pipeconfId == null) {
        throw new DeviceTaskException("unable to find pipeconf");
    }
    if (!pipeconfService.getPipeconf(pipeconfId).isPresent()) {
        throw new DeviceTaskException(format("pipeconf %s not registered", pipeconfId));
    }
    // Store binding in pipeconf service.
    pipeconfService.bindToDevice(pipeconfId, deviceId);
}
Also used : PiPipelineProgrammable(org.onosproject.net.behaviour.PiPipelineProgrammable) PiPipeconfId(org.onosproject.net.pi.model.PiPipeconfId) DeviceTaskException(org.onosproject.provider.general.device.impl.DeviceTaskExecutor.DeviceTaskException)

Aggregations

DeviceTaskException (org.onosproject.provider.general.device.impl.DeviceTaskExecutor.DeviceTaskException)2 PiPipelineProgrammable (org.onosproject.net.behaviour.PiPipelineProgrammable)1 DeviceHandshaker (org.onosproject.net.device.DeviceHandshaker)1 PiPipeconfId (org.onosproject.net.pi.model.PiPipeconfId)1