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