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