use of org.onosproject.net.driver.Driver in project onos by opennetworkinglab.
the class PiPipeconfManager method buildMergedDriver.
private Driver buildMergedDriver(PiPipeconfId pipeconfId, String baseDriverName, String newDriverName) {
final Driver baseDriver = getDriver(baseDriverName);
if (baseDriver == null) {
log.error("Base driver {} not found, cannot build a merged one", baseDriverName);
return null;
}
final PiPipeconf pipeconf = pipeconfs.get(pipeconfId);
if (pipeconf == null) {
log.error("Pipeconf {} is not registered, cannot build a merged driver", pipeconfId);
return null;
}
// extract the behaviours from the pipipeconf.
final Map<Class<? extends Behaviour>, Class<? extends Behaviour>> behaviours = new HashMap<>();
pipeconf.behaviours().forEach(b -> behaviours.put(b, pipeconf.implementation(b).get()));
// general, we should give higher priority to pipeconf behaviours.
if (baseDriver.hasBehaviour(PortStatisticsDiscovery.class) && behaviours.remove(PortStatisticsDiscovery.class) != null) {
log.warn("Ignoring {} behaviour from pipeconf {}, but using " + "the one provided by {} driver...", PortStatisticsDiscovery.class.getSimpleName(), pipeconfId, baseDriver.name());
}
final Driver piPipeconfDriver = new DefaultDriver(newDriverName, baseDriver.parents(), baseDriver.manufacturer(), baseDriver.hwVersion(), baseDriver.swVersion(), behaviours, new HashMap<>());
// merge it with the base driver that was assigned to the device
return piPipeconfDriver.merge(baseDriver);
}
use of org.onosproject.net.driver.Driver in project onos by opennetworkinglab.
the class PiPipeconfManager method doMergeDriver.
private String doMergeDriver(String baseDriverName, PiPipeconfId pipeconfId) {
final String newDriverName = mergedDriverName(baseDriverName, pipeconfId);
// Serialize per newDriverName, avoid creating duplicates.
locks.get(newDriverName).lock();
try {
// If merged driver exists already we don't create a new one.
if (getDriver(newDriverName) != null) {
return newDriverName;
}
log.debug("Creating merged driver {}...", newDriverName);
final Driver mergedDriver = buildMergedDriver(pipeconfId, baseDriverName, newDriverName);
if (mergedDriver == null) {
// Error logged by buildMergedDriver
return null;
}
registerMergedDriver(mergedDriver);
if (missingMergedDrivers.remove(newDriverName)) {
log.info("There are still {} missing merged drivers", missingMergedDrivers.size());
}
return newDriverName;
} finally {
locks.get(newDriverName).unlock();
}
}
use of org.onosproject.net.driver.Driver in project onos by opennetworkinglab.
the class ExtensionInstructionSerializer method write.
@Override
public void write(Kryo kryo, Output output, Instructions.ExtensionInstructionWrapper object) {
kryo.writeClassAndObject(output, object.extensionInstruction().type());
kryo.writeClassAndObject(output, object.deviceId());
DriverService driverService = DefaultServiceDirectory.getService(DriverService.class);
// It raises ItemNotFoundException if it failed to find driver
Driver driver = driverService.getDriver(object.deviceId());
kryo.writeClassAndObject(output, driver.name());
kryo.writeClassAndObject(output, object.extensionInstruction().serialize());
}
use of org.onosproject.net.driver.Driver in project onos by opennetworkinglab.
the class MockDriverHandler method init.
// Centralize some initialization.
private void init(Map<Class<? extends Behaviour>, Class<? extends Behaviour>> behaviours, DeviceId mockDeviceId, CoreService mockCoreService, DeviceService mockDeviceService) throws NetconfException {
Map<String, String> properties = new HashMap<String, String>();
Driver mockDriver = new DefaultDriver("mockDriver", null, "ONOSProject", "1.0.0", "1.0.0", behaviours, properties);
mockDriverData = new DefaultDriverData(mockDriver, mockDeviceId);
ncc = new MockNetconfController();
ncc.connectDevice(mockDeviceId);
coreService = mockCoreService;
mastershipService = new MockMastershipService();
deviceService = mockDeviceService;
}
use of org.onosproject.net.driver.Driver in project onos by opennetworkinglab.
the class NetconfSessionMinaImpl method getClientCapabilites.
/**
* Get the list of the netconf client capabilities from device driver property.
*
* @param deviceId the deviceID for which to recover the capabilities from the driver.
* @return the String list of clientCapability property, or null if it is not configured
*/
public Set<String> getClientCapabilites(DeviceId deviceId) {
Set<String> capabilities = new LinkedHashSet<>();
DriverService driverService = directory.get(DriverService.class);
try {
Driver driver = driverService.getDriver(deviceId);
if (driver == null) {
return capabilities;
}
String clientCapabilities = driver.getProperty(NETCONF_CLIENT_CAPABILITY);
if (clientCapabilities == null) {
return capabilities;
}
String[] textStr = clientCapabilities.split("\\|");
capabilities.addAll(Arrays.asList(textStr));
return capabilities;
} catch (ItemNotFoundException e) {
log.warn("Driver for device {} currently not available", deviceId);
return capabilities;
}
}
Aggregations