summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVijay Bellur <vijay@gluster.com>2010-09-02 04:03:12 +0000
committerVijay Bellur <vijay@dev.gluster.com>2010-09-02 03:28:39 -0700
commitea86a09143c5c59349ca82ddcbc2178a84cccde7 (patch)
tree7352001356f468407036e35f991a1d9ca2b4ee67
parent232d32ca93bf974734bc4bc4802f1430bb4b0c95 (diff)
cli: Changes for GET_NEXT volume info
Signed-off-by: Vijay Bellur <vijay@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 1255 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1255
-rw-r--r--cli/src/cli-cmd-volume.c27
-rw-r--r--cli/src/cli-cmd.h7
-rw-r--r--cli/src/cli-mem-types.h1
-rw-r--r--cli/src/cli.h5
-rw-r--r--cli/src/cli3_1-cops.c86
-rw-r--r--rpc/rpc-lib/src/protocol-common.h1
-rw-r--r--rpc/xdr/src/cli1-xdr.h2
-rw-r--r--rpc/xdr/src/cli1.x4
8 files changed, 120 insertions, 13 deletions
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
index 3bbccc900..399d146d1 100644
--- a/cli/src/cli-cmd-volume.c
+++ b/cli/src/cli-cmd-volume.c
@@ -69,9 +69,11 @@ int
cli_cmd_volume_info_cbk (struct cli_state *state, struct cli_cmd_word *word,
const char **words, int wordcount)
{
- int ret = -1;
- rpc_clnt_procedure_t *proc = NULL;
- call_frame_t *frame = NULL;
+ int ret = -1;
+ rpc_clnt_procedure_t *proc = NULL;
+ call_frame_t *frame = NULL;
+ cli_cmd_volume_get_ctx_t ctx = {0,};
+ cli_local_t *local = NULL;
proc = &cli_rpc_prog->proctable[GF1_CLI_GET_VOLUME];
@@ -79,8 +81,23 @@ cli_cmd_volume_info_cbk (struct cli_state *state, struct cli_cmd_word *word,
if (!frame)
goto out;
+ if ((wordcount == 2) || (wordcount == 3 &&
+ !strcmp (words[2], "all"))) {
+ ctx.flags = GF_CLI_GET_NEXT_VOLUME;
+ proc = &cli_rpc_prog->proctable[GF1_CLI_GET_NEXT_VOLUME];
+ }
+
+ local = cli_local_get ();
+
+ if (!local)
+ goto out;
+
+ local->u.get_vol.flags = ctx.flags;
+
+ frame->local = local;
+
if (proc->fn) {
- ret = proc->fn (frame, THIS, NULL);
+ ret = proc->fn (frame, THIS, &ctx);
}
out:
@@ -131,7 +148,7 @@ out:
}
}
if (options)
- dict_destroy (options);
+ dict_unref (options);
return ret;
}
diff --git a/cli/src/cli-cmd.h b/cli/src/cli-cmd.h
index 42d5316ac..b7cd7aadc 100644
--- a/cli/src/cli-cmd.h
+++ b/cli/src/cli-cmd.h
@@ -33,6 +33,13 @@ struct cli_cmd {
const char *desc;
};
+struct cli_cmd_volume_get_ctx_ {
+ char *volname;
+ int flags;
+};
+
+typedef struct cli_cmd_volume_get_ctx_ cli_cmd_volume_get_ctx_t;
+
int cli_cmd_volume_register (struct cli_state *state);
int cli_cmd_probe_register (struct cli_state *state);
diff --git a/cli/src/cli-mem-types.h b/cli/src/cli-mem-types.h
index 5677bd1b0..86e346641 100644
--- a/cli/src/cli-mem-types.h
+++ b/cli/src/cli-mem-types.h
@@ -31,6 +31,7 @@ enum cli_mem_types_ {
cli_mt_char,
cli_mt_call_pool_t,
cli_mt_cli_local_t,
+ cli_mt_cli_get_vol_ctx_t,
cli_mt_end
};
diff --git a/cli/src/cli.h b/cli/src/cli.h
index 257bb1402..fdf53421f 100644
--- a/cli/src/cli.h
+++ b/cli/src/cli.h
@@ -126,6 +126,11 @@ struct cli_local {
char *volname;
dict_t *dict;
} replace_brick;
+
+ struct {
+ char *volname;
+ int flags;
+ } get_vol;
} u;
};
diff --git a/cli/src/cli3_1-cops.c b/cli/src/cli3_1-cops.c
index e4b41c4db..e7be89873 100644
--- a/cli/src/cli3_1-cops.c
+++ b/cli/src/cli3_1-cops.c
@@ -48,6 +48,10 @@ char *cli_volume_status[] = {"Created",
"Stopped"
};
+int32_t
+gf_cli3_1_get_volume (call_frame_t *frame, xlator_t *this,
+ void *data);
+
int
gf_cli3_1_probe_cbk (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
@@ -252,6 +256,8 @@ gf_cli3_1_get_volume_cbk (struct rpc_req *req, struct iovec *iov,
int32_t brick_count = 0;
char *brick = NULL;
int32_t j = 1;
+ cli_local_t *local = NULL;
+
if (-1 == req->rpc_status) {
goto out;
@@ -300,7 +306,14 @@ gf_cli3_1_get_volume_cbk (struct rpc_req *req, struct iovec *iov,
goto out;
}
- cli_out ("Number of Volumes: %d", count);
+ local = ((call_frame_t *)myframe)->local;
+ //cli_out ("Number of Volumes: %d", count);
+
+ if (!count) {
+ local->u.get_vol.volname = NULL;
+ ret = 0;
+ goto out;
+ }
while ( i <= count) {
cli_out ("");
@@ -324,12 +337,17 @@ gf_cli3_1_get_volume_cbk (struct rpc_req *req, struct iovec *iov,
if (ret)
goto out;
+
cli_out ("Volume Name: %s", volname);
cli_out ("Type: %s", cli_volume_type[type]);
cli_out ("Status: %s", cli_volume_status[status], brick_count);
cli_out ("Number of Bricks: %d", brick_count);
j = 1;
+
+ GF_FREE (local->u.get_vol.volname);
+ local->u.get_vol.volname = gf_strdup (volname);
+
if (brick_count)
cli_out ("Bricks:");
@@ -344,6 +362,8 @@ gf_cli3_1_get_volume_cbk (struct rpc_req *req, struct iovec *iov,
}
i++;
}
+
+
} else {
ret = -1;
goto out;
@@ -1052,18 +1072,68 @@ out:
}
int32_t
+gf_cli3_1_get_next_volume (call_frame_t *frame, xlator_t *this,
+ void *data)
+{
+
+ int ret = 0;
+ cli_cmd_volume_get_ctx_t *ctx = NULL;
+ cli_local_t *local = NULL;
+
+ if (!frame || !this || !data) {
+ ret = -1;
+ goto out;
+ }
+
+ ctx = data;
+
+ ret = gf_cli3_1_get_volume (frame, this, data);
+
+ local = frame->local;
+
+ ctx->volname = local->u.get_vol.volname;
+
+ while (ctx->volname) {
+ ret = gf_cli3_1_get_volume (frame, this, ctx);
+ if (ret)
+ goto out;
+ ctx->volname = local->u.get_vol.volname;
+ }
+
+out:
+ return ret;
+}
+
+int32_t
gf_cli3_1_get_volume (call_frame_t *frame, xlator_t *this,
- void *data)
+ void *data)
{
- gf1_cli_get_vol_req req = {0,};
- int ret = 0;
+ gf1_cli_get_vol_req req = {0,};
+ int ret = 0;
+ cli_cmd_volume_get_ctx_t *ctx = NULL;
+ dict_t *dict = NULL;
- if (!frame || !this) {
+ if (!frame || !this || !data) {
ret = -1;
goto out;
}
- req.flags = GF_CLI_GET_VOLUME_ALL;
+ ctx = data;
+ req.flags = ctx->flags;
+
+ dict = dict_new ();
+ if (!dict)
+ goto out;
+
+ if (ctx->volname) {
+ ret = dict_set_str (dict, "volname", ctx->volname);
+ if (ret)
+ goto out;
+ }
+
+ ret = dict_allocate_and_serialize (dict,
+ &req.dict.dict_val,
+ (size_t *)&req.dict.dict_len);
ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
GD_MGMT_CLI_GET_VOLUME, NULL,
@@ -1075,6 +1145,7 @@ out:
return ret;
}
+
int32_t
gf_cli3_1_create_volume (call_frame_t *frame, xlator_t *this,
void *data)
@@ -1117,7 +1188,7 @@ gf_cli3_1_create_volume (call_frame_t *frame, xlator_t *this,
local = cli_local_get ();
if (local) {
- local->u.create_vol.dict = dict;
+ local->u.create_vol.dict = dict_ref (dict);
frame->local = local;
}
@@ -1691,6 +1762,7 @@ struct rpc_clnt_procedure gluster3_1_cli_actors[GF1_CLI_MAXVALUE] = {
[GF1_CLI_RENAME_VOLUME] = {"RENAME_VOLUME", gf_cli3_1_rename_volume},
[GF1_CLI_DEFRAG_VOLUME] = {"DEFRAG_VOLUME", gf_cli3_1_defrag_volume},
[GF1_CLI_GET_VOLUME] = {"GET_VOLUME", gf_cli3_1_get_volume},
+ [GF1_CLI_GET_NEXT_VOLUME] = {"GET_NEXT_VOLUME", gf_cli3_1_get_next_volume},
[GF1_CLI_SET_VOLUME] = {"SET_VOLUME", gf_cli3_1_set_volume},
[GF1_CLI_ADD_BRICK] = {"ADD_BRICK", gf_cli3_1_add_brick},
[GF1_CLI_REMOVE_BRICK] = {"REMOVE_BRICK", gf_cli3_1_remove_brick},
diff --git a/rpc/rpc-lib/src/protocol-common.h b/rpc/rpc-lib/src/protocol-common.h
index 14b81faba..8f79a03a4 100644
--- a/rpc/rpc-lib/src/protocol-common.h
+++ b/rpc/rpc-lib/src/protocol-common.h
@@ -114,6 +114,7 @@ enum gf_cli_procnum {
GF1_CLI_LIST_FRIENDS,
GF1_CLI_CREATE_VOLUME,
GF1_CLI_GET_VOLUME,
+ GF1_CLI_GET_NEXT_VOLUME,
GF1_CLI_DELETE_VOLUME,
GF1_CLI_START_VOLUME,
GF1_CLI_STOP_VOLUME,
diff --git a/rpc/xdr/src/cli1-xdr.h b/rpc/xdr/src/cli1-xdr.h
index 6f2f8d3e1..e725e5257 100644
--- a/rpc/xdr/src/cli1-xdr.h
+++ b/rpc/xdr/src/cli1-xdr.h
@@ -58,6 +58,8 @@ typedef enum gf1_cli_friends_list gf1_cli_friends_list;
enum gf1_cli_get_volume {
GF_CLI_GET_VOLUME_ALL = 1,
+ GF_CLI_GET_VOLUME = 1 + 1,
+ GF_CLI_GET_NEXT_VOLUME = 1 + 2,
};
typedef enum gf1_cli_get_volume gf1_cli_get_volume;
diff --git a/rpc/xdr/src/cli1.x b/rpc/xdr/src/cli1.x
index 9912f750b..359a77423 100644
--- a/rpc/xdr/src/cli1.x
+++ b/rpc/xdr/src/cli1.x
@@ -18,7 +18,9 @@ enum gf1_cli_friends_list {
} ;
enum gf1_cli_get_volume {
- GF_CLI_GET_VOLUME_ALL = 1
+ GF_CLI_GET_VOLUME_ALL = 1,
+ GF_CLI_GET_VOLUME,
+ GF_CLI_GET_NEXT_VOLUME
} ;
enum gf1_cli_op_flags {