Java Code Examples for org.onosproject.net.Device#serialNumber()

The following examples show how to use org.onosproject.net.Device#serialNumber() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CienaWaveserverDeviceDescription.java    From onos with Apache License 2.0 6 votes vote down vote up
@Override
public DeviceDescription discoverDeviceDetails() {
    log.debug("getting device description");
    DeviceService deviceService = checkNotNull(handler().get(DeviceService.class));
    DeviceId deviceId = handler().data().deviceId();
    Device device = deviceService.getDevice(deviceId);

    if (device == null) {
        return new DefaultDeviceDescription(deviceId.uri(),
                                            Device.Type.OTN,
                                            "Ciena",
                                            "WaveServer",
                                            "Unknown",
                                            "Unknown",
                                            new ChassisId());
    } else {
        return new DefaultDeviceDescription(device.id().uri(),
                                            Device.Type.OTN,
                                            device.manufacturer(),
                                            device.hwVersion(),
                                            device.swVersion(),
                                            device.serialNumber(),
                                            device.chassisId());
    }
}
 
Example 2
Source File: TapiDeviceDescriptionDiscovery.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public DeviceDescription discoverDeviceDetails() {
    log.debug("Getting device description");
    DeviceService deviceService = checkNotNull(handler().get(DeviceService.class));
    DeviceId deviceId = handler().data().deviceId();
    Device device = deviceService.getDevice(deviceId);

    if (device == null) {
        //TODO need to obtain from the device.
        return new DefaultDeviceDescription(deviceId.uri(),
                Device.Type.OLS,
                "Tapi",
                "0",
                "2.1",
                "Unknown",
                new ChassisId(),
                DefaultAnnotations.builder().set("protocol", "REST").build());
    } else {
        return new DefaultDeviceDescription(device.id().uri(),
                Device.Type.OLS,
                device.manufacturer(),
                device.hwVersion(),
                device.swVersion(),
                device.serialNumber(),
                device.chassisId());
    }
}
 
Example 3
Source File: TopologySimulator.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Produces a device description from the given device.
 *
 * @param device device to copy
 * @return device description
 */
static DeviceDescription description(Device device) {
    return new DefaultDeviceDescription(device.id().uri(), device.type(),
                                        device.manufacturer(),
                                        device.hwVersion(), device.swVersion(),
                                        device.serialNumber(), device.chassisId());
}
 
Example 4
Source File: BasicDeviceOperator.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a description of the given device.
 *
 * @param device the device
 * @return a description of the device
 */
public static DeviceDescription descriptionOf(Device device) {
    checkNotNull(device, "Must supply non-null Device");
    return new DefaultDeviceDescription(device.id().uri(), device.type(),
            device.manufacturer(), device.hwVersion(),
            device.swVersion(), device.serialNumber(),
            device.chassisId(), (SparseAnnotations) device.annotations());
}
 
Example 5
Source File: RestDeviceProvider.java    From onos with Apache License 2.0 4 votes vote down vote up
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);
}