diff options
author | Vijay Bellur <vijay@gluster.com> | 2010-07-26 12:10:08 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2010-07-27 01:20:12 -0700 |
commit | a7795fedd4ee2ed7de2dce89fd782ae20b03f6a4 (patch) | |
tree | 60e173fcab4bbcf78060755b93dda83e2b707a42 /cli/src/cli-cmd-volume.c | |
parent | f803fae036177c3b9d9513f5b6300d426366eb62 (diff) |
cli: Changes to provide proper exit status for gluster commandline
Signed-off-by: Vijay Bellur <vijay@gluster.com>
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
BUG: 1205 ()
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1205
Diffstat (limited to 'cli/src/cli-cmd-volume.c')
-rw-r--r-- | cli/src/cli-cmd-volume.c | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index 445432ecd03..cc8200bd20f 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -144,7 +144,6 @@ cli_cmd_volume_start_cbk (struct cli_state *state, struct cli_cmd_word *word, call_frame_t *frame = NULL; char *volname = NULL; - proc = &cli_rpc_prog->proctable[GF1_CLI_START_VOLUME]; frame = create_frame (THIS, THIS->ctx->pool); if (!frame) @@ -159,12 +158,14 @@ cli_cmd_volume_start_cbk (struct cli_state *state, struct cli_cmd_word *word, volname = (char *)words[2]; GF_ASSERT (volname); + proc = &cli_rpc_prog->proctable[GF1_CLI_START_VOLUME]; + if (proc->fn) { ret = proc->fn (frame, THIS, volname); } out: - if (ret && volname) + if (!proc && ret && volname) cli_out ("Starting Volume %s failed", volname); return ret; @@ -180,7 +181,6 @@ cli_cmd_volume_stop_cbk (struct cli_state *state, struct cli_cmd_word *word, call_frame_t *frame = NULL; char *volname = NULL; - proc = &cli_rpc_prog->proctable[GF1_CLI_STOP_VOLUME]; frame = create_frame (THIS, THIS->ctx->pool); if (!frame) @@ -190,12 +190,14 @@ cli_cmd_volume_stop_cbk (struct cli_state *state, struct cli_cmd_word *word, volname = (char *)words[2]; GF_ASSERT (volname); + proc = &cli_rpc_prog->proctable[GF1_CLI_STOP_VOLUME]; + if (proc->fn) { ret = proc->fn (frame, THIS, volname); } out: - if (ret) + if (!proc && ret) cli_out ("Stopping Volume %s failed", volname); return ret; @@ -211,7 +213,6 @@ cli_cmd_volume_rename_cbk (struct cli_state *state, struct cli_cmd_word *word, call_frame_t *frame = NULL; dict_t *dict = NULL; - proc = &cli_rpc_prog->proctable[GF1_CLI_RENAME_VOLUME]; frame = create_frame (THIS, THIS->ctx->pool); if (!frame) @@ -236,12 +237,14 @@ cli_cmd_volume_rename_cbk (struct cli_state *state, struct cli_cmd_word *word, if (ret) goto out; + proc = &cli_rpc_prog->proctable[GF1_CLI_RENAME_VOLUME]; + if (proc->fn) { ret = proc->fn (frame, THIS, dict); } out: - if (ret) { + if (!proc && ret) { char *volname = (char *) words[2]; if (dict) dict_destroy (dict); @@ -261,7 +264,6 @@ cli_cmd_volume_defrag_cbk (struct cli_state *state, struct cli_cmd_word *word, call_frame_t *frame = NULL; char *volname = NULL; - proc = &cli_rpc_prog->proctable[GF1_CLI_DEFRAG_VOLUME]; frame = create_frame (THIS, THIS->ctx->pool); if (!frame) @@ -271,12 +273,14 @@ cli_cmd_volume_defrag_cbk (struct cli_state *state, struct cli_cmd_word *word, volname = (char *)words[2]; GF_ASSERT (volname); + proc = &cli_rpc_prog->proctable[GF1_CLI_DEFRAG_VOLUME]; + if (proc->fn) { ret = proc->fn (frame, THIS, volname); } out: - if (ret) + if (!proc && ret) cli_out ("Defrag of Volume %s failed", volname); return 0; @@ -293,7 +297,6 @@ cli_cmd_volume_set_cbk (struct cli_state *state, struct cli_cmd_word *word, char *volname = NULL; dict_t *dict = NULL; - proc = &cli_rpc_prog->proctable[GF1_CLI_SET_VOLUME]; frame = create_frame (THIS, THIS->ctx->pool); if (!frame) @@ -310,12 +313,14 @@ cli_cmd_volume_set_cbk (struct cli_state *state, struct cli_cmd_word *word, goto out; //TODO: Build validation here + proc = &cli_rpc_prog->proctable[GF1_CLI_SET_VOLUME]; + if (proc->fn) { ret = proc->fn (frame, THIS, dict); } out: - if (ret) { + if (!proc && ret) { if (dict) dict_destroy (dict); cli_out ("Changing option on Volume %s failed", volname); @@ -335,8 +340,6 @@ cli_cmd_volume_add_brick_cbk (struct cli_state *state, call_frame_t *frame = NULL; dict_t *options = NULL; - proc = &cli_rpc_prog->proctable[GF1_CLI_ADD_BRICK]; - frame = create_frame (THIS, THIS->ctx->pool); if (!frame) goto out; @@ -346,12 +349,14 @@ cli_cmd_volume_add_brick_cbk (struct cli_state *state, if (ret) goto out; + proc = &cli_rpc_prog->proctable[GF1_CLI_ADD_BRICK]; + if (proc->fn) { ret = proc->fn (frame, THIS, options); } out: - if (ret) { + if (!proc && ret) { char *volname = (char *) words[2]; cli_out ("Adding brick to Volume %s failed",volname ); } @@ -369,8 +374,6 @@ cli_cmd_volume_remove_brick_cbk (struct cli_state *state, call_frame_t *frame = NULL; dict_t *options = NULL; - proc = &cli_rpc_prog->proctable[GF1_CLI_REMOVE_BRICK]; - frame = create_frame (THIS, THIS->ctx->pool); if (!frame) goto out; @@ -380,12 +383,14 @@ cli_cmd_volume_remove_brick_cbk (struct cli_state *state, if (ret) goto out; + proc = &cli_rpc_prog->proctable[GF1_CLI_REMOVE_BRICK]; + if (proc->fn) { ret = proc->fn (frame, THIS, options); } out: - if (ret) { + if (!proc && ret) { char *volname = (char *) words[2]; cli_out ("Removing brick from Volume %s failed",volname ); } |