Tested this patch and it works, thanks. Tested-by: Yifeng Sun <[email protected]>
Reviewed-by: Yifeng Sun <[email protected]> On Wed, Dec 13, 2017 at 3:10 PM, Ben Pfaff <[email protected]> wrote: > Signed-off-by: Ben Pfaff <[email protected]> > --- > NEWS | 1 + > ovsdb/ovsdb-tool.1.in | 4 ++++ > ovsdb/ovsdb-tool.c | 27 +++++++++++++++++++++++++++ > tests/ovsdb-tool.at | 28 ++++++++++------------------ > 4 files changed, 42 insertions(+), 18 deletions(-) > > diff --git a/NEWS b/NEWS > index 85ad5cfa322e..f15551e58759 100644 > --- a/NEWS > +++ b/NEWS > @@ -7,6 +7,7 @@ Post-v2.8.0 > * Protocol documentation moved from ovsdb-server(1) to > ovsdb-server(7). > * ovsdb-client: New "get-schema-cksum" and "query" commands. > * ovsdb-client: New "backup" and "restore" commands. > + * ovsdb-tool: New "db-name" and "schema-name" commands. > - OVN: > * The "requested-chassis" option for a logical switch port now > accepts a > chassis "hostname" in addition to a chassis "name". > diff --git a/ovsdb/ovsdb-tool.1.in b/ovsdb/ovsdb-tool.1.in > index ebfd33b27163..f6144e7021c0 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 8908bae3628a..2c5931aa14c4 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 }, > diff --git a/tests/ovsdb-tool.at b/tests/ovsdb-tool.at > index 2ce0f3571165..1409a80c4b1f 100644 > --- a/tests/ovsdb-tool.at > +++ b/tests/ovsdb-tool.at > @@ -302,36 +302,28 @@ _uuid name number > OVS_APP_EXIT_AND_WAIT([ovsdb-server]) > AT_CLEANUP > > -AT_SETUP([ovsdb-tool schema-version]) > -AT_KEYWORDS([ovsdb file positive]) > +AT_SETUP([ovsdb-tool schema-version, schema-cksum, schema-name]) > +AT_KEYWORDS([ovsdb file positive schema-version schema-cksum]) > ordinal_schema > schema > AT_CHECK([ovsdb-tool schema-version schema], [0], [5.1.3 > ]) > -AT_CLEANUP > - > -AT_SETUP([ovsdb-tool db-version]) > -AT_KEYWORDS([ovsdb file positive]) > -ordinal_schema > schema > -touch .db.~lock~ > -AT_CHECK([ovsdb-tool create db schema], [0], [], [ignore]) > -AT_CHECK([ovsdb-tool db-version db], [0], [5.1.3 > -]) > -AT_CLEANUP > - > -AT_SETUP([ovsdb-tool schema-cksum]) > -AT_KEYWORDS([ovsdb file positive]) > -ordinal_schema > schema > AT_CHECK([ovsdb-tool schema-cksum schema], [0], [12345678 9 > ]) > +AT_CHECK([ovsdb-tool schema-name schema], [0], [ordinals > +]) > AT_CLEANUP > > -AT_SETUP([ovsdb-tool db-cksum]) > -AT_KEYWORDS([ovsdb file positive]) > +AT_SETUP([ovsdb-tool db-version, db-cksum, db-name]) > +AT_KEYWORDS([ovsdb file positive db-version db-cksum]) > ordinal_schema > schema > touch .db.~lock~ > AT_CHECK([ovsdb-tool create db schema], [0], [], [ignore]) > +AT_CHECK([ovsdb-tool db-version db], [0], [5.1.3 > +]) > AT_CHECK([ovsdb-tool db-cksum db], [0], [12345678 9 > ]) > +AT_CHECK([ovsdb-tool db-name db], [0], [ordinals > +]) > AT_CLEANUP > > AT_SETUP([ovsdb-tool needs-conversion (no conversion needed)]) > -- > 2.10.2 > > _______________________________________________ > dev mailing list > [email protected] > https://mail.openvswitch.org/mailman/listinfo/ovs-dev > _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
