summaryrefslogtreecommitdiffstats
path: root/events/src/utils.py
diff options
context:
space:
mode:
authorAravinda VK <avishwan@redhat.com>2016-08-17 13:46:00 +0530
committerAtin Mukherjee <amukherj@redhat.com>2016-08-30 18:34:59 -0700
commitb71ae7d77d7ab1581d266f6435d134958844d0db (patch)
tree1e2044ee1c7d7ec4dc5a620693484fb091ffb2c9 /events/src/utils.py
parentc1f5cf0bda47fc34725084ee3988b0efe2dcfc8a (diff)
eventsapi: Add support for Client side Events
Client side gf_event uses ctx->cmd_args.volfile_server to push notifications to the eventsd. Socket server changed from Unix domain socket to UDP to support external events. Following to be addressed in different patch - Port used for eventsd is 24009. Make it configurable Already configurable in Server side. Configurable in gf_event API is required. - Auth Token yet to be added as discussed in https://www.gluster.org/pipermail/gluster-devel/2016-August/050324.html Change-Id: I159acf80b681d10b82d52cfb3ffdf85cb896542d BUG: 1367774 Signed-off-by: Aravinda VK <avishwan@redhat.com> Reviewed-on: http://review.gluster.org/15189 Smoke: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Prashanth Pai <ppai@redhat.com> Reviewed-by: Atin Mukherjee <amukherj@redhat.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
Diffstat (limited to 'events/src/utils.py')
-rw-r--r--events/src/utils.py28
1 files changed, 24 insertions, 4 deletions
diff --git a/events/src/utils.py b/events/src/utils.py
index 772221a1e25..386e8f28449 100644
--- a/events/src/utils.py
+++ b/events/src/utils.py
@@ -17,11 +17,10 @@ import requests
from eventsapiconf import (LOG_FILE,
WEBHOOKS_FILE,
DEFAULT_CONFIG_FILE,
- CUSTOM_CONFIG_FILE)
+ CUSTOM_CONFIG_FILE,
+ UUID_FILE)
import eventtypes
-from gluster.cliutils import get_node_uuid
-
# Webhooks list
_webhooks = {}
@@ -32,6 +31,23 @@ _config = {}
# Init Logger instance
logger = logging.getLogger(__name__)
+NodeID = None
+
+
+def get_node_uuid():
+ val = None
+ with open(UUID_FILE) as f:
+ for line in f:
+ if line.startswith("UUID="):
+ val = line.strip().split("=")[-1]
+ break
+ return val
+
+
+def get_config(key):
+ if not _config:
+ load_config()
+ return _config.get(key, None)
def get_event_type_name(idx):
@@ -109,8 +125,12 @@ def load_all():
def publish(ts, event_key, data):
+ global NodeID
+ if NodeID is None:
+ NodeID = get_node_uuid()
+
message = {
- "nodeid": get_node_uuid(),
+ "nodeid": NodeID,
"ts": int(ts),
"event": get_event_type_name(event_key),
"message": data