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