Search in sources :

Example 1 with DriverProvider

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);
}
Also used : DriverProvider(org.onosproject.net.driver.DriverProvider)

Example 2 with DriverProvider

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());
}
Also used : DriverProvider(org.onosproject.net.driver.DriverProvider) AbstractHandlerBehaviour(org.onosproject.net.driver.AbstractHandlerBehaviour) Behaviour(org.onosproject.net.driver.Behaviour) PiPipeconfId(org.onosproject.net.pi.model.PiPipeconfId) Driver(org.onosproject.net.driver.Driver) BasicDeviceConfig(org.onosproject.net.config.basics.BasicDeviceConfig) Test(org.junit.Test)

Aggregations

DriverProvider (org.onosproject.net.driver.DriverProvider)2 Test (org.junit.Test)1 BasicDeviceConfig (org.onosproject.net.config.basics.BasicDeviceConfig)1 AbstractHandlerBehaviour (org.onosproject.net.driver.AbstractHandlerBehaviour)1 Behaviour (org.onosproject.net.driver.Behaviour)1 Driver (org.onosproject.net.driver.Driver)1 PiPipeconfId (org.onosproject.net.pi.model.PiPipeconfId)1