use of org.onosproject.net.driver.Driver in project onos by opennetworkinglab.
the class SnmpAlarmProvider method getAlarmTranslator.
private DeviceAlarmConfig getAlarmTranslator(SnmpDevice device) {
Driver deviceDriver = driverService.getDriver(device.deviceId());
if (deviceDriver != null && deviceDriver.hasBehaviour(DeviceAlarmConfig.class)) {
DriverData driverData = new DefaultDriverData(deviceDriver, device.deviceId());
DeviceAlarmConfig alarmTranslator = deviceDriver.createBehaviour(driverData, DeviceAlarmConfig.class);
alarmTranslator.setHandler(new DefaultDriverHandler(driverData));
return alarmTranslator;
} else {
log.warn("Device does not support alarm {}", device.deviceId());
}
return null;
}
use of org.onosproject.net.driver.Driver in project onos by opennetworkinglab.
the class FlowEntryBuilder method getDriver.
/**
* Retrieves the driver handler for the specified device.
*
* @param deviceId device identifier
* @param driverService service handle for the driver service
* @return driver handler
*/
protected static DriverHandler getDriver(DeviceId deviceId, DriverService driverService) {
Driver driver = driverService.getDriver(deviceId);
DriverHandler handler = new DefaultDriverHandler(new DefaultDriverData(driver, deviceId));
return handler;
}
use of org.onosproject.net.driver.Driver in project onos by opennetworkinglab.
the class GroupModBuilder method buildExtensionAction.
private OFAction buildExtensionAction(ExtensionTreatment i, DeviceId deviceId) {
if (!driverService.isPresent()) {
log.error("No driver service present");
return null;
}
Driver driver = driverService.get().getDriver(deviceId);
if (driver.hasBehaviour(ExtensionTreatmentInterpreter.class)) {
DefaultDriverHandler handler = new DefaultDriverHandler(new DefaultDriverData(driver, deviceId));
ExtensionTreatmentInterpreter interpreter = handler.behaviour(ExtensionTreatmentInterpreter.class);
return interpreter.mapInstruction(factory, i);
}
return null;
}
use of org.onosproject.net.driver.Driver in project onos by opennetworkinglab.
the class OpenFlowGroupProvider method isGroupCapable.
/**
* Determine whether the given switch is group-capable.
*
* @param sw switch
* @return the boolean value of groupCapable property, or true if it is not configured.
*/
private boolean isGroupCapable(OpenFlowSwitch sw) {
Driver driver;
try {
driver = driverService.getDriver(DeviceId.deviceId(Dpid.uri(sw.getDpid())));
} catch (ItemNotFoundException e) {
driver = driverService.getDriver(sw.manufacturerDescription(), sw.hardwareDescription(), sw.softwareDescription());
}
if (driver == null) {
return true;
}
String isGroupCapable = driver.getProperty(GROUP_CAPABLE);
return isGroupCapable == null || Boolean.parseBoolean(isGroupCapable);
}
use of org.onosproject.net.driver.Driver in project onos by opennetworkinglab.
the class RestDeviceProvider method getDesc.
private DeviceDescription getDesc(RestSBDevice restSBDev) {
DeviceId deviceId = restSBDev.deviceId();
Driver driver = getDriver(restSBDev);
if (restSBDev.isProxy()) {
if (driver != null && driver.hasBehaviour(DevicesDiscovery.class)) {
// Creates the driver to communicate with the server
DevicesDiscovery devicesDiscovery = devicesDiscovery(restSBDev, driver);
return devicesDiscovery.deviceDetails(deviceId);
} else {
log.warn("Driver not found for {}", restSBDev);
return null;
}
} else if (driver != null && driver.hasBehaviour(DeviceDescriptionDiscovery.class)) {
DriverHandler h = driverService.createHandler(deviceId);
DeviceDescriptionDiscovery deviceDiscovery = h.behaviour(DeviceDescriptionDiscovery.class);
return deviceDiscovery.discoverDeviceDetails();
}
ChassisId cid = new ChassisId();
String ipAddress = restSBDev.ip().toString();
SparseAnnotations annotations = DefaultAnnotations.builder().set(IPADDRESS, ipAddress).set(AnnotationKeys.PROTOCOL, REST.toUpperCase()).build();
String manufacturer = UNKNOWN;
String hwVersion = UNKNOWN;
String swVersion = UNKNOWN;
String serialNumber = UNKNOWN;
Device device = deviceService.getDevice(deviceId);
if (device != null) {
manufacturer = device.manufacturer();
hwVersion = device.hwVersion();
swVersion = device.swVersion();
serialNumber = device.serialNumber();
}
return new DefaultDeviceDescription(deviceId.uri(), Device.Type.SWITCH, manufacturer, hwVersion, swVersion, serialNumber, cid, annotations);
}
Aggregations