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;
}
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();
}
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());
}
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);
}
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);
}
}
Aggregations