From 6d5abe94343a5c5e8f00efe2871d9825091024eb Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 9 May 2011 10:29:51 -0700 Subject: [PATCH] ovs-vsctl: Issue warning for likely erroneous "get" commands. Suggested-by: Reid Price Feature #5527. --- utilities/ovs-vsctl.8.in | 5 +++++ utilities/ovs-vsctl.c | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/utilities/ovs-vsctl.8.in b/utilities/ovs-vsctl.8.in index 0b3e164e..fcfec024 100644 --- a/utilities/ovs-vsctl.8.in +++ b/utilities/ovs-vsctl.8.in @@ -596,6 +596,11 @@ For a map column, without \fB\-\-if\-exists\fR it is an error if If \fB@\fIname\fR is specified, then the UUID for \fIrecord\fR may be referred to by that name later in the same \fBovs\-vsctl\fR invocation in contexts where a UUID is expected. +.IP +Both \fB\-\-id\fR and the \fIcolumn\fR arguments are optional, but +usually at least one or the other should be specified. If both are +omitted, then \fBget\fR has no effect except to verify that +\fIrecord\fR exists in \fItable\fR. . .IP "\fBset \fItable record column\fR[\fB:\fIkey\fR]\fB=\fIvalue\fR..." Sets the value of each specified \fIcolumn\fR in the given diff --git a/utilities/ovs-vsctl.c b/utilities/ovs-vsctl.c index 2c1ba6df..6c2fbece 100644 --- a/utilities/ovs-vsctl.c +++ b/utilities/ovs-vsctl.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "command-line.h" #include "compiler.h" @@ -2547,10 +2548,20 @@ pre_parse_column_key_value(struct vsctl_context *ctx, static void pre_cmd_get(struct vsctl_context *ctx) { + const char *id = shash_find_data(&ctx->options, "--id"); const char *table_name = ctx->argv[1]; const struct vsctl_table_class *table; int i; + /* Using "get" without --id or a column name could possibly make sense. + * Maybe, for example, a ovs-vsctl run wants to assert that a row exists. + * But it is unlikely that an interactive user would want to do that, so + * issue a warning if we're running on a terminal. */ + if (!id && ctx->argc <= 3 && isatty(STDOUT_FILENO)) { + VLOG_WARN("\"get\" command without row arguments or \"--id\" is " + "possibly erroneous"); + } + table = pre_get_table(ctx, table_name); for (i = 3; i < ctx->argc; i++) { if (!strcasecmp(ctx->argv[i], "_uuid") -- 2.30.2