Search in sources :

Example 1 with Mode

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

the class ServerInterfaceConfig method getInterfaces.

@Override
public List<DeviceInterfaceDescription> getInterfaces() {
    // Retrieve the device ID
    DeviceId deviceId = getDeviceId();
    checkNotNull(deviceId, MSG_DEVICE_ID_NULL);
    // .. and the device itself
    RestServerSBDevice device = null;
    try {
        device = (RestServerSBDevice) getDevice(deviceId);
    } catch (ClassCastException ccEx) {
        log.error("Failed to get interfaces for device {}", deviceId);
        return Collections.EMPTY_LIST;
    }
    if (device == null) {
        log.error("No device with ID {} is available for interface discovery", deviceId);
        return Collections.EMPTY_LIST;
    }
    if ((device.nics() == null) || (device.nics().size() == 0)) {
        log.error("No interfaces available on {}", deviceId);
        return Collections.EMPTY_LIST;
    }
    // List of port descriptions to return
    List<DeviceInterfaceDescription> intfDescriptions = Lists.newArrayList();
    // Sorted list of NIC ports
    Set<NicDevice> nics = new TreeSet(device.nics());
    // Iterate through the NICs of this device to populate the list
    for (NicDevice nic : nics) {
        List<VlanId> devVlanIds = getVlanIdListForDevice(nic);
        Mode devMode = getDeviceMode(devVlanIds);
        // Create an interface description and add it to the list
        intfDescriptions.add(new DefaultDeviceInterfaceDescription(nic.name(), devMode, devVlanIds, RATE_LIMIT_STATUS, NO_LIMIT));
    }
    return ImmutableList.copyOf(intfDescriptions);
}
Also used : NicDevice(org.onosproject.drivers.server.devices.nic.NicDevice) DeviceId(org.onosproject.net.DeviceId) TreeSet(java.util.TreeSet) DeviceInterfaceDescription(org.onosproject.net.device.DeviceInterfaceDescription) DefaultDeviceInterfaceDescription(org.onosproject.net.device.DefaultDeviceInterfaceDescription) Mode(org.onosproject.net.device.DeviceInterfaceDescription.Mode) DefaultDeviceInterfaceDescription(org.onosproject.net.device.DefaultDeviceInterfaceDescription) RestServerSBDevice(org.onosproject.drivers.server.devices.RestServerSBDevice) VlanId(org.onlab.packet.VlanId)

Aggregations

TreeSet (java.util.TreeSet)1 VlanId (org.onlab.packet.VlanId)1 RestServerSBDevice (org.onosproject.drivers.server.devices.RestServerSBDevice)1 NicDevice (org.onosproject.drivers.server.devices.nic.NicDevice)1 DeviceId (org.onosproject.net.DeviceId)1 DefaultDeviceInterfaceDescription (org.onosproject.net.device.DefaultDeviceInterfaceDescription)1 DeviceInterfaceDescription (org.onosproject.net.device.DeviceInterfaceDescription)1 Mode (org.onosproject.net.device.DeviceInterfaceDescription.Mode)1