Search in sources :

Example 6 with DeviceDescriptionDiscovery

use of org.onosproject.net.device.DeviceDescriptionDiscovery 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 7 with DeviceDescriptionDiscovery

use of org.onosproject.net.device.DeviceDescriptionDiscovery in project onos by opennetworkinglab.

the class Tl1DeviceProvider method updateDevice.

/**
 * Tries to update the device and port descriptions through the {@code DeviceDescriptionDiscovery} behaviour.
 *
 * @param deviceId the device
 */
void updateDevice(DeviceId deviceId) {
    Device device = deviceService.getDevice(deviceId);
    if (!device.is(DeviceDescriptionDiscovery.class)) {
        return;
    }
    try {
        // Update device description
        DeviceDescriptionDiscovery discovery = device.as(DeviceDescriptionDiscovery.class);
        DeviceDescription dd = discovery.discoverDeviceDetails();
        if (dd == null) {
            return;
        }
        providerService.deviceConnected(deviceId, new DefaultDeviceDescription(dd, true, dd.annotations()));
        // Update ports
        providerService.updatePorts(deviceId, discovery.discoverPortDetails());
    } catch (IllegalStateException | IllegalArgumentException e) {
        log.error("Cannot update device description {}", deviceId, e);
    }
}
Also used : DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription) DeviceDescription(org.onosproject.net.device.DeviceDescription) DeviceDescriptionDiscovery(org.onosproject.net.device.DeviceDescriptionDiscovery) Device(org.onosproject.net.Device) Tl1Device(org.onosproject.tl1.Tl1Device) DefaultTl1Device(org.onosproject.tl1.DefaultTl1Device) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription)

Example 8 with DeviceDescriptionDiscovery

use of org.onosproject.net.device.DeviceDescriptionDiscovery in project onos by opennetworkinglab.

the class OvsdbDeviceProvider method discoverPorts.

private void discoverPorts(DeviceId deviceId) {
    Device device = deviceService.getDevice(deviceId);
    if (device.is(DeviceDescriptionDiscovery.class)) {
        DeviceDescriptionDiscovery deviceDescriptionDiscovery = device.as(DeviceDescriptionDiscovery.class);
        providerService.updatePorts(deviceId, deviceDescriptionDiscovery.discoverPortDetails());
    } else {
        log.warn("Device " + deviceId + " does not support behaviour DeviceDescriptionDiscovery");
    }
}
Also used : DeviceDescriptionDiscovery(org.onosproject.net.device.DeviceDescriptionDiscovery) Device(org.onosproject.net.Device)

Example 9 with DeviceDescriptionDiscovery

use of org.onosproject.net.device.DeviceDescriptionDiscovery in project onos by opennetworkinglab.

the class AbstractDeviceProvider method discoverDevice.

/**
 * Discovers the device details using the device discovery behaviour of
 * the supplied driver handler context for interacting with a specific
 * device.
 *
 * @param handler driver handler context
 */
protected void discoverDevice(DriverHandler handler) {
    DeviceId deviceId = handler.data().deviceId();
    DeviceDescriptionDiscovery discovery = handler.behaviour(DeviceDescriptionDiscovery.class);
    DeviceDescription description = discovery.discoverDeviceDetails();
    if (description != null) {
        providerService.deviceConnected(deviceId, description);
    } else {
        log.info("No other description given for device {}", deviceId);
    }
    providerService.updatePorts(deviceId, discovery.discoverPortDetails());
}
Also used : DeviceDescription(org.onosproject.net.device.DeviceDescription) DeviceDescriptionDiscovery(org.onosproject.net.device.DeviceDescriptionDiscovery) DeviceId(org.onosproject.net.DeviceId)

Example 10 with DeviceDescriptionDiscovery

use of org.onosproject.net.device.DeviceDescriptionDiscovery in project onos by opennetworkinglab.

the class NetconfDeviceProvider method getDeviceDescription.

private DeviceDescription getDeviceDescription(DeviceId deviceId, NetconfDeviceConfig config) {
    Driver driver = driverService.getDriver(deviceId);
    if (driver.hasBehaviour(DeviceDescriptionDiscovery.class)) {
        final DriverData data = new DefaultDriverData(driver, deviceId);
        final DriverHandler handler = new DefaultDriverHandler(data);
        // creating the behaviour because the core has yet no notion of device.
        DeviceDescriptionDiscovery deviceDescriptionDiscovery = driver.createBehaviour(handler, DeviceDescriptionDiscovery.class);
        return getDeviceRepresentation(deviceId, config, deviceDescriptionDiscovery);
    } else {
        return existingOrEmptyDescription(deviceId, config);
    }
}
Also used : DefaultDriverData(org.onosproject.net.driver.DefaultDriverData) DriverData(org.onosproject.net.driver.DriverData) DeviceDescriptionDiscovery(org.onosproject.net.device.DeviceDescriptionDiscovery) 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)

Aggregations

DeviceDescriptionDiscovery (org.onosproject.net.device.DeviceDescriptionDiscovery)10 DefaultDeviceDescription (org.onosproject.net.device.DefaultDeviceDescription)6 Device (org.onosproject.net.Device)5 DeviceDescription (org.onosproject.net.device.DeviceDescription)5 DeviceId (org.onosproject.net.DeviceId)4 DefaultDriverHandler (org.onosproject.net.driver.DefaultDriverHandler)4 Driver (org.onosproject.net.driver.Driver)3 DriverHandler (org.onosproject.net.driver.DriverHandler)3 ChassisId (org.onlab.packet.ChassisId)2 DevicesDiscovery (org.onosproject.net.behaviour.DevicesDiscovery)2 DefaultDriverData (org.onosproject.net.driver.DefaultDriverData)2 DefaultRestSBDevice (org.onosproject.protocol.rest.DefaultRestSBDevice)2 RestSBDevice (org.onosproject.protocol.rest.RestSBDevice)2 Beta (com.google.common.annotations.Beta)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 ArrayList (java.util.ArrayList)1 EnumSet (java.util.EnumSet)1 List (java.util.List)1 Optional (java.util.Optional)1