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