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