use of org.onosproject.net.pi.model.PiPipeconfId in project onos by opennetworkinglab.
the class PiPipeconfManagerTest method mergeDriver.
@Test
public void mergeDriver() {
PiPipeconfId piPipeconfId = new PiPipeconfId(cfgService.getConfig(DEVICE_ID, BasicDeviceConfig.class).pipeconf());
assertEquals(pipeconf.id(), piPipeconfId);
String baseDriverName = cfgService.getConfig(DEVICE_ID, BasicDeviceConfig.class).driver();
assertEquals(BASE_DRIVER, baseDriverName);
mgr.register(pipeconf);
assertEquals("Returned PiPipeconf is not correct", pipeconf, mgr.getPipeconf(pipeconf.id()).get());
String mergedDriverName = mgr.getMergedDriver(DEVICE_ID, piPipeconfId);
String expectedName = BASE_DRIVER + ":" + piPipeconfId.id();
assertEquals(expectedName, mergedDriverName);
// we assume that the provider is 1 and that it contains 1 driver
// we also assume that everything after driverAdminService.registerProvider(provider); has been tested.
assertEquals("Provider should be registered", 1, providers.size());
assertTrue("Merged driver name should be valid", mergedDriverName != null && !mergedDriverName.isEmpty());
DriverProvider provider = providers.iterator().next();
assertEquals("Provider should contain one driver", 1, provider.getDrivers().size());
Driver driver = provider.getDrivers().iterator().next();
Set<Class<? extends Behaviour>> expectedBehaviours = Sets.newHashSet();
expectedBehaviours.addAll(BASIC_PIPECONF.behaviours());
expectedBehaviours.addAll(baseDriver.behaviours());
// FIXME: remove when stratum_bmv2 will be open source
// (see PiPipeconfManager)
// expectedBehaviours.remove(PortStatisticsDiscovery.class);
assertEquals("The driver contains wrong behaviours", expectedBehaviours, driver.behaviours());
}
use of org.onosproject.net.pi.model.PiPipeconfId in project onos by opennetworkinglab.
the class PiPipeconfManager method checkMissingMergedDriver.
private void checkMissingMergedDriver(DeviceId deviceId) {
final PiPipeconfId pipeconfId = pipeconfMappingStore.getPipeconfId(deviceId);
final BasicDeviceConfig cfg = cfgService.getConfig(deviceId, BasicDeviceConfig.class);
if (pipeconfId == null) {
// No pipeconf associated.
return;
}
if (cfg == null || cfg.driver() == null) {
log.warn("Missing basic device config or driver key in netcfg for " + "{}, which is odd since it has a " + "pipeconf associated ({})", deviceId, pipeconfId);
return;
}
final String baseDriverName = cfg.driver();
final String mergedDriverName = mergedDriverName(baseDriverName, pipeconfId);
if (driverExists(mergedDriverName) || missingMergedDrivers.contains(mergedDriverName)) {
// Not missing, or already aware of it missing.
return;
}
log.info("Detected missing merged driver: {}", mergedDriverName);
missingMergedDrivers.add(mergedDriverName);
// Attempt building the driver now if all pieces are present.
// If not, either a driver or pipeconf event will re-trigger
// the process.
attemptDriverMerge(mergedDriverName);
}
use of org.onosproject.net.pi.model.PiPipeconfId in project onos by opennetworkinglab.
the class PiPipeconfManager method bindToDevice.
@Override
public void bindToDevice(PiPipeconfId pipeconfId, DeviceId deviceId) {
PiPipeconfId existingPipeconfId = pipeconfMappingStore.getPipeconfId(deviceId);
if (existingPipeconfId != null && !existingPipeconfId.equals(pipeconfId)) {
log.error("Cannot set binding for {} to {} as one already exists ({})", deviceId, pipeconfId, existingPipeconfId);
return;
}
pipeconfMappingStore.createOrUpdateBinding(deviceId, pipeconfId);
}
use of org.onosproject.net.pi.model.PiPipeconfId in project onos by opennetworkinglab.
the class PiPipeconfManager method attemptDriverMerge.
private void attemptDriverMerge(String mergedDriverName) {
final String baseDriverName = getBaseDriverNameFromMerged(mergedDriverName);
final PiPipeconfId pipeconfId = getPipeconfIdFromMerged(mergedDriverName);
if (driverExists(baseDriverName) && pipeconfs.containsKey(pipeconfId)) {
doMergeDriver(baseDriverName, pipeconfId);
}
}
Aggregations