summaryrefslogtreecommitdiff
path: root/ovsdb/ovsdb-tool.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2011-02-08 15:23:33 -0800
committerBen Pfaff <blp@nicira.com>2011-02-15 12:24:29 -0800
commit6aa09313722406629133b375871547fb426800ef (patch)
treee949d3551517b8248b1783a4f6d87abf278051af /ovsdb/ovsdb-tool.c
parente1ebc8cea2991e19456cb9fce54ac8167f6dbf4c (diff)
downloadopenvswitch-6aa09313722406629133b375871547fb426800ef.tar.gz
ovsdb-tool: Add commands for printing the database checksum.
Diffstat (limited to 'ovsdb/ovsdb-tool.c')
-rw-r--r--ovsdb/ovsdb-tool.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/ovsdb/ovsdb-tool.c b/ovsdb/ovsdb-tool.c
index 2e134ce69..3730e6727 100644
--- a/ovsdb/ovsdb-tool.c
+++ b/ovsdb/ovsdb-tool.c
@@ -111,7 +111,9 @@ usage(void)
" compact DB [DST] compact DB in-place (or to DST)\n"
" convert DB SCHEMA [DST] convert DB to SCHEMA (to DST)\n"
" db-version DB report version of schema used by DB\n"
+ " db-cksum DB report checksum of schema used by DB\n"
" schema-version SCHEMA report SCHEMA's schema version\n"
+ " schema-cksum SCHEMA report SCHEMA's checksum\n"
" query DB TRNS execute read-only transaction on DB\n"
" transact DB TRNS execute read/write transaction on DB\n"
" show-log DB prints information about DB's log entries\n",
@@ -253,6 +255,17 @@ do_db_version(int argc OVS_UNUSED, char *argv[])
}
static void
+do_db_cksum(int argc OVS_UNUSED, char *argv[])
+{
+ const char *db_file_name = argv[1];
+ struct ovsdb_schema *schema;
+
+ check_ovsdb_error(ovsdb_file_read_schema(db_file_name, &schema));
+ puts(schema->cksum);
+ ovsdb_schema_destroy(schema);
+}
+
+static void
do_schema_version(int argc OVS_UNUSED, char *argv[])
{
const char *schema_file_name = argv[1];
@@ -264,6 +277,17 @@ do_schema_version(int argc OVS_UNUSED, char *argv[])
}
static void
+do_schema_cksum(int argc OVS_UNUSED, char *argv[])
+{
+ const char *schema_file_name = argv[1];
+ struct ovsdb_schema *schema;
+
+ check_ovsdb_error(ovsdb_schema_from_file(schema_file_name, &schema));
+ puts(schema->cksum);
+ ovsdb_schema_destroy(schema);
+}
+
+static void
transact(bool read_only, const char *db_file_name, const char *transaction)
{
struct json *request, *result;
@@ -435,7 +459,9 @@ static const struct command all_commands[] = {
{ "compact", 1, 2, do_compact },
{ "convert", 2, 3, do_convert },
{ "db-version", 1, 1, do_db_version },
+ { "db-cksum", 1, 1, do_db_cksum },
{ "schema-version", 1, 1, do_schema_version },
+ { "schema-cksum", 1, 1, do_schema_cksum },
{ "query", 2, 2, do_query },
{ "transact", 2, 2, do_transact },
{ "show-log", 1, 1, do_show_log },