diff options
author | Vijay Avuthu <vavuthu@redhat.com> | 2017-12-18 15:57:44 +0530 |
---|---|---|
committer | ShwethaHPanduranga <shwetha-h-p@review.gluster.org> | 2018-01-23 06:35:17 +0000 |
commit | 99aedb316e3c9491e4d752d1bbc49b6496a7e627 (patch) | |
tree | 878b85eee0fb72d261311735965a0878f54a8db2 /glustolibs-gluster/glustolibs/gluster/gluster_init.py | |
parent | f7f48bcf66e73f96ece8ccd18420f2fea7ecb686 (diff) |
Adding AFR self heal daemon test cases
Gave meaningful names to functions
Returning -1 if there is no process running
Replace numbers with words
Rewording the msg "More than 1 or 0 self heal daemon"
Review Comments incorporated
Change-Id: If424a6f78536279c178ee45d62099fd8f63421dd
Signed-off-by: Vijay Avuthu <vavuthu@redhat.com>
Diffstat (limited to 'glustolibs-gluster/glustolibs/gluster/gluster_init.py')
-rw-r--r-- | glustolibs-gluster/glustolibs/gluster/gluster_init.py | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/glustolibs-gluster/glustolibs/gluster/gluster_init.py b/glustolibs-gluster/glustolibs/gluster/gluster_init.py index d45a186d0..5d08acd0e 100644 --- a/glustolibs-gluster/glustolibs/gluster/gluster_init.py +++ b/glustolibs-gluster/glustolibs/gluster/gluster_init.py @@ -167,3 +167,58 @@ def env_setup_servers(servers): return False return True + + +def get_glusterd_pids(nodes): + """ + Checks if glusterd process is running and + return the process id's in dictionary format + + Args: + nodes ( str|list ) : Node/Nodes of the cluster + + Returns: + tuple : Tuple containing two elements (ret, gluster_pids). + The first element 'ret' is of type 'bool', True if only if + glusterd is running on all the nodes in the list and each + node contains only one instance of glusterd running. + False otherwise. + + The second element 'glusterd_pids' is of type dictonary and + it contains the process ID's for glusterd. + + """ + glusterd_pids = {} + _rc = True + if isinstance(nodes, str): + nodes = [nodes] + + cmd = "pidof glusterd" + g.log.info("Executing cmd: %s on node %s" % (cmd, nodes)) + results = g.run_parallel(nodes, cmd) + for node in results: + ret, out, err = results[node] + if ret == 0: + if len(out.strip().split("\n")) == 1: + if not out.strip(): + g.log.error("NO glusterd process found " + "on node %s" % node) + _rc = False + glusterd_pids[node] = ['-1'] + else: + g.log.info("glusterd process with " + "pid %s found on %s", + out.strip().split("\n"), node) + glusterd_pids[node] = (out.strip().split("\n")) + else: + g.log.error("More than One glusterd process " + "found on node %s" % node) + _rc = False + glusterd_pids[node] = out + else: + g.log.error("Not able to get glusterd process " + "from node %s" % node) + _rc = False + glusterd_pids[node] = ['-1'] + + return _rc, glusterd_pids |