tom | 41a2c5f | 2014-09-19 09:20:35 -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; |
| 6 | import org.onlab.onos.net.Port; |
| 7 | import org.onlab.onos.net.PortNumber; |
| 8 | import org.onlab.onos.net.provider.ProviderId; |
| 9 | |
| 10 | import java.util.List; |
| 11 | |
| 12 | /** |
tom | e472987 | 2014-09-23 00:37:37 -0700 | [diff] [blame] | 13 | * Manages inventory of infrastructure devices; not intended for direct use. |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 14 | */ |
| 15 | public interface DeviceStore { |
| 16 | |
| 17 | /** |
| 18 | * Returns the number of devices known to the system. |
| 19 | * |
| 20 | * @return number of devices |
| 21 | */ |
| 22 | int getDeviceCount(); |
| 23 | |
| 24 | /** |
| 25 | * Returns an iterable collection of all devices known to the system. |
| 26 | * |
| 27 | * @return device collection |
| 28 | */ |
| 29 | Iterable<Device> getDevices(); |
| 30 | |
| 31 | /** |
| 32 | * Returns the device with the specified identifier. |
| 33 | * |
| 34 | * @param deviceId device identifier |
| 35 | * @return device |
| 36 | */ |
| 37 | Device getDevice(DeviceId deviceId); |
| 38 | |
| 39 | /** |
| 40 | * Creates a new infrastructure device, or updates an existing one using |
| 41 | * the supplied device description. |
| 42 | * |
| 43 | * @param providerId provider identifier |
| 44 | * @param deviceId device identifier |
| 45 | * @param deviceDescription device description |
| 46 | * @return ready to send event describing what occurred; null if no change |
| 47 | */ |
| 48 | DeviceEvent createOrUpdateDevice(ProviderId providerId, DeviceId deviceId, |
| 49 | DeviceDescription deviceDescription); |
| 50 | |
| 51 | /** |
| 52 | * Removes the specified infrastructure device. |
| 53 | * |
| 54 | * @param deviceId device identifier |
| 55 | * @return ready to send event describing what occurred; null if no change |
| 56 | */ |
| 57 | DeviceEvent markOffline(DeviceId deviceId); |
| 58 | |
| 59 | /** |
| 60 | * Updates the ports of the specified infrastructure device using the given |
| 61 | * list of port descriptions. The list is assumed to be comprehensive. |
| 62 | * |
| 63 | * @param deviceId device identifier |
| 64 | * @param portDescriptions list of port descriptions |
| 65 | * @return ready to send events describing what occurred; empty list if no change |
| 66 | */ |
| 67 | List<DeviceEvent> updatePorts(DeviceId deviceId, |
| 68 | List<PortDescription> portDescriptions); |
| 69 | |
| 70 | /** |
| 71 | * Updates the port status of the specified infrastructure device using the |
| 72 | * given port description. |
| 73 | * |
| 74 | * @param deviceId device identifier |
| 75 | * @param portDescription port description |
| 76 | * @return ready to send event describing what occurred; null if no change |
| 77 | */ |
| 78 | DeviceEvent updatePortStatus(DeviceId deviceId, |
| 79 | PortDescription portDescription); |
| 80 | |
| 81 | /** |
| 82 | * Returns the list of ports that belong to the specified device. |
| 83 | * |
| 84 | * @param deviceId device identifier |
| 85 | * @return list of device ports |
| 86 | */ |
| 87 | List<Port> getPorts(DeviceId deviceId); |
| 88 | |
| 89 | /** |
| 90 | * Returns the specified device port. |
| 91 | * |
| 92 | * @param deviceId device identifier |
| 93 | * @param portNumber port number |
| 94 | * @return device port |
| 95 | */ |
| 96 | Port getPort(DeviceId deviceId, PortNumber portNumber); |
| 97 | |
| 98 | /** |
| 99 | * Indicates whether the specified device is available/online. |
| 100 | * |
| 101 | * @param deviceId device identifier |
| 102 | * @return true if device is available |
| 103 | */ |
| 104 | boolean isAvailable(DeviceId deviceId); |
| 105 | |
| 106 | /** |
| 107 | * Returns the mastership role determined for this device. |
| 108 | * |
| 109 | * @param deviceId device identifier |
| 110 | * @return mastership role |
| 111 | */ |
| 112 | MastershipRole getRole(DeviceId deviceId); |
| 113 | |
| 114 | /** |
| 115 | * Administratively sets the role of the specified device. |
| 116 | * |
| 117 | * @param deviceId device identifier |
| 118 | * @param role mastership role to apply |
| 119 | * @return mastership role change event or null if no change |
| 120 | */ |
| 121 | DeviceEvent setRole(DeviceId deviceId, MastershipRole role); |
| 122 | |
| 123 | /** |
| 124 | * Administratively removes the specified device from the store. |
| 125 | * |
| 126 | * @param deviceId device to be removed |
| 127 | */ |
| 128 | DeviceEvent removeDevice(DeviceId deviceId); |
| 129 | } |