CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Open Networking Laboratory |
| 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; |
lishuai | 6c56f5e | 2015-11-17 16:38:19 +0800 | [diff] [blame] | 19 | |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 20 | import org.onlab.packet.IpAddress; |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 21 | import org.onosproject.net.DeviceId; |
| 22 | import org.onosproject.net.behaviour.ControllerInfo; |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 23 | import org.onosproject.ovsdb.rfc.jsonrpc.OvsdbRpc; |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 24 | import org.onosproject.ovsdb.rfc.message.OperationResult; |
| 25 | import org.onosproject.ovsdb.rfc.message.TableUpdates; |
| 26 | import org.onosproject.ovsdb.rfc.notation.Row; |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 27 | import org.onosproject.ovsdb.rfc.notation.Uuid; |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 28 | import org.onosproject.ovsdb.rfc.operations.Operation; |
| 29 | import org.onosproject.ovsdb.rfc.schema.DatabaseSchema; |
| 30 | |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 31 | import java.util.List; |
Hyunsun Moon | 646d8c4 | 2015-10-08 20:32:44 -0700 | [diff] [blame] | 32 | import java.util.Map; |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 33 | import java.util.Set; |
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 | /** |
Hyunsun Moon | 646d8c4 | 2015-10-08 20:32:44 -0700 | [diff] [blame] | 47 | * 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 | /** |
BitOhenry | 264f35a | 2015-11-03 20:58:39 +0800 | [diff] [blame] | 58 | * Drops the configuration for tunnel. |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 59 | * |
| 60 | * @param srcIp source IP address |
| 61 | * @param dstIp destination IP address |
| 62 | */ |
| 63 | void dropTunnel(IpAddress srcIp, IpAddress dstIp); |
| 64 | |
| 65 | /** |
BitOhenry | 264f35a | 2015-11-03 20:58:39 +0800 | [diff] [blame] | 66 | * Gets tunnels of node. |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 67 | * |
| 68 | * @return set of tunnels; empty if no tunnel is find |
| 69 | */ |
| 70 | Set<OvsdbTunnel> getTunnels(); |
| 71 | |
| 72 | /** |
| 73 | * Creates a bridge. |
| 74 | * |
| 75 | * @param bridgeName bridge name |
| 76 | */ |
| 77 | void createBridge(String bridgeName); |
| 78 | |
| 79 | /** |
lishuai | 6c56f5e | 2015-11-17 16:38:19 +0800 | [diff] [blame] | 80 | * Creates a bridge. |
| 81 | * |
| 82 | * @param bridgeName bridge name |
| 83 | * @param dpid data path id |
| 84 | * @param exPortName external port name |
| 85 | */ |
| 86 | void createBridge(String bridgeName, String dpid, String exPortName); |
| 87 | |
| 88 | /** |
Hyunsun Moon | 646d8c4 | 2015-10-08 20:32:44 -0700 | [diff] [blame] | 89 | * Creates a bridge with given name and dpid. |
| 90 | * Sets the bridge's controller with given controllers. |
| 91 | * |
| 92 | * @param bridgeName bridge name |
| 93 | * @param dpid data path id |
| 94 | * @param controllers controllers |
| 95 | * @return true if bridge creation is successful, false otherwise |
| 96 | */ |
| 97 | boolean createBridge(String bridgeName, String dpid, List<ControllerInfo> controllers); |
| 98 | |
| 99 | /** |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 100 | * Drops a bridge. |
| 101 | * |
| 102 | * @param bridgeName bridge name |
| 103 | */ |
| 104 | void dropBridge(String bridgeName); |
| 105 | |
| 106 | /** |
BitOhenry | 264f35a | 2015-11-03 20:58:39 +0800 | [diff] [blame] | 107 | * Gets bridges of node. |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 108 | * |
| 109 | * @return set of bridges; empty if no bridge is find |
| 110 | */ |
| 111 | Set<OvsdbBridge> getBridges(); |
| 112 | |
| 113 | /** |
BitOhenry | 264f35a | 2015-11-03 20:58:39 +0800 | [diff] [blame] | 114 | * Gets controllers of node. |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 115 | * |
Brian O'Connor | 5251562 | 2015-10-09 17:03:44 -0700 | [diff] [blame] | 116 | * @param openflowDeviceId target device id |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 117 | * @return set of controllers; empty if no controller is find |
| 118 | */ |
| 119 | Set<ControllerInfo> getControllers(DeviceId openflowDeviceId); |
| 120 | |
| 121 | /** |
Brian O'Connor | 6ee8aa3 | 2015-10-09 16:07:42 -0700 | [diff] [blame] | 122 | * Sets the Controllers for the specified bridge. |
Brian O'Connor | 5251562 | 2015-10-09 17:03:44 -0700 | [diff] [blame] | 123 | * <p> |
Brian O'Connor | 6ee8aa3 | 2015-10-09 16:07:42 -0700 | [diff] [blame] | 124 | * This method will replace the existing controller list with the new controller |
| 125 | * list. |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 126 | * |
Brian O'Connor | 6ee8aa3 | 2015-10-09 16:07:42 -0700 | [diff] [blame] | 127 | * @param bridgeUuid bridge uuid |
| 128 | * @param controllers list of controllers |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 129 | */ |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 130 | void setControllersWithUuid(Uuid bridgeUuid, List<ControllerInfo> controllers); |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 131 | |
| 132 | /** |
Brian O'Connor | 6ee8aa3 | 2015-10-09 16:07:42 -0700 | [diff] [blame] | 133 | * Sets the Controllers for the specified device. |
Brian O'Connor | 5251562 | 2015-10-09 17:03:44 -0700 | [diff] [blame] | 134 | * <p> |
Brian O'Connor | 6ee8aa3 | 2015-10-09 16:07:42 -0700 | [diff] [blame] | 135 | * This method will replace the existing controller list with the new controller |
| 136 | * list. |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 137 | * |
Brian O'Connor | 6ee8aa3 | 2015-10-09 16:07:42 -0700 | [diff] [blame] | 138 | * @param deviceId device id (likely Openflow device) |
| 139 | * @param controllers list of controllers |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 140 | */ |
| 141 | void setControllersWithDeviceId(DeviceId deviceId, List<ControllerInfo> controllers); |
| 142 | |
| 143 | /** |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 144 | * Creates a port. |
| 145 | * |
| 146 | * @param bridgeName bridge name |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 147 | * @param portName port name |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 148 | */ |
| 149 | void createPort(String bridgeName, String portName); |
| 150 | |
| 151 | /** |
| 152 | * Drops a port. |
| 153 | * |
| 154 | * @param bridgeName bridge name |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 155 | * @param portName port name |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 156 | */ |
| 157 | void dropPort(String bridgeName, String portName); |
| 158 | |
| 159 | /** |
BitOhenry | 264f35a | 2015-11-03 20:58:39 +0800 | [diff] [blame] | 160 | * Gets ports of bridge. |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 161 | * |
| 162 | * @return set of ports; empty if no ports is find |
| 163 | */ |
| 164 | Set<OvsdbPort> getPorts(); |
| 165 | |
| 166 | /** |
| 167 | * Checks if the node is still connected. |
| 168 | * |
| 169 | * @return true if the node is still connected |
| 170 | */ |
| 171 | boolean isConnected(); |
| 172 | |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 173 | /** |
| 174 | * Gets the Bridge uuid. |
| 175 | * |
| 176 | * @param bridgeName bridge name |
| 177 | * @return bridge uuid, empty if no uuid is find |
| 178 | */ |
| 179 | String getBridgeUuid(String bridgeName); |
| 180 | |
| 181 | /** |
| 182 | * Gets the Port uuid. |
| 183 | * |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 184 | * @param portName port name |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 185 | * @param bridgeUuid bridge uuid |
| 186 | * @return port uuid, empty if no uuid is find |
| 187 | */ |
| 188 | String getPortUuid(String portName, String bridgeUuid); |
| 189 | |
| 190 | /** |
| 191 | * Gets the Interface uuid. |
| 192 | * |
| 193 | * @param portUuid port uuid |
| 194 | * @param portName port name |
| 195 | * @return interface uuid, empty if no uuid is find |
| 196 | */ |
| 197 | String getInterfaceUuid(String portUuid, String portName); |
| 198 | |
| 199 | /** |
| 200 | * Gets the Controller uuid. |
| 201 | * |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 202 | * @param controllerName controller name |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 203 | * @param controllerTarget controller target |
| 204 | * @return controller uuid, empty if no uuid is find |
| 205 | */ |
| 206 | String getControllerUuid(String controllerName, String controllerTarget); |
| 207 | |
| 208 | /** |
BitOhenry | 3f28c68 | 2015-11-07 10:40:03 +0800 | [diff] [blame] | 209 | * Gets the OVS uuid. |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 210 | * |
| 211 | * @param dbName database name |
| 212 | * @return ovs uuid, empty if no uuid is find |
| 213 | */ |
| 214 | String getOvsUuid(String dbName); |
| 215 | |
| 216 | /** |
BitOhenry | 3f28c68 | 2015-11-07 10:40:03 +0800 | [diff] [blame] | 217 | * Gets the OVSDB database schema. |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 218 | * |
| 219 | * @param dbName database name |
| 220 | * @return database schema |
| 221 | */ |
| 222 | ListenableFuture<DatabaseSchema> getOvsdbSchema(String dbName); |
| 223 | |
| 224 | /** |
BitOhenry | 3f28c68 | 2015-11-07 10:40:03 +0800 | [diff] [blame] | 225 | * Gets the OVSDB table updates. |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 226 | * |
| 227 | * @param dbName database name |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 228 | * @param id random uuid |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 229 | * @return table updates |
| 230 | */ |
| 231 | ListenableFuture<TableUpdates> monitorTables(String dbName, String id); |
| 232 | |
| 233 | /** |
BitOhenry | 3f28c68 | 2015-11-07 10:40:03 +0800 | [diff] [blame] | 234 | * Gets the OVSDB config operation result. |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 235 | * |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 236 | * @param dbName database name |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 237 | * @param operations the list of operations |
| 238 | * @return operation results |
| 239 | */ |
| 240 | ListenableFuture<List<OperationResult>> transactConfig(String dbName, |
| 241 | List<Operation> operations); |
| 242 | |
| 243 | /** |
BitOhenry | 3f28c68 | 2015-11-07 10:40:03 +0800 | [diff] [blame] | 244 | * Gets the OVSDB database schema from local. |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 245 | * |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 246 | * @param dbName database name |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 247 | * @return database schema |
| 248 | */ |
| 249 | DatabaseSchema getDatabaseSchema(String dbName); |
| 250 | |
| 251 | /** |
BitOhenry | 3f28c68 | 2015-11-07 10:40:03 +0800 | [diff] [blame] | 252 | * Gets the OVSDB row from local OVSDB store. |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 253 | * |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 254 | * @param dbName database name |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 255 | * @param tableName table name |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 256 | * @param uuid row uuid |
BitOhenry | 3f28c68 | 2015-11-07 10:40:03 +0800 | [diff] [blame] | 257 | * @return row OVSDB row |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 258 | */ |
| 259 | Row getRow(String dbName, String tableName, String uuid); |
| 260 | |
| 261 | /** |
BitOhenry | 3f28c68 | 2015-11-07 10:40:03 +0800 | [diff] [blame] | 262 | * Removes the OVSDB row from local OVSDB store. |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 263 | * |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 264 | * @param dbName database name |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 265 | * @param tableName table name |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 266 | * @param uuid row uuid |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 267 | */ |
| 268 | void removeRow(String dbName, String tableName, String uuid); |
| 269 | |
| 270 | /** |
BitOhenry | 3f28c68 | 2015-11-07 10:40:03 +0800 | [diff] [blame] | 271 | * Updates the local OVSDB store. |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 272 | * |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 273 | * @param dbName database name |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 274 | * @param tableName table name |
andrea | ed976a4 | 2015-10-05 14:38:25 -0700 | [diff] [blame] | 275 | * @param uuid row uuid |
BitOhenry | 3f28c68 | 2015-11-07 10:40:03 +0800 | [diff] [blame] | 276 | * @param row OVSDB row |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 277 | */ |
| 278 | void updateOvsdbStore(String dbName, String tableName, String uuid, Row row); |
| 279 | |
CNlucius | a66c397 | 2015-09-06 20:31:29 +0800 | [diff] [blame] | 280 | /** |
BitOhenry | 3f28c68 | 2015-11-07 10:40:03 +0800 | [diff] [blame] | 281 | * Gets OVSDB local ports. |
CNlucius | a66c397 | 2015-09-06 20:31:29 +0800 | [diff] [blame] | 282 | * |
| 283 | * @param ifaceids the ifaceid that needed |
BitOhenry | 3f28c68 | 2015-11-07 10:40:03 +0800 | [diff] [blame] | 284 | * @return OVSDB ports |
CNlucius | a66c397 | 2015-09-06 20:31:29 +0800 | [diff] [blame] | 285 | */ |
| 286 | Set<OvsdbPort> getLocalPorts(Iterable<String> ifaceids); |
Hyunsun Moon | 5fb20a5 | 2015-09-25 17:02:33 -0700 | [diff] [blame] | 287 | |
| 288 | /** |
BitOhenry | 3f28c68 | 2015-11-07 10:40:03 +0800 | [diff] [blame] | 289 | * Disconnects the OVSDB server. |
Hyunsun Moon | 5fb20a5 | 2015-09-25 17:02:33 -0700 | [diff] [blame] | 290 | */ |
| 291 | void disconnect(); |
CNlucius | 74fd494 | 2015-07-20 14:28:04 +0800 | [diff] [blame] | 292 | } |