Search in sources :

Example 21 with Driver

use of org.onosproject.net.driver.Driver in project onos by opennetworkinglab.

the class RestDeviceProvider method getDriver.

private Driver getDriver(RestSBDevice restSBDev) {
    String driverName = netCfgService.getConfig(restSBDev.deviceId(), BasicDeviceConfig.class).driver();
    Driver driver = driverService.getDriver(driverName);
    if (driver == null) {
        driver = driverService.getDriver(restSBDev.manufacturer().get(), restSBDev.hwVersion().get(), restSBDev.swVersion().get());
    }
    checkNotNull(driver, DRIVERNULL);
    return driver;
}
Also used : Driver(org.onosproject.net.driver.Driver) BasicDeviceConfig(org.onosproject.net.config.basics.BasicDeviceConfig)

Example 22 with Driver

use of org.onosproject.net.driver.Driver in project onos by opennetworkinglab.

the class RestDeviceProvider method deviceAdded.

private void deviceAdded(RestSBDevice restSBDev) {
    checkNotNull(restSBDev, DEVICENULL);
    Driver driver = getDriver(restSBDev);
    // Check if the server is controlling a single or multiple devices
    if (restSBDev.isProxy()) {
        if (driver.hasBehaviour(DevicesDiscovery.class)) {
            DevicesDiscovery devicesDiscovery = devicesDiscovery(restSBDev, driver);
            Set<DeviceId> deviceIds = devicesDiscovery.deviceIds();
            restSBDev.setActive(true);
            deviceIds.forEach(deviceId -> {
                controller.addProxiedDevice(deviceId, restSBDev);
                DeviceDescription devDesc = devicesDiscovery.deviceDetails(deviceId);
                checkNotNull(devDesc, "DeviceDescription cannot be null");
                providerService.deviceConnected(deviceId, mergeAnn(restSBDev.deviceId(), devDesc));
                if (driver.hasBehaviour(DeviceDescriptionDiscovery.class)) {
                    DriverHandler h = driverService.createHandler(deviceId);
                    DeviceDescriptionDiscovery devDisc = h.behaviour(DeviceDescriptionDiscovery.class);
                    providerService.updatePorts(deviceId, devDisc.discoverPortDetails());
                }
                checkAndUpdateDevice(deviceId);
            });
        } else {
            log.warn("Device is proxy but driver does not have proxy discovery behaviour {}", restSBDev);
        }
    } else {
        DeviceId deviceId = restSBDev.deviceId();
        if (driver != null && driver.hasBehaviour(DevicesDiscovery.class)) {
            restSBDev.setActive(true);
            DevicesDiscovery devicesDiscovery = devicesDiscovery(restSBDev, driver);
            DeviceDescription deviceDescription = devicesDiscovery.deviceDetails(deviceId);
            checkNotNull(deviceDescription, "DeviceDescription cannot be null");
            providerService.deviceConnected(deviceId, deviceDescription);
            if (driver.hasBehaviour(DeviceDescriptionDiscovery.class)) {
                DriverHandler h = driverService.createHandler(deviceId);
                DeviceDescriptionDiscovery deviceDiscovery = h.behaviour(DeviceDescriptionDiscovery.class);
                providerService.updatePorts(deviceId, deviceDiscovery.discoverPortDetails());
            }
        } else {
            DeviceDescription deviceDescription = getDesc(restSBDev);
            restSBDev.setActive(true);
            providerService.deviceConnected(deviceId, deviceDescription);
        }
        checkAndUpdateDevice(deviceId);
    }
}
Also used : DeviceDescription(org.onosproject.net.device.DeviceDescription) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription) DeviceDescriptionDiscovery(org.onosproject.net.device.DeviceDescriptionDiscovery) DeviceId(org.onosproject.net.DeviceId) DefaultDriverHandler(org.onosproject.net.driver.DefaultDriverHandler) DriverHandler(org.onosproject.net.driver.DriverHandler) Driver(org.onosproject.net.driver.Driver) DevicesDiscovery(org.onosproject.net.behaviour.DevicesDiscovery)

Example 23 with Driver

use of org.onosproject.net.driver.Driver in project onos by opennetworkinglab.

the class OpenFlowMeterProvider method isMeterCapable.

/**
 * Determine whether the given switch is meter-capable.
 *
 * @param sw switch
 * @return the boolean value of meterCapable property, or true if it is not configured.
 */
private boolean isMeterCapable(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());
    }
    String isMeterCapable = driver.getProperty(METER_CAPABLE);
    return isMeterCapable == null || Boolean.parseBoolean(isMeterCapable);
}
Also used : Driver(org.onosproject.net.driver.Driver) ItemNotFoundException(org.onlab.util.ItemNotFoundException)

Example 24 with Driver

use of org.onosproject.net.driver.Driver in project onos by opennetworkinglab.

the class DriverRegistryManager method registerProvider.

@Override
public void registerProvider(DriverProvider provider) {
    provider.getDrivers().forEach(driver -> {
        Driver d = addDriver(driver);
        driverByKey.put(key(driver.manufacturer(), driver.hwVersion(), driver.swVersion()), d);
        d.behaviours().forEach(b -> {
            Class<? extends Behaviour> implementation = d.implementation(b);
            classes.put(b.getName(), b);
            classes.put(implementation.getName(), implementation);
        });
        post(new DriverEvent(DRIVER_ENHANCED, driver));
    });
    providers.add(provider);
    checkRequiredDrivers();
}
Also used : DriverEvent(org.onosproject.net.driver.DriverEvent) Driver(org.onosproject.net.driver.Driver)

Example 25 with Driver

use of org.onosproject.net.driver.Driver in project onos by opennetworkinglab.

the class TopologyViewMessageHandlerBase method deviceMessage.

// Produces a device event message to the client.
protected ObjectNode deviceMessage(DeviceEvent event) {
    Device device = event.subject();
    String uiType = device.annotations().value(AnnotationKeys.UI_TYPE);
    String driverName = device.annotations().value(DRIVER);
    Driver driver = driverName == null ? null : services.driver().getDriver(driverName);
    String devType = uiType != null ? uiType : (driver != null ? driver.getProperty(AnnotationKeys.UI_TYPE) : null);
    if (devType == null) {
        devType = device.type().toString().toLowerCase();
    }
    String name = device.annotations().value(AnnotationKeys.NAME);
    name = isNullOrEmpty(name) ? device.id().toString() : name;
    ObjectNode payload = objectNode().put("id", device.id().toString()).put("type", devType).put("online", services.device().isAvailable(device.id())).put("master", master(device.id()));
    payload.set("labels", labels("", name, device.id().toString()));
    payload.set("props", props(device.annotations()));
    BasicDeviceConfig cfg = get(NetworkConfigService.class).getConfig(device.id(), BasicDeviceConfig.class);
    if (!addLocation(cfg, payload)) {
        addMetaUi(device.id().toString(), payload);
    }
    String type = DEVICE_EVENT.get(event.type());
    return JsonUtils.envelope(type, payload);
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) Device(org.onosproject.net.Device) Driver(org.onosproject.net.driver.Driver) TopoUtils.compactLinkString(org.onosproject.ui.topo.TopoUtils.compactLinkString) BasicDeviceConfig(org.onosproject.net.config.basics.BasicDeviceConfig)

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