tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 1 | package org.onlab.onos.net.device; |
| 2 | |
| 3 | import org.onlab.onos.net.Device; |
| 4 | import org.onlab.onos.net.DeviceId; |
| 5 | import org.onlab.onos.net.MastershipRole; |
tom | b36046e | 2014-08-27 00:22:24 -0700 | [diff] [blame] | 6 | import org.onlab.onos.net.Port; |
| 7 | import org.onlab.onos.net.PortNumber; |
| 8 | |
| 9 | import java.util.List; |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 10 | |
| 11 | /** |
| 12 | * Service for interacting with the inventory of infrastructure devices. |
| 13 | */ |
| 14 | public interface DeviceService { |
| 15 | |
| 16 | /** |
tom | ad2d209 | 2014-09-06 23:24:20 -0700 | [diff] [blame] | 17 | * Returns the number of infrastructure devices known to the system. |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 18 | * |
tom | ad2d209 | 2014-09-06 23:24:20 -0700 | [diff] [blame] | 19 | * @return number of infrastructure devices |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 20 | */ |
tom | ad2d209 | 2014-09-06 23:24:20 -0700 | [diff] [blame] | 21 | int getDeviceCount(); |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 22 | |
| 23 | /** |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 24 | * Returns a collection of the currently known infrastructure |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 25 | * devices. |
| 26 | * |
| 27 | * @return collection of devices |
| 28 | */ |
| 29 | Iterable<Device> getDevices(); |
| 30 | |
| 31 | /** |
| 32 | * Returns the device with the specified identifier. |
| 33 | * |
| 34 | * @param deviceId device identifier |
| 35 | * @return device or null if one with the given identifier is not known |
| 36 | */ |
| 37 | Device getDevice(DeviceId deviceId); |
| 38 | |
tom | ad2d209 | 2014-09-06 23:24:20 -0700 | [diff] [blame] | 39 | /** |
| 40 | * Returns the current mastership role for the specified device. |
| 41 | * |
| 42 | * @param deviceId device identifier |
| 43 | * @return designated mastership role |
| 44 | */ |
| 45 | MastershipRole getRole(DeviceId deviceId); |
| 46 | |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 47 | |
tom | b36046e | 2014-08-27 00:22:24 -0700 | [diff] [blame] | 48 | /** |
| 49 | * Returns the list of ports associated with the device. |
| 50 | * |
| 51 | * @param deviceId device identifier |
| 52 | * @return list of ports |
| 53 | */ |
| 54 | List<Port> getPorts(DeviceId deviceId); |
| 55 | |
| 56 | /** |
| 57 | * Returns the port with the specified number and hosted by the given device. |
tom | ff7eb7c | 2014-09-08 12:49:03 -0700 | [diff] [blame] | 58 | * |
| 59 | * @param deviceId device identifier |
tom | b36046e | 2014-08-27 00:22:24 -0700 | [diff] [blame] | 60 | * @param portNumber port number |
| 61 | * @return device port |
| 62 | */ |
| 63 | Port getPort(DeviceId deviceId, PortNumber portNumber); |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 64 | |
| 65 | /** |
tom | ff7eb7c | 2014-09-08 12:49:03 -0700 | [diff] [blame] | 66 | * Indicates whether or not the device is presently online and available. |
| 67 | * |
| 68 | * @param deviceId device identifier |
| 69 | * @return true if the device is available |
| 70 | */ |
| 71 | boolean isAvailable(DeviceId deviceId); |
| 72 | |
| 73 | /** |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 74 | * Adds the specified device listener. |
| 75 | * |
| 76 | * @param listener device listener |
| 77 | */ |
| 78 | void addListener(DeviceListener listener); |
| 79 | |
| 80 | /** |
| 81 | * Removes the specified device listener. |
| 82 | * |
| 83 | * @param listener device listener |
| 84 | */ |
| 85 | void removeListener(DeviceListener listener); |
tom | b36046e | 2014-08-27 00:22:24 -0700 | [diff] [blame] | 86 | |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 87 | } |