From 6689104ce7eed29c7878c124fa13caecaa1245ef Mon Sep 17 00:00:00 2001 From: Pranith K Date: Wed, 29 Sep 2010 03:59:19 +0000 Subject: mgmt/glusterd: volume start force Signed-off-by: Pranith Kumar K Signed-off-by: Vijay Bellur BUG: 1736 (implement volume start force) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1736 --- cli/src/cli-cmd-volume.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) (limited to 'cli/src/cli-cmd-volume.c') diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index c7a027a1..8d846d87 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -44,7 +44,7 @@ cli_cmd_volume_help_cbk (struct cli_state *state, struct cli_cmd_word *in_word, void cli_cmd_volume_start_usage () { - cli_out ("Usage: volume start "); + cli_out ("Usage: volume start [force]"); } void @@ -71,11 +71,12 @@ cli_cmd_volume_info_usage () cli_out ("Usage: volume info [all|]"); } -void +void cli_cmd_volume_set_usage () { cli_out ("Usage: volume set "); } + int cli_cmd_volume_info_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) @@ -252,7 +253,6 @@ out: return ret; } - int cli_cmd_volume_start_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) @@ -260,29 +260,40 @@ cli_cmd_volume_start_cbk (struct cli_state *state, struct cli_cmd_word *word, int ret = -1; rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; - char *volname = NULL; - + gf1_cli_start_vol_req req = {0,}; frame = create_frame (THIS, THIS->ctx->pool); if (!frame) goto out; - if (wordcount != 3) { + if (wordcount < 3 || wordcount > 4) { cli_cmd_volume_start_usage (); goto out; } - volname = (char *)words[2]; + req.volname = (char *)words[2]; + if (!req.volname) + goto out; + + if (wordcount == 4) { + if (!strcmp("force", words[3])) { + req.flags |= GF_CLI_FLAG_OP_FORCE; + } else { + ret = -1; + cli_cmd_volume_start_usage (); + goto out; + } + } proc = &cli_rpc_prog->proctable[GF1_CLI_START_VOLUME]; if (proc->fn) { - ret = proc->fn (frame, THIS, volname); + ret = proc->fn (frame, THIS, &req); } out: - if (!proc && ret && volname) - cli_out ("Starting Volume %s failed", volname); + if (!proc && ret && req.volname) + cli_out ("Starting Volume %s failed", req.volname); return ret; } @@ -812,7 +823,7 @@ struct cli_cmd volume_cmds[] = { cli_cmd_volume_delete_cbk, "delete volume specified by "}, - { "volume start ", + { "volume start [force]", cli_cmd_volume_start_cbk, "start volume specified by "}, -- cgit