From 3bab32ce9c10039e76c33741f7a190d34c754b62 Mon Sep 17 00:00:00 2001
From: jiffin tony thottan <jthottan@redhat.com>
Date: Mon, 7 Dec 2015 14:38:54 +0530
Subject: [PATCH 403/406] glusterd/ganesha : throw proper error for "gluster
nfs-ganesha disable"
For first time or if "gluster nfs-ganesha enable" fails the global option
"nfs-ganesha" won't be stored in glusterd's dictionary. In both cases the
"gluster nfs-ganesha disable" throws following error :
"nfs-ganesha: failed: nfs-ganesha is already (null)d."
Upstream reference
>Change-Id: I7c9fd6dabedc0cfb14c5190b3554bc63a6bc0340
>BUG: 1427759
>Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
>Reviewed-on: https://review.gluster.org/16791
>Smoke: Gluster Build System <jenkins@build.gluster.org>
>NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
>Reviewed-by: soumya k <skoduri@redhat.com>
>Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
>Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
Change-Id: I7c9fd6dabedc0cfb14c5190b3554bc63a6bc0340
BUG: 1427452
Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/104147
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
---
cli/src/cli-cmd-parser.c | 7 +++++--
xlators/mgmt/glusterd/src/glusterd-ganesha.c | 28 +++++++++-------------------
2 files changed, 14 insertions(+), 21 deletions(-)
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index 7637944..9a50501 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -883,14 +883,17 @@ cli_cmd_ganesha_parse (struct cli_state *state,
}
if (strcmp (value, "enable") == 0) {
- question = "Enabling NFS-Ganesha requires Gluster-NFS to be"
- " disabled across the trusted pool. Do you "
+ question = "Enabling NFS-Ganesha requires Gluster-NFS to be "
+ "disabled across the trusted pool. Do you "
"still want to continue?\n";
} else if (strcmp (value, "disable") == 0) {
question = "Disabling NFS-Ganesha will tear down entire "
"ganesha cluster across the trusted pool. Do you "
"still want to continue?\n";
+ } else {
+ ret = -1;
+ goto out;
}
answer = cli_cmd_get_confirmation (state, question);
diff --git a/xlators/mgmt/glusterd/src/glusterd-ganesha.c b/xlators/mgmt/glusterd/src/glusterd-ganesha.c
index ae07eaa..9c5e147 100644
--- a/xlators/mgmt/glusterd/src/glusterd-ganesha.c
+++ b/xlators/mgmt/glusterd/src/glusterd-ganesha.c
@@ -267,8 +267,7 @@ glusterd_op_stage_set_ganesha (dict_t *dict, char **op_errstr)
int ret = -1;
char *volname = NULL;
int exists = 0;
- int value = -1;
- gf_boolean_t option = _gf_false;
+ char *value = NULL;
char *str = NULL;
int dict_count = 0;
int flags = 0;
@@ -282,8 +281,8 @@ glusterd_op_stage_set_ganesha (dict_t *dict, char **op_errstr)
priv = this->private;
GF_ASSERT (priv);
- value = dict_get_str_boolean (dict, "value", _gf_false);
- if (value == -1) {
+ ret = dict_get_str (dict, "value", &value);
+ if (value == NULL) {
gf_msg (this->name, GF_LOG_ERROR, errno,
GD_MSG_DICT_GET_FAILED,
"value not present.");
@@ -292,22 +291,13 @@ glusterd_op_stage_set_ganesha (dict_t *dict, char **op_errstr)
/* This dict_get will fail if the user had never set the key before */
/*Ignoring the ret value and proceeding */
ret = dict_get_str (priv->opts, GLUSTERD_STORE_KEY_GANESHA_GLOBAL, &str);
- if (ret == -1) {
- gf_msg (this->name, GF_LOG_WARNING, errno,
- GD_MSG_DICT_GET_FAILED, "Global dict not present.");
- ret = 0;
- goto out;
+ /* Check if the feature is already enabled/disable, fail in that case */
+ if (str ? strcmp (value, str) == 0 : strcmp (value, "disable") == 0) {
+ gf_asprintf (op_errstr, "nfs-ganesha is already %sd.", value);
+ ret = -1;
+ goto out;
}
- /* Validity of the value is already checked */
- ret = gf_string2boolean (str, &option);
- /* Check if the feature is already enabled, fail in that case */
- if (value == option) {
- gf_asprintf (op_errstr, "nfs-ganesha is already %sd.", str);
- ret = -1;
- goto out;
- }
-
- if (value) {
+ if (strcmp (value, "enable") == 0) {
ret = start_ganesha (op_errstr);
if (ret) {
gf_msg (THIS->name, GF_LOG_ERROR, 0,
--
1.8.3.1