diff options
author | Ben Pfaff <blp@nicira.com> | 2011-05-09 10:29:51 -0700 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2011-05-10 09:10:16 -0700 |
commit | 6d5abe94343a5c5e8f00efe2871d9825091024eb (patch) | |
tree | 13d7aae0a2d19e8acf3bca876f3d894f2ad312d5 /utilities | |
parent | daa8bd2bf878640556195016df8c5ea2f812f9cc (diff) |
ovs-vsctl: Issue warning for likely erroneous "get" commands.
Suggested-by: Reid Price <reid@nicira.com>
Feature #5527.
Diffstat (limited to 'utilities')
-rw-r--r-- | utilities/ovs-vsctl.8.in | 5 | ||||
-rw-r--r-- | utilities/ovs-vsctl.c | 11 |
2 files changed, 16 insertions, 0 deletions
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 <stdarg.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> #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") |