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 | */ |
Ayaka Koshibe | 25fd23a | 2014-10-03 15:50:43 -0700 | [diff] [blame] | 45 | //XXX do we want this method here when MastershipService already does? |
tom | ad2d209 | 2014-09-06 23:24:20 -0700 | [diff] [blame] | 46 | MastershipRole getRole(DeviceId deviceId); |
| 47 | |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 48 | |
tom | b36046e | 2014-08-27 00:22:24 -0700 | [diff] [blame] | 49 | /** |
| 50 | * Returns the list of ports associated with the device. |
| 51 | * |
| 52 | * @param deviceId device identifier |
| 53 | * @return list of ports |
| 54 | */ |
| 55 | List<Port> getPorts(DeviceId deviceId); |
| 56 | |
| 57 | /** |
| 58 | * Returns the port with the specified number and hosted by the given device. |
tom | ff7eb7c | 2014-09-08 12:49:03 -0700 | [diff] [blame] | 59 | * |
| 60 | * @param deviceId device identifier |
tom | b36046e | 2014-08-27 00:22:24 -0700 | [diff] [blame] | 61 | * @param portNumber port number |
| 62 | * @return device port |
| 63 | */ |
| 64 | Port getPort(DeviceId deviceId, PortNumber portNumber); |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 65 | |
| 66 | /** |
tom | ff7eb7c | 2014-09-08 12:49:03 -0700 | [diff] [blame] | 67 | * Indicates whether or not the device is presently online and available. |
| 68 | * |
| 69 | * @param deviceId device identifier |
| 70 | * @return true if the device is available |
| 71 | */ |
| 72 | boolean isAvailable(DeviceId deviceId); |
| 73 | |
| 74 | /** |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 75 | * Adds the specified device listener. |
| 76 | * |
| 77 | * @param listener device listener |
| 78 | */ |
| 79 | void addListener(DeviceListener listener); |
| 80 | |
| 81 | /** |
| 82 | * Removes the specified device listener. |
| 83 | * |
| 84 | * @param listener device listener |
| 85 | */ |
| 86 | void removeListener(DeviceListener listener); |
tom | b36046e | 2014-08-27 00:22:24 -0700 | [diff] [blame] | 87 | |
tom | e33cc1a | 2014-08-25 21:59:41 -0700 | [diff] [blame] | 88 | } |