From 673f2f90f35e5ea381bd22a43403278f89c957a5 Mon Sep 17 00:00:00 2001 From: Jiffin Tony Thottan Date: Mon, 16 Oct 2017 14:24:29 +0530 Subject: Revert "glusterd: (storhaug) remove ganesha (843e1b0)" please note as an additional change, macro GLUSTERD_GET_SNAP_DIR moved from glusterd-store.c to glusterd-snapshot-utils.h Change-Id: I811efefc148453fe32e4f0d322e80455447cec71 updates: #663 Signed-off-by: Jiffin Tony Thottan --- cli/src/cli-cmd-parser.c | 118 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) (limited to 'cli/src/cli-cmd-parser.c') diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index decdd10cb50..18aef217a9a 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -5772,3 +5772,121 @@ out: return ret; } + +/* Parsing global option for NFS-Ganesha config + * gluster nfs-ganesha enable/disable */ + +int32_t +cli_cmd_ganesha_parse(struct cli_state *state, const char **words, + int wordcount, dict_t **options, char **op_errstr) +{ + dict_t *dict = NULL; + int ret = -1; + char *key = NULL; + char *value = NULL; + char *w = NULL; + char *opwords[] = {"enable", "disable", NULL}; + const char *question = NULL; + gf_answer_t answer = GF_ANSWER_NO; + + GF_ASSERT(words); + GF_ASSERT(options); + + dict = dict_new(); + + if (!dict) + goto out; + + if (wordcount != 2) + goto out; + + key = (char *)words[0]; + value = (char *)words[1]; + + if (!key || !value) { + cli_out("Usage : nfs-ganesha "); + ret = -1; + goto out; + } + + ret = gf_strip_whitespace(value, strlen(value)); + if (ret == -1) + goto out; + + if (strcmp(key, "nfs-ganesha")) { + gf_asprintf(op_errstr, + "Global option: error: ' %s '" + "is not a valid global option.", + key); + ret = -1; + goto out; + } + + w = str_getunamb(value, opwords); + if (!w) { + cli_out( + "Invalid global option \n" + "Usage : nfs-ganesha "); + ret = -1; + goto out; + } + + if (strcmp(value, "enable") == 0) { + 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 the 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); + if (GF_ANSWER_NO == answer) { + gf_log("cli", GF_LOG_ERROR, + "Global operation " + "cancelled, exiting"); + ret = -1; + goto out; + } + cli_out("This will take a few minutes to complete. Please wait .."); + + ret = dict_set_str(dict, "key", key); + if (ret) { + gf_log(THIS->name, GF_LOG_ERROR, "dict set on key failed"); + goto out; + } + + ret = dict_set_str(dict, "value", value); + if (ret) { + gf_log(THIS->name, GF_LOG_ERROR, "dict set on value failed"); + goto out; + } + + ret = dict_set_str(dict, "globalname", "All"); + if (ret) { + gf_log(THIS->name, GF_LOG_ERROR, + "dict set on global" + " key failed."); + goto out; + } + + ret = dict_set_int32(dict, "hold_global_locks", _gf_true); + if (ret) { + gf_log(THIS->name, GF_LOG_ERROR, + "dict set on global key " + "failed."); + goto out; + } + + *options = dict; +out: + if (ret) + dict_unref(dict); + + return ret; +} -- cgit