Blob Blame History Raw
From 7a723c0c971b13a3db39f210919a054e0ea8ec94 Mon Sep 17 00:00:00 2001
From: Milind Changire <mchangir@redhat.com>
Date: Wed, 26 Oct 2016 11:12:48 +0530
Subject: [PATCH 144/157] 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.

mainline:
> > Reviewed-on: http://review.gluster.org/15675
> > Smoke: Gluster Build System <jenkins@build.gluster.org>
> > CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
> > NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
> > Reviewed-by: Dan Lambright <dlambrig@redhat.com>
(cherry picked from commit 8f8e23b0142a21779648802664db5b3d5253e4e0)

release-3.9:
> Reviewed-on: http://review.gluster.org/15708
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
> Smoke: Gluster Build System <jenkins@build.gluster.org>
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
> Reviewed-by: Aravinda VK <avishwan@redhat.com>
(cherry picked from commit 20408dcb5c7491894761fdd86499e038357bd95a)

Change-Id: I205dc14884d707087edce42e8cf4208bd89d31dc
BUG: 1386185
Signed-off-by: Milind Changire <mchangir@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/88233
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
---
 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 f2679d2..2d4f465 100644
--- a/cli/src/cli-cmd-volume.c
+++ b/cli/src/cli-cmd-volume.c
@@ -1196,7 +1196,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;
@@ -1231,11 +1231,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;
                 }
         }
@@ -1273,6 +1276,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);
@@ -1283,22 +1287,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;
 
@@ -1326,6 +1334,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 1b1c691..06953b2 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"
-- 
1.7.1