summaryrefslogtreecommitdiffstats
path: root/events/src/utils.py
diff options
context:
space:
mode:
authorAravinda VK <avishwan@redhat.com>2016-09-26 17:08:31 +0530
committerAravinda VK <avishwan@redhat.com>2016-10-19 23:10:44 -0700
commita482645865af56b8d34a17430649c3c646f3d450 (patch)
treed255e93eaeafd384d0ba2c0c03c2e0f37aa9442e /events/src/utils.py
parent460016428cf27484c333227f534c2e2f73a37fb1 (diff)
eventsapi: Auto convert Boolean and Int attributes
Before publishing in JSON format, automatically convert the attribute to "bool" or "int" if configured. For example, instead of sending force="1", convert to bool and send as force=True { "event": "VOLUME_START", "name" : "gv1", "force": "1" } Convert to, { "event": "VOLUME_START", "name" : "gv1", "force": true } BUG: 1379328 Change-Id: Iabc51fd61abc267a7c8dcf0aeac6b3c722d89649 Signed-off-by: Aravinda VK <avishwan@redhat.com> Reviewed-on: http://review.gluster.org/15574 NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Prashanth Pai <ppai@redhat.com> Smoke: Gluster Build System <jenkins@build.gluster.org>
Diffstat (limited to 'events/src/utils.py')
-rw-r--r--events/src/utils.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/events/src/utils.py b/events/src/utils.py
index dadd9ae3332..6f695c37eba 100644
--- a/events/src/utils.py
+++ b/events/src/utils.py
@@ -35,6 +35,14 @@ logger = logging.getLogger(__name__)
NodeID = None
+def boolify(value):
+ value = str(value)
+ if value.lower() in ["1", "on", "true", "yes"]:
+ return True
+ else:
+ return False
+
+
def get_node_uuid():
val = None
with open(UUID_FILE) as f: