]> git.proxmox.com Git - mirror_ovs.git/blob - lib/ovsdb-idl.h
ovsdb-idl: Simplify usage of ovsdb_idl_run().
[mirror_ovs.git] / lib / ovsdb-idl.h
1 /* Copyright (c) 2009, 2010 Nicira Networks.
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #ifndef OVSDB_IDL_H
17 #define OVSDB_IDL_H 1
18
19 #include <stdbool.h>
20 #include <stdint.h>
21 #include "compiler.h"
22
23 struct json;
24 struct ovsdb_datum;
25 struct ovsdb_idl_class;
26 struct ovsdb_idl_column;
27 struct ovsdb_idl_table_class;
28 struct uuid;
29
30 struct ovsdb_idl *ovsdb_idl_create(const char *remote,
31 const struct ovsdb_idl_class *);
32 void ovsdb_idl_destroy(struct ovsdb_idl *);
33
34 bool ovsdb_idl_run(struct ovsdb_idl *);
35 void ovsdb_idl_wait(struct ovsdb_idl *);
36
37 unsigned int ovsdb_idl_get_seqno(const struct ovsdb_idl *);
38 bool ovsdb_idl_has_ever_connected(const struct ovsdb_idl *);
39 void ovsdb_idl_force_reconnect(struct ovsdb_idl *);
40
41 const struct ovsdb_idl_row *ovsdb_idl_get_row_for_uuid(
42 const struct ovsdb_idl *, const struct ovsdb_idl_table_class *,
43 const struct uuid *);
44 const struct ovsdb_idl_row *ovsdb_idl_first_row(
45 const struct ovsdb_idl *, const struct ovsdb_idl_table_class *);
46 const struct ovsdb_idl_row *ovsdb_idl_next_row(const struct ovsdb_idl_row *);
47
48 enum ovsdb_idl_txn_status {
49 TXN_UNCHANGED, /* Transaction didn't include any changes. */
50 TXN_INCOMPLETE, /* Commit in progress, please wait. */
51 TXN_ABORTED, /* ovsdb_idl_txn_abort() called. */
52 TXN_SUCCESS, /* Commit successful. */
53 TXN_TRY_AGAIN, /* Commit failed because a "verify" operation
54 * reported an inconsistency, due to a network
55 * problem, or other transient failure. */
56 TXN_ERROR /* Commit failed due to a hard error. */
57 };
58
59 const char *ovsdb_idl_txn_status_to_string(enum ovsdb_idl_txn_status);
60
61 struct ovsdb_idl_txn *ovsdb_idl_txn_create(struct ovsdb_idl *);
62 void ovsdb_idl_txn_add_comment(struct ovsdb_idl_txn *, const char *, ...)
63 PRINTF_FORMAT (2, 3);
64 void ovsdb_idl_txn_set_dry_run(struct ovsdb_idl_txn *);
65 void ovsdb_idl_txn_increment(struct ovsdb_idl_txn *, const char *table,
66 const char *column, const struct json *where);
67 void ovsdb_idl_txn_destroy(struct ovsdb_idl_txn *);
68 void ovsdb_idl_txn_wait(const struct ovsdb_idl_txn *);
69 enum ovsdb_idl_txn_status ovsdb_idl_txn_commit(struct ovsdb_idl_txn *);
70 enum ovsdb_idl_txn_status ovsdb_idl_txn_commit_block(struct ovsdb_idl_txn *);
71 void ovsdb_idl_txn_abort(struct ovsdb_idl_txn *);
72
73 const char *ovsdb_idl_txn_get_error(const struct ovsdb_idl_txn *);
74
75 int64_t ovsdb_idl_txn_get_increment_new_value(const struct ovsdb_idl_txn *);
76 const struct uuid *ovsdb_idl_txn_get_insert_uuid(const struct ovsdb_idl_txn *,
77 const struct uuid *);
78
79 void ovsdb_idl_txn_read(const struct ovsdb_idl_row *,
80 const struct ovsdb_idl_column *,
81 struct ovsdb_datum *);
82 void ovsdb_idl_txn_write(const struct ovsdb_idl_row *,
83 const struct ovsdb_idl_column *,
84 struct ovsdb_datum *);
85 void ovsdb_idl_txn_delete(const struct ovsdb_idl_row *);
86 const struct ovsdb_idl_row *ovsdb_idl_txn_insert(
87 struct ovsdb_idl_txn *, const struct ovsdb_idl_table_class *,
88 const struct uuid *);
89
90 struct ovsdb_idl *ovsdb_idl_txn_get_idl (struct ovsdb_idl_txn *);
91
92 #endif /* ovsdb-idl.h */