3604df
From 9f2bd89762a853b2af93d290db68017555ab6c1a Mon Sep 17 00:00:00 2001
3604df
From: Manikandan Selvaganesh <mselvaga@redhat.com>
3604df
Date: Mon, 22 Aug 2016 12:43:19 +0530
3604df
Subject: [PATCH 50/86] quota/cli: add user driven quota events
3604df
3604df
This patch targets to capture all the user driven quota related events
3604df
which are important to be notified.
3604df
3604df
>Reviewed-on: http://review.gluster.org/15230
3604df
>Smoke: Gluster Build System <jenkins@build.gluster.org>
3604df
>NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
3604df
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
3604df
>Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
3604df
3604df
Change-Id: I90c0af434363465e9dbdf6fca65ac220251d8d3c
3604df
BUG: 1361078
3604df
Signed-off-by: Manikandan Selvaganesh <mselvaga@redhat.com>
3604df
Reviewed-on: https://code.engineering.redhat.com/gerrit/84797
3604df
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
3604df
Tested-by: Atin Mukherjee <amukherj@redhat.com>
3604df
---
3604df
 cli/src/cli-cmd-volume.c |   47 ++++++++++++++++++++++++++++++++++++++++++++++
3604df
 events/eventskeygen.py   |   13 ++++++++++++
3604df
 2 files changed, 60 insertions(+), 0 deletions(-)
3604df
3604df
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
3604df
index 0ea461e..27cb9dd 100644
3604df
--- a/cli/src/cli-cmd-volume.c
3604df
+++ b/cli/src/cli-cmd-volume.c
3604df
@@ -1707,6 +1707,53 @@ out:
3604df
                                  "logs for more details");
3604df
         }
3604df
 
3604df
+        /* Events for Quota */
3604df
+         if (ret == 0) {
3604df
+                switch (type) {
3604df
+                case GF_QUOTA_OPTION_TYPE_ENABLE:
3604df
+                        gf_event (EVENT_QUOTA_ENABLE, "volume=%s", volname);
3604df
+                        break;
3604df
+                case GF_QUOTA_OPTION_TYPE_DISABLE:
3604df
+                        gf_event (EVENT_QUOTA_DISABLE, "volume=%s", volname);
3604df
+                        break;
3604df
+                case GF_QUOTA_OPTION_TYPE_LIMIT_USAGE:
3604df
+                        gf_event (EVENT_QUOTA_SET_USAGE_LIMIT, "volume=%s;"
3604df
+                                  "path=%s;limit=%s", volname, words[4],
3604df
+                                  words[5]);
3604df
+                        break;
3604df
+                case GF_QUOTA_OPTION_TYPE_LIMIT_OBJECTS:
3604df
+                        gf_event (EVENT_QUOTA_SET_OBJECTS_LIMIT, "volume=%s;"
3604df
+                                  "path=%s;limit=%s", volname, words[4],
3604df
+                                  words[5]);
3604df
+                        break;
3604df
+                case GF_QUOTA_OPTION_TYPE_REMOVE:
3604df
+                        gf_event (EVENT_QUOTA_REMOVE_USAGE_LIMIT, "volume=%s;"
3604df
+                                  "path=%s", volname, words[4]);
3604df
+                        break;
3604df
+                case GF_QUOTA_OPTION_TYPE_REMOVE_OBJECTS:
3604df
+                        gf_event (EVENT_QUOTA_REMOVE_OBJECTS_LIMIT,
3604df
+                                  "volume=%s;" "path=%s", volname, words[4]);
3604df
+                        break;
3604df
+                case GF_QUOTA_OPTION_TYPE_ALERT_TIME:
3604df
+                        gf_event (EVENT_QUOTA_ALERT_TIME, "volume=%s;time=%s",
3604df
+                                  volname, words[4]);
3604df
+                        break;
3604df
+                case GF_QUOTA_OPTION_TYPE_SOFT_TIMEOUT:
3604df
+                        gf_event (EVENT_QUOTA_SOFT_TIMEOUT, "volume=%s;"
3604df
+                                  "soft-timeout=%s", volname, words[4]);
3604df
+                        break;
3604df
+                case GF_QUOTA_OPTION_TYPE_HARD_TIMEOUT:
3604df
+                        gf_event (EVENT_QUOTA_HARD_TIMEOUT, "volume=%s;"
3604df
+                                  "hard-timeout=%s", volname, words[4]);
3604df
+                        break;
3604df
+                case GF_QUOTA_OPTION_TYPE_DEFAULT_SOFT_LIMIT:
3604df
+                        gf_event (EVENT_QUOTA_DEFAULT_SOFT_LIMIT, "volume=%s;"
3604df
+                                  "default-soft-limit=%s", volname, words[4]);
3604df
+                        break;
3604df
+                }
3604df
+        }
3604df
+
3604df
+
3604df
         CLI_STACK_DESTROY (frame);
3604df
         return ret;
3604df
 }
3604df
diff --git a/events/eventskeygen.py b/events/eventskeygen.py
3604df
index 885c9de..144c554 100644
3604df
--- a/events/eventskeygen.py
3604df
+++ b/events/eventskeygen.py
3604df
@@ -69,6 +69,7 @@ keys = (
3604df
     "EVENT_BRICKPATH_RESOLVE_FAILED",
3604df
 
3604df
     "EVENT_NOTIFY_UNKNOWN_OP",
3604df
+
3604df
     "EVENT_QUORUM_LOST",
3604df
     "EVENT_QUORUM_REGAINED",
3604df
     "EVENT_REBALANCE_START_FAILED",
3604df
@@ -78,6 +79,18 @@ keys = (
3604df
     "EVENT_IMPORT_BRICK_FAILED",
3604df
     "EVENT_COMPARE_FRIEND_VOLUME_FAILED",
3604df
     "EVENT_NFS_GANESHA_EXPORT_FAILED",
3604df
+
3604df
+    "EVENT_QUOTA_ENABLE",
3604df
+    "EVENT_QUOTA_DISABLE",
3604df
+    "EVENT_QUOTA_SET_USAGE_LIMIT",
3604df
+    "EVENT_QUOTA_SET_OBJECTS_LIMIT",
3604df
+    "EVENT_QUOTA_REMOVE_USAGE_LIMIT",
3604df
+    "EVENT_QUOTA_REMOVE_OBJECTS_LIMIT",
3604df
+    "EVENT_QUOTA_ALERT_TIME",
3604df
+    "EVENT_QUOTA_SOFT_TIMEOUT",
3604df
+    "EVENT_QUOTA_HARD_TIMEOUT",
3604df
+    "EVENT_QUOTA_DEFAULT_SOFT_LIMIT",
3604df
+
3604df
 )
3604df
 
3604df
 LAST_EVENT = "EVENT_LAST"
3604df
-- 
3604df
1.7.1
3604df