use of org.onosproject.net.driver.DriverProvider in project onos by opennetworkinglab.
the class PiPipeconfManager method registerMergedDriver.
private void registerMergedDriver(Driver driver) {
final DriverProvider provider = new InternalDriverProvider(driver);
if (driverAdminService.getProviders().contains(provider)) {
// A provider for this driver already exist.
return;
}
driverAdminService.registerProvider(provider);
}
use of org.onosproject.net.driver.DriverProvider 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());
}
Aggregations