summaryrefslogtreecommitdiff
path: root/ovsdb
diff options
context:
space:
mode:
authorBen Pfaff <blp@ovn.org>2017-12-06 10:36:32 -0800
committerBen Pfaff <blp@ovn.org>2017-12-19 13:52:56 -0800
commit439902cbacc1dfc9b4a34610c233f468c8146b5c (patch)
treea59955761ff05114ce6ed8b05dc986d4f1f0e03d /ovsdb
parent804c477b9cd688b375abc158537036a018d87502 (diff)
downloadopenvswitch-439902cbacc1dfc9b4a34610c233f468c8146b5c.tar.gz
ovsdb-tool: Add new "db-name" and "schema-name" commands.
Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'ovsdb')
-rw-r--r--ovsdb/ovsdb-tool.1.in4
-rw-r--r--ovsdb/ovsdb-tool.c27
2 files changed, 31 insertions, 0 deletions
diff --git a/ovsdb/ovsdb-tool.1.in b/ovsdb/ovsdb-tool.1.in
index 4cce97c99..7b89ffeec 100644
--- a/ovsdb/ovsdb-tool.1.in
+++ b/ovsdb/ovsdb-tool.1.in
@@ -37,6 +37,10 @@ ovsdb\-tool \- Open vSwitch database management utility
.br
\fBovsdb\-tool \fR[\fIoptions\fR] [\fB\-m\fR | \fB\-\-more\fR]... \fBshow\-log \fR[\fIdb\fR]
.br
+\fBovsdb\-tool \fR[\fIoptions\fR] \fBdb\-name \fR[\fIdb\fR]
+.br
+\fBovsdb\-tool \fR[\fIoptions\fR] \fBschema\-name \fR[\fIschema\fR]
+.br
\fBovsdb\-tool help\fR
.so lib/vlog-syn.man
.so lib/common-syn.man
diff --git a/ovsdb/ovsdb-tool.c b/ovsdb/ovsdb-tool.c
index 8908bae36..2c5931aa1 100644
--- a/ovsdb/ovsdb-tool.c
+++ b/ovsdb/ovsdb-tool.c
@@ -135,8 +135,10 @@ usage(void)
" create [DB [SCHEMA]] create DB with the given SCHEMA\n"
" compact [DB [DST]] compact DB in-place (or to DST)\n"
" convert [DB [SCHEMA [DST]]] convert DB to SCHEMA (to DST)\n"
+ " db-name [DB] report name of schema used by DB\n"
" db-version [DB] report version of schema used by DB\n"
" db-cksum [DB] report checksum of schema used by DB\n"
+ " schema-name [SCHEMA] report SCHEMA's name\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"
@@ -325,6 +327,17 @@ do_needs_conversion(struct ovs_cmdl_context *ctx)
}
static void
+do_db_name(struct ovs_cmdl_context *ctx)
+{
+ const char *db_file_name = ctx->argc >= 2 ? ctx->argv[1] : default_db();
+ struct ovsdb_schema *schema;
+
+ check_ovsdb_error(ovsdb_file_read_schema(db_file_name, &schema));
+ puts(schema->name);
+ ovsdb_schema_destroy(schema);
+}
+
+static void
do_db_version(struct ovs_cmdl_context *ctx)
{
const char *db_file_name = ctx->argc >= 2 ? ctx->argv[1] : default_db();
@@ -369,6 +382,18 @@ do_schema_cksum(struct ovs_cmdl_context *ctx)
}
static void
+do_schema_name(struct ovs_cmdl_context *ctx)
+{
+ const char *schema_file_name
+ = ctx->argc >= 2 ? ctx->argv[1] : default_schema();
+ struct ovsdb_schema *schema;
+
+ check_ovsdb_error(ovsdb_schema_from_file(schema_file_name, &schema));
+ puts(schema->name);
+ ovsdb_schema_destroy(schema);
+}
+
+static void
transact(bool read_only, int argc, char *argv[])
{
const char *db_file_name = argc >= 3 ? argv[1] : default_db();
@@ -590,8 +615,10 @@ static const struct ovs_cmdl_command all_commands[] = {
{ "compact", "[db [dst]]", 0, 2, do_compact, OVS_RW },
{ "convert", "[db [schema [dst]]]", 0, 3, do_convert, OVS_RW },
{ "needs-conversion", NULL, 0, 2, do_needs_conversion, OVS_RO },
+ { "db-name", "[db]", 0, 1, do_db_name, OVS_RO },
{ "db-version", "[db]", 0, 1, do_db_version, OVS_RO },
{ "db-cksum", "[db]", 0, 1, do_db_cksum, OVS_RO },
+ { "schema-name", "[schema]", 0, 1, do_schema_name, OVS_RO },
{ "schema-version", "[schema]", 0, 1, do_schema_version, OVS_RO },
{ "schema-cksum", "[schema]", 0, 1, do_schema_cksum, OVS_RO },
{ "query", "[db] trns", 1, 2, do_query, OVS_RO },