CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
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 | |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 18 | import com.google.common.util.concurrent.ListenableFuture; |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 19 | import org.onlab.packet.IpAddress; |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 20 | import org.onosproject.net.DeviceId; |
| 21 | import org.onosproject.net.behaviour.ControllerInfo; |
Pier Ventre | f5d7236 | 2016-07-17 12:02:14 +0200 | [diff] [blame] | 22 | import org.onosproject.net.behaviour.MirroringStatistics; |
| 23 | import org.onosproject.net.behaviour.MirroringName; |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 24 | import org.onosproject.ovsdb.rfc.jsonrpc.OvsdbRpc; |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 25 | import org.onosproject.ovsdb.rfc.message.TableUpdates; |
| 26 | import org.onosproject.ovsdb.rfc.notation.Row; |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 27 | import org.onosproject.ovsdb.rfc.schema.DatabaseSchema; |
| 28 | |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 29 | import java.util.List; |
Hyunsun Moon | 646d8c4 | 2015-10-08 20:32:44 -0700 | [diff] [blame] | 30 | import java.util.Map; |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 31 | import java.util.Set; |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 32 | |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 33 | /** |
| 34 | * Represents to provider facing side of a node. |
| 35 | */ |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 36 | public interface OvsdbClientService extends OvsdbRpc { |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 37 | /** |
| 38 | * Gets the node identifier. |
| 39 | * |
| 40 | * @return node identifier |
| 41 | */ |
| 42 | OvsdbNodeId nodeId(); |
| 43 | |
| 44 | /** |
Pier Ventre | f5d7236 | 2016-07-17 12:02:14 +0200 | [diff] [blame] | 45 | * Creates a mirror port. Mirrors the traffic |
| 46 | * that goes to selectDstPort or comes from |
| 47 | * selectSrcPort or packets containing selectVlan |
| 48 | * to mirrorPort or to all ports that trunk mirrorVlan. |
| 49 | * |
| 50 | * @param bridgeName the name of the bridge |
| 51 | * @param mirror the OVSDB mirror description |
| 52 | * @return true if mirror creation is successful, false otherwise |
| 53 | */ |
| 54 | boolean createMirror(String bridgeName, OvsdbMirror mirror); |
| 55 | |
| 56 | /** |
| 57 | * Gets the Mirror uuid. |
| 58 | * |
| 59 | * @param mirrorName mirror name |
| 60 | * @return mirror uuid, empty if no uuid is found |
| 61 | */ |
| 62 | String getMirrorUuid(String mirrorName); |
| 63 | |
| 64 | /** |
| 65 | * Gets mirroring statistics of the device. |
| 66 | * |
| 67 | * @param deviceId target device id |
| 68 | * @return set of mirroring statistics; empty if no mirror is found |
| 69 | */ |
| 70 | Set<MirroringStatistics> getMirroringStatistics(DeviceId deviceId); |
| 71 | |
| 72 | /** |
| 73 | * Drops the configuration for mirror. |
| 74 | * |
Ray Milkey | ef79434 | 2016-11-09 16:20:29 -0800 | [diff] [blame] | 75 | * @param mirroringName name of mirror to drop |
Pier Ventre | f5d7236 | 2016-07-17 12:02:14 +0200 | [diff] [blame] | 76 | */ |
| 77 | void dropMirror(MirroringName mirroringName); |
| 78 | |
| 79 | /** |
Hyunsun Moon | 646d8c4 | 2015-10-08 20:32:44 -0700 | [diff] [blame] | 80 | * Creates a tunnel port with given options. |
| 81 | * |
Hyunsun Moon | dd14e8e | 2016-06-09 16:17:32 -0700 | [diff] [blame] | 82 | * @deprecated version 1.7.0 - Hummingbird |
Hyunsun Moon | 646d8c4 | 2015-10-08 20:32:44 -0700 | [diff] [blame] | 83 | * @param bridgeName bridge name |
| 84 | * @param portName port name |
| 85 | * @param tunnelType tunnel type |
| 86 | * @param options tunnel options |
| 87 | * @return true if tunnel creation is successful, false otherwise |
| 88 | */ |
Hyunsun Moon | dd14e8e | 2016-06-09 16:17:32 -0700 | [diff] [blame] | 89 | @Deprecated |
| 90 | boolean createTunnel(String bridgeName, String portName, String tunnelType, |
| 91 | Map<String, String> options); |
Hyunsun Moon | 646d8c4 | 2015-10-08 20:32:44 -0700 | [diff] [blame] | 92 | |
| 93 | /** |
BitOhenry | 264f35a | 2015-11-03 20:58:39 +0800 | [diff] [blame] | 94 | * Drops the configuration for tunnel. |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 95 | * |
Hyunsun Moon | dd14e8e | 2016-06-09 16:17:32 -0700 | [diff] [blame] | 96 | * @deprecated version 1.7.0 - Hummingbird |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 97 | * @param srcIp source IP address |
| 98 | * @param dstIp destination IP address |
| 99 | */ |
Hyunsun Moon | dd14e8e | 2016-06-09 16:17:32 -0700 | [diff] [blame] | 100 | @Deprecated |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 101 | void dropTunnel(IpAddress srcIp, IpAddress dstIp); |
| 102 | |
| 103 | /** |
Hyunsun Moon | dd14e8e | 2016-06-09 16:17:32 -0700 | [diff] [blame] | 104 | * Creates an interface with a given OVSDB interface description. |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 105 | * |
Hyunsun Moon | dd14e8e | 2016-06-09 16:17:32 -0700 | [diff] [blame] | 106 | * @param bridgeName bridge name |
| 107 | * @param ovsdbIface ovsdb interface description |
| 108 | * @return true if interface creation is successful, false otherwise |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 109 | */ |
Hyunsun Moon | dd14e8e | 2016-06-09 16:17:32 -0700 | [diff] [blame] | 110 | boolean createInterface(String bridgeName, OvsdbInterface ovsdbIface); |
| 111 | |
| 112 | /** |
| 113 | * Removes an interface with the supplied interface name. |
| 114 | * |
| 115 | * @param ifaceName interface name |
| 116 | * @return true if interface creation is successful, false otherwise |
| 117 | */ |
| 118 | boolean dropInterface(String ifaceName); |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 119 | |
| 120 | /** |
| 121 | * Creates a bridge. |
| 122 | * |
Hyunsun Moon | 1251e19 | 2016-06-07 16:57:05 -0700 | [diff] [blame] | 123 | * @deprecated version 1.7.0 - Hummingbird |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 124 | * @param bridgeName bridge name |
| 125 | */ |
Hyunsun Moon | 1251e19 | 2016-06-07 16:57:05 -0700 | [diff] [blame] | 126 | @Deprecated |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 127 | void createBridge(String bridgeName); |
| 128 | |
| 129 | /** |
lishuai | 6c56f5e | 2015-11-17 16:38:19 +0800 | [diff] [blame] | 130 | * Creates a bridge. |
| 131 | * |
Hyunsun Moon | 1251e19 | 2016-06-07 16:57:05 -0700 | [diff] [blame] | 132 | * @deprecated version 1.7.0 - Hummingbird |
lishuai | 6c56f5e | 2015-11-17 16:38:19 +0800 | [diff] [blame] | 133 | * @param bridgeName bridge name |
| 134 | * @param dpid data path id |
| 135 | * @param exPortName external port name |
| 136 | */ |
Hyunsun Moon | 1251e19 | 2016-06-07 16:57:05 -0700 | [diff] [blame] | 137 | @Deprecated |
lishuai | 6c56f5e | 2015-11-17 16:38:19 +0800 | [diff] [blame] | 138 | void createBridge(String bridgeName, String dpid, String exPortName); |
| 139 | |
| 140 | /** |
Hyunsun Moon | 646d8c4 | 2015-10-08 20:32:44 -0700 | [diff] [blame] | 141 | * Creates a bridge with given name and dpid. |
| 142 | * Sets the bridge's controller with given controllers. |
| 143 | * |
Hyunsun Moon | 1251e19 | 2016-06-07 16:57:05 -0700 | [diff] [blame] | 144 | * @deprecated version 1.7.0 - Hummingbird |
Hyunsun Moon | 646d8c4 | 2015-10-08 20:32:44 -0700 | [diff] [blame] | 145 | * @param bridgeName bridge name |
| 146 | * @param dpid data path id |
| 147 | * @param controllers controllers |
| 148 | * @return true if bridge creation is successful, false otherwise |
| 149 | */ |
Hyunsun Moon | 1251e19 | 2016-06-07 16:57:05 -0700 | [diff] [blame] | 150 | @Deprecated |
Hyunsun Moon | 646d8c4 | 2015-10-08 20:32:44 -0700 | [diff] [blame] | 151 | boolean createBridge(String bridgeName, String dpid, List<ControllerInfo> controllers); |
| 152 | |
| 153 | /** |
Hyunsun Moon | 1251e19 | 2016-06-07 16:57:05 -0700 | [diff] [blame] | 154 | * Creates a bridge with a given bridge description. |
| 155 | * |
| 156 | * @param ovsdbBridge ovsdb bridge description |
| 157 | * @return true if bridge creation is successful, otherwise false |
| 158 | */ |
| 159 | boolean createBridge(OvsdbBridge ovsdbBridge); |
| 160 | |
| 161 | /** |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 162 | * Drops a bridge. |
| 163 | * |
| 164 | * @param bridgeName bridge name |
| 165 | */ |
| 166 | void dropBridge(String bridgeName); |
| 167 | |
| 168 | /** |
BitOhenry | 264f35a | 2015-11-03 20:58:39 +0800 | [diff] [blame] | 169 | * Gets bridges of node. |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 170 | * |
| 171 | * @return set of bridges; empty if no bridge is find |
| 172 | */ |
| 173 | Set<OvsdbBridge> getBridges(); |
| 174 | |
| 175 | /** |
BitOhenry | 264f35a | 2015-11-03 20:58:39 +0800 | [diff] [blame] | 176 | * Gets controllers of node. |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 177 | * |
Brian O'Connor | 5251562 | 2015-10-09 17:03:44 -0700 | [diff] [blame] | 178 | * @param openflowDeviceId target device id |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 179 | * @return set of controllers; empty if no controller is find |
| 180 | */ |
| 181 | Set<ControllerInfo> getControllers(DeviceId openflowDeviceId); |
| 182 | |
| 183 | /** |
Hyunsun Moon | 1251e19 | 2016-06-07 16:57:05 -0700 | [diff] [blame] | 184 | * Returns local controller information. |
| 185 | * The connection is a TCP connection to the local ONOS instance's IP |
| 186 | * and the default OpenFlow port. |
| 187 | * |
| 188 | * @return local controller |
| 189 | */ |
| 190 | ControllerInfo localController(); |
| 191 | |
| 192 | /** |
Brian O'Connor | 6ee8aa3 | 2015-10-09 16:07:42 -0700 | [diff] [blame] | 193 | * Sets the Controllers for the specified device. |
Brian O'Connor | 5251562 | 2015-10-09 17:03:44 -0700 | [diff] [blame] | 194 | * <p> |
Brian O'Connor | 6ee8aa3 | 2015-10-09 16:07:42 -0700 | [diff] [blame] | 195 | * This method will replace the existing controller list with the new controller |
| 196 | * list. |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 197 | * |
Brian O'Connor | 6ee8aa3 | 2015-10-09 16:07:42 -0700 | [diff] [blame] | 198 | * @param deviceId device id (likely Openflow device) |
| 199 | * @param controllers list of controllers |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 200 | */ |
| 201 | void setControllersWithDeviceId(DeviceId deviceId, List<ControllerInfo> controllers); |
| 202 | |
| 203 | /** |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 204 | * Creates a port. |
| 205 | * |
| 206 | * @param bridgeName bridge name |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 207 | * @param portName port name |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 208 | */ |
| 209 | void createPort(String bridgeName, String portName); |
| 210 | |
| 211 | /** |
| 212 | * Drops a port. |
| 213 | * |
| 214 | * @param bridgeName bridge name |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 215 | * @param portName port name |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 216 | */ |
| 217 | void dropPort(String bridgeName, String portName); |
| 218 | |
| 219 | /** |
BitOhenry | 264f35a | 2015-11-03 20:58:39 +0800 | [diff] [blame] | 220 | * Gets ports of bridge. |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 221 | * |
| 222 | * @return set of ports; empty if no ports is find |
| 223 | */ |
| 224 | Set<OvsdbPort> getPorts(); |
| 225 | |
| 226 | /** |
| 227 | * Checks if the node is still connected. |
| 228 | * |
| 229 | * @return true if the node is still connected |
| 230 | */ |
| 231 | boolean isConnected(); |
| 232 | |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 233 | /** |
| 234 | * Gets the Bridge uuid. |
| 235 | * |
| 236 | * @param bridgeName bridge name |
| 237 | * @return bridge uuid, empty if no uuid is find |
| 238 | */ |
| 239 | String getBridgeUuid(String bridgeName); |
| 240 | |
| 241 | /** |
| 242 | * Gets the Port uuid. |
| 243 | * |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 244 | * @param portName port name |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 245 | * @param bridgeUuid bridge uuid |
| 246 | * @return port uuid, empty if no uuid is find |
| 247 | */ |
| 248 | String getPortUuid(String portName, String bridgeUuid); |
| 249 | |
| 250 | /** |
BitOhenry | 3f28c68 | 2015-11-07 10:40:03 +0800 | [diff] [blame] | 251 | * Gets the OVSDB database schema. |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 252 | * |
| 253 | * @param dbName database name |
| 254 | * @return database schema |
| 255 | */ |
| 256 | ListenableFuture<DatabaseSchema> getOvsdbSchema(String dbName); |
| 257 | |
| 258 | /** |
BitOhenry | 3f28c68 | 2015-11-07 10:40:03 +0800 | [diff] [blame] | 259 | * Gets the OVSDB table updates. |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 260 | * |
| 261 | * @param dbName database name |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 262 | * @param id random uuid |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 263 | * @return table updates |
| 264 | */ |
| 265 | ListenableFuture<TableUpdates> monitorTables(String dbName, String id); |
| 266 | |
| 267 | /** |
BitOhenry | 3f28c68 | 2015-11-07 10:40:03 +0800 | [diff] [blame] | 268 | * Gets the OVSDB database schema from local. |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 269 | * |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 270 | * @param dbName database name |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 271 | * @return database schema |
| 272 | */ |
| 273 | DatabaseSchema getDatabaseSchema(String dbName); |
| 274 | |
| 275 | /** |
BitOhenry | 3f28c68 | 2015-11-07 10:40:03 +0800 | [diff] [blame] | 276 | * Gets the OVSDB row from local OVSDB store. |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 277 | * |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 278 | * @param dbName database name |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 279 | * @param tableName table name |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 280 | * @param uuid row uuid |
BitOhenry | 3f28c68 | 2015-11-07 10:40:03 +0800 | [diff] [blame] | 281 | * @return row OVSDB row |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 282 | */ |
| 283 | Row getRow(String dbName, String tableName, String uuid); |
| 284 | |
| 285 | /** |
BitOhenry | 3f28c68 | 2015-11-07 10:40:03 +0800 | [diff] [blame] | 286 | * Removes the OVSDB row from local OVSDB store. |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 287 | * |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 288 | * @param dbName database name |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 289 | * @param tableName table name |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 290 | * @param uuid row uuid |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 291 | */ |
| 292 | void removeRow(String dbName, String tableName, String uuid); |
| 293 | |
| 294 | /** |
BitOhenry | 3f28c68 | 2015-11-07 10:40:03 +0800 | [diff] [blame] | 295 | * Updates the local OVSDB store. |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 296 | * |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 297 | * @param dbName database name |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 298 | * @param tableName table name |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 299 | * @param uuid row uuid |
BitOhenry | 3f28c68 | 2015-11-07 10:40:03 +0800 | [diff] [blame] | 300 | * @param row OVSDB row |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 301 | */ |
| 302 | void updateOvsdbStore(String dbName, String tableName, String uuid, Row row); |
| 303 | |
CNlucius | a66c397 | 2015-09-06 20:31:29 +0800 | [diff] [blame] | 304 | /** |
BitOhenry | 3f28c68 | 2015-11-07 10:40:03 +0800 | [diff] [blame] | 305 | * Gets OVSDB local ports. |
CNlucius | a66c397 | 2015-09-06 20:31:29 +0800 | [diff] [blame] | 306 | * |
| 307 | * @param ifaceids the ifaceid that needed |
BitOhenry | 3f28c68 | 2015-11-07 10:40:03 +0800 | [diff] [blame] | 308 | * @return OVSDB ports |
CNlucius | a66c397 | 2015-09-06 20:31:29 +0800 | [diff] [blame] | 309 | */ |
| 310 | Set<OvsdbPort> getLocalPorts(Iterable<String> ifaceids); |
Hyunsun Moon | 5fb20a5 | 2015-09-25 17:02:33 -0700 | [diff] [blame] | 311 | |
| 312 | /** |
BitOhenry | 3f28c68 | 2015-11-07 10:40:03 +0800 | [diff] [blame] | 313 | * Disconnects the OVSDB server. |
Hyunsun Moon | 5fb20a5 | 2015-09-25 17:02:33 -0700 | [diff] [blame] | 314 | */ |
| 315 | void disconnect(); |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 316 | } |