diff mbox

[ovs-dev] utilities/ovs-vsctl.c: honor 'help' as ovs-ofctl and dpctl

Message ID 1452020330-24441-1-git-send-email-aconole@redhat.com
State Changes Requested
Headers show

Commit Message

Aaron Conole Jan. 5, 2016, 6:58 p.m. UTC
Currently, ovs-ofctl and ovs-dpctl allow a 'help' keyword, in addition to -h
and --help. However, ovs-vsctl does not honor the same 'help' keyword. This
change adds a 'help' which redirects to usage(), bringing ovs-vsctl in line
with ovs-ofctl and ovs-dpctl.

Signed-off-by: Aaron Conole <aconole@redhat.com>
---
 utilities/ovs-vsctl.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Ben Pfaff Jan. 11, 2016, 5:27 p.m. UTC | #1
On Tue, Jan 05, 2016 at 01:58:50PM -0500, Aaron Conole wrote:
> Currently, ovs-ofctl and ovs-dpctl allow a 'help' keyword, in addition to -h
> and --help. However, ovs-vsctl does not honor the same 'help' keyword. This
> change adds a 'help' which redirects to usage(), bringing ovs-vsctl in line
> with ovs-ofctl and ovs-dpctl.
> 
> Signed-off-by: Aaron Conole <aconole@redhat.com>

I agree that it's useful to add such a command, but this is a poor
implementation because it still tries to connect to the database.  For
example, on my machine here:

    blp@sigabrt:~/nicira/ovs/_build(0)$ utilities/ovs-vsctl help
    ovs-vsctl: unix:/var/run/openvswitch/db.sock: database connection failed (No such file or directory)
    blp@sigabrt:~/nicira/ovs/_build(1)$ 

Not very helpful!
Aaron Conole Jan. 11, 2016, 6:53 p.m. UTC | #2
Ben Pfaff <blp@ovn.org> writes:
> On Tue, Jan 05, 2016 at 01:58:50PM -0500, Aaron Conole wrote:
>> Currently, ovs-ofctl and ovs-dpctl allow a 'help' keyword, in addition to -h
>> and --help. However, ovs-vsctl does not honor the same 'help' keyword. This
>> change adds a 'help' which redirects to usage(), bringing ovs-vsctl in line
>> with ovs-ofctl and ovs-dpctl.
>> 
>> Signed-off-by: Aaron Conole <aconole@redhat.com>
>
> I agree that it's useful to add such a command, but this is a poor
> implementation because it still tries to connect to the database.  For
> example, on my machine here:
>
>     blp@sigabrt:~/nicira/ovs/_build(0)$ utilities/ovs-vsctl help
>     ovs-vsctl: unix:/var/run/openvswitch/db.sock: database connection
> failed (No such file or directory)
>     blp@sigabrt:~/nicira/ovs/_build(1)$ 
>
> Not very helpful!

d'oh! Thanks, I missed that use case completely.

-Aaron
diff mbox

Patch

diff --git a/utilities/ovs-vsctl.c b/utilities/ovs-vsctl.c
index 36290db..5d5983d 100644
--- a/utilities/ovs-vsctl.c
+++ b/utilities/ovs-vsctl.c
@@ -92,7 +92,7 @@  static struct ovsdb_idl *the_idl;
 static struct ovsdb_idl_txn *the_idl_txn;
 OVS_NO_RETURN static void vsctl_exit(int status);
 
-OVS_NO_RETURN static void usage(void);
+OVS_NO_RETURN static void usage(struct ctl_context *);
 static void parse_options(int argc, char *argv[], struct shash *local_options);
 static void run_prerequisites(struct ctl_command[], size_t n_commands,
                               struct ovsdb_idl *);
@@ -292,7 +292,7 @@  parse_options(int argc, char *argv[], struct shash *local_options)
             break;
 
         case 'h':
-            usage();
+            usage(NULL);
 
         case OPT_COMMANDS:
             ctl_print_commands();
@@ -350,7 +350,7 @@  parse_options(int argc, char *argv[], struct shash *local_options)
 }
 
 static void
-usage(void)
+usage(struct ctl_context *ctx OVS_UNUSED)
 {
     printf("\
 %s: ovs-vswitchd management utility\n\
@@ -2701,6 +2701,7 @@  vsctl_exit(int status)
 static const struct ctl_command_syntax vsctl_commands[] = {
     /* Open vSwitch commands. */
     {"init", 0, 0, "", NULL, cmd_init, NULL, "", RW},
+    {"help", 0, 0, "", NULL, usage, NULL, "", RO},
 
     /* Bridge commands. */
     {"add-br", 1, 3, "NEW-BRIDGE [PARENT] [NEW-VLAN]", pre_get_info,