Search in sources :

Example 11 with Driver

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;
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Driver(org.onosproject.net.driver.Driver) DriverService(org.onosproject.net.driver.DriverService) ItemNotFoundException(org.onlab.util.ItemNotFoundException)

Example 12 with Driver

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;
}
Also used : OpenFlowSwitchDriver(org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver) DefaultDriverHandler(org.onosproject.net.driver.DefaultDriverHandler) Dpid(org.onosproject.openflow.controller.Dpid) Driver(org.onosproject.net.driver.Driver) OpenFlowSwitchDriver(org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver) ItemNotFoundException(org.onlab.util.ItemNotFoundException) DefaultDriverData(org.onosproject.net.driver.DefaultDriverData)

Example 13 with Driver

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;
}
Also used : DefaultDriverHandler(org.onosproject.net.driver.DefaultDriverHandler) Driver(org.onosproject.net.driver.Driver) ExtensionTreatmentInterpreter(org.onosproject.openflow.controller.ExtensionTreatmentInterpreter) DefaultDriverData(org.onosproject.net.driver.DefaultDriverData)

Example 14 with Driver

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;
}
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 15 with Driver

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);
}
Also used : DeviceHandshaker(org.onosproject.net.device.DeviceHandshaker) ChassisId(org.onlab.packet.ChassisId) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription) Driver(org.onosproject.net.driver.Driver)

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