diff options
author | Ben Pfaff <blp@nicira.com> | 2009-12-16 13:30:53 -0800 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2009-12-16 13:30:53 -0800 |
commit | d171b5846f4988e66c45a6ed5998bbaef82571f9 (patch) | |
tree | b806bc671fa52a1bb36eb3029dac8693f47fb543 /ovsdb/file.c | |
parent | 5f98eed4eb5b75ab02422de1b5dbd5276ad5593d (diff) | |
download | openvswitch-d171b5846f4988e66c45a6ed5998bbaef82571f9.tar.gz |
ovsdb: Add "comment" feature to transactions and make ovs-vsctl use them.
The idea here is that transaction comments get copied to the ovsdb-server's
transaction log, which can then make it clear later why a particular change
was made to the database, to ease debugging.
Diffstat (limited to 'ovsdb/file.c')
-rw-r--r-- | ovsdb/file.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/ovsdb/file.c b/ovsdb/file.c index 377ca280f..97359d035 100644 --- a/ovsdb/file.c +++ b/ovsdb/file.c @@ -27,6 +27,7 @@ #include "ovsdb-error.h" #include "row.h" #include "table.h" +#include "timeval.h" #include "transaction.h" #include "uuid.h" #include "util.h" @@ -185,6 +186,11 @@ ovsdb_file_txn_from_json(struct ovsdb *db, const struct json *json, table = shash_find_data(&db->tables, table_name); if (!table) { + if (!strcmp(table_name, "_date") + || !strcmp(table_name, "_comment")) { + continue; + } + error = ovsdb_syntax_error(json, "unknown table", "No table named %s.", table_name); goto error; @@ -299,6 +305,7 @@ ovsdb_file_replica_commit(struct ovsdb_replica *r_, struct ovsdb_file_replica *r = ovsdb_file_replica_cast(r_); struct ovsdb_file_replica_aux aux; struct ovsdb_error *error; + const char *comment; aux.json = NULL; aux.table_json = NULL; @@ -310,6 +317,13 @@ ovsdb_file_replica_commit(struct ovsdb_replica *r_, return NULL; } + comment = ovsdb_txn_get_comment(txn); + if (comment) { + json_object_put_string(aux.json, "_comment", comment); + } + + json_object_put(aux.json, "_date", json_integer_create(time_now())); + error = ovsdb_log_write(r->log, aux.json); json_destroy(aux.json); if (error) { |