diff options
Diffstat (limited to 'events')
-rw-r--r-- | events/src/eventsapiconf.py.in | 2 | ||||
-rw-r--r-- | events/src/glustereventsd.py | 13 | ||||
-rw-r--r-- | events/src/utils.py | 8 |
3 files changed, 22 insertions, 1 deletions
diff --git a/events/src/eventsapiconf.py.in b/events/src/eventsapiconf.py.in index ecccd3dbda4..e0028761bcc 100644 --- a/events/src/eventsapiconf.py.in +++ b/events/src/eventsapiconf.py.in @@ -24,3 +24,5 @@ RESTART_CONFIGS = ["port"] EVENTS_ENABLED = @EVENTS_ENABLED@ UUID_FILE = "@GLUSTERD_WORKDIR@/glusterd.info" PID_FILE = "@localstatedir@/run/glustereventsd.pid" +AUTO_BOOL_ATTRIBUTES = ["force", "push-pem", "no-verify"] +AUTO_INT_ATTRIBUTES = ["ssh-port"] diff --git a/events/src/glustereventsd.py b/events/src/glustereventsd.py index d057e097c97..86e64b01ad5 100644 --- a/events/src/glustereventsd.py +++ b/events/src/glustereventsd.py @@ -21,7 +21,8 @@ from eventtypes import all_events import handlers import utils from eventsapiconf import SERVER_ADDRESS, PID_FILE -from utils import logger, PidFile, PidFileLockFailed +from eventsapiconf import AUTO_BOOL_ATTRIBUTES, AUTO_INT_ATTRIBUTES +from utils import logger, PidFile, PidFileLockFailed, boolify class GlusterEventsRequestHandler(SocketServer.BaseRequestHandler): @@ -45,6 +46,16 @@ class GlusterEventsRequestHandler(SocketServer.BaseRequestHandler): logger.warn("Unable to parse Event {0}".format(data)) return + for k, v in data_dict.iteritems(): + try: + if k in AUTO_BOOL_ATTRIBUTES: + data_dict[k] = boolify(v) + if k in AUTO_INT_ATTRIBUTES: + data_dict[k] = int(v) + except ValueError: + # Auto Conversion failed, Retain the old value + continue + try: # Event Type to Function Map, Recieved event data will be in # the form <TIMESTAMP> <TYPE> <DETAIL>, Get Event name for the 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: |