diff mbox series

[ovs-dev,RFC,47/52] ovsdb-client; Add new "get-schema-cksum" command.

Message ID 20170919220125.32535-48-blp@ovn.org
State RFC
Headers show
Series clustering implementation | expand

Commit Message

Ben Pfaff Sept. 19, 2017, 10:01 p.m. UTC
I don't have a particular use for this but it allows ovsdb-client to do
all the things with schemas that ovsdb-tool can.

Signed-off-by: Ben Pfaff <blp@ovn.org>
---
 NEWS                    |  1 +
 ovsdb/ovsdb-client.1.in |  5 +++++
 ovsdb/ovsdb-client.c    | 13 +++++++++++++
 3 files changed, 19 insertions(+)
diff mbox series

Patch

diff --git a/NEWS b/NEWS
index f678e7caedb9..066f88215627 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,7 @@  Post-v2.8.0
        "ovsdb-client convert".
      * ovsdb-server now always hosts a built-in database named _Server.  See
        ovsdb-server(5) for more details.
+     * ovsdb-client: New "get-schema-cksum" command.
    - ovs-vsctl and other commands that display data in tables now support a
      --max-column-width option to limit column width.
    - OVN:
diff --git a/ovsdb/ovsdb-client.1.in b/ovsdb/ovsdb-client.1.in
index f8630ba40f25..e8e1c69eedd3 100644
--- a/ovsdb/ovsdb-client.1.in
+++ b/ovsdb/ovsdb-client.1.in
@@ -156,6 +156,11 @@  If \fIdatabase\fR was created before schema versioning was introduced,
 then it will not have a version number and this command will print a
 blank line.
 .
+.IP "\fBget\-schema\-cksum\fI \fR[\fIserver\fR] \fR[\fIdatabase\fR]"
+Connects to \fIserver\fR, retrieves the schema for \fIdatabase\fR, and
+prints its checksum on stdout.  If \fIdatabase\fR does not include a
+checksum, prints a blank line.
+.
 .SS "Data Management Commands"
 .PP
 These commands read or modify the data in a database.
diff --git a/ovsdb/ovsdb-client.c b/ovsdb/ovsdb-client.c
index e12702200616..7ef0716ea3af 100644
--- a/ovsdb/ovsdb-client.c
+++ b/ovsdb/ovsdb-client.c
@@ -274,6 +274,9 @@  usage(void)
            "\n  get-schema-version [SERVER] [DATABASE]\n"
            "    retrieve schema for DATABASE from SERVER and report only its\n"
            "    version number on stdout\n"
+           "\n  get-schema-cksum [SERVER] [DATABASE]\n"
+           "    retrieve schema for DATABASE from SERVER and report only its\n"
+           "    checksum on stdout\n"
            "\n  list-tables [SERVER] [DATABASE]\n"
            "    list tables for DATABASE on SERVER\n"
            "\n  list-columns [SERVER] [DATABASE] [TABLE]\n"
@@ -473,6 +476,15 @@  do_get_schema_version(struct jsonrpc *rpc, const char *database,
 }
 
 static void
+do_get_schema_cksum(struct jsonrpc *rpc, const char *database,
+                      int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
+{
+    struct ovsdb_schema *schema = fetch_schema(rpc, database);
+    puts(schema->cksum);
+    ovsdb_schema_destroy(schema);
+}
+
+static void
 do_list_tables(struct jsonrpc *rpc, const char *database,
                int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
 {
@@ -1666,6 +1678,7 @@  static const struct ovsdb_client_command all_commands[] = {
     { "list-dbs",           NEED_RPC,      0, 0,       do_list_dbs },
     { "get-schema",         NEED_DATABASE, 0, 0,       do_get_schema },
     { "get-schema-version", NEED_DATABASE, 0, 0,       do_get_schema_version },
+    { "get-schema-cksum",   NEED_DATABASE, 0, 0,       do_get_schema_cksum },
     { "list-tables",        NEED_DATABASE, 0, 0,       do_list_tables },
     { "list-columns",       NEED_DATABASE, 0, 1,       do_list_columns },
     { "transact",           NEED_RPC,      1, 1,       do_transact },