blob: ed5d33d19bc19ba93c26e7916682feca626d461e [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2014-present Open Networking Foundation
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.device;
tom41a2c5f2014-09-19 09:20:35 -070017
Brian O'Connorabafb502014-12-02 22:26:20 -080018import org.onosproject.net.Device;
19import org.onosproject.net.DeviceId;
20import org.onosproject.net.Port;
21import org.onosproject.net.PortNumber;
22import org.onosproject.net.provider.ProviderId;
23import org.onosproject.store.Store;
tom41a2c5f2014-09-19 09:20:35 -070024
sangho538108b2015-04-08 14:29:20 -070025import java.util.Collection;
tom41a2c5f2014-09-19 09:20:35 -070026import java.util.List;
Yuta HIGUCHI6eb00cc2016-06-10 11:55:12 -070027import java.util.stream.Stream;
tom41a2c5f2014-09-19 09:20:35 -070028
29/**
tome4729872014-09-23 00:37:37 -070030 * Manages inventory of infrastructure devices; not intended for direct use.
tom41a2c5f2014-09-19 09:20:35 -070031 */
tomf80c9722014-09-24 14:49:18 -070032public interface DeviceStore extends Store<DeviceEvent, DeviceStoreDelegate> {
tom41a2c5f2014-09-19 09:20:35 -070033
34 /**
35 * Returns the number of devices known to the system.
36 *
37 * @return number of devices
38 */
39 int getDeviceCount();
40
41 /**
mskala0d0c6832017-07-12 11:21:23 +020042 * Returns the number of currently available devices known to the system.
43 *
44 * @return number of devices
45 */
46 int getAvailableDeviceCount();
47
48 /**
tom41a2c5f2014-09-19 09:20:35 -070049 * Returns an iterable collection of all devices known to the system.
50 *
51 * @return device collection
52 */
53 Iterable<Device> getDevices();
54
55 /**
Yuta HIGUCHIf1f2ac02014-11-26 14:02:22 -080056 * Returns an iterable collection of all devices currently available to the system.
57 *
58 * @return device collection
59 */
60 Iterable<Device> getAvailableDevices();
61
Yuta HIGUCHIf1f2ac02014-11-26 14:02:22 -080062 /**
tom41a2c5f2014-09-19 09:20:35 -070063 * Returns the device with the specified identifier.
64 *
65 * @param deviceId device identifier
66 * @return device
67 */
68 Device getDevice(DeviceId deviceId);
69
70 /**
71 * Creates a new infrastructure device, or updates an existing one using
72 * the supplied device description.
73 *
74 * @param providerId provider identifier
75 * @param deviceId device identifier
76 * @param deviceDescription device description
77 * @return ready to send event describing what occurred; null if no change
78 */
79 DeviceEvent createOrUpdateDevice(ProviderId providerId, DeviceId deviceId,
80 DeviceDescription deviceDescription);
81
helenyrwufd296b62016-06-22 17:43:02 -070082
Yuta HIGUCHI5f6739c2014-10-01 14:04:01 -070083 // TODO: We may need to enforce that ancillary cannot interfere this state
tom41a2c5f2014-09-19 09:20:35 -070084 /**
85 * Removes the specified infrastructure device.
86 *
87 * @param deviceId device identifier
88 * @return ready to send event describing what occurred; null if no change
89 */
90 DeviceEvent markOffline(DeviceId deviceId);
91
92 /**
helenyrwufd296b62016-06-22 17:43:02 -070093 * Marks the device as available.
94 *
95 * @param deviceId device identifier
Palash Kala6c526062018-04-03 18:25:11 +090096 * @return ready to send event describing what occurred; null if no change
helenyrwufd296b62016-06-22 17:43:02 -070097 */
Palash Kala6c526062018-04-03 18:25:11 +090098 DeviceEvent markOnline(DeviceId deviceId);
helenyrwufd296b62016-06-22 17:43:02 -070099
100 /**
tom41a2c5f2014-09-19 09:20:35 -0700101 * Updates the ports of the specified infrastructure device using the given
102 * list of port descriptions. The list is assumed to be comprehensive.
103 *
Yuta HIGUCHI5f6739c2014-10-01 14:04:01 -0700104 * @param providerId provider identifier
tom41a2c5f2014-09-19 09:20:35 -0700105 * @param deviceId device identifier
106 * @param portDescriptions list of port descriptions
107 * @return ready to send events describing what occurred; empty list if no change
108 */
Yuta HIGUCHI5f6739c2014-10-01 14:04:01 -0700109 List<DeviceEvent> updatePorts(ProviderId providerId, DeviceId deviceId,
tom41a2c5f2014-09-19 09:20:35 -0700110 List<PortDescription> portDescriptions);
111
112 /**
113 * Updates the port status of the specified infrastructure device using the
114 * given port description.
115 *
Yuta HIGUCHI5f6739c2014-10-01 14:04:01 -0700116 * @param providerId provider identifier
tom41a2c5f2014-09-19 09:20:35 -0700117 * @param deviceId device identifier
118 * @param portDescription port description
119 * @return ready to send event describing what occurred; null if no change
120 */
Yuta HIGUCHI5f6739c2014-10-01 14:04:01 -0700121 DeviceEvent updatePortStatus(ProviderId providerId, DeviceId deviceId,
tom41a2c5f2014-09-19 09:20:35 -0700122 PortDescription portDescription);
123
124 /**
125 * Returns the list of ports that belong to the specified device.
126 *
127 * @param deviceId device identifier
128 * @return list of device ports
129 */
130 List<Port> getPorts(DeviceId deviceId);
131
132 /**
Yuta HIGUCHI6eb00cc2016-06-10 11:55:12 -0700133 * Returns the stream of port descriptions that belong to the specified device.
134 *
135 * @param providerId provider identifier
136 * @param deviceId device identifier
137 * @return stream of device portdescriptions
138 */
139 Stream<PortDescription> getPortDescriptions(ProviderId providerId, DeviceId deviceId);
140
141 /**
sangho538108b2015-04-08 14:29:20 -0700142 * Updates the port statistics of the specified device using the give port
143 * statistics.
144 *
145 * @param providerId provider identifier
146 * @param deviceId device identifier
147 * @param portStats list of port statistics
148 * @return ready to send event describing what occurred;
149 */
150 DeviceEvent updatePortStatistics(ProviderId providerId, DeviceId deviceId,
151 Collection<PortStatistics> portStats);
152
153 /**
154 * Returns the list of port statistics of the specified device.
155 *
156 * @param deviceId device identifier
157 * @return list of port statistics of all ports of the device
158 */
159 List<PortStatistics> getPortStatistics(DeviceId deviceId);
160
161 /**
Viswanath KSP22774cd2016-08-20 20:06:30 +0530162 * Returns the port statistics of the specified device and port.
163 *
164 * @param deviceId device identifier
165 * @param portNumber port identifier
166 * @return port statistics of specific port of the device
167 */
168 default PortStatistics getStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
169 return null;
170 }
171
172 /**
Dusan Pajin11ff4a82015-08-20 18:03:05 +0200173 * Returns the list of delta port statistics of the specified device.
174 *
Madan Jampanif97edc12015-08-31 14:41:01 -0700175 * @param deviceId device identifier
Dusan Pajin11ff4a82015-08-20 18:03:05 +0200176 * @return list of delta port statistics of all ports of the device
177 */
178 List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId);
179
180 /**
Viswanath KSP22774cd2016-08-20 20:06:30 +0530181 * Returns the port delta statistics of the specified device and port.
182 *
183 * @param deviceId device identifier
184 * @param portNumber port identifier
185 * @return port statistics of specific port of the device
186 */
187 default PortStatistics getDeltaStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
188 return null;
189 }
190
191 /**
tom41a2c5f2014-09-19 09:20:35 -0700192 * Returns the specified device port.
193 *
194 * @param deviceId device identifier
195 * @param portNumber port number
196 * @return device port
197 */
198 Port getPort(DeviceId deviceId, PortNumber portNumber);
199
200 /**
Yuta HIGUCHI6eb00cc2016-06-10 11:55:12 -0700201 * Returns the specified device port description.
202 *
203 * @param providerId provider identifier
204 * @param deviceId device identifier
205 * @param portNumber port number
206 * @return device port description
207 */
208 PortDescription getPortDescription(ProviderId providerId, DeviceId deviceId, PortNumber portNumber);
209
210 /**
pierventree1f80102021-10-01 22:01:22 +0200211 * Returns the specified device description.
212 *
213 * @param providerId provider identifier
214 * @param deviceId device identifier
215 * @return device description or null if not present
216 */
217 default DeviceDescription getDeviceDescription(ProviderId providerId, DeviceId deviceId) {
218 return null;
219 }
220
221 /**
tom41a2c5f2014-09-19 09:20:35 -0700222 * Indicates whether the specified device is available/online.
223 *
224 * @param deviceId device identifier
225 * @return true if device is available
226 */
227 boolean isAvailable(DeviceId deviceId);
228
229 /**
tom41a2c5f2014-09-19 09:20:35 -0700230 * Administratively removes the specified device from the store.
231 *
232 * @param deviceId device to be removed
Yuta HIGUCHI5c947272014-11-03 21:39:21 -0800233 * @return null if no such device, or was forwarded to remove master
tom41a2c5f2014-09-19 09:20:35 -0700234 */
235 DeviceEvent removeDevice(DeviceId deviceId);
sangho538108b2015-04-08 14:29:20 -0700236
tom41a2c5f2014-09-19 09:20:35 -0700237}