]> git.proxmox.com Git - ovs.git/blame - ovsdb/ovsdb.h
vswitchd: Add OVS version to database, give system info its own columns.
[ovs.git] / ovsdb / ovsdb.h
CommitLineData
58985e09 1/* Copyright (c) 2009, 2010 Nicira Networks
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"
20#include "hmap.h"
21#include "list.h"
22#include "shash.h"
23
24struct json;
bd06962a
BP
25struct ovsdb_log;
26struct ovsdb_txn;
f85f8ebb
BP
27struct uuid;
28
29/* Database schema. */
30struct ovsdb_schema {
31 char *name;
f85f8ebb
BP
32 struct shash tables; /* Contains "struct ovsdb_table_schema *"s. */
33};
34
2e57b537 35struct ovsdb_schema *ovsdb_schema_create(const char *name);
58985e09 36struct ovsdb_schema *ovsdb_schema_clone(const struct ovsdb_schema *);
f85f8ebb
BP
37void ovsdb_schema_destroy(struct ovsdb_schema *);
38
39struct ovsdb_error *ovsdb_schema_from_file(const char *file_name,
40 struct ovsdb_schema **)
41 WARN_UNUSED_RESULT;
42struct ovsdb_error *ovsdb_schema_from_json(struct json *,
43 struct ovsdb_schema **)
44 WARN_UNUSED_RESULT;
45struct json *ovsdb_schema_to_json(const struct ovsdb_schema *);
46\f
47/* Database. */
48struct ovsdb {
49 struct ovsdb_schema *schema;
bd06962a 50 struct list replicas; /* Contains "struct ovsdb_replica"s. */
f85f8ebb
BP
51 struct shash tables; /* Contains "struct ovsdb_table *"s. */
52
53 /* Triggers. */
54 struct list triggers; /* Contains "struct ovsdb_trigger"s. */
55 bool run_triggers;
56};
57
bd06962a 58struct ovsdb *ovsdb_create(struct ovsdb_schema *);
f85f8ebb
BP
59void ovsdb_destroy(struct ovsdb *);
60
61struct ovsdb_error *ovsdb_from_json(const struct json *, struct ovsdb **)
62 WARN_UNUSED_RESULT;
63struct json *ovsdb_to_json(const struct ovsdb *);
64
65struct ovsdb_table *ovsdb_get_table(const struct ovsdb *, const char *);
66
67struct json *ovsdb_execute(struct ovsdb *, const struct json *params,
68 long long int elapsed_msec,
69 long long int *timeout_msec);
bd06962a
BP
70\f
71/* Database replication. */
72
73struct ovsdb_replica {
74 struct list node; /* Element in "struct ovsdb" replicas list. */
75 const struct ovsdb_replica_class *class;
76};
77
78struct ovsdb_replica_class {
79 struct ovsdb_error *(*commit)(struct ovsdb_replica *,
80 const struct ovsdb_txn *, bool durable);
81 void (*destroy)(struct ovsdb_replica *);
82};
83
84void ovsdb_replica_init(struct ovsdb_replica *,
85 const struct ovsdb_replica_class *);
86
87void ovsdb_add_replica(struct ovsdb *, struct ovsdb_replica *);
88void ovsdb_remove_replica(struct ovsdb *, struct ovsdb_replica *);
f85f8ebb
BP
89
90#endif /* ovsdb/ovsdb.h */