diff options
author | Aravinda VK <avishwan@redhat.com> | 2016-07-19 17:28:14 +0530 |
---|---|---|
committer | Aravinda VK <avishwan@redhat.com> | 2016-07-28 03:14:18 -0700 |
commit | 7e00626b0dcd04b4f38d7cb1a3288ba6740ed9b6 (patch) | |
tree | 20cea0bd79bdd9f364ce460410008acc769b6e8f /events/src | |
parent | ec6925a379c7bee071df1638bc2751b266cee346 (diff) |
eventsapi: Volume Set and Reset Events
Example of published data for Volume Set:
{
"nodeid": NODEID,
"ts": TIMESTAMP,
"event": "VOLUME_SET",
"message": {
"name": VOLUME_NAME,
"options": [[KEY1, VALUE1], [KEY2, VALUE2],..]
}
}
Example of published data for Volume Reset:
{
"nodeid": NODEID,
"ts": TIMESTAMP,
"event": "VOLUME_RESET",
"message": {
"name": VOLUME_NAME,
"option": KEY
}
}
BUG: 1358671
Change-Id: If30cc95396459b2a9993b3412ee6d05d27f6a86a
Signed-off-by: Aravinda VK <avishwan@redhat.com>
Reviewed-on: http://review.gluster.org/14973
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: Atin Mukherjee <amukherj@redhat.com>
Diffstat (limited to 'events/src')
-rw-r--r-- | events/src/eventtypes.py | 2 | ||||
-rw-r--r-- | events/src/handlers.py | 19 |
2 files changed, 21 insertions, 0 deletions
diff --git a/events/src/eventtypes.py b/events/src/eventtypes.py index 4812e659de3..b09e5bcff9a 100644 --- a/events/src/eventtypes.py +++ b/events/src/eventtypes.py @@ -6,4 +6,6 @@ all_events = [ "EVENT_VOLUME_START", "EVENT_VOLUME_STOP", "EVENT_VOLUME_DELETE", + "EVENT_VOLUME_SET", + "EVENT_VOLUME_RESET", ] diff --git a/events/src/handlers.py b/events/src/handlers.py index 9b756a91d51..21d3e83de54 100644 --- a/events/src/handlers.py +++ b/events/src/handlers.py @@ -19,3 +19,22 @@ def generic_handler(ts, key, data): Ex: handle_event_volume_create(ts, key, data) """ utils.publish(ts, key, data) + + +def handle_event_volume_set(ts, key, data): + """ + Recieved data will have all the options as one string, split into + list of options. "key1,value1,key2,value2" into + [[key1, value1], [key2, value2]] + """ + opts = data.get("options", "").strip(",").split(",") + data["options"] = [] + for i, opt in enumerate(opts): + if i % 2 == 0: + # Add new array with key + data["options"].append([opt]) + else: + # Add to the last added array + data["options"][-1].append(opt) + + utils.publish(ts, key, data) |