CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame^] | 2 | * Copyright 2015-present Open Networking Foundation |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 3 | * |
| 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 | */ |
| 16 | package org.onosproject.ovsdb.controller; |
| 17 | |
Ray Milkey | b125032 | 2017-06-05 17:18:17 -0700 | [diff] [blame] | 18 | import java.util.List; |
| 19 | import java.util.Set; |
| 20 | |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 21 | import org.onosproject.net.DeviceId; |
Frank Wang | e11a98d | 2016-10-26 17:04:03 +0800 | [diff] [blame] | 22 | import org.onosproject.net.PortNumber; |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 23 | import org.onosproject.net.behaviour.ControllerInfo; |
Pier Ventre | f5d7236 | 2016-07-17 12:02:14 +0200 | [diff] [blame] | 24 | import org.onosproject.net.behaviour.MirroringName; |
Ray Milkey | b125032 | 2017-06-05 17:18:17 -0700 | [diff] [blame] | 25 | import org.onosproject.net.behaviour.MirroringStatistics; |
Frank Wang | e11a98d | 2016-10-26 17:04:03 +0800 | [diff] [blame] | 26 | import org.onosproject.net.behaviour.QosId; |
| 27 | import org.onosproject.net.behaviour.QueueId; |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 28 | import org.onosproject.ovsdb.rfc.jsonrpc.OvsdbRpc; |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 29 | import org.onosproject.ovsdb.rfc.message.TableUpdates; |
| 30 | import org.onosproject.ovsdb.rfc.notation.Row; |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 31 | import org.onosproject.ovsdb.rfc.schema.DatabaseSchema; |
| 32 | |
Ray Milkey | b125032 | 2017-06-05 17:18:17 -0700 | [diff] [blame] | 33 | import com.google.common.util.concurrent.ListenableFuture; |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 34 | |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 35 | /** |
| 36 | * Represents to provider facing side of a node. |
| 37 | */ |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 38 | public interface OvsdbClientService extends OvsdbRpc { |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 39 | /** |
| 40 | * Gets the node identifier. |
| 41 | * |
| 42 | * @return node identifier |
| 43 | */ |
| 44 | OvsdbNodeId nodeId(); |
| 45 | |
| 46 | /** |
Pier Ventre | f5d7236 | 2016-07-17 12:02:14 +0200 | [diff] [blame] | 47 | * Creates a mirror port. Mirrors the traffic |
| 48 | * that goes to selectDstPort or comes from |
| 49 | * selectSrcPort or packets containing selectVlan |
| 50 | * to mirrorPort or to all ports that trunk mirrorVlan. |
| 51 | * |
| 52 | * @param bridgeName the name of the bridge |
| 53 | * @param mirror the OVSDB mirror description |
| 54 | * @return true if mirror creation is successful, false otherwise |
| 55 | */ |
| 56 | boolean createMirror(String bridgeName, OvsdbMirror mirror); |
| 57 | |
| 58 | /** |
| 59 | * Gets the Mirror uuid. |
| 60 | * |
| 61 | * @param mirrorName mirror name |
| 62 | * @return mirror uuid, empty if no uuid is found |
| 63 | */ |
| 64 | String getMirrorUuid(String mirrorName); |
| 65 | |
| 66 | /** |
| 67 | * Gets mirroring statistics of the device. |
| 68 | * |
| 69 | * @param deviceId target device id |
| 70 | * @return set of mirroring statistics; empty if no mirror is found |
| 71 | */ |
| 72 | Set<MirroringStatistics> getMirroringStatistics(DeviceId deviceId); |
| 73 | |
| 74 | /** |
| 75 | * Drops the configuration for mirror. |
| 76 | * |
Ray Milkey | ef79434 | 2016-11-09 16:20:29 -0800 | [diff] [blame] | 77 | * @param mirroringName name of mirror to drop |
Pier Ventre | f5d7236 | 2016-07-17 12:02:14 +0200 | [diff] [blame] | 78 | */ |
| 79 | void dropMirror(MirroringName mirroringName); |
| 80 | |
| 81 | /** |
Frank Wang | e11a98d | 2016-10-26 17:04:03 +0800 | [diff] [blame] | 82 | * apply qos to port. |
| 83 | * |
| 84 | * @param portNumber port identifier |
| 85 | * @param qosName the qos name |
| 86 | */ |
| 87 | void applyQos(PortNumber portNumber, String qosName); |
| 88 | |
| 89 | /** |
| 90 | * Creates a qos port. |
| 91 | * |
| 92 | * @param portNumber port identifier |
| 93 | */ |
| 94 | void removeQos(PortNumber portNumber); |
| 95 | |
| 96 | /** |
| 97 | * Creates a qos. associates with queue to |
| 98 | * provide the ability of limit the rate of different flows |
| 99 | * depend on itself priority. |
| 100 | * |
| 101 | * @param ovsdbQos the OVSDB Qos |
| 102 | * @return true if qos creation is successful, false otherwise |
| 103 | */ |
| 104 | boolean createQos(OvsdbQos ovsdbQos); |
| 105 | |
| 106 | /** |
| 107 | * Drops the configuration for qos. |
| 108 | * |
| 109 | * @param qosId qos identifier |
| 110 | */ |
| 111 | void dropQos(QosId qosId); |
| 112 | |
| 113 | /** |
| 114 | * Gets a qos of node. |
| 115 | * @param qosId qos identifier |
| 116 | * @return null if no qos is find |
| 117 | */ |
| 118 | OvsdbQos getQos(QosId qosId); |
| 119 | |
| 120 | /** |
| 121 | * Gets qoses of node. |
| 122 | * |
| 123 | * @return set of qoses; empty if no qos is find |
| 124 | */ |
| 125 | Set<OvsdbQos> getQoses(); |
| 126 | |
| 127 | /** |
| 128 | * Creates queues. limits the rate of each flow |
| 129 | * depend on itself priority. |
| 130 | * |
| 131 | * @param queue the OVSDB queue description |
| 132 | * @return true if queue creation is successful, false otherwise |
| 133 | */ |
| 134 | boolean createQueue(OvsdbQueue queue); |
| 135 | |
| 136 | /** |
| 137 | * Drops the configuration for queue. |
| 138 | * |
| 139 | * @param queueId queue identifier |
| 140 | */ |
| 141 | void dropQueue(QueueId queueId); |
| 142 | |
| 143 | /** |
| 144 | * Gets a queue of node. |
| 145 | * @param queueId the queue identifier |
| 146 | * @return null if no queue is find |
| 147 | */ |
| 148 | OvsdbQueue getQueue(QueueId queueId); |
| 149 | |
| 150 | /** |
| 151 | * Gets queues of node. |
| 152 | * |
| 153 | * @return set of queues; empty if no queue is find |
| 154 | */ |
| 155 | Set<OvsdbQueue> getQueues(); |
| 156 | |
| 157 | /** |
Hyunsun Moon | dd14e8e | 2016-06-09 16:17:32 -0700 | [diff] [blame] | 158 | * Creates an interface with a given OVSDB interface description. |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 159 | * |
Hyunsun Moon | dd14e8e | 2016-06-09 16:17:32 -0700 | [diff] [blame] | 160 | * @param bridgeName bridge name |
| 161 | * @param ovsdbIface ovsdb interface description |
| 162 | * @return true if interface creation is successful, false otherwise |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 163 | */ |
Hyunsun Moon | dd14e8e | 2016-06-09 16:17:32 -0700 | [diff] [blame] | 164 | boolean createInterface(String bridgeName, OvsdbInterface ovsdbIface); |
| 165 | |
| 166 | /** |
| 167 | * Removes an interface with the supplied interface name. |
| 168 | * |
| 169 | * @param ifaceName interface name |
| 170 | * @return true if interface creation is successful, false otherwise |
| 171 | */ |
| 172 | boolean dropInterface(String ifaceName); |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 173 | |
| 174 | /** |
Hyunsun Moon | 1251e19 | 2016-06-07 16:57:05 -0700 | [diff] [blame] | 175 | * Creates a bridge with a given bridge description. |
| 176 | * |
| 177 | * @param ovsdbBridge ovsdb bridge description |
| 178 | * @return true if bridge creation is successful, otherwise false |
| 179 | */ |
| 180 | boolean createBridge(OvsdbBridge ovsdbBridge); |
| 181 | |
| 182 | /** |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 183 | * Drops a bridge. |
| 184 | * |
| 185 | * @param bridgeName bridge name |
| 186 | */ |
| 187 | void dropBridge(String bridgeName); |
| 188 | |
| 189 | /** |
BitOhenry | 264f35a | 2015-11-03 20:58:39 +0800 | [diff] [blame] | 190 | * Gets bridges of node. |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 191 | * |
| 192 | * @return set of bridges; empty if no bridge is find |
| 193 | */ |
| 194 | Set<OvsdbBridge> getBridges(); |
| 195 | |
| 196 | /** |
BitOhenry | 264f35a | 2015-11-03 20:58:39 +0800 | [diff] [blame] | 197 | * Gets controllers of node. |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 198 | * |
Brian O'Connor | 5251562 | 2015-10-09 17:03:44 -0700 | [diff] [blame] | 199 | * @param openflowDeviceId target device id |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 200 | * @return set of controllers; empty if no controller is find |
| 201 | */ |
| 202 | Set<ControllerInfo> getControllers(DeviceId openflowDeviceId); |
| 203 | |
| 204 | /** |
Hyunsun Moon | 1251e19 | 2016-06-07 16:57:05 -0700 | [diff] [blame] | 205 | * Returns local controller information. |
| 206 | * The connection is a TCP connection to the local ONOS instance's IP |
| 207 | * and the default OpenFlow port. |
| 208 | * |
| 209 | * @return local controller |
| 210 | */ |
| 211 | ControllerInfo localController(); |
| 212 | |
| 213 | /** |
Brian O'Connor | 6ee8aa3 | 2015-10-09 16:07:42 -0700 | [diff] [blame] | 214 | * Sets the Controllers for the specified device. |
Brian O'Connor | 5251562 | 2015-10-09 17:03:44 -0700 | [diff] [blame] | 215 | * <p> |
Brian O'Connor | 6ee8aa3 | 2015-10-09 16:07:42 -0700 | [diff] [blame] | 216 | * This method will replace the existing controller list with the new controller |
| 217 | * list. |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 218 | * |
Brian O'Connor | 6ee8aa3 | 2015-10-09 16:07:42 -0700 | [diff] [blame] | 219 | * @param deviceId device id (likely Openflow device) |
| 220 | * @param controllers list of controllers |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 221 | */ |
| 222 | void setControllersWithDeviceId(DeviceId deviceId, List<ControllerInfo> controllers); |
| 223 | |
| 224 | /** |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 225 | * Creates a port. |
| 226 | * |
| 227 | * @param bridgeName bridge name |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 228 | * @param portName port name |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 229 | */ |
| 230 | void createPort(String bridgeName, String portName); |
| 231 | |
| 232 | /** |
| 233 | * Drops a port. |
| 234 | * |
| 235 | * @param bridgeName bridge name |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 236 | * @param portName port name |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 237 | */ |
| 238 | void dropPort(String bridgeName, String portName); |
| 239 | |
| 240 | /** |
BitOhenry | 264f35a | 2015-11-03 20:58:39 +0800 | [diff] [blame] | 241 | * Gets ports of bridge. |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 242 | * |
| 243 | * @return set of ports; empty if no ports is find |
| 244 | */ |
| 245 | Set<OvsdbPort> getPorts(); |
| 246 | |
| 247 | /** |
| 248 | * Checks if the node is still connected. |
| 249 | * |
| 250 | * @return true if the node is still connected |
| 251 | */ |
| 252 | boolean isConnected(); |
| 253 | |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 254 | /** |
| 255 | * Gets the Bridge uuid. |
| 256 | * |
| 257 | * @param bridgeName bridge name |
| 258 | * @return bridge uuid, empty if no uuid is find |
| 259 | */ |
| 260 | String getBridgeUuid(String bridgeName); |
| 261 | |
| 262 | /** |
| 263 | * Gets the Port uuid. |
| 264 | * |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 265 | * @param portName port name |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 266 | * @param bridgeUuid bridge uuid |
| 267 | * @return port uuid, empty if no uuid is find |
| 268 | */ |
| 269 | String getPortUuid(String portName, String bridgeUuid); |
| 270 | |
| 271 | /** |
BitOhenry | 3f28c68 | 2015-11-07 10:40:03 +0800 | [diff] [blame] | 272 | * Gets the OVSDB database schema. |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 273 | * |
| 274 | * @param dbName database name |
| 275 | * @return database schema |
| 276 | */ |
| 277 | ListenableFuture<DatabaseSchema> getOvsdbSchema(String dbName); |
| 278 | |
| 279 | /** |
BitOhenry | 3f28c68 | 2015-11-07 10:40:03 +0800 | [diff] [blame] | 280 | * Gets the OVSDB table updates. |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 281 | * |
| 282 | * @param dbName database name |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 283 | * @param id random uuid |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 284 | * @return table updates |
| 285 | */ |
| 286 | ListenableFuture<TableUpdates> monitorTables(String dbName, String id); |
| 287 | |
| 288 | /** |
BitOhenry | 3f28c68 | 2015-11-07 10:40:03 +0800 | [diff] [blame] | 289 | * Gets the OVSDB database schema from local. |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 290 | * |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 291 | * @param dbName database name |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 292 | * @return database schema |
| 293 | */ |
| 294 | DatabaseSchema getDatabaseSchema(String dbName); |
| 295 | |
| 296 | /** |
BitOhenry | 3f28c68 | 2015-11-07 10:40:03 +0800 | [diff] [blame] | 297 | * Gets the OVSDB row from local OVSDB store. |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 298 | * |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 299 | * @param dbName database name |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 300 | * @param tableName table name |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 301 | * @param uuid row uuid |
BitOhenry | 3f28c68 | 2015-11-07 10:40:03 +0800 | [diff] [blame] | 302 | * @return row OVSDB row |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 303 | */ |
| 304 | Row getRow(String dbName, String tableName, String uuid); |
| 305 | |
| 306 | /** |
BitOhenry | 3f28c68 | 2015-11-07 10:40:03 +0800 | [diff] [blame] | 307 | * Removes the OVSDB row from local OVSDB store. |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 308 | * |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 309 | * @param dbName database name |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 310 | * @param tableName table name |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 311 | * @param uuid row uuid |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 312 | */ |
| 313 | void removeRow(String dbName, String tableName, String uuid); |
| 314 | |
| 315 | /** |
BitOhenry | 3f28c68 | 2015-11-07 10:40:03 +0800 | [diff] [blame] | 316 | * Updates the local OVSDB store. |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 317 | * |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 318 | * @param dbName database name |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 319 | * @param tableName table name |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 320 | * @param uuid row uuid |
BitOhenry | 3f28c68 | 2015-11-07 10:40:03 +0800 | [diff] [blame] | 321 | * @param row OVSDB row |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 322 | */ |
| 323 | void updateOvsdbStore(String dbName, String tableName, String uuid, Row row); |
| 324 | |
CNlucius | a66c397 | 2015-09-06 20:31:29 +0800 | [diff] [blame] | 325 | /** |
BitOhenry | 3f28c68 | 2015-11-07 10:40:03 +0800 | [diff] [blame] | 326 | * Gets OVSDB local ports. |
CNlucius | a66c397 | 2015-09-06 20:31:29 +0800 | [diff] [blame] | 327 | * |
| 328 | * @param ifaceids the ifaceid that needed |
BitOhenry | 3f28c68 | 2015-11-07 10:40:03 +0800 | [diff] [blame] | 329 | * @return OVSDB ports |
CNlucius | a66c397 | 2015-09-06 20:31:29 +0800 | [diff] [blame] | 330 | */ |
| 331 | Set<OvsdbPort> getLocalPorts(Iterable<String> ifaceids); |
Hyunsun Moon | 5fb20a5 | 2015-09-25 17:02:33 -0700 | [diff] [blame] | 332 | |
| 333 | /** |
BitOhenry | 3f28c68 | 2015-11-07 10:40:03 +0800 | [diff] [blame] | 334 | * Disconnects the OVSDB server. |
Hyunsun Moon | 5fb20a5 | 2015-09-25 17:02:33 -0700 | [diff] [blame] | 335 | */ |
| 336 | void disconnect(); |
Saritha | 1583a6f | 2017-06-16 14:42:58 +0530 | [diff] [blame] | 337 | |
| 338 | /** |
| 339 | * Gets created ports for the particular bridgeId. |
| 340 | * |
| 341 | * @param portNames the portNames which needs to checked for create |
| 342 | * @param bridgeId bridgeIdentifier |
| 343 | * @return OvsdbPortNames the created ports from port table for the bridgeId by considering input port list. |
| 344 | * Considered port as created if port's interface table also gets created,irrespective |
| 345 | * of ofport value(has errors or not) |
| 346 | */ |
| 347 | public List<OvsdbPortName> getPorts(List<String> portNames, DeviceId bridgeId); |
| 348 | |
| 349 | /** |
| 350 | * Gets error status for the given portNames. |
| 351 | * |
| 352 | * @param portNames the portNames which need to be checked for errors |
| 353 | * @param bridgeId bridgeIdentifier |
| 354 | * @return errorstatus true if input port list contains error, false otherwise |
| 355 | */ |
| 356 | boolean getPortError(List<OvsdbPortName> portNames, DeviceId bridgeId); |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 357 | } |