use of org.onosproject.net.pi.model.PiPipeconfId in project onos by opennetworkinglab.
the class AbstractFabricHandlerBehavior method setCapabilitiesFromHandler.
private void setCapabilitiesFromHandler(DeviceId deviceId, PiPipeconfService pipeconfService) {
checkNotNull(deviceId);
checkNotNull(pipeconfService);
// Get pipeconf capabilities.
final PiPipeconfId pipeconfId = pipeconfService.ofDevice(deviceId).orElse(null);
if (pipeconfId == null) {
throw new IllegalStateException(format("Unable to get pipeconf ID of device %s", deviceId.toString()));
}
if (!pipeconfService.getPipeconf(pipeconfId).isPresent()) {
throw new IllegalStateException(format("Pipeconf '%s' is not registered ", pipeconfId));
}
this.capabilities = new FabricCapabilities(pipeconfService.getPipeconf(pipeconfId).get());
}
use of org.onosproject.net.pi.model.PiPipeconfId in project onos by opennetworkinglab.
the class DriverManager method getPipeconfMergedDriver.
private Driver getPipeconfMergedDriver(DeviceId deviceId) {
PiPipeconfId pipeconfId = pipeconfService.ofDevice(deviceId).orElse(null);
if (pipeconfId == null) {
log.warn("Missing pipeconf for {}, cannot produce a pipeconf merged driver", deviceId);
return null;
}
String mergedDriverName = pipeconfService.getMergedDriver(deviceId, pipeconfId);
if (mergedDriverName == null) {
log.warn("Unable to get pipeconf merged driver for {} and {}", deviceId, pipeconfId);
return null;
}
try {
return getDriver(mergedDriverName);
} catch (ItemNotFoundException e) {
log.warn("Specified pipeconf merged driver {} for {} not found", mergedDriverName, deviceId);
return null;
}
}
use of org.onosproject.net.pi.model.PiPipeconfId in project onos by opennetworkinglab.
the class PiPipeconfWatchdogManager method probeTask.
private void probeTask(Device device) {
if (!isLocalMaster(device)) {
return;
}
final PiPipeconfId pipeconfId = pipeconfMappingStore.getPipeconfId(device.id());
if (pipeconfId == null || !device.is(PiPipelineProgrammable.class)) {
return;
}
if (pipeconfService.getPipeconf(pipeconfId).isEmpty()) {
log.warn("Pipeconf {} is not registered, skipping probe for {}", pipeconfId, device.id());
return;
}
final PiPipeconf pipeconf = pipeconfService.getPipeconf(pipeconfId).get();
if (!device.is(DeviceHandshaker.class)) {
log.error("Missing DeviceHandshaker behavior for {}", device.id());
return;
}
final boolean success = doSetPipeconfIfRequired(device, pipeconf);
// the mastership after pipeline probe returns.
if (isLocalMaster(device)) {
// (next reconcile interval)
if (success) {
signalStatusReady(device.id());
signalStatusConfigured(device.id());
} else {
// When a network partition occurs watchdog is stuck for LONG_TIMEOUT
// before returning and will mark the device offline. However, in the
// meanwhile the mastership has been passed to another instance which is
// already connected and has already marked the device online.
signalStatusUnknown(device.id());
}
} else {
log.warn("No longer the master for {} aborting probe task", device.id());
}
}
use of org.onosproject.net.pi.model.PiPipeconfId in project onos by opennetworkinglab.
the class GeneralDeviceProvider method getPipeconfId.
private PiPipeconfId getPipeconfId(DeviceId deviceId, PiPipelineProgrammable pipelineProg) {
// Places to look for a pipeconf ID (in priority order)):
// 1) netcfg
// 2) device driver (default one)
final PiPipeconfId pipeconfId = getPipeconfFromCfg(deviceId);
if (pipeconfId != null && !pipeconfId.id().isEmpty()) {
return pipeconfId;
}
if (pipelineProg != null && pipelineProg.getDefaultPipeconf().isPresent()) {
final PiPipeconf defaultPipeconf = pipelineProg.getDefaultPipeconf().get();
log.info("Using default pipeconf {} for {}", defaultPipeconf.id(), deviceId);
return defaultPipeconf.id();
}
return null;
}
use of org.onosproject.net.pi.model.PiPipeconfId 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