summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
authorMeghana Madhusudhan <mmadhusu@redhat.com>2015-02-02 16:23:22 +0530
committerKaleb KEITHLEY <kkeithle@redhat.com>2015-03-18 04:33:13 -0700
commit38ccaaf9d1a93c4fc6d733ee3bd5c73e5457bdab (patch)
tree8856e8a6a869d6a0f1444c74e6bd05b08d950940 /cli
parent8a9c909702f4f6836bd1d0c791a7b1ae79d4ba15 (diff)
CLI : GLobal option for NFS-Ganesha
A new global CLI option has been introduced for NFS-Ganesha. gluster features.ganesha enable/disable. This option is persistent and shall be inherited by new volumes created after this option is set. gluster features.ganesha enable It carries out the following functions: 1. Disables gluster-nfs across the cluster 2. Starts NFS-Ganesha server on a subset of nodes and exports '/'. 3. Creates the HA cluster for NFS-Ganesha. 4. Writes the option into the global config file. gluster features.ganesha disable 1. Stops NFS-Ganesha server. 2. Tears down the HA cluster for NFS-Ganesha With this change the older volume set options with keys "nfs-ganesha.host" and "nfs-ganesha.enable" will no longer be supported. This commit has only has the CLI related changes. Another patch will be submitted to support this feature entirely. Change-Id: Ie4b66a16c23b33b795738654b9a68f8e2c34efe3 BUG: 1188184 Signed-off-by: Meghana Madhusudhan <mmadhusu@redhat.com> Reviewed-on: http://review.gluster.org/9538 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Niels de Vos <ndevos@redhat.com>
Diffstat (limited to 'cli')
-rw-r--r--cli/src/cli-cmd-parser.c93
-rw-r--r--cli/src/cli-cmd-volume.c54
-rw-r--r--cli/src/cli-rpc-ops.c80
-rw-r--r--cli/src/cli.h3
4 files changed, 229 insertions, 1 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index aa512738784..c7fdafb32b6 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -754,6 +754,99 @@ out:
return ret;
}
+/* Parsing global option for NFS-Ganesha config
+ * gluster features.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;
+ int flags = 0;
+ char *key = NULL;
+ char *value = NULL;
+ int i = 0;
+ char *w = NULL;
+ char *opwords[] = { "enable", "disable" };
+ 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 : features.ganesha <enable/disable>");
+ ret = -1;
+ goto out;
+ }
+
+ ret = gf_strip_whitespace (value, strlen (value));
+ if (ret == -1)
+ goto out;
+
+ if (strcmp (key, "features.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 : features.ganesha <enable/disable>");
+ ret = -1;
+ goto out;
+ }
+
+ question = "Enabling NFS-Ganesha requires Gluster-NFS to be"
+ "disabled across the trusted pool. Do you "
+ "still want to continue?";
+
+ if (strcmp (value, "enable") == 0) {
+ 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;
+ }
+ }
+
+ 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;
+ }
+
+ *options = dict;
+out:
+ if (ret)
+ dict_unref (dict);
+
+ return ret;
+}
+
int32_t
cli_cmd_quota_parse (const char **words, int wordcount, dict_t **options)
{
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
index a14a772cfb7..dc223990741 100644
--- a/cli/src/cli-cmd-volume.c
+++ b/cli/src/cli-cmd-volume.c
@@ -725,7 +725,7 @@ cli_cmd_volume_set_cbk (struct cli_state *state, struct cli_cmd_word *word,
int sent = 0;
int parse_error = 0;
- int ret = -1;
+ int ret = -1;
rpc_clnt_procedure_t *proc = NULL;
call_frame_t *frame = NULL;
dict_t *options = NULL;
@@ -1248,6 +1248,54 @@ out:
return ret;
}
+int cli_cmd_ganesha_cbk (struct cli_state *state, struct cli_cmd_word *word,
+ const char **words, int wordcount)
+
+{
+ int sent = 0;
+ int parse_error = 0;
+ int ret = -1;
+ rpc_clnt_procedure_t *proc = NULL;
+ call_frame_t *frame = NULL;
+ dict_t *options = NULL;
+ cli_local_t *local = NULL;
+ char *op_errstr = NULL;
+
+ proc = &cli_rpc_prog->proctable[GLUSTER_CLI_GANESHA];
+
+ frame = create_frame (THIS, THIS->ctx->pool);
+ if (!frame)
+ goto out;
+
+ ret = cli_cmd_ganesha_parse (state, words, wordcount,
+ &options, &op_errstr);
+ if (ret) {
+ if (op_errstr) {
+ cli_err ("%s", op_errstr);
+ GF_FREE (op_errstr);
+ } else
+ cli_usage_out (word->pattern);
+ parse_error = 1;
+ goto out;
+ }
+
+ CLI_LOCAL_INIT (local, words, frame, options);
+
+ if (proc->fn) {
+ ret = proc->fn (frame, THIS, options);
+ }
+
+out:
+ if (ret) {
+ cli_cmd_sent_status_get (&sent);
+ if ((sent == 0) && (parse_error == 0))
+ cli_out ("Setting global option failed");
+ }
+
+ CLI_STACK_DESTROY (frame);
+ return ret;
+}
+
int
cli_cmd_quota_cbk (struct cli_state *state, struct cli_cmd_word *word,
const char **words, int wordcount)
@@ -2395,6 +2443,10 @@ struct cli_cmd volume_cmds[] = {
cli_cmd_quota_cbk,
"quota translator specific operations"},
+ { "features.ganesha { enable| disable } ",
+ cli_cmd_ganesha_cbk,
+ "global ganesha operations" },
+
{ "volume top <VOLNAME> {open|read|write|opendir|readdir|clear} [nfs|brick <brick>] [list-cnt <value>] |\n"
"volume top <VOLNAME> {read-perf|write-perf} [bs <size> count <count>] [brick <brick>] [list-cnt <value>]",
cli_cmd_volume_top_cbk,
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index a02761d5e6e..00ea6633bb6 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -1698,6 +1698,61 @@ out:
return ret;
}
+int
+gf_cli_ganesha_cbk (struct rpc_req *req, struct iovec *iov,
+ int count, void *myframe)
+{
+ gf_cli_rsp rsp = {0,};
+ int ret = -1;
+ dict_t *dict = NULL;
+ char *help_str = NULL;
+ char msg[1024] = {0,};
+ char tmp_str[512] = {0,};
+
+ if (-1 == req->rpc_status) {
+ goto out;
+ }
+
+ ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp);
+ if (ret < 0) {
+ gf_log (((call_frame_t *) myframe)->this->name, GF_LOG_ERROR,
+ "Failed to decode xdr response");
+ goto out;
+ }
+
+ gf_log ("cli", GF_LOG_DEBUG, "Received resp to ganesha");
+
+ dict = dict_new ();
+
+ if (!dict) {
+ ret = -1;
+ goto out;
+ }
+
+ ret = dict_unserialize (rsp.dict.dict_val, rsp.dict.dict_len, &dict);
+ if (ret)
+ goto out;
+
+ if (rsp.op_ret) {
+ if (strcmp (rsp.op_errstr, ""))
+ cli_err ("ganesha enable: failed: %s", rsp.op_errstr);
+ else
+ cli_err ("ganesha enable: failed");
+ }
+
+ else {
+ cli_out("ganesha enable : success ");
+ }
+
+ ret = rsp.op_ret;
+
+out:
+ if (dict)
+ dict_unref (dict);
+ cli_cmd_broadcast_response (ret);
+ return ret;
+}
+
char *
is_server_debug_xlator (void *myframe)
{
@@ -3586,6 +3641,30 @@ out:
}
int32_t
+gf_cli_ganesha (call_frame_t *frame, xlator_t *this, void *data)
+{
+ gf_cli_req req = { {0,} } ;
+ int ret = 0;
+ dict_t *dict = NULL;
+
+ if (!frame || !this || !data) {
+ ret = -1;
+ goto out;
+ }
+
+ dict = data;
+
+ ret = cli_to_glusterd (&req, frame, gf_cli_ganesha_cbk,
+ (xdrproc_t) xdr_gf_cli_req, dict,
+ GLUSTER_CLI_GANESHA, this, cli_rpc_prog,
+ NULL);
+out:
+ gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret);
+
+ return ret;
+}
+
+int32_t
gf_cli_set_volume (call_frame_t *frame, xlator_t *this,
void *data)
{
@@ -9770,6 +9849,7 @@ struct rpc_clnt_procedure gluster_cli_actors[GLUSTER_CLI_MAXVALUE] = {
[GLUSTER_CLI_SYS_EXEC] = {"SYS_EXEC", gf_cli_sys_exec},
[GLUSTER_CLI_SNAP] = {"SNAP", gf_cli_snapshot},
[GLUSTER_CLI_BARRIER_VOLUME] = {"BARRIER VOLUME", gf_cli_barrier_volume},
+ [GLUSTER_CLI_GANESHA] = {"GANESHA", gf_cli_ganesha},
[GLUSTER_CLI_GET_VOL_OPT] = {"GET_VOL_OPT", gf_cli_get_vol_opt},
};
diff --git a/cli/src/cli.h b/cli/src/cli.h
index 2e1369af944..6951555d479 100644
--- a/cli/src/cli.h
+++ b/cli/src/cli.h
@@ -239,6 +239,9 @@ cli_cmd_quota_parse (const char **words, int wordcount, dict_t **opt);
int32_t
cli_cmd_volume_set_parse (const char **words, int wordcount,
dict_t **options, char **op_errstr);
+int32_t
+cli_cmd_ganesha_parse (struct cli_state *state, const char **words,
+ int wordcount, dict_t **options, char **op_errstr);
int32_t
cli_cmd_volume_add_brick_parse (const char **words, int wordcount,