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;
}
}
use of org.onosproject.net.driver.Driver in project onos by opennetworkinglab.
the class Controller method getOFSwitchInstance.
/**
* Forward to the driver-manager to get an IOFSwitch instance.
*
* @param dpid data path id
* @param desc switch description
* @param ofv OpenFlow version
* @return switch instance
*/
protected OpenFlowSwitchDriver getOFSwitchInstance(long dpid, OFDescStatsReply desc, OFVersion ofv) {
Dpid dpidObj = new Dpid(dpid);
Driver driver;
try {
driver = driverService.getDriver(DeviceId.deviceId(Dpid.uri(dpidObj)));
} catch (ItemNotFoundException e) {
driver = driverService.getDriver(desc.getMfrDesc(), desc.getHwDesc(), desc.getSwDesc());
}
if (driver == null) {
log.error("No OpenFlow driver for {} : {}", dpidObj, desc);
return null;
}
log.info("Driver '{}' assigned to device {}", driver.name(), dpidObj);
if (!driver.hasBehaviour(OpenFlowSwitchDriver.class)) {
log.error("Driver {} does not support OpenFlowSwitchDriver behaviour", driver.name());
return null;
}
DefaultDriverHandler handler = new DefaultDriverHandler(new DefaultDriverData(driver, deviceId(uri(dpidObj))));
OpenFlowSwitchDriver ofSwitchDriver = driver.createBehaviour(handler, OpenFlowSwitchDriver.class);
ofSwitchDriver.init(dpidObj, desc, ofv);
ofSwitchDriver.setAgent(agent);
ofSwitchDriver.setRoleHandler(new RoleManager(ofSwitchDriver));
return ofSwitchDriver;
}
use of org.onosproject.net.driver.Driver in project onos by opennetworkinglab.
the class FlowModBuilderVer13 method buildExtensionAction.
protected OFAction buildExtensionAction(ExtensionTreatment i) {
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 GroupBucketEntryBuilder method getDriver.
private DriverHandler getDriver(Dpid dpid) {
DeviceId deviceId = DeviceId.deviceId(Dpid.uri(dpid));
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 GeneralDeviceProvider method forgeDeviceDescription.
private DeviceDescription forgeDeviceDescription(DeviceId deviceId, boolean defaultAvailable) {
// Uses handshaker and provider config to get driver data.
final DeviceHandshaker handshaker = getBehaviour(deviceId, DeviceHandshaker.class);
final Driver driver = handshaker != null ? handshaker.handler().driver() : null;
return new DefaultDeviceDescription(deviceId.uri(), Device.Type.SWITCH, driver != null ? driver.manufacturer() : UNKNOWN, driver != null ? driver.hwVersion() : UNKNOWN, driver != null ? driver.swVersion() : UNKNOWN, UNKNOWN, new ChassisId(), defaultAvailable, DefaultAnnotations.EMPTY);
}
Aggregations