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