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