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