use of org.onosproject.net.behaviour.PiPipelineProgrammable in project onos by opennetworkinglab.
the class PiPipeconfWatchdogManager method doSetPipeconfIfRequired.
/**
* Returns true if the given device is known to be configured with the given
* pipeline, false otherwise. If necessary, this method enforces setting the
* given pipeconf using drivers.
*
* @param device device
* @param pipeconf pipeconf
* @return boolean
*/
private boolean doSetPipeconfIfRequired(Device device, PiPipeconf pipeconf) {
log.debug("Starting watchdog task for {} ({})", device.id(), pipeconf.id());
final PiPipelineProgrammable pipelineProg = device.as(PiPipelineProgrammable.class);
final DeviceHandshaker handshaker = device.as(DeviceHandshaker.class);
if (!handshaker.hasConnection()) {
log.warn("There is no connectivity with {}", device.id());
return false;
}
if (Futures.getUnchecked(pipelineProg.isPipeconfSet(pipeconf)) && configuredDevices.contains(device.id())) {
log.debug("Pipeconf {} already configured on {}", pipeconf.id(), device.id());
return true;
}
return Futures.getUnchecked(pipelineProg.setPipeconf(pipeconf));
}
use of org.onosproject.net.behaviour.PiPipelineProgrammable 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