]>
Commit | Line | Data |
---|---|---|
d56748e8 | 1 | /* Copyright (c) 2009, 2010, 2011, 2012, 2013 Nicira, Inc. |
f85f8ebb BP |
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_OVSDB_H | |
17 | #define OVSDB_OVSDB_H 1 | |
18 | ||
19 | #include "compiler.h" | |
ee89ea7b | 20 | #include "openvswitch/hmap.h" |
b19bab5b | 21 | #include "openvswitch/list.h" |
ee89ea7b | 22 | #include "openvswitch/shash.h" |
f85f8ebb BP |
23 | |
24 | struct json; | |
bd06962a | 25 | struct ovsdb_log; |
da897f41 | 26 | struct ovsdb_session; |
bd06962a | 27 | struct ovsdb_txn; |
0d085684 | 28 | struct simap; |
f85f8ebb BP |
29 | struct uuid; |
30 | ||
31 | /* Database schema. */ | |
32 | struct ovsdb_schema { | |
33 | char *name; | |
8159b984 | 34 | char *version; |
6aa09313 | 35 | char *cksum; |
f85f8ebb BP |
36 | struct shash tables; /* Contains "struct ovsdb_table_schema *"s. */ |
37 | }; | |
38 | ||
8159b984 | 39 | struct ovsdb_schema *ovsdb_schema_create(const char *name, |
6aa09313 BP |
40 | const char *version, |
41 | const char *cksum); | |
58985e09 | 42 | struct ovsdb_schema *ovsdb_schema_clone(const struct ovsdb_schema *); |
f85f8ebb BP |
43 | void ovsdb_schema_destroy(struct ovsdb_schema *); |
44 | ||
45 | struct ovsdb_error *ovsdb_schema_from_file(const char *file_name, | |
46 | struct ovsdb_schema **) | |
cab50449 | 47 | OVS_WARN_UNUSED_RESULT; |
f85f8ebb BP |
48 | struct ovsdb_error *ovsdb_schema_from_json(struct json *, |
49 | struct ovsdb_schema **) | |
cab50449 | 50 | OVS_WARN_UNUSED_RESULT; |
f85f8ebb | 51 | struct json *ovsdb_schema_to_json(const struct ovsdb_schema *); |
403e3a25 BP |
52 | |
53 | bool ovsdb_schema_equal(const struct ovsdb_schema *, | |
54 | const struct ovsdb_schema *); | |
f85f8ebb BP |
55 | \f |
56 | /* Database. */ | |
57 | struct ovsdb { | |
58 | struct ovsdb_schema *schema; | |
ca6ba700 | 59 | struct ovs_list replicas; /* Contains "struct ovsdb_replica"s. */ |
f85f8ebb BP |
60 | struct shash tables; /* Contains "struct ovsdb_table *"s. */ |
61 | ||
62 | /* Triggers. */ | |
ca6ba700 | 63 | struct ovs_list triggers; /* Contains "struct ovsdb_trigger"s. */ |
f85f8ebb | 64 | bool run_triggers; |
d6db7b3c LR |
65 | |
66 | struct ovsdb_table *rbac_role; | |
f85f8ebb BP |
67 | }; |
68 | ||
bd06962a | 69 | struct ovsdb *ovsdb_create(struct ovsdb_schema *); |
f85f8ebb BP |
70 | void ovsdb_destroy(struct ovsdb *); |
71 | ||
0d085684 BP |
72 | void ovsdb_get_memory_usage(const struct ovsdb *, struct simap *usage); |
73 | ||
f85f8ebb BP |
74 | struct ovsdb_table *ovsdb_get_table(const struct ovsdb *, const char *); |
75 | ||
da897f41 | 76 | struct json *ovsdb_execute(struct ovsdb *, const struct ovsdb_session *, |
e51879e9 | 77 | const struct json *params, bool read_only, |
d6db7b3c | 78 | const char *role, const char *id, |
f85f8ebb BP |
79 | long long int elapsed_msec, |
80 | long long int *timeout_msec); | |
bd06962a BP |
81 | \f |
82 | /* Database replication. */ | |
83 | ||
84 | struct ovsdb_replica { | |
ca6ba700 | 85 | struct ovs_list node; /* Element in "struct ovsdb" replicas list. */ |
bd06962a BP |
86 | const struct ovsdb_replica_class *class; |
87 | }; | |
88 | ||
89 | struct ovsdb_replica_class { | |
90 | struct ovsdb_error *(*commit)(struct ovsdb_replica *, | |
91 | const struct ovsdb_txn *, bool durable); | |
92 | void (*destroy)(struct ovsdb_replica *); | |
93 | }; | |
94 | ||
95 | void ovsdb_replica_init(struct ovsdb_replica *, | |
96 | const struct ovsdb_replica_class *); | |
97 | ||
98 | void ovsdb_add_replica(struct ovsdb *, struct ovsdb_replica *); | |
99 | void ovsdb_remove_replica(struct ovsdb *, struct ovsdb_replica *); | |
f85f8ebb BP |
100 | |
101 | #endif /* ovsdb/ovsdb.h */ |