summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
authorVijay Bellur <vijay@gluster.com>2010-07-22 04:17:35 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-07-22 23:10:38 -0700
commitbe4dee16c18e262b168c74face54cf17ca13e2f4 (patch)
tree5301cf748e07815303d5ba16d5b765849a8165a0 /cli
parent5601c137674b4dabd39b1cf26a36327bfbc707a6 (diff)
Changes for Dynamic Volume Management
Signed-off-by: Amar Tumballi <amar@gluster.com> Signed-off-by: Vijay Bellur <vijay@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 1196 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1196
Diffstat (limited to 'cli')
-rw-r--r--cli/src/cli-cmd-parser.c42
-rw-r--r--cli/src/cli-cmd-volume.c13
-rw-r--r--cli/src/cli3_1-cops.c8
3 files changed, 44 insertions, 19 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index cffa22a7e70..6c96d0836c8 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -78,7 +78,10 @@ cli_cmd_volume_create_parse (const char **words, int wordcount, dict_t **options
ret = dict_set_int32 (dict, "replica-count", count);
if (ret)
goto out;
-
+ if (count < 2) {
+ ret = -1;
+ goto out;
+ }
brick_index = 5;
} else if ((strcasecmp (words[3], "stripe")) == 0) {
type = GF_CLUSTER_TYPE_STRIPE;
@@ -91,6 +94,10 @@ cli_cmd_volume_create_parse (const char **words, int wordcount, dict_t **options
ret = dict_set_int32 (dict, "stripe-count", count);
if (ret)
goto out;
+ if (count < 2) {
+ ret = -1;
+ goto out;
+ }
brick_index = 5;
} else {
type = GF_CLUSTER_TYPE_NONE;
@@ -214,7 +221,7 @@ out:
}
int32_t
-cli_cmd_volume_add_brick_parse (const char **words, int wordcount,
+cli_cmd_volume_add_brick_parse (const char **words, int wordcount,
dict_t **options)
{
dict_t *dict = NULL;
@@ -222,9 +229,10 @@ cli_cmd_volume_add_brick_parse (const char **words, int wordcount,
int ret = -1;
gf1_cluster_type type = GF_CLUSTER_TYPE_NONE;
int count = 0;
- char key[50];
+ //char key[50] = {0,};
int brick_count = 0, brick_index = 0;
-
+ char brick_list[8192] = {0,};
+
GF_ASSERT (words);
GF_ASSERT (options);
@@ -257,20 +265,32 @@ cli_cmd_volume_add_brick_parse (const char **words, int wordcount,
brick_index = 3;
}
- ret = dict_set_int32 (dict, "type", type);
-
- if (ret)
- goto out;
-
+ strcpy (brick_list, " ");
while (brick_index < wordcount) {
GF_ASSERT (words[brick_index]);
+ if (!strchr (words[brick_index], ':')) {
+ gf_log ("cli", GF_LOG_ERROR,
+ "wrong brick type, use <HOSTNAME>:<export-dir>");
+ ret = -1;
+ goto out;
+ }
+ strcat (brick_list, words[brick_index]);
+ strcat (brick_list, " ");
+ ++brick_count;
+ ++brick_index;
+ /*
+ char key[50];
snprintf (key, 50, "brick%d", ++brick_count);
ret = dict_set_str (dict, key, (char *)words[brick_index++]);
if (ret)
goto out;
+ */
}
+ ret = dict_set_str (dict, "bricks", brick_list);
+ if (ret)
+ goto out;
ret = dict_set_int32 (dict, "count", brick_count);
@@ -291,7 +311,7 @@ out:
int32_t
-cli_cmd_volume_remove_brick_parse (const char **words, int wordcount,
+cli_cmd_volume_remove_brick_parse (const char **words, int wordcount,
dict_t **options)
{
dict_t *dict = NULL;
@@ -301,7 +321,7 @@ cli_cmd_volume_remove_brick_parse (const char **words, int wordcount,
int count = 0;
char key[50];
int brick_count = 0, brick_index = 0;
-
+
GF_ASSERT (words);
GF_ASSERT (options);
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
index d3960d06575..445432ecd03 100644
--- a/cli/src/cli-cmd-volume.c
+++ b/cli/src/cli-cmd-volume.c
@@ -36,6 +36,12 @@ extern struct rpc_clnt *global_rpc;
extern rpc_clnt_prog_t *cli_rpc_prog;
+void
+cli_cmd_volume_start_usage ()
+{
+ cli_out ("Usage: volume start <volname>");
+}
+
int
cli_cmd_volume_info_cbk (struct cli_state *state, struct cli_cmd_word *word,
const char **words, int wordcount)
@@ -145,6 +151,11 @@ cli_cmd_volume_start_cbk (struct cli_state *state, struct cli_cmd_word *word,
goto out;
//TODO: Build validation here
+ if (wordcount < 3) {
+ cli_cmd_volume_start_usage ();
+ goto out;
+ }
+
volname = (char *)words[2];
GF_ASSERT (volname);
@@ -153,7 +164,7 @@ cli_cmd_volume_start_cbk (struct cli_state *state, struct cli_cmd_word *word,
}
out:
- if (ret)
+ if (ret && volname)
cli_out ("Starting Volume %s failed", volname);
return ret;
diff --git a/cli/src/cli3_1-cops.c b/cli/src/cli3_1-cops.c
index dc9241bc60a..444c0031d91 100644
--- a/cli/src/cli3_1-cops.c
+++ b/cli/src/cli3_1-cops.c
@@ -747,7 +747,6 @@ gf_cli3_1_create_volume (call_frame_t *frame, xlator_t *this,
goto out;
ret = dict_get_int32 (dict, "count", &req.count);
-
if (ret)
goto out;
@@ -977,16 +976,11 @@ gf_cli3_1_add_brick (call_frame_t *frame, xlator_t *this,
if (ret)
goto out;
- ret = dict_get_int32 (dict, "type", (int32_t *)&req.type);
-
- if (ret)
- goto out;
-
ret = dict_get_int32 (dict, "count", &req.count);
-
if (ret)
goto out;
+
ret = dict_allocate_and_serialize (dict,
&req.bricks.bricks_val,
(size_t *)&req.bricks.bricks_len);