summaryrefslogtreecommitdiffstats
path: root/cli/src
diff options
context:
space:
mode:
authorKaushik BV <kaushikbv@gluster.com>2011-04-17 11:21:51 +0000
committerAnand Avati <avati@gluster.com>2011-04-17 21:41:12 -0700
commit72b57e311fe8634d26b4c56a78016f9359208443 (patch)
treec5d902483373ebd44cf7d07fc8ff17ba2081d8e8 /cli/src
parent91b3d10880678cfa9c5ce03204eb62897a4564e8 (diff)
cli: UI cleanup for geo-replication commandv3.2.0qa14
* provide a unified output in case of failure of geo-replication session * provide a better formatting of the output geo-replication status command * update the help option of geo-replication command * fix few typos Signed-off-by: Kaushik BV <kaushikbv@gluster.com> Signed-off-by: Anand Avati <avati@gluster.com> BUG: 2536 (gsync service introspection) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2536
Diffstat (limited to 'cli/src')
-rw-r--r--cli/src/cli-cmd-volume.c4
-rw-r--r--cli/src/cli-rpc-ops.c56
2 files changed, 39 insertions, 21 deletions
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
index 9dc70d2ea79..f6caddbc334 100644
--- a/cli/src/cli-cmd-volume.c
+++ b/cli/src/cli-cmd-volume.c
@@ -1086,7 +1086,7 @@ out:
dict_unref (options);
if (ret && parse_err == 0)
- cli_out (GEOREP" start failed");
+ cli_out (GEOREP" command failed");
return ret;
}
@@ -1165,7 +1165,7 @@ struct cli_cmd volume_cmds[] = {
"reset all the reconfigured options"},
#if (SYNCDAEMON_COMPILE)
- {"volume "GEOREP" <start|stop|config> <MASTER> <SLAVE> [options]",
+ {"volume "GEOREP" <start|stop|config|status> [[<VOLNAME>] <SLAVE>] [options]",
cli_cmd_volume_gsync_set_cbk,
"Geo-sync operations"},
#endif
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index 1b882cd8f72..aa6d80f371e 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -2630,20 +2630,27 @@ gf_cli3_1_gsync_out_status (dict_t *dict)
char mst[PATH_MAX] = {0, };
char slv[PATH_MAX]= {0, };
char sts[PATH_MAX] = {0, };
+ char hyphens[81] = {0, };
char *mst_val = NULL;
char *slv_val = NULL;
char *sts_val = NULL;
+ cli_out ("%-20s %-50s %-10s", "MASTER", "SLAVE", "STATUS");
+
+ for (i=0; i<sizeof(hyphens)-1; i++)
+ hyphens[i] = '-';
+
+ cli_out ("%s", hyphens);
+
ret = dict_get_int32 (dict, "gsync-count", &gsync_count);
if (ret) {
- cli_out ("No "GEOREP" sessions for the selected");
+ gf_log ("cli", GF_LOG_INFO, "No active geo-replication sessions"
+ "present for the selected");
ret = 0;
goto out;
}
- cli_out (GEOREP" Status:");
-
for (i = 1; i <= gsync_count; i++) {
snprintf (mst, sizeof(mst), "master%d", i);
snprintf (slv, sizeof(slv), "slave%d", i);
@@ -2661,7 +2668,7 @@ gf_cli3_1_gsync_out_status (dict_t *dict)
if (ret)
goto out;
- cli_out ("Master:%-20s Slave:%-50s Status:%-10s", mst_val,
+ cli_out ("%-20s %-50s %-10s", mst_val,
slv_val, sts_val);
}
@@ -2707,25 +2714,36 @@ gf_cli3_1_gsync_set_cbk (struct rpc_req *req, struct iovec *iov,
if (rsp.op_ret) {
cli_out ("%s", rsp.op_errstr ? rsp.op_errstr :
- "command unsuccessful");
+ GEOREP" command unsuccessful");
+ ret = rsp.op_ret;
goto out;
- } else {
- if (rsp.type == GF_GSYNC_OPTION_TYPE_START)
- cli_out ("Gsync started Successfully");
- else if (rsp.config_type == GF_GSYNC_OPTION_TYPE_CONFIG_GET_ALL
- || rsp.config_type == GF_GSYNC_OPTION_TYPE_CONFIG_GET)
- ret = gf_cli3_1_gsync_get_command (rsp);
- else if (rsp.type == GF_GSYNC_OPTION_TYPE_STATUS)
- ret = gf_cli3_1_gsync_out_status (dict);
- else if (rsp.type == GF_GSYNC_OPTION_TYPE_STOP)
+ }
+
+ switch (rsp.type) {
+ case GF_GSYNC_OPTION_TYPE_START:
+ cli_out (GEOREP" session started Successfully");
+ break;
+
+ case GF_GSYNC_OPTION_TYPE_STOP:
cli_out (GEOREP" session stopped successfully");
- else if (!rsp.op_errstr)
- cli_out ("command executed successfully");
- else
- cli_out (rsp.op_errstr);
+ break;
+
+ case GF_GSYNC_OPTION_TYPE_CONFIGURE:
+ if(rsp.config_type==GF_GSYNC_OPTION_TYPE_CONFIG_GET_ALL
+ || rsp.config_type==GF_GSYNC_OPTION_TYPE_CONFIG_GET)
+ ret = gf_cli3_1_gsync_get_command (rsp);
+ else
+ cli_out (GEOREP" config updated successfully");
+ break;
+
+ case GF_GSYNC_OPTION_TYPE_STATUS:
+ ret = gf_cli3_1_gsync_out_status (dict);
+ goto out;
+ default:
+ cli_out (GEOREP" command executed successfully");
}
+
out:
- ret = rsp.op_ret;
cli_cmd_broadcast_response (ret);