summaryrefslogtreecommitdiffstats
path: root/cli/src
diff options
context:
space:
mode:
Diffstat (limited to 'cli/src')
-rw-r--r--cli/src/cli-cmd-parser.c56
-rw-r--r--cli/src/cli-cmd-volume.c51
-rw-r--r--cli/src/cli-cmd.h2
-rw-r--r--cli/src/cli.h4
4 files changed, 92 insertions, 21 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index 7291a46aa13..917be5337cd 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -1406,17 +1406,19 @@ out:
}
int32_t
-cli_cmd_volume_set_parse (const char **words, int wordcount, dict_t **options,
- char **op_errstr)
+cli_cmd_volume_set_parse (struct cli_state *state, const char **words,
+ int wordcount, dict_t **options, char **op_errstr)
{
- dict_t *dict = NULL;
- char *volname = NULL;
- int ret = -1;
- int count = 0;
- char *key = NULL;
- char *value = NULL;
- int i = 0;
- char str[50] = {0,};
+ dict_t *dict = NULL;
+ char *volname = NULL;
+ int ret = -1;
+ int count = 0;
+ char *key = NULL;
+ char *value = NULL;
+ int i = 0;
+ char str[50] = {0,};
+ const char *question = NULL;
+ gf_answer_t answer = GF_ANSWER_NO;
GF_ASSERT (words);
GF_ASSERT (options);
@@ -1438,6 +1440,22 @@ cli_cmd_volume_set_parse (const char **words, int wordcount, dict_t **options,
if (ret)
goto out;
+ if (!strcmp (volname, "all")) {
+ 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;
+ }
+ }
+
if ((!strcmp (volname, "help") || !strcmp (volname, "help-xml"))
&& wordcount == 3 ) {
ret = dict_set_str (dict, volname, volname);
@@ -1507,6 +1525,24 @@ cli_cmd_volume_set_parse (const char **words, int wordcount, dict_t **options,
if (ret)
goto out;
+
+ if ((!strcmp (key, "cluster.enable-shared-storage")) &&
+ (!strcmp (value, "disable"))) {
+ question = "Disabling cluster.enable-shared-storage "
+ "will delete the shared storage volume"
+ "(gluster_shared_storage), which is used "
+ "by snapshot scheduler, geo-replication "
+ "and NFS-Ganesha. Do you still want to "
+ "continue?";
+ answer = cli_cmd_get_confirmation (state, question);
+ if (GF_ANSWER_NO == answer) {
+ gf_log ("cli", GF_LOG_ERROR, "Operation "
+ "cancelled, exiting");
+ *op_errstr = gf_strdup ("Aborted by user.");
+ ret = -1;
+ goto out;
+ }
+ }
}
ret = dict_set_int32 (dict, "count", wordcount-3);
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
index da6603cc1f6..6dd30580004 100644
--- a/cli/src/cli-cmd-volume.c
+++ b/cli/src/cli-cmd-volume.c
@@ -286,22 +286,28 @@ cli_cmd_volume_delete_cbk (struct cli_state *state, struct cli_cmd_word *word,
goto out;
}
- answer = cli_cmd_get_confirmation (state, question);
-
- if (GF_ANSWER_NO == answer) {
- ret = 0;
- goto out;
- }
-
volname = (char *)words[2];
ret = dict_set_str (dict, "volname", volname);
-
if (ret) {
gf_log (THIS->name, GF_LOG_WARNING, "dict set failed");
goto out;
}
+ if (!strcmp (volname, GLUSTER_SHARED_STORAGE)) {
+ question = "Deleting the shared storage volume"
+ "(gluster_shared_storage), will affect features "
+ "like snapshot scheduler, geo-replication "
+ "and NFS-Ganesha. Do you still want to "
+ "continue?";
+ }
+
+ answer = cli_cmd_get_confirmation (state, question);
+ if (GF_ANSWER_NO == answer) {
+ ret = 0;
+ goto out;
+ }
+
CLI_LOCAL_INIT (local, words, frame, dict);
if (proc->fn) {
@@ -473,6 +479,14 @@ cli_cmd_volume_stop_cbk (struct cli_state *state, struct cli_cmd_word *word,
goto out;
}
+ if (!strcmp (volname, GLUSTER_SHARED_STORAGE)) {
+ question = "Stopping the shared storage volume"
+ "(gluster_shared_storage), will affect features "
+ "like snapshot scheduler, geo-replication "
+ "and NFS-Ganesha. Do you still want to "
+ "continue?";
+ }
+
if (wordcount == 4) {
if (!strcmp("force", words[3])) {
flags |= GF_CLI_FLAG_OP_FORCE;
@@ -483,6 +497,7 @@ cli_cmd_volume_stop_cbk (struct cli_state *state, struct cli_cmd_word *word,
goto out;
}
}
+
ret = dict_set_int32 (dict, "flags", flags);
if (ret) {
gf_log (THIS->name, GF_LOG_ERROR,
@@ -732,7 +747,8 @@ cli_cmd_volume_set_cbk (struct cli_state *state, struct cli_cmd_word *word,
if (!frame)
goto out;
- ret = cli_cmd_volume_set_parse (words, wordcount, &options, &op_errstr);
+ ret = cli_cmd_volume_set_parse (state, words, wordcount,
+ &options, &op_errstr);
if (ret) {
if (op_errstr) {
cli_err ("%s", op_errstr);
@@ -1612,6 +1628,7 @@ cli_cmd_volume_remove_brick_cbk (struct cli_state *state,
int parse_error = 0;
int need_question = 0;
cli_local_t *local = NULL;
+ char *volname = NULL;
const char *question = "Removing brick(s) can result in data loss. "
"Do you want to Continue?";
@@ -1628,6 +1645,22 @@ cli_cmd_volume_remove_brick_cbk (struct cli_state *state,
goto out;
}
+ ret = dict_get_str (options, "volname", &volname);
+ if (ret || !volname) {
+ gf_log ("cli", GF_LOG_ERROR, "Failed to fetch volname");
+ ret = -1;
+ goto out;
+ }
+
+ if (!strcmp (volname, GLUSTER_SHARED_STORAGE)) {
+ question = "Removing brick from the shared storage volume"
+ "(gluster_shared_storage), will affect features "
+ "like snapshot scheduler, geo-replication "
+ "and NFS-Ganesha. Do you still want to "
+ "continue?";
+ need_question = _gf_true;
+ }
+
if (!(state->mode & GLUSTER_MODE_SCRIPT) && need_question) {
/* we need to ask question only in case of 'commit or force' */
answer = cli_cmd_get_confirmation (state, question);
diff --git a/cli/src/cli-cmd.h b/cli/src/cli-cmd.h
index 94fa3e9c671..3a689c45b88 100644
--- a/cli/src/cli-cmd.h
+++ b/cli/src/cli-cmd.h
@@ -20,6 +20,8 @@
#include "cli.h"
#include "list.h"
+#define GLUSTER_SHARED_STORAGE "gluster_shared_storage"
+
#define CLI_LOCAL_INIT(local, words, frame, dictionary) \
do { \
local = cli_local_get (); \
diff --git a/cli/src/cli.h b/cli/src/cli.h
index c9283b5b875..6c0fbcedd45 100644
--- a/cli/src/cli.h
+++ b/cli/src/cli.h
@@ -248,8 +248,8 @@ int32_t
cli_cmd_bitrot_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);
+cli_cmd_volume_set_parse (struct cli_state *state, 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);