diff options
author | Vishal Pandey <vishpandey2014@gmail.com> | 2017-11-14 14:33:19 +0530 |
---|---|---|
committer | Aravinda VK <avishwan@redhat.com> | 2017-11-15 09:57:00 +0000 |
commit | 5f5d166e89367dc0d72fa02ca4e8ca2d28a06cdd (patch) | |
tree | f3eaf5174792a7706d5d00659023145bf88aa9f5 /events | |
parent | a5b5cbb99eb946cdc9ad08b2d321005def13f0a1 (diff) |
eventsapi: glustereventsd hardcodes working-directory
Issue:
Glusterevents daemon hardcodes glusterd working directory
even though it can be changed later in .vol file
which causes breaks in the code.
Fix: Use python subprocess module to get the working directory
of gluster daemon in eventsapiconf.py.in.
Change-Id: I5e92185604f8c8aeb77dabdc00f9ea0f8e92c88d
BUG: 1512455
Signed-off-by: Vishal Pandey <vishpandey2014@gmail.com>
Diffstat (limited to 'events')
-rw-r--r-- | events/src/eventsapiconf.py.in | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/events/src/eventsapiconf.py.in b/events/src/eventsapiconf.py.in index 687eaa39c00..003cb981572 100644 --- a/events/src/eventsapiconf.py.in +++ b/events/src/eventsapiconf.py.in @@ -9,12 +9,29 @@ # cases as published by the Free Software Foundation. # +import subprocess +glusterd_workdir = None + +# Methods +def get_glusterd_workdir(): + global glusterd_workdir + if glusterd_workdir is not None: + return glusterd_workdir + proc = subprocess.Popen(["gluster", "system::", "getwd"], + stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out, err = proc.communicate() + if proc.returncode == 0: + glusterd_workdir = out.strip() + else: + glusterd_workdir = "@GLUSTERD_WORKDIR@" + return glusterd_workdir + SERVER_ADDRESS = "0.0.0.0" DEFAULT_CONFIG_FILE = "@SYSCONF_DIR@/glusterfs/eventsconfig.json" CUSTOM_CONFIG_FILE_TO_SYNC = "/events/config.json" -CUSTOM_CONFIG_FILE = "@GLUSTERD_WORKDIR@" + CUSTOM_CONFIG_FILE_TO_SYNC +CUSTOM_CONFIG_FILE = get_glusterd_workdir() + CUSTOM_CONFIG_FILE_TO_SYNC WEBHOOKS_FILE_TO_SYNC = "/events/webhooks.json" -WEBHOOKS_FILE = "@GLUSTERD_WORKDIR@" + WEBHOOKS_FILE_TO_SYNC +WEBHOOKS_FILE = get_glusterd_workdir() + WEBHOOKS_FILE_TO_SYNC LOG_FILE = "@localstatedir@/log/glusterfs/events.log" EVENTSD = "glustereventsd" CONFIG_KEYS = ["log-level", "port", "disable-events-log"] @@ -22,11 +39,11 @@ BOOL_CONFIGS = ["disable-events-log"] INT_CONFIGS = ["port"] RESTART_CONFIGS = ["port"] EVENTS_ENABLED = @EVENTS_ENABLED@ -UUID_FILE = "@GLUSTERD_WORKDIR@/glusterd.info" +UUID_FILE = get_glusterd_workdir() + "/glusterd.info" PID_FILE = "@localstatedir@/run/glustereventsd.pid" AUTO_BOOL_ATTRIBUTES = ["force", "push-pem", "no-verify"] AUTO_INT_ATTRIBUTES = ["ssh-port"] -CERTS_DIR = "@GLUSTERD_WORKDIR@/events" +CERTS_DIR = get_glusterd_workdir() + "/events" # Errors ERROR_SAME_CONFIG = 2 |