From 75cb75fe8207eb4407253b42bb2d0d8f2c7341ee Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Sun, 15 Dec 2013 08:05:04 +0530 Subject: heal: glfs-heal implementation Change-Id: I634f24d90cd856ceab3cc0c6e9a91003f443403e BUG: 1039544 Signed-off-by: Pranith Kumar K Reviewed-on: http://review.gluster.org/6511 Tested-by: Gluster Build System Reviewed-by: Ravishankar N Reviewed-by: Vijay Bellur --- cli/src/cli-cmd-volume.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'cli/src') diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index 22bf66b4fb5..80b559dc69f 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -2033,6 +2033,10 @@ cli_cmd_volume_heal_cbk (struct cli_state *state, struct cli_cmd_word *word, dict_t *options = NULL; xlator_t *this = NULL; cli_local_t *local = NULL; + int heal_op = 0; + runner_t runner = {0}; + char buff[PATH_MAX] = {0}; + char *out = NULL; this = THIS; frame = create_frame (this, this->ctx->pool); @@ -2051,13 +2055,32 @@ cli_cmd_volume_heal_cbk (struct cli_state *state, struct cli_cmd_word *word, parse_error = 1; goto out; } + ret = dict_get_int32 (options, "heal-op", &heal_op); + if (ret < 0) + goto out; - proc = &cli_rpc_prog->proctable[GLUSTER_CLI_HEAL_VOLUME]; + if (heal_op == GF_AFR_OP_INDEX_SUMMARY) { + runinit (&runner); + runner_add_args (&runner, SBIN_DIR"/glfsheal", words[2], NULL); + runner_redir (&runner, STDOUT_FILENO, RUN_PIPE); + ret = runner_start (&runner); + if (ret == -1) + goto out; + while ((out = fgets(buff, sizeof(buff), + runner_chio (&runner, STDOUT_FILENO)))) { + printf ("%s", out); + } - CLI_LOCAL_INIT (local, words, frame, options); + ret = runner_end (&runner); + ret = WEXITSTATUS (ret); + } else { + proc = &cli_rpc_prog->proctable[GLUSTER_CLI_HEAL_VOLUME]; - if (proc->fn) { - ret = proc->fn (frame, THIS, options); + CLI_LOCAL_INIT (local, words, frame, options); + + if (proc->fn) { + ret = proc->fn (frame, THIS, options); + } } out: -- cgit