summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-op-sm.c
diff options
context:
space:
mode:
authorKaushik BV <kaushikbv@gluster.com>2011-07-12 05:33:29 +0000
committerAnand Avati <avati@gluster.com>2011-07-12 09:03:03 -0700
commit1d0cb953bb117689fb8381d65932ead486d13b05 (patch)
tree50e87fcca9bcbac92e116c53dd7bb918ee6b031c /xlators/mgmt/glusterd/src/glusterd-op-sm.c
parentf9e0638b7597f4b1a4245f63c94d3d6bd3158136 (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 831e6bbdc40..83f64bf9d26 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -1345,6 +1345,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) {
@@ -1353,7 +1386,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);
@@ -1369,27 +1401,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);
@@ -5609,6 +5620,25 @@ glusterd_op_log_level (dict_t *dict)
}
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;
@@ -5623,7 +5653,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);
@@ -5631,8 +5662,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;
@@ -5711,7 +5755,6 @@ glusterd_op_set_volume (dict_t *dict)
}
}
-
if ( count == 1 ) {
gf_log ("", GF_LOG_ERROR, "No options received ");
ret = -1;
@@ -5782,11 +5825,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);