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