blob: d552a70a6be88c49f500732010fdbf901924b251 [file] [log] [blame]
CNlucius74fd4942015-07-20 14:28:04 +08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
CNlucius74fd4942015-07-20 14:28:04 +08003 *
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 */
16package org.onosproject.ovsdb.controller;
17
Ray Milkeyb1250322017-06-05 17:18:17 -070018import java.util.List;
tanbangchengc944c282017-11-12 20:42:59 +080019import java.util.Map;
nitinanand9e8f8362018-05-31 15:11:04 +053020import java.util.Optional;
Ray Milkeyb1250322017-06-05 17:18:17 -070021import java.util.Set;
22
andreaed976a42015-10-05 14:38:25 -070023import org.onosproject.net.DeviceId;
Frank Wange11a98d2016-10-26 17:04:03 +080024import org.onosproject.net.PortNumber;
andreaed976a42015-10-05 14:38:25 -070025import org.onosproject.net.behaviour.ControllerInfo;
nitinanand9e8f8362018-05-31 15:11:04 +053026import org.onosproject.net.behaviour.DeviceCpuStats;
27import org.onosproject.net.behaviour.DeviceMemoryStats;
Pier Ventref5d72362016-07-17 12:02:14 +020028import org.onosproject.net.behaviour.MirroringName;
Ray Milkeyb1250322017-06-05 17:18:17 -070029import org.onosproject.net.behaviour.MirroringStatistics;
Frank Wange11a98d2016-10-26 17:04:03 +080030import org.onosproject.net.behaviour.QosId;
tanbangchengc944c282017-11-12 20:42:59 +080031import org.onosproject.net.behaviour.QueueDescription;
Frank Wange11a98d2016-10-26 17:04:03 +080032import org.onosproject.net.behaviour.QueueId;
Jonathan Hart51539b82015-10-29 09:53:04 -070033import org.onosproject.ovsdb.rfc.jsonrpc.OvsdbRpc;
YuanyouZhangd06bb6b2015-08-05 16:59:07 +080034import org.onosproject.ovsdb.rfc.message.TableUpdates;
35import org.onosproject.ovsdb.rfc.notation.Row;
YuanyouZhangd06bb6b2015-08-05 16:59:07 +080036import org.onosproject.ovsdb.rfc.schema.DatabaseSchema;
37
Ray Milkeyb1250322017-06-05 17:18:17 -070038import com.google.common.util.concurrent.ListenableFuture;
nitinanand9e8f8362018-05-31 15:11:04 +053039import org.onosproject.ovsdb.rfc.table.OvsdbTable;
YuanyouZhangd06bb6b2015-08-05 16:59:07 +080040
CNlucius74fd4942015-07-20 14:28:04 +080041/**
42 * Represents to provider facing side of a node.
43 */
Jonathan Hart51539b82015-10-29 09:53:04 -070044public interface OvsdbClientService extends OvsdbRpc {
CNlucius74fd4942015-07-20 14:28:04 +080045 /**
46 * Gets the node identifier.
47 *
48 * @return node identifier
49 */
50 OvsdbNodeId nodeId();
51
52 /**
Pier Ventref5d72362016-07-17 12:02:14 +020053 * Creates a mirror port. Mirrors the traffic
54 * that goes to selectDstPort or comes from
55 * selectSrcPort or packets containing selectVlan
56 * to mirrorPort or to all ports that trunk mirrorVlan.
57 *
58 * @param bridgeName the name of the bridge
59 * @param mirror the OVSDB mirror description
60 * @return true if mirror creation is successful, false otherwise
61 */
62 boolean createMirror(String bridgeName, OvsdbMirror mirror);
63
64 /**
65 * Gets the Mirror uuid.
66 *
67 * @param mirrorName mirror name
68 * @return mirror uuid, empty if no uuid is found
69 */
70 String getMirrorUuid(String mirrorName);
71
72 /**
73 * Gets mirroring statistics of the device.
74 *
75 * @param deviceId target device id
76 * @return set of mirroring statistics; empty if no mirror is found
77 */
78 Set<MirroringStatistics> getMirroringStatistics(DeviceId deviceId);
79
80 /**
81 * Drops the configuration for mirror.
82 *
Ray Milkeyef794342016-11-09 16:20:29 -080083 * @param mirroringName name of mirror to drop
Pier Ventref5d72362016-07-17 12:02:14 +020084 */
85 void dropMirror(MirroringName mirroringName);
86
87 /**
Frank Wange11a98d2016-10-26 17:04:03 +080088 * apply qos to port.
89 *
90 * @param portNumber port identifier
91 * @param qosName the qos name
92 */
93 void applyQos(PortNumber portNumber, String qosName);
94
95 /**
96 * Creates a qos port.
97 *
98 * @param portNumber port identifier
99 */
100 void removeQos(PortNumber portNumber);
101
102 /**
103 * Creates a qos. associates with queue to
104 * provide the ability of limit the rate of different flows
105 * depend on itself priority.
106 *
107 * @param ovsdbQos the OVSDB Qos
108 * @return true if qos creation is successful, false otherwise
109 */
110 boolean createQos(OvsdbQos ovsdbQos);
111
112 /**
113 * Drops the configuration for qos.
114 *
115 * @param qosId qos identifier
116 */
117 void dropQos(QosId qosId);
118
119 /**
120 * Gets a qos of node.
121 * @param qosId qos identifier
122 * @return null if no qos is find
123 */
124 OvsdbQos getQos(QosId qosId);
125
126 /**
127 * Gets qoses of node.
128 *
129 * @return set of qoses; empty if no qos is find
130 */
131 Set<OvsdbQos> getQoses();
132
133 /**
tanbangchengc944c282017-11-12 20:42:59 +0800134 * Bind Queue to QoS.
135 *
136 * @param qosId qos identifier
137 * @param queues the Queue key and Queue description
138 */
139 void bindQueues(QosId qosId, Map<Long, QueueDescription> queues);
140
141 /**
142 * Unbind Queue from QoS.
143 *
144 * @param qosId qos identifier
145 * @param queueKeys queue key
146 */
147 void unbindQueues(QosId qosId, List<Long> queueKeys);
148
149 /**
Frank Wange11a98d2016-10-26 17:04:03 +0800150 * Creates queues. limits the rate of each flow
151 * depend on itself priority.
152 *
153 * @param queue the OVSDB queue description
154 * @return true if queue creation is successful, false otherwise
155 */
156 boolean createQueue(OvsdbQueue queue);
157
158 /**
159 * Drops the configuration for queue.
160 *
161 * @param queueId queue identifier
162 */
163 void dropQueue(QueueId queueId);
164
165 /**
166 * Gets a queue of node.
167 * @param queueId the queue identifier
168 * @return null if no queue is find
169 */
170 OvsdbQueue getQueue(QueueId queueId);
171
172 /**
173 * Gets queues of node.
174 *
175 * @return set of queues; empty if no queue is find
176 */
177 Set<OvsdbQueue> getQueues();
178
179 /**
Hyunsun Moondd14e8e2016-06-09 16:17:32 -0700180 * Creates an interface with a given OVSDB interface description.
CNlucius74fd4942015-07-20 14:28:04 +0800181 *
Hyunsun Moondd14e8e2016-06-09 16:17:32 -0700182 * @param bridgeName bridge name
183 * @param ovsdbIface ovsdb interface description
184 * @return true if interface creation is successful, false otherwise
CNlucius74fd4942015-07-20 14:28:04 +0800185 */
Hyunsun Moondd14e8e2016-06-09 16:17:32 -0700186 boolean createInterface(String bridgeName, OvsdbInterface ovsdbIface);
187
188 /**
189 * Removes an interface with the supplied interface name.
190 *
191 * @param ifaceName interface name
192 * @return true if interface creation is successful, false otherwise
193 */
194 boolean dropInterface(String ifaceName);
CNlucius74fd4942015-07-20 14:28:04 +0800195
196 /**
Hyunsun Moon1251e192016-06-07 16:57:05 -0700197 * Creates a bridge with a given bridge description.
198 *
199 * @param ovsdbBridge ovsdb bridge description
200 * @return true if bridge creation is successful, otherwise false
201 */
202 boolean createBridge(OvsdbBridge ovsdbBridge);
203
204 /**
CNlucius74fd4942015-07-20 14:28:04 +0800205 * Drops a bridge.
206 *
207 * @param bridgeName bridge name
208 */
209 void dropBridge(String bridgeName);
210
211 /**
BitOhenry264f35a2015-11-03 20:58:39 +0800212 * Gets bridges of node.
CNlucius74fd4942015-07-20 14:28:04 +0800213 *
214 * @return set of bridges; empty if no bridge is find
215 */
216 Set<OvsdbBridge> getBridges();
217
218 /**
BitOhenry264f35a2015-11-03 20:58:39 +0800219 * Gets controllers of node.
andreaed976a42015-10-05 14:38:25 -0700220 *
Brian O'Connor52515622015-10-09 17:03:44 -0700221 * @param openflowDeviceId target device id
andreaed976a42015-10-05 14:38:25 -0700222 * @return set of controllers; empty if no controller is find
223 */
224 Set<ControllerInfo> getControllers(DeviceId openflowDeviceId);
225
226 /**
Hyunsun Moon1251e192016-06-07 16:57:05 -0700227 * Returns local controller information.
228 * The connection is a TCP connection to the local ONOS instance's IP
229 * and the default OpenFlow port.
230 *
231 * @return local controller
232 */
233 ControllerInfo localController();
234
235 /**
Brian O'Connor6ee8aa32015-10-09 16:07:42 -0700236 * Sets the Controllers for the specified device.
Brian O'Connor52515622015-10-09 17:03:44 -0700237 * <p>
Brian O'Connor6ee8aa32015-10-09 16:07:42 -0700238 * This method will replace the existing controller list with the new controller
239 * list.
andreaed976a42015-10-05 14:38:25 -0700240 *
Brian O'Connor6ee8aa32015-10-09 16:07:42 -0700241 * @param deviceId device id (likely Openflow device)
242 * @param controllers list of controllers
andreaed976a42015-10-05 14:38:25 -0700243 */
244 void setControllersWithDeviceId(DeviceId deviceId, List<ControllerInfo> controllers);
245
246 /**
CNlucius74fd4942015-07-20 14:28:04 +0800247 * Creates a port.
248 *
249 * @param bridgeName bridge name
andreaed976a42015-10-05 14:38:25 -0700250 * @param portName port name
CNlucius74fd4942015-07-20 14:28:04 +0800251 */
252 void createPort(String bridgeName, String portName);
253
254 /**
255 * Drops a port.
256 *
257 * @param bridgeName bridge name
andreaed976a42015-10-05 14:38:25 -0700258 * @param portName port name
CNlucius74fd4942015-07-20 14:28:04 +0800259 */
260 void dropPort(String bridgeName, String portName);
261
262 /**
BitOhenry264f35a2015-11-03 20:58:39 +0800263 * Gets ports of bridge.
CNlucius74fd4942015-07-20 14:28:04 +0800264 *
265 * @return set of ports; empty if no ports is find
266 */
267 Set<OvsdbPort> getPorts();
268
269 /**
270 * Checks if the node is still connected.
271 *
272 * @return true if the node is still connected
273 */
274 boolean isConnected();
275
YuanyouZhangd06bb6b2015-08-05 16:59:07 +0800276 /**
277 * Gets the Bridge uuid.
278 *
279 * @param bridgeName bridge name
280 * @return bridge uuid, empty if no uuid is find
281 */
282 String getBridgeUuid(String bridgeName);
283
284 /**
285 * Gets the Port uuid.
286 *
andreaed976a42015-10-05 14:38:25 -0700287 * @param portName port name
YuanyouZhangd06bb6b2015-08-05 16:59:07 +0800288 * @param bridgeUuid bridge uuid
289 * @return port uuid, empty if no uuid is find
290 */
291 String getPortUuid(String portName, String bridgeUuid);
292
293 /**
BitOhenry3f28c682015-11-07 10:40:03 +0800294 * Gets the OVSDB database schema.
YuanyouZhangd06bb6b2015-08-05 16:59:07 +0800295 *
296 * @param dbName database name
297 * @return database schema
298 */
299 ListenableFuture<DatabaseSchema> getOvsdbSchema(String dbName);
300
301 /**
BitOhenry3f28c682015-11-07 10:40:03 +0800302 * Gets the OVSDB table updates.
YuanyouZhangd06bb6b2015-08-05 16:59:07 +0800303 *
304 * @param dbName database name
andreaed976a42015-10-05 14:38:25 -0700305 * @param id random uuid
YuanyouZhangd06bb6b2015-08-05 16:59:07 +0800306 * @return table updates
307 */
308 ListenableFuture<TableUpdates> monitorTables(String dbName, String id);
309
310 /**
BitOhenry3f28c682015-11-07 10:40:03 +0800311 * Gets the OVSDB database schema from local.
YuanyouZhangd06bb6b2015-08-05 16:59:07 +0800312 *
andreaed976a42015-10-05 14:38:25 -0700313 * @param dbName database name
YuanyouZhangd06bb6b2015-08-05 16:59:07 +0800314 * @return database schema
315 */
316 DatabaseSchema getDatabaseSchema(String dbName);
317
318 /**
BitOhenry3f28c682015-11-07 10:40:03 +0800319 * Gets the OVSDB row from local OVSDB store.
YuanyouZhangd06bb6b2015-08-05 16:59:07 +0800320 *
andreaed976a42015-10-05 14:38:25 -0700321 * @param dbName database name
YuanyouZhangd06bb6b2015-08-05 16:59:07 +0800322 * @param tableName table name
andreaed976a42015-10-05 14:38:25 -0700323 * @param uuid row uuid
BitOhenry3f28c682015-11-07 10:40:03 +0800324 * @return row OVSDB row
YuanyouZhangd06bb6b2015-08-05 16:59:07 +0800325 */
326 Row getRow(String dbName, String tableName, String uuid);
327
328 /**
BitOhenry3f28c682015-11-07 10:40:03 +0800329 * Removes the OVSDB row from local OVSDB store.
YuanyouZhangd06bb6b2015-08-05 16:59:07 +0800330 *
andreaed976a42015-10-05 14:38:25 -0700331 * @param dbName database name
YuanyouZhangd06bb6b2015-08-05 16:59:07 +0800332 * @param tableName table name
andreaed976a42015-10-05 14:38:25 -0700333 * @param uuid row uuid
YuanyouZhangd06bb6b2015-08-05 16:59:07 +0800334 */
335 void removeRow(String dbName, String tableName, String uuid);
336
337 /**
BitOhenry3f28c682015-11-07 10:40:03 +0800338 * Updates the local OVSDB store.
YuanyouZhangd06bb6b2015-08-05 16:59:07 +0800339 *
andreaed976a42015-10-05 14:38:25 -0700340 * @param dbName database name
YuanyouZhangd06bb6b2015-08-05 16:59:07 +0800341 * @param tableName table name
andreaed976a42015-10-05 14:38:25 -0700342 * @param uuid row uuid
BitOhenry3f28c682015-11-07 10:40:03 +0800343 * @param row OVSDB row
YuanyouZhangd06bb6b2015-08-05 16:59:07 +0800344 */
345 void updateOvsdbStore(String dbName, String tableName, String uuid, Row row);
346
CNluciusa66c3972015-09-06 20:31:29 +0800347 /**
BitOhenry3f28c682015-11-07 10:40:03 +0800348 * Gets OVSDB local ports.
CNluciusa66c3972015-09-06 20:31:29 +0800349 *
350 * @param ifaceids the ifaceid that needed
BitOhenry3f28c682015-11-07 10:40:03 +0800351 * @return OVSDB ports
CNluciusa66c3972015-09-06 20:31:29 +0800352 */
353 Set<OvsdbPort> getLocalPorts(Iterable<String> ifaceids);
Hyunsun Moon5fb20a52015-09-25 17:02:33 -0700354
355 /**
BitOhenry3f28c682015-11-07 10:40:03 +0800356 * Disconnects the OVSDB server.
Hyunsun Moon5fb20a52015-09-25 17:02:33 -0700357 */
358 void disconnect();
Saritha1583a6f2017-06-16 14:42:58 +0530359
360 /**
361 * Gets created ports for the particular bridgeId.
362 *
363 * @param portNames the portNames which needs to checked for create
364 * @param bridgeId bridgeIdentifier
365 * @return OvsdbPortNames the created ports from port table for the bridgeId by considering input port list.
366 * Considered port as created if port's interface table also gets created,irrespective
367 * of ofport value(has errors or not)
368 */
369 public List<OvsdbPortName> getPorts(List<String> portNames, DeviceId bridgeId);
370
371 /**
372 * Gets error status for the given portNames.
373 *
374 * @param portNames the portNames which need to be checked for errors
375 * @param bridgeId bridgeIdentifier
376 * @return errorstatus true if input port list contains error, false otherwise
377 */
378 boolean getPortError(List<OvsdbPortName> portNames, DeviceId bridgeId);
nitinanand9e8f8362018-05-31 15:11:04 +0530379
380 /**
381 * Gets First row for the given table of given DB.
382 *
383 * @param dbName db name
384 * @param tblName table name
385 * @return first table entry
386 */
387
388 public Optional<Object> getFirstRow(String dbName, OvsdbTable tblName);
389
390 /**
391 * Gets device CPU usage in percentage.
392 * @return device memory usage.
393 */
394 Optional<DeviceCpuStats> getDeviceCpuUsage();
395
396 /**
397 * Gets device memory usage in kilobytes.
398 * @return device memory usage.
399 */
400 Optional<DeviceMemoryStats> getDeviceMemoryUsage();
401
CNlucius74fd4942015-07-20 14:28:04 +0800402}