Search in sources :

Example 26 with Driver

use of org.onosproject.net.driver.Driver in project onos by opennetworkinglab.

the class OFAgentVirtualGroupBucketEntryBuilder method getDriver.

/**
 * Retrieves the driver handler for the specified device.
 *
 * @param dpid datapath identifier
 * @return driver handler
 */
protected DriverHandler getDriver(Dpid dpid) {
    DeviceId devId = DeviceId.deviceId(Dpid.uri(dpid));
    log.debug("running getDriver for {}", devId);
    Driver driver = driverService.getDriver(DRIVER_NAME);
    DriverHandler handler = new DefaultDriverHandler(new DefaultDriverData(driver, devId));
    return handler;
}
Also used : DeviceId(org.onosproject.net.DeviceId) DefaultDriverHandler(org.onosproject.net.driver.DefaultDriverHandler) DriverHandler(org.onosproject.net.driver.DriverHandler) DefaultDriverHandler(org.onosproject.net.driver.DefaultDriverHandler) Driver(org.onosproject.net.driver.Driver) DefaultDriverData(org.onosproject.net.driver.DefaultDriverData)

Example 27 with Driver

use of org.onosproject.net.driver.Driver in project onos by opennetworkinglab.

the class DriverRegistryManager method registerProvider.

@Override
public void registerProvider(DriverProvider provider) {
    provider.getDrivers().forEach(driver -> {
        Driver d = addDriver(driver);
        driverByKey.put(key(driver.manufacturer(), driver.hwVersion(), driver.swVersion()), d);
        d.behaviours().forEach(b -> {
            Class<? extends Behaviour> implementation = d.implementation(b);
            classes.put(b.getName(), b);
            classes.put(implementation.getName(), implementation);
        });
        post(new DriverEvent(DRIVER_ENHANCED, driver));
    });
    providers.add(provider);
    checkRequiredDrivers();
}
Also used : DriverEvent(org.onosproject.net.driver.DriverEvent) Driver(org.onosproject.net.driver.Driver)

Example 28 with Driver

use of org.onosproject.net.driver.Driver 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)

Example 29 with Driver

use of org.onosproject.net.driver.Driver in project onos by opennetworkinglab.

the class GeneralDeviceProvider method getBehaviour.

private <T extends Behaviour> T getBehaviour(DeviceId deviceId, Class<T> type) {
    Driver driver = getDriver(deviceId);
    if (driver == null) {
        return null;
    }
    if (!driver.hasBehaviour(type)) {
        return null;
    }
    final DriverData data = new DefaultDriverData(driver, deviceId);
    final DefaultDriverHandler handler = new DefaultDriverHandler(data);
    return driver.createBehaviour(handler, type);
}
Also used : DefaultDriverData(org.onosproject.net.driver.DefaultDriverData) DriverData(org.onosproject.net.driver.DriverData) DefaultDriverHandler(org.onosproject.net.driver.DefaultDriverHandler) Driver(org.onosproject.net.driver.Driver) DefaultDriverData(org.onosproject.net.driver.DefaultDriverData)

Example 30 with Driver

use of org.onosproject.net.driver.Driver in project onos by opennetworkinglab.

the class NetconfDeviceProvider method getDeviceDescription.

private DeviceDescription getDeviceDescription(DeviceId deviceId, NetconfDeviceConfig config) {
    Driver driver = driverService.getDriver(deviceId);
    if (driver.hasBehaviour(DeviceDescriptionDiscovery.class)) {
        final DriverData data = new DefaultDriverData(driver, deviceId);
        final DriverHandler handler = new DefaultDriverHandler(data);
        // creating the behaviour because the core has yet no notion of device.
        DeviceDescriptionDiscovery deviceDescriptionDiscovery = driver.createBehaviour(handler, DeviceDescriptionDiscovery.class);
        return getDeviceRepresentation(deviceId, config, deviceDescriptionDiscovery);
    } else {
        return existingOrEmptyDescription(deviceId, config);
    }
}
Also used : DefaultDriverData(org.onosproject.net.driver.DefaultDriverData) DriverData(org.onosproject.net.driver.DriverData) DeviceDescriptionDiscovery(org.onosproject.net.device.DeviceDescriptionDiscovery) DefaultDriverHandler(org.onosproject.net.driver.DefaultDriverHandler) DefaultDriverHandler(org.onosproject.net.driver.DefaultDriverHandler) DriverHandler(org.onosproject.net.driver.DriverHandler) Driver(org.onosproject.net.driver.Driver) DefaultDriverData(org.onosproject.net.driver.DefaultDriverData)

Aggregations

Driver (org.onosproject.net.driver.Driver)32 DefaultDriverHandler (org.onosproject.net.driver.DefaultDriverHandler)15 DefaultDriverData (org.onosproject.net.driver.DefaultDriverData)14 DriverHandler (org.onosproject.net.driver.DriverHandler)8 DeviceId (org.onosproject.net.DeviceId)6 Device (org.onosproject.net.Device)5 Behaviour (org.onosproject.net.driver.Behaviour)5 DefaultDriver (org.onosproject.net.driver.DefaultDriver)5 HashMap (java.util.HashMap)4 ChassisId (org.onlab.packet.ChassisId)4 ItemNotFoundException (org.onlab.util.ItemNotFoundException)4 Test (org.junit.Test)3 BasicDeviceConfig (org.onosproject.net.config.basics.BasicDeviceConfig)3 DeviceDescriptionDiscovery (org.onosproject.net.device.DeviceDescriptionDiscovery)3 DriverService (org.onosproject.net.driver.DriverService)3 MepId (org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId)2 CfmConfigException (org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException)2 DefaultDevice (org.onosproject.net.DefaultDevice)2 DevicesDiscovery (org.onosproject.net.behaviour.DevicesDiscovery)2 DefaultDeviceDescription (org.onosproject.net.device.DefaultDeviceDescription)2