ovs-appctl: Print command arguments for "help".
authorJustin Pettit <jpettit@nicira.com>
Mon, 26 Sep 2011 21:59:35 +0000 (14:59 -0700)
committerJustin Pettit <jpettit@nicira.com>
Fri, 30 Sep 2011 01:52:28 +0000 (18:52 -0700)
14 files changed:
lib/bond.c
lib/cfm.c
lib/coverage.c
lib/lacp.c
lib/stress.c
lib/unixctl.c
lib/unixctl.h
lib/vlog.c
ofproto/ofproto-dpif.c
ofproto/ofproto.c
ovsdb/ovsdb-server.c
tests/test-openflowd.c
vswitchd/bridge.c
vswitchd/ovs-vswitchd.c

index 416f2b300329432c3e0439866a986375d856459f..1f2b641a11ca2ee72344f351e71b2b46f7f838c4 100644 (file)
@@ -1205,16 +1205,18 @@ bond_unixctl_hash(struct unixctl_conn *conn, const char *args_,
 void
 bond_init(void)
 {
-    unixctl_command_register("bond/list", bond_unixctl_list, NULL);
-    unixctl_command_register("bond/show", bond_unixctl_show, NULL);
-    unixctl_command_register("bond/migrate", bond_unixctl_migrate, NULL);
-    unixctl_command_register("bond/set-active-slave",
+    unixctl_command_register("bond/list", "", bond_unixctl_list, NULL);
+    unixctl_command_register("bond/show", "port", bond_unixctl_show, NULL);
+    unixctl_command_register("bond/migrate", "port hash slave",
+                             bond_unixctl_migrate, NULL);
+    unixctl_command_register("bond/set-active-slave", "port slave",
                              bond_unixctl_set_active_slave, NULL);
-    unixctl_command_register("bond/enable-slave", bond_unixctl_enable_slave,
-                             NULL);
-    unixctl_command_register("bond/disable-slave", bond_unixctl_disable_slave,
-                             NULL);
-    unixctl_command_register("bond/hash", bond_unixctl_hash, NULL);
+    unixctl_command_register("bond/enable-slave", "port slave",
+                             bond_unixctl_enable_slave, NULL);
+    unixctl_command_register("bond/disable-slave", "port slave",
+                             bond_unixctl_disable_slave, NULL);
+    unixctl_command_register("bond/hash", "mac [vlan] [basis]",
+                             bond_unixctl_hash, NULL);
 }
 \f
 static void
index c3d96d8a0b45557049c0c20ce8921bc80894b6e4..0bb2bf19e47593572cf62bac223315710b79d5be 100644 (file)
--- a/lib/cfm.c
+++ b/lib/cfm.c
@@ -220,7 +220,7 @@ lookup_remote_mp(const struct cfm *cfm, uint64_t mpid)
 void
 cfm_init(void)
 {
-    unixctl_command_register("cfm/show", cfm_unixctl_show, NULL);
+    unixctl_command_register("cfm/show", "interface", cfm_unixctl_show, NULL);
 }
 
 /* Allocates a 'cfm' object called 'name'.  'cfm' should be initialized by
index 2b8b6e6ced1edb32077cc55fade1691bcf62307a..105cd37db3ae3cd675164f224819b7adf0b64ee5 100644 (file)
@@ -58,7 +58,7 @@ coverage_unixctl_log(struct unixctl_conn *conn, const char *args OVS_UNUSED,
 void
 coverage_init(void)
 {
-    unixctl_command_register("coverage/log", coverage_unixctl_log, NULL);
+    unixctl_command_register("coverage/log", "", coverage_unixctl_log, NULL);
 }
 
 /* Sorts coverage counters in descending order by count, within equal counts
index 2504e6b3fb845952c91b44a466beaaf997ce6f99..a565419d6bb5267d713d546d1188b4b495c2faf0 100644 (file)
@@ -187,7 +187,7 @@ parse_lacp_packet(const struct ofpbuf *b)
 void
 lacp_init(void)
 {
-    unixctl_command_register("lacp/show", lacp_unixctl_show, NULL);
+    unixctl_command_register("lacp/show", "port", lacp_unixctl_show, NULL);
 }
 
 /* Creates a LACP object. */
index 53f6fc02c2e00810e00722c90496617d087ec3f2..412df4fed1d01e033e87e4afa1ad8734c4179130 100644 (file)
@@ -215,8 +215,10 @@ stress_unixctl_set(struct unixctl_conn *conn, const char *args_,
 void
 stress_init_command(void)
 {
-    unixctl_command_register("stress/list", stress_unixctl_list, NULL);
-    unixctl_command_register("stress/set", stress_unixctl_set, NULL);
-    unixctl_command_register("stress/enable", stress_unixctl_enable, NULL);
-    unixctl_command_register("stress/disable", stress_unixctl_disable, NULL);
+    unixctl_command_register("stress/list", "", stress_unixctl_list, NULL);
+    unixctl_command_register("stress/set", "option period [random | periodic]",
+                             stress_unixctl_set, NULL);
+    unixctl_command_register("stress/enable", "", stress_unixctl_enable, NULL);
+    unixctl_command_register("stress/disable", "",
+                             stress_unixctl_disable, NULL);
 }
index ca90b396aa8abf26d50843a015a56849c51ec60f..7cc7e5e234a6ee4e45d79ededbf8e150c488d68a 100644 (file)
@@ -48,6 +48,7 @@ COVERAGE_DEFINE(unixctl_received);
 COVERAGE_DEFINE(unixctl_replied);
 \f
 struct unixctl_command {
+    const char *args;
     unixctl_cb_func *cb;
     void *aux;
 };
@@ -85,23 +86,18 @@ unixctl_help(struct unixctl_conn *conn, const char *args OVS_UNUSED,
              void *aux OVS_UNUSED)
 {
     struct ds ds = DS_EMPTY_INITIALIZER;
-    struct shash_node *node;
-    struct svec names;
-    const char *name;
+    const struct shash_node **nodes = shash_sort(&commands);
     size_t i;
 
     ds_put_cstr(&ds, "The available commands are:\n");
 
-    svec_init(&names);
-    SHASH_FOR_EACH (node, &commands) {
-        svec_add(&names, node->name);
+    for (i = 0; i < shash_count(&commands); i++) {
+        const struct shash_node *node = nodes[i];
+        const struct unixctl_command *command = node->data;
+        
+        ds_put_format(&ds, "  %-23s%s\n", node->name, command->args);
     }
-    svec_sort(&names);
-
-    SVEC_FOR_EACH (i, name, &names) {
-        ds_put_format(&ds, "\t%s\n", name);
-    }
-    svec_destroy(&names);
+    free(nodes);
 
     unixctl_command_reply(conn, 214, ds_cstr(&ds));
     ds_destroy(&ds);
@@ -115,13 +111,15 @@ unixctl_version(struct unixctl_conn *conn, const char *args OVS_UNUSED,
 }
 
 void
-unixctl_command_register(const char *name, unixctl_cb_func *cb, void *aux)
+unixctl_command_register(const char *name, const char *args,
+        unixctl_cb_func *cb, void *aux)
 {
     struct unixctl_command *command;
 
     assert(!shash_find_data(&commands, name)
            || shash_find_data(&commands, name) == cb);
     command = xmalloc(sizeof *command);
+    command->args = args;
     command->cb = cb;
     command->aux = aux;
     shash_add(&commands, name, command);
@@ -212,8 +210,8 @@ unixctl_server_create(const char *path, struct unixctl_server **serverp)
         return 0;
     }
 
-    unixctl_command_register("help", unixctl_help, NULL);
-    unixctl_command_register("version", unixctl_version, NULL);
+    unixctl_command_register("help", "", unixctl_help, NULL);
+    unixctl_command_register("version", "", unixctl_version, NULL);
 
     server = xmalloc(sizeof *server);
     list_init(&server->conns);
index 2ab9a6853c02425b3acef7cae42c86775582deff..d93e5e440b6ee0647d3d1c489a3f1a4097d0199b 100644 (file)
@@ -41,7 +41,7 @@ const char *unixctl_client_target(const struct unixctl_client *);
 struct unixctl_conn;
 typedef void unixctl_cb_func(struct unixctl_conn *,
                              const char *args, void *aux);
-void unixctl_command_register(const char *name,
+void unixctl_command_register(const char *name, const char *args,
                               unixctl_cb_func *cb, void *aux);
 void unixctl_command_reply(struct unixctl_conn *, int code,
                            const char *body);
index 1fe23837cbe4d909fdfa559f19e7d185c45eacb0..301473cd827462e9d781ede7e15e42a31cbd9c37 100644 (file)
@@ -464,9 +464,11 @@ vlog_init(void)
         VLOG_ERR("current time is negative: %s (%ld)", s, (long int) now);
     }
 
-    unixctl_command_register("vlog/set", vlog_unixctl_set, NULL);
-    unixctl_command_register("vlog/list", vlog_unixctl_list, NULL);
-    unixctl_command_register("vlog/reopen", vlog_unixctl_reopen, NULL);
+    unixctl_command_register("vlog/set",
+                   "{module[:facility[:level]] | PATTERN:facility:pattern}",
+                   vlog_unixctl_set, NULL);
+    unixctl_command_register("vlog/list", "", vlog_unixctl_list, NULL);
+    unixctl_command_register("vlog/reopen", "", vlog_unixctl_reopen, NULL);
 }
 
 /* Closes the logging subsystem. */
index f9738e7446f49a7d818037c4a6380a718a89c5f8..165732c90436d21184b22956dfd83184a1192fae 100644 (file)
@@ -4687,11 +4687,13 @@ ofproto_dpif_unixctl_init(void)
     }
     registered = true;
 
-    unixctl_command_register("ofproto/trace", ofproto_unixctl_trace, NULL);
-    unixctl_command_register("fdb/show", ofproto_unixctl_fdb_show, NULL);
-
-    unixctl_command_register("ofproto/clog", ofproto_dpif_clog, NULL);
-    unixctl_command_register("ofproto/unclog", ofproto_dpif_unclog, NULL);
+    unixctl_command_register("ofproto/trace",
+                      "bridge {tun_id in_port packet | odp_flow [-generate]}",
+                      ofproto_unixctl_trace, NULL);
+    unixctl_command_register("fdb/show", "bridge", ofproto_unixctl_fdb_show,
+                             NULL); 
+    unixctl_command_register("ofproto/clog", "", ofproto_dpif_clog, NULL);
+    unixctl_command_register("ofproto/unclog", "", ofproto_dpif_unclog, NULL);
 }
 \f
 const struct ofproto_class ofproto_dpif_class = {
index 1309b492ab03ef252c6bcfd8fca6970ab9522a93..1cc1e4e1c6f567bd94d0be6112257b19123f2eda 100644 (file)
@@ -3115,5 +3115,5 @@ ofproto_unixctl_init(void)
     }
     registered = true;
 
-    unixctl_command_register("ofproto/list", ofproto_unixctl_list, NULL);
+    unixctl_command_register("ofproto/list", "", ofproto_unixctl_list, NULL);
 }
index 06ac98be6b2326c4ca3e4bee4bce9cc5d20db4c8..530568aec37d343cd24bcb55cbac8ab3810fe184 100644 (file)
@@ -135,11 +135,11 @@ main(int argc, char *argv[])
 
     daemonize_complete();
 
-    unixctl_command_register("exit", ovsdb_server_exit, &exiting);
-    unixctl_command_register("ovsdb-server/compact", ovsdb_server_compact,
-                             file);
-    unixctl_command_register("ovsdb-server/reconnect", ovsdb_server_reconnect,
-                             jsonrpc);
+    unixctl_command_register("exit", "", ovsdb_server_exit, &exiting);
+    unixctl_command_register("ovsdb-server/compact", "",
+                             ovsdb_server_compact, file);
+    unixctl_command_register("ovsdb-server/reconnect", "",
+                             ovsdb_server_reconnect, jsonrpc);
 
     exiting = false;
     while (!exiting) {
index 3cc3a751afb1deec7acf3e8941646d7c376101eb..4cd93127c0a157a3552b65516ba526f7c16e6683 100644 (file)
@@ -109,7 +109,7 @@ main(int argc, char *argv[])
         exit(EXIT_FAILURE);
     }
 
-    unixctl_command_register("exit", test_openflowd_exit, &exiting);
+    unixctl_command_register("exit", "", test_openflowd_exit, &exiting);
 
     VLOG_INFO("Open vSwitch version %s", VERSION BUILDNR);
     VLOG_INFO("OpenFlow protocol version 0x%02x", OFP_VERSION);
index 46d061821a1f1b3323e31b69a34cd6177f41229a..33c9bd76caa009652b75ba4d43a66a9a3b0b4a5e 100644 (file)
@@ -272,11 +272,11 @@ bridge_init(const char *remote)
     ovsdb_idl_omit(idl, &ovsrec_ssl_col_external_ids);
 
     /* Register unixctl commands. */
-    unixctl_command_register("qos/show", qos_unixctl_show, NULL);
-    unixctl_command_register("bridge/dump-flows", bridge_unixctl_dump_flows,
-                             NULL);
-    unixctl_command_register("bridge/reconnect", bridge_unixctl_reconnect,
-                             NULL);
+    unixctl_command_register("qos/show", "interface", qos_unixctl_show, NULL);
+    unixctl_command_register("bridge/dump-flows", "bridge",
+                             bridge_unixctl_dump_flows, NULL);
+    unixctl_command_register("bridge/reconnect", "[bridge]",
+                             bridge_unixctl_reconnect, NULL);
     lacp_init();
     bond_init();
     cfm_init();
index 875da6985fd6cfdd903424e532db5ba5e70bbff3..4910d699c3c41e126023f237c169f319aa354794 100644 (file)
@@ -80,7 +80,7 @@ main(int argc, char *argv[])
     if (retval) {
         exit(EXIT_FAILURE);
     }
-    unixctl_command_register("exit", ovs_vswitchd_exit, &exiting);
+    unixctl_command_register("exit", "", ovs_vswitchd_exit, &exiting);
 
     bridge_init(remote);
     free(remote);