summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaushik BV <kaushikbv@gluster.com>2010-10-08 10:34:18 +0000
committerVijay Bellur <vijay@dev.gluster.com>2010-10-08 09:16:29 -0700
commit13f1fff6da4b2b9ee30f43346cb382abfc1bc304 (patch)
treef317506712fb4c3d15a8cf9e9e62d9606306dab1
parente0cdcbf68ab1dc1cc1af874cd84579d89a3e3747 (diff)
mgmt/Glusterd : Volume info fixes
Signed-off-by: Kaushik BV <kaushikbv@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 1872 (gluster volume info is not working with qa42-) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1872
-rw-r--r--cli/src/cli3_1-cops.c41
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handler.c27
2 files changed, 41 insertions, 27 deletions
diff --git a/cli/src/cli3_1-cops.c b/cli/src/cli3_1-cops.c
index 8f170b98f..5b5d5425f 100644
--- a/cli/src/cli3_1-cops.c
+++ b/cli/src/cli3_1-cops.c
@@ -368,6 +368,8 @@ gf_cli3_1_get_volume_cbk (struct rpc_req *req, struct iovec *iov,
data_pair_t *pairs = NULL;
char *ptr = NULL;
data_t *value = NULL;
+ int opt_count = 0;
+ int k = 0;
@@ -512,23 +514,36 @@ gf_cli3_1_get_volume_cbk (struct rpc_req *req, struct iovec *iov,
goto out;
}
- snprintf (key, 256, "volume%d.option.",i);
+ snprintf (key, 256, "volume%d.opt_count",i);
+ ret = dict_get_int32 (dict, key, &opt_count);
+ if (ret)
+ goto out;
+
+ if (!opt_count)
+ goto out;
+
cli_out ("Options Reconfigured:");
- while (pairs) {
- ptr = strstr (pairs->key, "option.");
- if (ptr) {
- value = pairs->value;
- if (!value) {
- ret = -1;
- goto out;
+ k = 0;
+ while ( k < opt_count) {
+
+ snprintf (key, 256, "volume%d.option.",i);
+ while (pairs) {
+ ptr = strstr (pairs->key, "option.");
+ if (ptr) {
+ value = pairs->value;
+ if (!value) {
+ ret = -1;
+ goto out;
+ }
+ cli_out_options (key, pairs->key,
+ value->data);
}
- cli_out_options (key, pairs->key,
- value->data);
+ pairs = pairs->next;
}
- pairs = pairs->next;
- }
+ k++;
+ }
- i++;
+ i++;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index dcc408eb0..ba9aeb8f9 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -269,6 +269,7 @@ glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo,
char reconfig_key[256] = {0, };
dict_t *dict = NULL;
data_t *value = NULL;
+ int opt_count = 0;
GF_ASSERT (volinfo);
@@ -318,34 +319,32 @@ glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo,
dict = volinfo->dict;
if (!dict) {
- ret = -1;
+ ret = 0;
goto out;
}
pairs = dict->members_list;
- if (!pairs) {
- ret = -1;
- goto out;
- }
while (pairs) {
if (1 == glusterd_check_option_exists (pairs->key, NULL)) {
value = pairs->value;
- if (!value) {
- ret = -1;
- goto out;
- }
+ if (!value)
+ continue;
+
snprintf (reconfig_key, 256, "volume%d.option.%s", count,
pairs->key);
- gf_log ("", GF_LOG_DEBUG,
- "Setting dict with key=%s, value=%s",
- reconfig_key, pairs->value->data);
- ret = dict_set_str (volumes, gf_strdup (reconfig_key),
- value->data);
+ ret = dict_set_str (volumes, reconfig_key, value->data);
+ if (!ret)
+ opt_count++;
}
pairs = pairs->next;
}
+ snprintf (key, 256, "volume%d.opt_count", count);
+ ret = dict_set_int32 (volumes, key, opt_count);
+ if (ret)
+ goto out;
+
out:
return ret;
}