Ovsdb plugin compatibility layer
[netvirt.git] / plugin / src / main / java / org / opendaylight / ovsdb / plugin / api / OvsdbConfigurationService.java
1 /*
2  * Copyright (C) 2013 Red Hat, Inc.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Authors : Madhu Venugopal, Brent Salisbury
9  */
10 package org.opendaylight.ovsdb.plugin.api;
11
12 import java.util.List;
13 import java.util.concurrent.ConcurrentMap;
14 import java.util.concurrent.ExecutionException;
15
16 import org.opendaylight.controller.sal.core.Node;
17 import org.opendaylight.ovsdb.plugin.api.Status;
18 import org.opendaylight.ovsdb.lib.notation.Row;
19 import org.opendaylight.ovsdb.lib.notation.UUID;
20 import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
21 import org.opendaylight.ovsdb.lib.schema.typed.TypedBaseTable;
22 import org.opendaylight.ovsdb.plugin.error.OvsdbPluginException;
23
24 public interface OvsdbConfigurationService {
25
26     /**
27      * @deprecated This version of insertRow is a short-term replacement for the older & now deprecated method of the same name.
28      * This API assumes an Open_vSwitch database Schema.
29      *
30      * This API is replaced by
31      * {@link #insertRow(Node, String, String, String, Row<GenericTableSchema>) insertRow} and
32      * {@link #insertTree(Node, String, String, String, Row<GenericTableSchema>) insertTree}
33      *
34      * @param node OVSDB Node
35      * @param tableName Table on which the row is inserted
36      * @param parentUuid UUID of the parent table to which this operation will result in attaching/mutating.
37      * @param row Row of table Content to be inserted
38      * @return UUID of the inserted Row
39      */
40     @Deprecated
41     public StatusWithUuid insertRow(Node node, String tableName, String parentUuid, Row<GenericTableSchema> row);
42
43     /**
44      * insert a Row in a Table of a specified Database Schema. This is a convenience method on top of
45      * {@link insertRow(Node, String, String, String, UUID, String, Row<GenericTableSchema>) insertRow}
46      * which assumes that OVSDB schema implementation that corresponds to the databaseName will provide
47      * the necessary service to populate the Parent Table Name and Parent Column Name.
48      *
49      * This method can insert just a single Row specified in the row parameter.
50      * But {@link #insertTree(Node, String, String, UUID, Row<GenericTableSchema>) insertTree}
51      * can insert a hierarchy of rows with parent-child relationship.
52      *
53      * @param node OVSDB Node
54      * @param databaseName Database Name that represents the Schema supported by the node.
55      * @param tableName Table on which the row is inserted
56      * @param parentUuid UUID of the parent table to which this operation will result in attaching/mutating.
57      * @param row Row of table Content to be inserted
58      * @throws OvsdbPluginException Any failure during the insert transaction will result in a specific exception.
59      * @return UUID of the inserted Row
60      */
61     public UUID insertRow(Node node, String databaseName, String tableName, UUID parentRowUuid,
62                           Row<GenericTableSchema> row) throws OvsdbPluginException;
63
64     /**
65      * insert a Row in a Table of a specified Database Schema.
66      *
67      * This method can insert just a single Row specified in the row parameter.
68      * But {@link #insertTree(Node, String, String, UUID, Row<GenericTableSchema>) insertTree}
69      * can insert a hierarchy of rows with parent-child relationship.
70      *
71      * @param node OVSDB Node
72      * @param databaseName Database Name that represents the Schema supported by the node.
73      * @param tableName Table on which the row is inserted
74      * @param parentTable Name of the Parent Table to which this operation will result in attaching/mutating.
75      * @param parentUuid UUID of a Row in parent table to which this operation will result in attaching/mutating.
76      * @param parentColumn Name of the Column in the Parent Table to be mutated with the UUID that results from the insert operation.
77      * @param row Row of table Content to be inserted
78      * @throws OvsdbPluginException Any failure during the insert transaction will result in a specific exception.
79      * @return UUID of the inserted Row
80      */
81     public UUID insertRow(Node node, String databaseName, String tableName, String parentTable, UUID parentRowUuid,
82                           String parentColumn, Row<GenericTableSchema> row) throws OvsdbPluginException;
83
84     /**
85      * inserts a Tree of Rows in multiple Tables that has parent-child relationships referenced through the OVSDB schema's refTable construct.
86      * This is a convenience method on top of {@link #insertTree(Node, String, String, String, UUID, String, Row<GenericTableSchema>) insertTree}
87      *
88      * @param node OVSDB Node
89      * @param databaseName Database Name that represents the Schema supported by the node.
90      * @param tableName Table on which the row is inserted
91      * @param parentUuid UUID of a Row in parent table to which this operation will result in attaching/mutating.
92      * @param row Row Tree with parent-child relationships via column of type refTable.
93      * @throws OvsdbPluginException Any failure during the insert transaction will result in a specific exception.
94      * @return Returns the row tree with the UUID of every inserted Row populated in the _uuid column of every row in the tree
95      */
96     public Row<GenericTableSchema> insertTree(Node node, String databaseName, String tableName, UUID parentRowUuid,
97                                               Row<GenericTableSchema> row) throws OvsdbPluginException;
98
99     /**
100      * inserts a Tree of Rows in multiple Tables that has parent-child relationships referenced through the OVSDB schema's refTable construct
101      *
102      * @param node OVSDB Node
103      * @param databaseName Database Name that represents the Schema supported by the node.
104      * @param tableName Table on which the row is inserted
105      * @param parentTable Name of the Parent Table to which this operation will result in attaching/mutating.
106      * @param parentUuid UUID of a Row in parent table to which this operation will result in attaching/mutating.
107      * @param parentColumn Name of the Column in the Parent Table to be mutated with the UUID that results from the insert operation.
108      * @param row Row Tree with parent-child relationships via column of type refTable.
109      * @throws OvsdbPluginException Any failure during the insert transaction will result in a specific exception.
110      * @return Returns the row tree with the UUID of every inserted Row populated in the _uuid column of every row in the tree
111      */
112     public Row<GenericTableSchema> insertTree(Node node, String databaseName, String tableName, String parentTable, UUID parentRowUuid,
113                                               String parentColumn, Row<GenericTableSchema> row) throws OvsdbPluginException;
114
115     /**
116      * @deprecated This version of updateRow is a short-term replacement for the older & now deprecated method of the same name.
117      * This API assumes an Open_vSwitch database Schema.
118      *
119      * This API is replaced by
120      * {@link #updateRow(Node, String, String, UUID, Row<GenericTableSchema>, boolean) updateRow}
121      *
122      * @param node OVSDB Node
123      * @param tableName Table on which the row is Updated
124      * @param parentUuid UUID of the parent row on which this operation might result in mutating.
125      * @param rowUuid UUID of the row that is being updated
126      * @param row Row of table Content to be Updated. Include just those columns that needs to be updated.
127      */
128     @Deprecated
129     public Status updateRow (Node node, String tableName, String parentUuid, String rowUuid, Row row);
130
131     /**
132      * update or mutate a Row in a Table of a specified Database Schema.
133      *
134      * @param node OVSDB Node
135      * @param databaseName Database Name that represents the Schema supported by the node.
136      * @param tableName Table on which the row is updated
137      * @param rowUuid UUID of the row being updated
138      * @param row Row of table Content to be updated
139      * @param overwrite true will overwrite/replace the existing row (matching the rowUuid) with the passed row object.
140      *                  false will update the existing row (matching the rowUuid) using only the columns in the passed row object.
141      * @throws OvsdbPluginException Any failure during the update operation will result in a specific exception.
142      * @return Returns the entire Row after the update operation.
143      */
144     public Row<GenericTableSchema> updateRow(Node node, String databaseName, String tableName, UUID rowUuid,
145                             Row<GenericTableSchema> row, boolean overwrite) throws OvsdbPluginException;
146
147     /**
148      * @deprecated This version of deleteRow is a short-term replacement for the older & now deprecated method of the same name.
149      * This API assumes an Open_vSwitch database Schema.
150      *
151      * This API is replaced by {@link #deleteRow(Node, String, String, UUID) deleteRow}
152      *
153      * @param node OVSDB Node
154      * @param tableName Table on which the row is Updated
155      * @param rowUuid UUID of the row that is being deleted
156      */
157     @Deprecated
158     public Status deleteRow (Node node, String tableName, String rowUuid);
159
160     /**
161      * update or mutate a Row in a Table of a specified Database Schema.
162      *
163      * @param node OVSDB Node
164      * @param databaseName Database Name that represents the Schema supported by the node.
165      * @param tableName Table on which the row is Updated
166      * @param rowUuid UUID of the row that is being deleted
167      * @throws OvsdbPluginException Any failure during the delete operation will result in a specific exception.
168      */
169
170     public void deleteRow (Node node, String databaseName, String tableName, UUID rowUuid) throws OvsdbPluginException;
171
172     /**
173      * update or mutate a Row in a Table of a specified Database Schema.
174      *
175      * @param node OVSDB Node
176      * @param databaseName Database Name that represents the Schema supported by the node.
177      * @param tableName Table on which the row is Updated
178      * @param parentTable Name of the Parent Table to which this operation will result in mutating.
179      * @param parentColumn Name of the Column in the Parent Table to be mutated.
180      * @param rowUuid UUID of the row that is being deleted
181      * @throws OvsdbPluginException Any failure during the delete operation will result in a specific exception.
182      */
183
184     public void deleteRow (Node node, String databaseName, String tableName, String parentTable,
185                            UUID parentRowUuid, String parentColumn, UUID rowUuid) throws OvsdbPluginException;
186
187     /**
188      * @deprecated This version of getRow is a short-term replacement for the older & now deprecated method of the same name.
189      * This API assumes an Open_vSwitch database Schema.
190      *
191      * This API is replaced by {@link #getRow(Node, String, String, UUID) getRow}
192      *
193      * @param node OVSDB Node
194      * @param tableName Table Name
195      * @param rowUuid UUID of the row being queried
196      * @return a row with a list of Column data that corresponds to an unique Row-identifier called uuid in a given table.
197      */
198     @Deprecated
199     public Row getRow(Node node, String tableName, String uuid);
200
201     /**
202      * Returns a Row from a table for the specified uuid.
203      *
204      * @param node OVSDB Node
205      * @param databaseName Database Name that represents the Schema supported by the node.
206      * @param tableName Table Name
207      * @param uuid UUID of the row being queried
208      * @throws OvsdbPluginException Any failure during the get operation will result in a specific exception.
209      * @return a row with a list of Column data that corresponds to an unique Row-identifier called uuid in a given table.
210      */
211     public Row<GenericTableSchema> getRow(Node node, String databaseName, String tableName, UUID uuid) throws OvsdbPluginException;
212
213     /**
214      * @Deprecated This version of getRows is a short-term replacement for the older & now deprecated method of the same name.
215      * This API assumes an Open_vSwitch database Schema.
216      *
217      * This API is replaced by
218      * {@link #getRows(Node, String, String) getRows} and {@link #getRows(Node, String, String, String) getRows}
219      *
220      * @param node OVSDB Node
221      * @param tableName Table Name
222      * @return List of rows that makes the entire Table.
223      */
224     @Deprecated
225     public ConcurrentMap<String, Row> getRows(Node node, String tableName);
226
227     /**
228      * Returns all rows of a table.
229      *
230      * @param node OVSDB Node
231      * @param databaseName Database Name that represents the Schema supported by the node.
232      * @param tableName Table Name
233      * @throws OvsdbPluginException Any failure during the get operation will result in a specific exception.
234      * @return Map of rows to its UUID that makes the entire Table.
235      */
236     public ConcurrentMap<UUID, Row<GenericTableSchema>> getRows(Node node, String databaseName, String tableName) throws OvsdbPluginException;
237
238     /**
239      * Returns all rows of a table filtered by query string.
240      *
241      * @param node OVSDB Node
242      * @param databaseName Database Name that represents the Schema supported by the node.
243      * @param tableName Table Name
244      * @param fiqlQuery FIQL style String Query {@link http://tools.ietf.org/html/draft-nottingham-atompub-fiql-00} to filter rows
245      * @throws OvsdbPluginException Any failure during the get operation will result in a specific exception.
246      * @return Map of rows to its UUID that makes the entire Table.
247      */
248     public ConcurrentMap<UUID, Row<GenericTableSchema>> getRows(Node node, String databaseName, String tableName, String fiqlQuery) throws OvsdbPluginException;
249
250     /**
251      * @Deprecated Returns all the Tables in a given Ndoe.
252      * This API assumes an Open_vSwitch database Schema.
253      *
254      * This API is replaced by
255      * {@link #getTables(Node, String) getTables}
256      * @param node OVSDB node
257      * @return List of Table Names that make up Open_vSwitch schema.
258      */
259     @Deprecated
260     public List<String> getTables(Node node);
261
262     /**
263      * Returns all the Tables in a given Node.
264      *
265      * @param node OVSDB node
266      * @param databaseName Database Name that represents the Schema supported by the node.
267      * @throws OvsdbPluginException Any failure during the get operation will result in a specific exception.
268      * @return List of Table Names that make up the schema represented by the databaseName
269      */
270     public List<String> getTables(Node node, String databaseName) throws OvsdbPluginException;
271
272     /**
273      * setOFController is a convenience method used by existing applications to setup Openflow Controller on
274      * a Open_vSwitch Bridge.
275      * This API assumes an Open_vSwitch database Schema.
276      *
277      * @param node Node
278      * @param bridgeUUID uuid of the Bridge for which the ip-address of Openflow Controller should be programmed.
279      * @return Boolean representing success or failure of the operation.
280      *
281      * @throws InterruptedException
282      * @throws ExecutionException
283      */
284     public Boolean setOFController(Node node, String bridgeUUID) throws InterruptedException, ExecutionException;
285
286     public <T extends TypedBaseTable<?>> String getTableName(Node node, Class<T> typedClass);
287     public <T extends TypedBaseTable<?>> T getTypedRow(Node node, Class<T> typedClass, Row row);
288     public <T extends TypedBaseTable<?>> T createTypedRow(Node node, Class<T> typedClass);
289 }