blob: bf91497c44c530c0bc0fc7e73821cc9693237148 [file] [log] [blame]
CNlucius74fd4942015-07-20 14:28:04 +08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
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
andreaed976a42015-10-05 14:38:25 -070018import com.google.common.util.concurrent.ListenableFuture;
lishuai6c56f5e2015-11-17 16:38:19 +080019
CNlucius74fd4942015-07-20 14:28:04 +080020import org.onlab.packet.IpAddress;
andreaed976a42015-10-05 14:38:25 -070021import org.onosproject.net.DeviceId;
22import org.onosproject.net.behaviour.ControllerInfo;
Jonathan Hart51539b82015-10-29 09:53:04 -070023import org.onosproject.ovsdb.rfc.jsonrpc.OvsdbRpc;
YuanyouZhangd06bb6b2015-08-05 16:59:07 +080024import org.onosproject.ovsdb.rfc.message.OperationResult;
25import org.onosproject.ovsdb.rfc.message.TableUpdates;
26import org.onosproject.ovsdb.rfc.notation.Row;
Jonathan Hart51539b82015-10-29 09:53:04 -070027import org.onosproject.ovsdb.rfc.notation.Uuid;
YuanyouZhangd06bb6b2015-08-05 16:59:07 +080028import org.onosproject.ovsdb.rfc.operations.Operation;
29import org.onosproject.ovsdb.rfc.schema.DatabaseSchema;
30
andreaed976a42015-10-05 14:38:25 -070031import java.util.List;
Hyunsun Moon646d8c42015-10-08 20:32:44 -070032import java.util.Map;
andreaed976a42015-10-05 14:38:25 -070033import java.util.Set;
YuanyouZhangd06bb6b2015-08-05 16:59:07 +080034
CNlucius74fd4942015-07-20 14:28:04 +080035/**
36 * Represents to provider facing side of a node.
37 */
Jonathan Hart51539b82015-10-29 09:53:04 -070038public interface OvsdbClientService extends OvsdbRpc {
CNlucius74fd4942015-07-20 14:28:04 +080039 /**
40 * Gets the node identifier.
41 *
42 * @return node identifier
43 */
44 OvsdbNodeId nodeId();
45
46 /**
Hyunsun Moon646d8c42015-10-08 20:32:44 -070047 * Creates a tunnel port with given options.
48 *
49 * @param bridgeName bridge name
50 * @param portName port name
51 * @param tunnelType tunnel type
52 * @param options tunnel options
53 * @return true if tunnel creation is successful, false otherwise
54 */
55 boolean createTunnel(String bridgeName, String portName, String tunnelType, Map<String, String> options);
56
57 /**
BitOhenry264f35a2015-11-03 20:58:39 +080058 * Drops the configuration for tunnel.
CNlucius74fd4942015-07-20 14:28:04 +080059 *
60 * @param srcIp source IP address
61 * @param dstIp destination IP address
62 */
63 void dropTunnel(IpAddress srcIp, IpAddress dstIp);
64
65 /**
BitOhenry264f35a2015-11-03 20:58:39 +080066 * Gets tunnels of node.
CNlucius74fd4942015-07-20 14:28:04 +080067 *
68 * @return set of tunnels; empty if no tunnel is find
69 */
70 Set<OvsdbTunnel> getTunnels();
71
72 /**
73 * Creates a bridge.
74 *
Hyunsun Moon1251e192016-06-07 16:57:05 -070075 * @deprecated version 1.7.0 - Hummingbird
CNlucius74fd4942015-07-20 14:28:04 +080076 * @param bridgeName bridge name
77 */
Hyunsun Moon1251e192016-06-07 16:57:05 -070078 @Deprecated
CNlucius74fd4942015-07-20 14:28:04 +080079 void createBridge(String bridgeName);
80
81 /**
lishuai6c56f5e2015-11-17 16:38:19 +080082 * Creates a bridge.
83 *
Hyunsun Moon1251e192016-06-07 16:57:05 -070084 * @deprecated version 1.7.0 - Hummingbird
lishuai6c56f5e2015-11-17 16:38:19 +080085 * @param bridgeName bridge name
86 * @param dpid data path id
87 * @param exPortName external port name
88 */
Hyunsun Moon1251e192016-06-07 16:57:05 -070089 @Deprecated
lishuai6c56f5e2015-11-17 16:38:19 +080090 void createBridge(String bridgeName, String dpid, String exPortName);
91
92 /**
Hyunsun Moon646d8c42015-10-08 20:32:44 -070093 * Creates a bridge with given name and dpid.
94 * Sets the bridge's controller with given controllers.
95 *
Hyunsun Moon1251e192016-06-07 16:57:05 -070096 * @deprecated version 1.7.0 - Hummingbird
Hyunsun Moon646d8c42015-10-08 20:32:44 -070097 * @param bridgeName bridge name
98 * @param dpid data path id
99 * @param controllers controllers
100 * @return true if bridge creation is successful, false otherwise
101 */
Hyunsun Moon1251e192016-06-07 16:57:05 -0700102 @Deprecated
Hyunsun Moon646d8c42015-10-08 20:32:44 -0700103 boolean createBridge(String bridgeName, String dpid, List<ControllerInfo> controllers);
104
105 /**
Hyunsun Moon1251e192016-06-07 16:57:05 -0700106 * Creates a bridge with a given bridge description.
107 *
108 * @param ovsdbBridge ovsdb bridge description
109 * @return true if bridge creation is successful, otherwise false
110 */
111 boolean createBridge(OvsdbBridge ovsdbBridge);
112
113 /**
CNlucius74fd4942015-07-20 14:28:04 +0800114 * Drops a bridge.
115 *
116 * @param bridgeName bridge name
117 */
118 void dropBridge(String bridgeName);
119
120 /**
BitOhenry264f35a2015-11-03 20:58:39 +0800121 * Gets bridges of node.
CNlucius74fd4942015-07-20 14:28:04 +0800122 *
123 * @return set of bridges; empty if no bridge is find
124 */
125 Set<OvsdbBridge> getBridges();
126
127 /**
BitOhenry264f35a2015-11-03 20:58:39 +0800128 * Gets controllers of node.
andreaed976a42015-10-05 14:38:25 -0700129 *
Brian O'Connor52515622015-10-09 17:03:44 -0700130 * @param openflowDeviceId target device id
andreaed976a42015-10-05 14:38:25 -0700131 * @return set of controllers; empty if no controller is find
132 */
133 Set<ControllerInfo> getControllers(DeviceId openflowDeviceId);
134
135 /**
Hyunsun Moon1251e192016-06-07 16:57:05 -0700136 * Returns local controller information.
137 * The connection is a TCP connection to the local ONOS instance's IP
138 * and the default OpenFlow port.
139 *
140 * @return local controller
141 */
142 ControllerInfo localController();
143
144 /**
Brian O'Connor6ee8aa32015-10-09 16:07:42 -0700145 * Sets the Controllers for the specified bridge.
Brian O'Connor52515622015-10-09 17:03:44 -0700146 * <p>
Brian O'Connor6ee8aa32015-10-09 16:07:42 -0700147 * This method will replace the existing controller list with the new controller
148 * list.
andreaed976a42015-10-05 14:38:25 -0700149 *
Brian O'Connor6ee8aa32015-10-09 16:07:42 -0700150 * @param bridgeUuid bridge uuid
151 * @param controllers list of controllers
andreaed976a42015-10-05 14:38:25 -0700152 */
Jonathan Hart51539b82015-10-29 09:53:04 -0700153 void setControllersWithUuid(Uuid bridgeUuid, List<ControllerInfo> controllers);
andreaed976a42015-10-05 14:38:25 -0700154
155 /**
Brian O'Connor6ee8aa32015-10-09 16:07:42 -0700156 * Sets the Controllers for the specified device.
Brian O'Connor52515622015-10-09 17:03:44 -0700157 * <p>
Brian O'Connor6ee8aa32015-10-09 16:07:42 -0700158 * This method will replace the existing controller list with the new controller
159 * list.
andreaed976a42015-10-05 14:38:25 -0700160 *
Brian O'Connor6ee8aa32015-10-09 16:07:42 -0700161 * @param deviceId device id (likely Openflow device)
162 * @param controllers list of controllers
andreaed976a42015-10-05 14:38:25 -0700163 */
164 void setControllersWithDeviceId(DeviceId deviceId, List<ControllerInfo> controllers);
165
166 /**
CNlucius74fd4942015-07-20 14:28:04 +0800167 * Creates a port.
168 *
169 * @param bridgeName bridge name
andreaed976a42015-10-05 14:38:25 -0700170 * @param portName port name
CNlucius74fd4942015-07-20 14:28:04 +0800171 */
172 void createPort(String bridgeName, String portName);
173
174 /**
175 * Drops a port.
176 *
177 * @param bridgeName bridge name
andreaed976a42015-10-05 14:38:25 -0700178 * @param portName port name
CNlucius74fd4942015-07-20 14:28:04 +0800179 */
180 void dropPort(String bridgeName, String portName);
181
182 /**
BitOhenry264f35a2015-11-03 20:58:39 +0800183 * Gets ports of bridge.
CNlucius74fd4942015-07-20 14:28:04 +0800184 *
185 * @return set of ports; empty if no ports is find
186 */
187 Set<OvsdbPort> getPorts();
188
189 /**
190 * Checks if the node is still connected.
191 *
192 * @return true if the node is still connected
193 */
194 boolean isConnected();
195
YuanyouZhangd06bb6b2015-08-05 16:59:07 +0800196 /**
197 * Gets the Bridge uuid.
198 *
199 * @param bridgeName bridge name
200 * @return bridge uuid, empty if no uuid is find
201 */
202 String getBridgeUuid(String bridgeName);
203
204 /**
205 * Gets the Port uuid.
206 *
andreaed976a42015-10-05 14:38:25 -0700207 * @param portName port name
YuanyouZhangd06bb6b2015-08-05 16:59:07 +0800208 * @param bridgeUuid bridge uuid
209 * @return port uuid, empty if no uuid is find
210 */
211 String getPortUuid(String portName, String bridgeUuid);
212
213 /**
214 * Gets the Interface uuid.
215 *
216 * @param portUuid port uuid
217 * @param portName port name
218 * @return interface uuid, empty if no uuid is find
219 */
220 String getInterfaceUuid(String portUuid, String portName);
221
222 /**
223 * Gets the Controller uuid.
224 *
andreaed976a42015-10-05 14:38:25 -0700225 * @param controllerName controller name
YuanyouZhangd06bb6b2015-08-05 16:59:07 +0800226 * @param controllerTarget controller target
227 * @return controller uuid, empty if no uuid is find
228 */
229 String getControllerUuid(String controllerName, String controllerTarget);
230
231 /**
BitOhenry3f28c682015-11-07 10:40:03 +0800232 * Gets the OVS uuid.
YuanyouZhangd06bb6b2015-08-05 16:59:07 +0800233 *
234 * @param dbName database name
235 * @return ovs uuid, empty if no uuid is find
236 */
237 String getOvsUuid(String dbName);
238
239 /**
BitOhenry3f28c682015-11-07 10:40:03 +0800240 * Gets the OVSDB database schema.
YuanyouZhangd06bb6b2015-08-05 16:59:07 +0800241 *
242 * @param dbName database name
243 * @return database schema
244 */
245 ListenableFuture<DatabaseSchema> getOvsdbSchema(String dbName);
246
247 /**
BitOhenry3f28c682015-11-07 10:40:03 +0800248 * Gets the OVSDB table updates.
YuanyouZhangd06bb6b2015-08-05 16:59:07 +0800249 *
250 * @param dbName database name
andreaed976a42015-10-05 14:38:25 -0700251 * @param id random uuid
YuanyouZhangd06bb6b2015-08-05 16:59:07 +0800252 * @return table updates
253 */
254 ListenableFuture<TableUpdates> monitorTables(String dbName, String id);
255
256 /**
BitOhenry3f28c682015-11-07 10:40:03 +0800257 * Gets the OVSDB config operation result.
YuanyouZhangd06bb6b2015-08-05 16:59:07 +0800258 *
andreaed976a42015-10-05 14:38:25 -0700259 * @param dbName database name
YuanyouZhangd06bb6b2015-08-05 16:59:07 +0800260 * @param operations the list of operations
261 * @return operation results
262 */
263 ListenableFuture<List<OperationResult>> transactConfig(String dbName,
264 List<Operation> operations);
265
266 /**
BitOhenry3f28c682015-11-07 10:40:03 +0800267 * Gets the OVSDB database schema from local.
YuanyouZhangd06bb6b2015-08-05 16:59:07 +0800268 *
andreaed976a42015-10-05 14:38:25 -0700269 * @param dbName database name
YuanyouZhangd06bb6b2015-08-05 16:59:07 +0800270 * @return database schema
271 */
272 DatabaseSchema getDatabaseSchema(String dbName);
273
274 /**
BitOhenry3f28c682015-11-07 10:40:03 +0800275 * Gets the OVSDB row from local OVSDB store.
YuanyouZhangd06bb6b2015-08-05 16:59:07 +0800276 *
andreaed976a42015-10-05 14:38:25 -0700277 * @param dbName database name
YuanyouZhangd06bb6b2015-08-05 16:59:07 +0800278 * @param tableName table name
andreaed976a42015-10-05 14:38:25 -0700279 * @param uuid row uuid
BitOhenry3f28c682015-11-07 10:40:03 +0800280 * @return row OVSDB row
YuanyouZhangd06bb6b2015-08-05 16:59:07 +0800281 */
282 Row getRow(String dbName, String tableName, String uuid);
283
284 /**
BitOhenry3f28c682015-11-07 10:40:03 +0800285 * Removes the OVSDB row from local OVSDB store.
YuanyouZhangd06bb6b2015-08-05 16:59:07 +0800286 *
andreaed976a42015-10-05 14:38:25 -0700287 * @param dbName database name
YuanyouZhangd06bb6b2015-08-05 16:59:07 +0800288 * @param tableName table name
andreaed976a42015-10-05 14:38:25 -0700289 * @param uuid row uuid
YuanyouZhangd06bb6b2015-08-05 16:59:07 +0800290 */
291 void removeRow(String dbName, String tableName, String uuid);
292
293 /**
BitOhenry3f28c682015-11-07 10:40:03 +0800294 * Updates the local OVSDB store.
YuanyouZhangd06bb6b2015-08-05 16:59:07 +0800295 *
andreaed976a42015-10-05 14:38:25 -0700296 * @param dbName database name
YuanyouZhangd06bb6b2015-08-05 16:59:07 +0800297 * @param tableName table name
andreaed976a42015-10-05 14:38:25 -0700298 * @param uuid row uuid
BitOhenry3f28c682015-11-07 10:40:03 +0800299 * @param row OVSDB row
YuanyouZhangd06bb6b2015-08-05 16:59:07 +0800300 */
301 void updateOvsdbStore(String dbName, String tableName, String uuid, Row row);
302
CNluciusa66c3972015-09-06 20:31:29 +0800303 /**
BitOhenry3f28c682015-11-07 10:40:03 +0800304 * Gets OVSDB local ports.
CNluciusa66c3972015-09-06 20:31:29 +0800305 *
306 * @param ifaceids the ifaceid that needed
BitOhenry3f28c682015-11-07 10:40:03 +0800307 * @return OVSDB ports
CNluciusa66c3972015-09-06 20:31:29 +0800308 */
309 Set<OvsdbPort> getLocalPorts(Iterable<String> ifaceids);
Hyunsun Moon5fb20a52015-09-25 17:02:33 -0700310
311 /**
BitOhenry3f28c682015-11-07 10:40:03 +0800312 * Disconnects the OVSDB server.
Hyunsun Moon5fb20a52015-09-25 17:02:33 -0700313 */
314 void disconnect();
CNlucius74fd4942015-07-20 14:28:04 +0800315}