Search in sources :

Example 16 with Driver

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;
}
Also used : DefaultDriverData(org.onosproject.net.driver.DefaultDriverData) DriverData(org.onosproject.net.driver.DriverData) DefaultDriverHandler(org.onosproject.net.driver.DefaultDriverHandler) Driver(org.onosproject.net.driver.Driver) DeviceAlarmConfig(org.onosproject.alarm.DeviceAlarmConfig) DefaultDriverData(org.onosproject.net.driver.DefaultDriverData)

Example 17 with Driver

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

Example 18 with Driver

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

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

Example 20 with Driver

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);
}
Also used : SparseAnnotations(org.onosproject.net.SparseAnnotations) ChassisId(org.onlab.packet.ChassisId) DeviceDescriptionDiscovery(org.onosproject.net.device.DeviceDescriptionDiscovery) DeviceId(org.onosproject.net.DeviceId) RestSBDevice(org.onosproject.protocol.rest.RestSBDevice) DefaultRestSBDevice(org.onosproject.protocol.rest.DefaultRestSBDevice) Device(org.onosproject.net.Device) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription) DefaultDriverHandler(org.onosproject.net.driver.DefaultDriverHandler) DriverHandler(org.onosproject.net.driver.DriverHandler) Driver(org.onosproject.net.driver.Driver) DevicesDiscovery(org.onosproject.net.behaviour.DevicesDiscovery)

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