summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-op-sm.c
diff options
context:
space:
mode:
authorKaushik BV <kaushikbv@gluster.com>2011-07-15 01:20:08 +0000
committerAnand Avati <avati@gluster.com>2011-07-17 07:46:18 -0700
commit3c6138dbf2ed6ebba6b8108be8f4999ff8226964 (patch)
treeb0d4f0f18b2cee10785cd823fe2b387a0cdb3a4d /xlators/mgmt/glusterd/src/glusterd-op-sm.c
parentf1b0e963976208cc93e69fc627a81a6f4ab1640b (diff)
mgmt/Glusterd: Implementation volume set help/help-xml
Signed-off-by: Kaushik BV <kaushikbv@gluster.com> Signed-off-by: Anand Avati <avati@gluster.com> BUG: 2041 (volume set help option) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2041
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-op-sm.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c98
1 files changed, 69 insertions, 29 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index 771c95bef4a..6ef1723bd72 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -1113,6 +1113,39 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
if (!val_dict)
goto out;
+ ret = dict_get_int32 (dict, "count", &dict_count);
+
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR, "Count(dict),not set in Volume-Set");
+ goto out;
+ }
+
+ if ( dict_count == 0 ) {
+ /*No options would be specified of volume set help */
+ if (dict_get (dict, "help" )) {
+ ret = 0;
+ goto out;
+ }
+
+ if (dict_get (dict, "help-xml" )) {
+
+#if (HAVE_LIB_XML)
+ ret = 0;
+ goto out;
+#else
+ ret = -1;
+ gf_log ("", GF_LOG_ERROR, "libxml not present in the"
+ "system");
+ *op_errstr = gf_strdup ("Error: xml libraries not "
+ "present to produce xml-output");
+ goto out;
+#endif
+ }
+ gf_log ("", GF_LOG_ERROR, "No options received ");
+ *op_errstr = gf_strdup ("Options not specified");
+ ret = -1;
+ goto out;
+ }
ret = dict_get_str (dict, "volname", &volname);
if (ret) {
@@ -1121,7 +1154,6 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
}
exists = glusterd_check_volume_exists (volname);
-
if (!exists) {
snprintf (errstr, sizeof (errstr), "Volume %s does not exist",
volname);
@@ -1137,27 +1169,6 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
goto out;
}
- ret = dict_get_int32 (dict, "count", &dict_count);
-
- if (ret) {
- gf_log ("", GF_LOG_ERROR, "Count(dict),not set in Volume-Set");
- goto out;
- }
-
- if ( dict_count == 1 ) {
- if (dict_get (dict, "history" )) {
- ret = 0;
- goto out;
- }
-
- gf_log ("", GF_LOG_ERROR, "No options received ");
- *op_errstr = gf_strdup ("Options not specified");
- ret = -1;
- goto out;
- }
-
-
-
for ( count = 1; ret != 1 ; count++ ) {
global_opt = _gf_false;
sprintf (str, "key%d", count);
@@ -3874,6 +3885,25 @@ glusterd_restart_brick_servers (glusterd_volinfo_t *volinfo)
}
static int
+glusterd_volset_help (dict_t *dict)
+{
+ int ret = -1;
+ gf_boolean_t xml_out = _gf_false;
+
+ if (dict_get (dict, "help" ))
+ xml_out = _gf_false;
+ else if (dict_get (dict, "help-xml" ))
+ xml_out = _gf_true;
+ else
+ goto out;
+
+ ret = glusterd_get_volopt_content (xml_out);
+ out:
+ gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret);
+ return ret;
+}
+
+static int
glusterd_op_set_volume (dict_t *dict)
{
int ret = 0;
@@ -3888,7 +3918,8 @@ glusterd_op_set_volume (dict_t *dict)
char *value = NULL;
char str[50] = {0, };
gf_boolean_t global_opt = _gf_false;
- glusterd_volinfo_t *voliter = NULL;
+ glusterd_volinfo_t *voliter = NULL;
+ int32_t dict_count = 0;
this = THIS;
GF_ASSERT (this);
@@ -3896,8 +3927,21 @@ glusterd_op_set_volume (dict_t *dict)
priv = this->private;
GF_ASSERT (priv);
- ret = dict_get_str (dict, "volname", &volname);
+ ret = dict_get_int32 (dict, "count", &dict_count);
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR, "Count(dict),not set in Volume-Set");
+ goto out;
+ }
+ if ( dict_count == 0 ) {
+ ret = glusterd_volset_help (dict);
+ if (ret)
+ gf_log ("glusterd", GF_LOG_ERROR, "Volume set help"
+ "internal error");
+ goto out;
+ }
+
+ ret = dict_get_str (dict, "volname", &volname);
if (ret) {
gf_log ("", GF_LOG_ERROR, "Unable to get volume name");
goto out;
@@ -3983,7 +4027,6 @@ glusterd_op_set_volume (dict_t *dict)
}
}
-
if ( count == 1 ) {
gf_log ("", GF_LOG_ERROR, "No options received ");
ret = -1;
@@ -4061,11 +4104,8 @@ glusterd_op_set_volume (dict_t *dict)
}
}
-
-
ret = 0;
-
-out:
+ out:
if (key_fixed)
GF_FREE (key_fixed);
gf_log ("", GF_LOG_DEBUG, "returning %d", ret);