From bf089252a62be7ef5a56597664f3dbb23b22951c Mon Sep 17 00:00:00 2001 From: Pranav Date: Tue, 21 Apr 2020 14:36:58 +0530 Subject: [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 --- glustolibs-gluster/glustolibs/gluster/heal_libs.py | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'glustolibs-gluster/glustolibs') 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 -- cgit