summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
authorPranith Kumar K <pranithk@gluster.com>2010-08-28 06:02:54 +0000
committerVijay Bellur <vijay@dev.gluster.com>2010-08-28 04:56:11 -0700
commit157560b6dce9cf790e8405ce895d80f4efab1539 (patch)
tree61059f04be060b47cdbd148d6b1dc8aaa6b2e582 /cli
parent48055db6c1b8e669e6c83cc3e579569f05629026 (diff)
cli, mgmt/glusterd: added volume stop <VOLNAME> force functionality
Signed-off-by: Pranith Kumar K <pranithk@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 1361 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1361
Diffstat (limited to 'cli')
-rw-r--r--cli/src/cli-cmd-volume.c32
-rw-r--r--cli/src/cli.h1
-rw-r--r--cli/src/cli3_1-cops.c6
3 files changed, 27 insertions, 12 deletions
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
index 8b2404012..1421157c8 100644
--- a/cli/src/cli-cmd-volume.c
+++ b/cli/src/cli-cmd-volume.c
@@ -31,6 +31,7 @@
#include "cli.h"
#include "cli-cmd.h"
#include "cli-mem-types.h"
+#include "cli1-xdr.h"
extern struct rpc_clnt *global_rpc;
@@ -49,7 +50,7 @@ cli_cmd_volume_start_usage ()
void
cli_cmd_volume_stop_usage ()
{
- cli_out ("Usage: volume stop <VOLNAME>");
+ cli_out ("Usage: volume stop <VOLNAME> [force]");
}
void
@@ -212,29 +213,42 @@ cli_cmd_volume_stop_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;
-
+ int flags = 0;
+ gf1_cli_stop_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_stop_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])) {
+ flags |= GF_CLI_FLAG_OP_FORCE;
+ } else {
+ ret = -1;
+ cli_cmd_volume_stop_usage ();
+ goto out;
+ }
+ }
+
+ req.flags = flags;
proc = &cli_rpc_prog->proctable[GF1_CLI_STOP_VOLUME];
if (proc->fn) {
- ret = proc->fn (frame, THIS, volname);
+ ret = proc->fn (frame, THIS, &req);
}
out:
- if (!proc && ret && volname)
- cli_out ("Stopping Volume %s failed", volname);
+ if (!proc && ret && req.volname)
+ cli_out ("Stopping Volume %s failed", req.volname);
return ret;
}
@@ -519,7 +533,7 @@ struct cli_cmd volume_cmds[] = {
cli_cmd_volume_start_cbk,
"start volume specified by <VOLNAME>"},
- { "volume stop <VOLNAME>",
+ { "volume stop <VOLNAME> [force]",
cli_cmd_volume_stop_cbk,
"stop volume specified by <VOLNAME>"},
diff --git a/cli/src/cli.h b/cli/src/cli.h
index d6e1a35d6..22159025e 100644
--- a/cli/src/cli.h
+++ b/cli/src/cli.h
@@ -110,6 +110,7 @@ struct cli_local {
struct {
char *volname;
+ int flags;
} stop_vol;
struct {
diff --git a/cli/src/cli3_1-cops.c b/cli/src/cli3_1-cops.c
index 77fb3852b..728c79095 100644
--- a/cli/src/cli3_1-cops.c
+++ b/cli/src/cli3_1-cops.c
@@ -1095,12 +1095,12 @@ gf_cli3_1_stop_volume (call_frame_t *frame, xlator_t *this,
goto out;
}
- req.volname = data;
-
+ req = *((gf1_cli_stop_vol_req*)data);
local = cli_local_get ();
if (local) {
- local->u.stop_vol.volname = data;
+ local->u.stop_vol.volname = req.volname;
+ local->u.stop_vol.flags = req.flags;
frame->local = local;
}