summaryrefslogtreecommitdiffstats
path: root/glustolibs-gluster/glustolibs
diff options
context:
space:
mode:
authorPranav <prprakas@redhat.com>2020-04-21 14:36:58 +0530
committerBala Konda Reddy M <bala12352@gmail.com>2020-04-23 13:16:31 +0000
commitbf089252a62be7ef5a56597664f3dbb23b22951c (patch)
tree185072183a673d84ed88904facd4007895d571f1 /glustolibs-gluster/glustolibs
parent1a269464cced564d01503a4675db42212cefc9f8 (diff)
[Lib] Add is_shd_daemon_running method
Verifies whether the shd daemon is up and running on a particular node. The method verifies whether the shd pid is present or not on the given node. If present, as an additional verification, verifies that the 'self-heal daemon' for the node specified is not there in the get volume status output Change-Id: I4865dc5c493a72ed7334ea998d0a231f4f8c75c8 Signed-off-by: Pranav <prprakas@redhat.com>
Diffstat (limited to 'glustolibs-gluster/glustolibs')
-rwxr-xr-xglustolibs-gluster/glustolibs/gluster/heal_libs.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/glustolibs-gluster/glustolibs/gluster/heal_libs.py b/glustolibs-gluster/glustolibs/gluster/heal_libs.py
index 504173ae7..d01939905 100755
--- a/glustolibs-gluster/glustolibs/gluster/heal_libs.py
+++ b/glustolibs-gluster/glustolibs/gluster/heal_libs.py
@@ -509,3 +509,33 @@ def bring_self_heal_daemon_process_offline(nodes):
_rc = False
return _rc
+
+
+def is_shd_daemon_running(mnode, node, volname):
+ """
+ Verifies whether the shd daemon is up and running on a particular node by
+ checking the existence of shd pid and parsing the get volume status output.
+
+ Args:
+ mnode (str): The first node in servers list
+ node (str): The node to be checked for whether the glustershd
+ process is up or not
+ volname (str): Name of the volume created
+
+ Returns:
+ boolean: True if shd is running on the node, False, otherwise
+ """
+
+ # Get glustershd pid from node.
+ ret, glustershd_pids = get_self_heal_daemon_pid(node)
+ if not ret and glustershd_pids[node] != -1:
+ return False
+ # Verifying glustershd process is no longer running from get status.
+ vol_status = get_volume_status(mnode, volname)
+ if vol_status is None:
+ return False
+ try:
+ _ = vol_status[volname][node]['Self-heal Daemon']
+ return True
+ except KeyError:
+ return False