]> git.proxmox.com Git - ovs.git/blame_incremental - ovsdb/ovsdb.h
ovn-controller: Handle physical changes correctly
[ovs.git] / ovsdb / ovsdb.h
... / ...
CommitLineData
1/* Copyright (c) 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
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"
20#include "hmap.h"
21#include "openvswitch/list.h"
22#include "shash.h"
23
24struct json;
25struct ovsdb_log;
26struct ovsdb_session;
27struct ovsdb_txn;
28struct simap;
29struct uuid;
30
31/* Database schema. */
32struct ovsdb_schema {
33 char *name;
34 char *version;
35 char *cksum;
36 struct shash tables; /* Contains "struct ovsdb_table_schema *"s. */
37};
38
39struct ovsdb_schema *ovsdb_schema_create(const char *name,
40 const char *version,
41 const char *cksum);
42struct ovsdb_schema *ovsdb_schema_clone(const struct ovsdb_schema *);
43void ovsdb_schema_destroy(struct ovsdb_schema *);
44
45struct ovsdb_error *ovsdb_schema_from_file(const char *file_name,
46 struct ovsdb_schema **)
47 OVS_WARN_UNUSED_RESULT;
48struct ovsdb_error *ovsdb_schema_from_json(struct json *,
49 struct ovsdb_schema **)
50 OVS_WARN_UNUSED_RESULT;
51struct json *ovsdb_schema_to_json(const struct ovsdb_schema *);
52
53bool ovsdb_schema_equal(const struct ovsdb_schema *,
54 const struct ovsdb_schema *);
55\f
56/* Database. */
57struct ovsdb {
58 struct ovsdb_schema *schema;
59 struct ovs_list replicas; /* Contains "struct ovsdb_replica"s. */
60 struct shash tables; /* Contains "struct ovsdb_table *"s. */
61
62 /* Triggers. */
63 struct ovs_list triggers; /* Contains "struct ovsdb_trigger"s. */
64 bool run_triggers;
65};
66
67struct ovsdb *ovsdb_create(struct ovsdb_schema *);
68void ovsdb_destroy(struct ovsdb *);
69
70void ovsdb_get_memory_usage(const struct ovsdb *, struct simap *usage);
71
72struct ovsdb_table *ovsdb_get_table(const struct ovsdb *, const char *);
73
74struct json *ovsdb_execute(struct ovsdb *, const struct ovsdb_session *,
75 const struct json *params,
76 long long int elapsed_msec,
77 long long int *timeout_msec);
78\f
79/* Database replication. */
80
81struct ovsdb_replica {
82 struct ovs_list node; /* Element in "struct ovsdb" replicas list. */
83 const struct ovsdb_replica_class *class;
84};
85
86struct ovsdb_replica_class {
87 struct ovsdb_error *(*commit)(struct ovsdb_replica *,
88 const struct ovsdb_txn *, bool durable);
89 void (*destroy)(struct ovsdb_replica *);
90};
91
92void ovsdb_replica_init(struct ovsdb_replica *,
93 const struct ovsdb_replica_class *);
94
95void ovsdb_add_replica(struct ovsdb *, struct ovsdb_replica *);
96void ovsdb_remove_replica(struct ovsdb *, struct ovsdb_replica *);
97
98#endif /* ovsdb/ovsdb.h */