Committed by
Gerrit Code Review
[ONOS-2162][ONOS-2259]-- OVSDB- The implementation of OvsdbProviderService
and OvsdbClientService. Change-Id: I3e04d7c111adf16201f8ad7ec732eb81de05b960
Showing
8 changed files
with
424 additions
and
1 deletions
| ... | @@ -31,6 +31,11 @@ | ... | @@ -31,6 +31,11 @@ |
| 31 | <artifactId>netty-transport-native-epoll</artifactId> | 31 | <artifactId>netty-transport-native-epoll</artifactId> |
| 32 | <version>${netty4.version}</version> | 32 | <version>${netty4.version}</version> |
| 33 | </dependency> | 33 | </dependency> |
| 34 | + <dependency> | ||
| 35 | + <groupId>org.onosproject</groupId> | ||
| 36 | + <artifactId>onos-ovsdb-rfc</artifactId> | ||
| 37 | + <version>${project.version}</version> | ||
| 38 | + </dependency> | ||
| 34 | </dependencies> | 39 | </dependencies> |
| 35 | 40 | ||
| 36 | </project> | 41 | </project> | ... | ... |
| ... | @@ -15,14 +15,24 @@ | ... | @@ -15,14 +15,24 @@ |
| 15 | */ | 15 | */ |
| 16 | package org.onosproject.ovsdb.controller; | 16 | package org.onosproject.ovsdb.controller; |
| 17 | 17 | ||
| 18 | +import java.util.List; | ||
| 18 | import java.util.Set; | 19 | import java.util.Set; |
| 19 | 20 | ||
| 20 | import org.onlab.packet.IpAddress; | 21 | import org.onlab.packet.IpAddress; |
| 21 | 22 | ||
| 23 | +import org.onosproject.ovsdb.rfc.jsonrpc.OvsdbRPC; | ||
| 24 | +import org.onosproject.ovsdb.rfc.message.OperationResult; | ||
| 25 | +import org.onosproject.ovsdb.rfc.message.TableUpdates; | ||
| 26 | +import org.onosproject.ovsdb.rfc.notation.Row; | ||
| 27 | +import org.onosproject.ovsdb.rfc.operations.Operation; | ||
| 28 | +import org.onosproject.ovsdb.rfc.schema.DatabaseSchema; | ||
| 29 | + | ||
| 30 | +import com.google.common.util.concurrent.ListenableFuture; | ||
| 31 | + | ||
| 22 | /** | 32 | /** |
| 23 | * Represents to provider facing side of a node. | 33 | * Represents to provider facing side of a node. |
| 24 | */ | 34 | */ |
| 25 | -public interface OvsdbClientService { | 35 | +public interface OvsdbClientService extends OvsdbRPC { |
| 26 | /** | 36 | /** |
| 27 | * Gets the node identifier. | 37 | * Gets the node identifier. |
| 28 | * | 38 | * |
| ... | @@ -104,4 +114,111 @@ public interface OvsdbClientService { | ... | @@ -104,4 +114,111 @@ public interface OvsdbClientService { |
| 104 | */ | 114 | */ |
| 105 | boolean isConnected(); | 115 | boolean isConnected(); |
| 106 | 116 | ||
| 117 | + /** | ||
| 118 | + * Gets the Bridge uuid. | ||
| 119 | + * | ||
| 120 | + * @param bridgeName bridge name | ||
| 121 | + * @return bridge uuid, empty if no uuid is find | ||
| 122 | + */ | ||
| 123 | + String getBridgeUuid(String bridgeName); | ||
| 124 | + | ||
| 125 | + /** | ||
| 126 | + * Gets the Port uuid. | ||
| 127 | + * | ||
| 128 | + * @param portName port name | ||
| 129 | + * @param bridgeUuid bridge uuid | ||
| 130 | + * @return port uuid, empty if no uuid is find | ||
| 131 | + */ | ||
| 132 | + String getPortUuid(String portName, String bridgeUuid); | ||
| 133 | + | ||
| 134 | + /** | ||
| 135 | + * Gets the Interface uuid. | ||
| 136 | + * | ||
| 137 | + * @param portUuid port uuid | ||
| 138 | + * @param portName port name | ||
| 139 | + * @return interface uuid, empty if no uuid is find | ||
| 140 | + */ | ||
| 141 | + String getInterfaceUuid(String portUuid, String portName); | ||
| 142 | + | ||
| 143 | + /** | ||
| 144 | + * Gets the Controller uuid. | ||
| 145 | + * | ||
| 146 | + * @param controllerName controller name | ||
| 147 | + * @param controllerTarget controller target | ||
| 148 | + * @return controller uuid, empty if no uuid is find | ||
| 149 | + */ | ||
| 150 | + String getControllerUuid(String controllerName, String controllerTarget); | ||
| 151 | + | ||
| 152 | + /** | ||
| 153 | + * Gets the Ovs uuid. | ||
| 154 | + * | ||
| 155 | + * @param dbName database name | ||
| 156 | + * @return ovs uuid, empty if no uuid is find | ||
| 157 | + */ | ||
| 158 | + String getOvsUuid(String dbName); | ||
| 159 | + | ||
| 160 | + /** | ||
| 161 | + * Gets the ovsdb database schema. | ||
| 162 | + * | ||
| 163 | + * @param dbName database name | ||
| 164 | + * @return database schema | ||
| 165 | + */ | ||
| 166 | + ListenableFuture<DatabaseSchema> getOvsdbSchema(String dbName); | ||
| 167 | + | ||
| 168 | + /** | ||
| 169 | + * Gets the ovsdb table updates. | ||
| 170 | + * | ||
| 171 | + * @param dbName database name | ||
| 172 | + * @param id random uuid | ||
| 173 | + * @return table updates | ||
| 174 | + */ | ||
| 175 | + ListenableFuture<TableUpdates> monitorTables(String dbName, String id); | ||
| 176 | + | ||
| 177 | + /** | ||
| 178 | + * Gets the ovsdb config operation result. | ||
| 179 | + * | ||
| 180 | + * @param dbName database name | ||
| 181 | + * @param operations the list of operations | ||
| 182 | + * @return operation results | ||
| 183 | + */ | ||
| 184 | + ListenableFuture<List<OperationResult>> transactConfig(String dbName, | ||
| 185 | + List<Operation> operations); | ||
| 186 | + | ||
| 187 | + /** | ||
| 188 | + * Gets the ovsdb database schema from local. | ||
| 189 | + * | ||
| 190 | + * @param dbName database name | ||
| 191 | + * @return database schema | ||
| 192 | + */ | ||
| 193 | + DatabaseSchema getDatabaseSchema(String dbName); | ||
| 194 | + | ||
| 195 | + /** | ||
| 196 | + * Gets the ovsdb row from the local ovsdb store. | ||
| 197 | + * | ||
| 198 | + * @param dbName database name | ||
| 199 | + * @param tableName table name | ||
| 200 | + * @param uuid row uuid | ||
| 201 | + * @return row ovsdb row | ||
| 202 | + */ | ||
| 203 | + Row getRow(String dbName, String tableName, String uuid); | ||
| 204 | + | ||
| 205 | + /** | ||
| 206 | + * Removes the ovsdb row from the local ovsdb store. | ||
| 207 | + * | ||
| 208 | + * @param dbName database name | ||
| 209 | + * @param tableName table name | ||
| 210 | + * @param uuid row uuid | ||
| 211 | + */ | ||
| 212 | + void removeRow(String dbName, String tableName, String uuid); | ||
| 213 | + | ||
| 214 | + /** | ||
| 215 | + * Update the local ovsdb store. | ||
| 216 | + * | ||
| 217 | + * @param dbName database name | ||
| 218 | + * @param tableName table name | ||
| 219 | + * @param uuid row uuid | ||
| 220 | + * @param row ovsdb row | ||
| 221 | + */ | ||
| 222 | + void updateOvsdbStore(String dbName, String tableName, String uuid, Row row); | ||
| 223 | + | ||
| 107 | } | 224 | } | ... | ... |
| 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 | + | ||
| 18 | +/** | ||
| 19 | + * Ovsdb related constants. | ||
| 20 | + */ | ||
| 21 | +public final class OvsdbConstant { | ||
| 22 | + | ||
| 23 | + /** | ||
| 24 | + * Default constructor. | ||
| 25 | + * | ||
| 26 | + * The constructor is private to prevent creating an instance of this | ||
| 27 | + * utility class. | ||
| 28 | + */ | ||
| 29 | + private OvsdbConstant() { | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + /** Ovsdb database Open_vSwitch. */ | ||
| 33 | + public static final String DATABASENAME = "Open_vSwitch"; | ||
| 34 | + | ||
| 35 | + /** Ovsdb table Bridge. */ | ||
| 36 | + public static final String BRIDGE = "Bridge"; | ||
| 37 | + | ||
| 38 | + /** Ovsdb table Interface. */ | ||
| 39 | + public static final String INTERFACE = "Interface"; | ||
| 40 | + | ||
| 41 | + /** Ovsdb table Controller. */ | ||
| 42 | + public static final String CONTROLLER = "Controller"; | ||
| 43 | + | ||
| 44 | + /** Ovsdb table Port. */ | ||
| 45 | + public static final String PORT = "Port"; | ||
| 46 | + | ||
| 47 | + /** Ovsdb bridge name. */ | ||
| 48 | + public static final String INTEGRATION_BRIDGE = "br-int"; | ||
| 49 | + | ||
| 50 | + /** Ovsdb vxlan tunnel type. */ | ||
| 51 | + public static final String TYPEVXLAN = "vxlan"; | ||
| 52 | + | ||
| 53 | + /** Openflow version. */ | ||
| 54 | + public static final String OPENFLOW13 = "OpenFlow13"; | ||
| 55 | + | ||
| 56 | + /** Ovsdb external_id_interface_id.. */ | ||
| 57 | + public static final String EXTERNAL_ID_INTERFACE_ID = "iface-id"; | ||
| 58 | + | ||
| 59 | + /** Ovsdb external_id_vm_mac. */ | ||
| 60 | + public static final String EXTERNAL_ID_VM_MAC = "attached-mac"; | ||
| 61 | + | ||
| 62 | + /** Openflow port. */ | ||
| 63 | + public static final int OFPORT = 6633; | ||
| 64 | + | ||
| 65 | + /** Ovsdb port. */ | ||
| 66 | + public static final int OVSDBPORT = 6640; | ||
| 67 | + | ||
| 68 | +} |
| 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 | + | ||
| 18 | +import java.util.concurrent.ConcurrentMap; | ||
| 19 | + | ||
| 20 | +import org.onosproject.ovsdb.rfc.notation.Row; | ||
| 21 | + | ||
| 22 | +import com.google.common.collect.Maps; | ||
| 23 | + | ||
| 24 | +/** | ||
| 25 | + * The class representing a table data. | ||
| 26 | + */ | ||
| 27 | +public class OvsdbRowStore { | ||
| 28 | + | ||
| 29 | + private final ConcurrentMap<String, Row> rowStore = Maps.newConcurrentMap(); | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * Gets the row. | ||
| 33 | + * | ||
| 34 | + * @param uuid the key of the rowStore | ||
| 35 | + * @return row the row of the rowStore | ||
| 36 | + */ | ||
| 37 | + public Row getRow(String uuid) { | ||
| 38 | + return rowStore.get(uuid); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + /** | ||
| 42 | + * Inserts a row to rowStore. | ||
| 43 | + * | ||
| 44 | + * @param uuid key of the row | ||
| 45 | + * @param row a row of the table | ||
| 46 | + */ | ||
| 47 | + public void insertRow(String uuid, Row row) { | ||
| 48 | + rowStore.put(uuid, row); | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + /** | ||
| 52 | + * Deletes a row to rowStore. | ||
| 53 | + * | ||
| 54 | + * @param uuid key of the row | ||
| 55 | + */ | ||
| 56 | + public void deleteRow(String uuid) { | ||
| 57 | + rowStore.remove(uuid); | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + /** | ||
| 61 | + * Gets the rowStore. | ||
| 62 | + * | ||
| 63 | + * @return rowStore | ||
| 64 | + */ | ||
| 65 | + public ConcurrentMap<String, Row> getRowStore() { | ||
| 66 | + return rowStore; | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | +} |
| 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 | + | ||
| 18 | +import java.util.concurrent.ConcurrentMap; | ||
| 19 | + | ||
| 20 | +import com.google.common.collect.Maps; | ||
| 21 | + | ||
| 22 | +/** | ||
| 23 | + * The cache for local ovsdb database. | ||
| 24 | + */ | ||
| 25 | +public class OvsdbStore { | ||
| 26 | + | ||
| 27 | + private final ConcurrentMap<String, OvsdbTableStore> ovsdbStore = Maps.newConcurrentMap(); | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * Gets the OvsdbTableStore. | ||
| 31 | + * | ||
| 32 | + * @param dbName ovsdb database name | ||
| 33 | + * @return tableStore OvsdbTableStore | ||
| 34 | + */ | ||
| 35 | + public OvsdbTableStore getOvsdbTableStore(String dbName) { | ||
| 36 | + OvsdbTableStore tableStore = ovsdbStore.get(dbName); | ||
| 37 | + if (tableStore == null) { | ||
| 38 | + return null; | ||
| 39 | + } | ||
| 40 | + return tableStore; | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + /** | ||
| 44 | + * Create or Update a value to ovsdbStore. | ||
| 45 | + * | ||
| 46 | + * @param dbName ovsdb database name | ||
| 47 | + * @param tableStore a database tableStore. | ||
| 48 | + */ | ||
| 49 | + public void createOrUpdateOvsdbStore(String dbName, OvsdbTableStore tableStore) { | ||
| 50 | + ovsdbStore.put(dbName, tableStore); | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + /** | ||
| 54 | + * Drops a value to rowStore. | ||
| 55 | + * | ||
| 56 | + * @param dbName ovsdb database name | ||
| 57 | + */ | ||
| 58 | + public void dropOvsdbStore(String dbName) { | ||
| 59 | + ovsdbStore.remove(dbName); | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + /** | ||
| 63 | + * Gets the ovsdbStore. | ||
| 64 | + * | ||
| 65 | + * @return ovsdbStore | ||
| 66 | + */ | ||
| 67 | + public ConcurrentMap<String, OvsdbTableStore> getOvsdbStore() { | ||
| 68 | + return ovsdbStore; | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | +} |
| 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 | + | ||
| 18 | +import java.util.concurrent.ConcurrentMap; | ||
| 19 | + | ||
| 20 | +import com.google.common.collect.Maps; | ||
| 21 | + | ||
| 22 | +/** | ||
| 23 | + * The class representing a database data. | ||
| 24 | + */ | ||
| 25 | +public class OvsdbTableStore { | ||
| 26 | + | ||
| 27 | + private final ConcurrentMap<String, OvsdbRowStore> tableStore = Maps.newConcurrentMap(); | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * Gets the ovsdbRowStore. | ||
| 31 | + * | ||
| 32 | + * @param tableName a ovsdb table name | ||
| 33 | + * @return OvsdbRowStore the data of the table | ||
| 34 | + */ | ||
| 35 | + public OvsdbRowStore getRows(String tableName) { | ||
| 36 | + return tableStore.get(tableName); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + /** | ||
| 40 | + * Create or update a value to tableStore. | ||
| 41 | + * | ||
| 42 | + * @param tableName key of the tableName | ||
| 43 | + * @param rowStore a row of the table | ||
| 44 | + */ | ||
| 45 | + public void createOrUpdateTable(String tableName, OvsdbRowStore rowStore) { | ||
| 46 | + tableStore.put(tableName, rowStore); | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + /** | ||
| 50 | + * Drops a value to table data. | ||
| 51 | + * | ||
| 52 | + * @param tableName key of the tableName | ||
| 53 | + */ | ||
| 54 | + public void dropTable(String tableName) { | ||
| 55 | + tableStore.remove(tableName); | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + /** | ||
| 59 | + * Gets the tableStore. | ||
| 60 | + * | ||
| 61 | + * @return tableStore | ||
| 62 | + */ | ||
| 63 | + public ConcurrentMap<String, OvsdbRowStore> getTableStore() { | ||
| 64 | + return tableStore; | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | +} |
This diff is collapsed. Click to expand it.
| ... | @@ -17,6 +17,10 @@ package org.onosproject.ovsdb.controller.driver; | ... | @@ -17,6 +17,10 @@ package org.onosproject.ovsdb.controller.driver; |
| 17 | 17 | ||
| 18 | import io.netty.channel.Channel; | 18 | import io.netty.channel.Channel; |
| 19 | 19 | ||
| 20 | +import org.onosproject.ovsdb.rfc.jsonrpc.Callback; | ||
| 21 | + | ||
| 22 | +import com.fasterxml.jackson.databind.JsonNode; | ||
| 23 | + | ||
| 20 | /** | 24 | /** |
| 21 | * Represents the driver side of an ovsdb node. This interface should never be | 25 | * Represents the driver side of an ovsdb node. This interface should never be |
| 22 | * exposed to consumers. | 26 | * exposed to consumers. |
| ... | @@ -52,4 +56,26 @@ public interface OvsdbProviderService { | ... | @@ -52,4 +56,26 @@ public interface OvsdbProviderService { |
| 52 | * @param connected whether the node is connected | 56 | * @param connected whether the node is connected |
| 53 | */ | 57 | */ |
| 54 | void setConnection(boolean connected); | 58 | void setConnection(boolean connected); |
| 59 | + | ||
| 60 | + /** | ||
| 61 | + * Processes result from ovsdb. | ||
| 62 | + * | ||
| 63 | + * @param response JsonNode response from ovsdb | ||
| 64 | + */ | ||
| 65 | + void processResult(JsonNode response); | ||
| 66 | + | ||
| 67 | + /** | ||
| 68 | + * processes request from ovsdb. | ||
| 69 | + * | ||
| 70 | + * @param request JsonNode request from ovsdb | ||
| 71 | + */ | ||
| 72 | + void processRequest(JsonNode request); | ||
| 73 | + | ||
| 74 | + /** | ||
| 75 | + * Sets call back. | ||
| 76 | + * | ||
| 77 | + * @param monitorCallback the callback to set | ||
| 78 | + */ | ||
| 79 | + void setCallback(Callback monitorCallback); | ||
| 80 | + | ||
| 55 | } | 81 | } | ... | ... |
-
Please register or login to post a comment