233933
From 8b501d9dfbeecb3ffdc3cd11b7c74aa929356ed6 Mon Sep 17 00:00:00 2001
233933
From: jiffin tony thottan <jthottan@redhat.com>
233933
Date: Mon, 7 Dec 2015 14:38:54 +0530
233933
Subject: [PATCH 059/124] glusterd/ganesha : throw proper error for "gluster
233933
 nfs-ganesha disable"
233933
233933
For first time or if "gluster nfs-ganesha enable" fails the global option
233933
"nfs-ganesha" won't be stored in glusterd's dictionary. In both cases the
233933
"gluster nfs-ganesha disable" throws following error :
233933
"nfs-ganesha: failed: nfs-ganesha is already (null)d."
233933
233933
Also this patch provides the missing prompt for nfs-ganesha disable in 3.10
233933
233933
Label: DOWNSTREAM ONLY
233933
233933
Change-Id: I7c9fd6dabedc0cfb14c5190b3554bc63a6bc0340
233933
Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
233933
Reviewed-on: https://review.gluster.org/16791
233933
Smoke: Gluster Build System <jenkins@build.gluster.org>
233933
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
233933
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
233933
Reviewed-by: soumya k <skoduri@redhat.com>
233933
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
233933
Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
233933
Reviewed-on: https://code.engineering.redhat.com/gerrit/167144
233933
Reviewed-by: Soumya Koduri <skoduri@redhat.com>
233933
Tested-by: RHGS Build Bot <nigelb@redhat.com>
233933
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
233933
---
233933
 cli/src/cli-cmd-parser.c                     | 33 +++++++++++++++++-----------
233933
 xlators/mgmt/glusterd/src/glusterd-ganesha.c | 22 +++++--------------
233933
 2 files changed, 26 insertions(+), 29 deletions(-)
233933
233933
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
233933
index cd9c445..f85958b 100644
233933
--- a/cli/src/cli-cmd-parser.c
233933
+++ b/cli/src/cli-cmd-parser.c
233933
@@ -5908,20 +5908,27 @@ cli_cmd_ganesha_parse(struct cli_state *state, const char **words,
233933
         goto out;
233933
     }
233933
 
233933
-    question =
233933
-        "Enabling NFS-Ganesha requires Gluster-NFS to be"
233933
-        " disabled across the trusted pool. Do you "
233933
-        "still want to continue?\n";
233933
-
233933
     if (strcmp(value, "enable") == 0) {
233933
-        answer = cli_cmd_get_confirmation(state, question);
233933
-        if (GF_ANSWER_NO == answer) {
233933
-            gf_log("cli", GF_LOG_ERROR,
233933
-                   "Global operation "
233933
-                   "cancelled, exiting");
233933
-            ret = -1;
233933
-            goto out;
233933
-        }
233933
+        question =
233933
+            "Enabling NFS-Ganesha requires Gluster-NFS to be "
233933
+            "disabled across the trusted pool. Do you "
233933
+            "still want to continue?\n";
233933
+    } else if (strcmp(value, "disable") == 0) {
233933
+        question =
233933
+            "Disabling NFS-Ganesha will tear down the entire "
233933
+            "ganesha cluster across the trusted pool. Do you "
233933
+            "still want to continue?\n";
233933
+    } else {
233933
+        ret = -1;
233933
+        goto out;
233933
+    }
233933
+    answer = cli_cmd_get_confirmation(state, question);
233933
+    if (GF_ANSWER_NO == answer) {
233933
+        gf_log("cli", GF_LOG_ERROR,
233933
+               "Global operation "
233933
+               "cancelled, exiting");
233933
+        ret = -1;
233933
+        goto out;
233933
     }
233933
     cli_out("This will take a few minutes to complete. Please wait ..");
233933
 
233933
diff --git a/xlators/mgmt/glusterd/src/glusterd-ganesha.c b/xlators/mgmt/glusterd/src/glusterd-ganesha.c
233933
index 6d72fda..1d17a33 100644
233933
--- a/xlators/mgmt/glusterd/src/glusterd-ganesha.c
233933
+++ b/xlators/mgmt/glusterd/src/glusterd-ganesha.c
233933
@@ -252,8 +252,7 @@ int
233933
 glusterd_op_stage_set_ganesha(dict_t *dict, char **op_errstr)
233933
 {
233933
     int ret = -1;
233933
-    int value = -1;
233933
-    gf_boolean_t option = _gf_false;
233933
+    char *value = NULL;
233933
     char *str = NULL;
233933
     glusterd_conf_t *priv = NULL;
233933
     xlator_t *this = NULL;
233933
@@ -264,8 +263,8 @@ glusterd_op_stage_set_ganesha(dict_t *dict, char **op_errstr)
233933
     priv = this->private;
233933
     GF_ASSERT(priv);
233933
 
233933
-    value = dict_get_str_boolean(dict, "value", _gf_false);
233933
-    if (value == -1) {
233933
+    ret = dict_get_str(dict, "value", &value);
233933
+    if (value == NULL) {
233933
         gf_msg(this->name, GF_LOG_ERROR, errno, GD_MSG_DICT_GET_FAILED,
233933
                "value not present.");
233933
         goto out;
233933
@@ -273,22 +272,13 @@ glusterd_op_stage_set_ganesha(dict_t *dict, char **op_errstr)
233933
     /* This dict_get will fail if the user had never set the key before */
233933
     /*Ignoring the ret value and proceeding */
233933
     ret = dict_get_str(priv->opts, GLUSTERD_STORE_KEY_GANESHA_GLOBAL, &str);
233933
-    if (ret == -1) {
233933
-        gf_msg(this->name, GF_LOG_WARNING, errno, GD_MSG_DICT_GET_FAILED,
233933
-               "Global dict not present.");
233933
-        ret = 0;
233933
-        goto out;
233933
-    }
233933
-    /* Validity of the value is already checked */
233933
-    ret = gf_string2boolean(str, &option);
233933
-    /* Check if the feature is already enabled, fail in that case */
233933
-    if (value == option) {
233933
-        gf_asprintf(op_errstr, "nfs-ganesha is already %sd.", str);
233933
+    if (str ? strcmp(value, str) == 0 : strcmp(value, "disable") == 0) {
233933
+        gf_asprintf(op_errstr, "nfs-ganesha is already %sd.", value);
233933
         ret = -1;
233933
         goto out;
233933
     }
233933
 
233933
-    if (value) {
233933
+    if (strcmp(value, "enable")) {
233933
         ret = start_ganesha(op_errstr);
233933
         if (ret) {
233933
             gf_msg(THIS->name, GF_LOG_ERROR, 0, GD_MSG_NFS_GNS_START_FAIL,
233933
-- 
233933
1.8.3.1
233933