From a482645865af56b8d34a17430649c3c646f3d450 Mon Sep 17 00:00:00 2001 From: Aravinda VK Date: Mon, 26 Sep 2016 17:08:31 +0530 Subject: 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 Reviewed-on: http://review.gluster.org/15574 NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Prashanth Pai Smoke: Gluster Build System --- events/src/utils.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'events/src/utils.py') 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: -- cgit