From 20408dcb5c7491894761fdd86499e038357bd95a Mon Sep 17 00:00:00 2001 From: Milind Changire Date: Wed, 19 Oct 2016 23:53:12 +0530 Subject: events: add TIER_START and TIER_START_FORCE events Add TIER_START and TIER_START_FORCE events Conditionally generate DETACH events as per user confirmation. > Reviewed-on: http://review.gluster.org/15675 > Smoke: Gluster Build System > CentOS-regression: Gluster Build System > NetBSD-regression: NetBSD Build System > Reviewed-by: Dan Lambright (cherry picked from commit 8f8e23b0142a21779648802664db5b3d5253e4e0) Change-Id: I205dc14884d707087edce42e8cf4208bd89d31dc BUG: 1387981 Signed-off-by: Milind Changire Reviewed-on: http://review.gluster.org/15708 NetBSD-regression: NetBSD Build System Smoke: Gluster Build System CentOS-regression: Gluster Build System Reviewed-by: Aravinda VK --- cli/src/cli-cmd-volume.c | 39 ++++++++++++++++++++++++++++----------- events/eventskeygen.py | 3 +++ 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index e850f1a0b91..9b4c43e03f5 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -1192,7 +1192,7 @@ out: int do_cli_cmd_volume_detach_tier (struct cli_state *state, struct cli_cmd_word *word, const char **words, - int wordcount) + int wordcount, gf_boolean_t *aborted) { int ret = -1; rpc_clnt_procedure_t *proc = NULL; @@ -1227,11 +1227,14 @@ do_cli_cmd_volume_detach_tier (struct cli_state *state, if (ret) goto out; + *aborted = _gf_false; + 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); if (GF_ANSWER_NO == answer) { ret = 0; + *aborted = _gf_true; goto out; } } @@ -1268,6 +1271,7 @@ cli_cmd_volume_tier_cbk (struct cli_state *state, cli_local_t *local = NULL; int i = 0; eventtypes_t event = EVENT_LAST; + gf_boolean_t aborted = _gf_false; if (wordcount < 4) { cli_usage_out (word->pattern); @@ -1278,22 +1282,26 @@ cli_cmd_volume_tier_cbk (struct cli_state *state, if (!strcmp(words[1], "detach-tier")) { ret = do_cli_cmd_volume_detach_tier (state, word, - words, wordcount); + words, wordcount, + &aborted); goto out; } else if (!strcmp(words[3], "detach")) { for (i = 3; i < wordcount; i++) words[i] = words[i+1]; ret = do_cli_cmd_volume_detach_tier (state, word, - words, wordcount-1); - if (!strcmp (words[wordcount-2], "commit")) { - event = EVENT_TIER_DETACH_COMMIT; - } else if (!strcmp (words[wordcount-2], "start")) { - event = EVENT_TIER_DETACH_START; - } else if (!strcmp (words[wordcount-2], "stop")) { - event = EVENT_TIER_DETACH_STOP; - } else if (!strcmp (words[wordcount-2], "force")) { - event = EVENT_TIER_DETACH_FORCE; + words, wordcount-1, + &aborted); + if (!aborted) { + if (!strcmp (words[wordcount-2], "commit")) { + event = EVENT_TIER_DETACH_COMMIT; + } else if (!strcmp (words[wordcount-2], "start")) { + event = EVENT_TIER_DETACH_START; + } else if (!strcmp (words[wordcount-2], "stop")) { + event = EVENT_TIER_DETACH_STOP; + } else if (!strcmp (words[wordcount-2], "force")) { + event = EVENT_TIER_DETACH_FORCE; + } } goto out; @@ -1321,6 +1329,15 @@ cli_cmd_volume_tier_cbk (struct cli_state *state, goto out; } + if (!strcmp (words[wordcount-1], "start")) { + event = EVENT_TIER_START; + } else { + if (!strcmp (words[wordcount-2], "start") && + !strcmp (words[wordcount-1], "force")) { + event = EVENT_TIER_START_FORCE; + } + } + proc = &cli_rpc_prog->proctable[GLUSTER_CLI_TIER]; frame = create_frame (THIS, THIS->ctx->pool); diff --git a/events/eventskeygen.py b/events/eventskeygen.py index c8723d542fe..d54968a1d33 100644 --- a/events/eventskeygen.py +++ b/events/eventskeygen.py @@ -189,6 +189,9 @@ keys = ( "EVENT_VOLUME_REBALANCE_FAILED", "EVENT_VOLUME_REBALANCE_COMPLETE", + #tier events + "EVENT_TIER_START", + "EVENT_TIER_START_FORCE", ) LAST_EVENT = "EVENT_LAST" -- cgit