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