]> git.proxmox.com Git - mirror_ovs.git/blame - ovsdb/ovsdb.h
raft: Avoid sending equal snapshots.
[mirror_ovs.git] / ovsdb / ovsdb.h
CommitLineData
1b1d2e6d 1/* Copyright (c) 2009, 2010, 2011, 2012, 2013, 2017 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"
1b1d2e6d 23#include "openvswitch/uuid.h"
f85f8ebb
BP
24
25struct json;
bd06962a 26struct ovsdb_log;
da897f41 27struct ovsdb_session;
bd06962a 28struct ovsdb_txn;
0d085684 29struct simap;
f85f8ebb
BP
30
31/* Database schema. */
32struct 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 39struct ovsdb_schema *ovsdb_schema_create(const char *name,
6aa09313
BP
40 const char *version,
41 const char *cksum);
58985e09 42struct ovsdb_schema *ovsdb_schema_clone(const struct ovsdb_schema *);
f85f8ebb
BP
43void ovsdb_schema_destroy(struct ovsdb_schema *);
44
45struct ovsdb_error *ovsdb_schema_from_file(const char *file_name,
46 struct ovsdb_schema **)
cab50449 47 OVS_WARN_UNUSED_RESULT;
53178986 48struct ovsdb_error *ovsdb_schema_from_json(const struct json *,
f85f8ebb 49 struct ovsdb_schema **)
cab50449 50 OVS_WARN_UNUSED_RESULT;
f85f8ebb 51struct json *ovsdb_schema_to_json(const struct ovsdb_schema *);
403e3a25
BP
52
53bool ovsdb_schema_equal(const struct ovsdb_schema *,
54 const struct ovsdb_schema *);
1b1d2e6d
BP
55
56struct ovsdb_error *ovsdb_schema_check_for_ephemeral_columns(
57 const struct ovsdb_schema *) OVS_WARN_UNUSED_RESULT;
58void ovsdb_schema_persist_ephemeral_columns(struct ovsdb_schema *,
59 const char *filename);
60
61struct ovsdb_version {
62 unsigned int x;
63 unsigned int y;
64 unsigned int z;
65};
66bool ovsdb_parse_version(const char *, struct ovsdb_version *);
67bool ovsdb_is_valid_version(const char *);
f85f8ebb
BP
68\f
69/* Database. */
695e8150
HZ
70struct ovsdb_txn_history_node {
71 struct ovs_list node; /* Element in struct ovsdb's txn_history list */
72 struct ovsdb_txn *txn;
73};
74
f85f8ebb 75struct ovsdb {
1b1d2e6d 76 char *name;
f85f8ebb 77 struct ovsdb_schema *schema;
1b1d2e6d
BP
78 struct ovsdb_storage *storage; /* If nonnull, log for transactions. */
79 struct uuid prereq;
009bf21f 80 struct ovs_list monitors; /* Contains "struct ovsdb_monitor"s. */
f85f8ebb
BP
81 struct shash tables; /* Contains "struct ovsdb_table *"s. */
82
83 /* Triggers. */
ca6ba700 84 struct ovs_list triggers; /* Contains "struct ovsdb_trigger"s. */
f85f8ebb 85 bool run_triggers;
bb66a0a6 86 bool run_triggers_now;
d6db7b3c
LR
87
88 struct ovsdb_table *rbac_role;
695e8150
HZ
89
90 /* History trasanctions for incremental monitor transfer. */
91 bool need_txn_history; /* Need to maintain history of transactions. */
92 unsigned int n_txn_history; /* Current number of history transactions. */
93 struct ovs_list txn_history; /* Contains "struct ovsdb_txn_history_node. */
f85f8ebb
BP
94};
95
1b1d2e6d 96struct ovsdb *ovsdb_create(struct ovsdb_schema *, struct ovsdb_storage *);
f85f8ebb
BP
97void ovsdb_destroy(struct ovsdb *);
98
0d085684
BP
99void ovsdb_get_memory_usage(const struct ovsdb *, struct simap *usage);
100
f85f8ebb
BP
101struct ovsdb_table *ovsdb_get_table(const struct ovsdb *, const char *);
102
1b1d2e6d
BP
103struct ovsdb_txn *ovsdb_execute_compose(
104 struct ovsdb *, const struct ovsdb_session *, const struct json *params,
105 bool read_only, const char *role, const char *id,
106 long long int elapsed_msec, long long int *timeout_msec,
107 bool *durable, struct json **);
108
da897f41 109struct json *ovsdb_execute(struct ovsdb *, const struct ovsdb_session *,
e51879e9 110 const struct json *params, bool read_only,
d6db7b3c 111 const char *role, const char *id,
f85f8ebb
BP
112 long long int elapsed_msec,
113 long long int *timeout_msec);
114
1b1d2e6d
BP
115struct ovsdb_error *ovsdb_snapshot(struct ovsdb *) OVS_WARN_UNUSED_RESULT;
116
117void ovsdb_replace(struct ovsdb *dst, struct ovsdb *src);
118
f85f8ebb 119#endif /* ovsdb/ovsdb.h */