From a817dfa6522ee29397fbc950b06ed11bbc57d469 Mon Sep 17 00:00:00 2001 From: Vijay Avuthu Date: Sat, 27 Jan 2018 16:04:43 +0530 Subject: Adding function bring_self_heal_daemon_process_offline to heal_libs Description: Bring the self-heal daemon process offline for the nodes Change-Id: I55301fb86a97147920991aa4455e8e5d80b1c5c3 Signed-off-by: Vijay Avuthu --- glustolibs-gluster/glustolibs/gluster/heal_libs.py | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/glustolibs-gluster/glustolibs/gluster/heal_libs.py b/glustolibs-gluster/glustolibs/gluster/heal_libs.py index b782caf86..3da020380 100644 --- a/glustolibs-gluster/glustolibs/gluster/heal_libs.py +++ b/glustolibs-gluster/glustolibs/gluster/heal_libs.py @@ -455,3 +455,47 @@ def is_shd_daemonized(nodes, timeout=120): g.log.info("Single self heal daemon process on all nodes %s", nodes) return True + + +def bring_self_heal_daemon_process_offline(nodes): + """ + Bring the self-heal daemon process offline for the nodes + + Args: + nodes ( str|list ) : Node/Nodes of the cluster to bring + self-heal daemon process offline + + Returns: + bool : True on successfully bringing self-heal daemon process offline. + False otherwise + """ + if isinstance(nodes, str): + nodes = [nodes] + + failed_nodes = [] + _rc = True + + g.log.info("Starting to get self heal daemon process on nodes %s" % nodes) + ret, pids = get_self_heal_daemon_pid(nodes) + if not ret: + g.log.error("Either no self heal daemon process found or more than" + " one self heal daemon process found : %s" % pids) + return False + g.log.info("Successful in getting single self heal daemon process" + " on all nodes %s", nodes) + + for node in pids: + pid = pids[node][0] + kill_cmd = "kill -SIGKILL %s" % pid + ret, _, _ = g.run(node, kill_cmd) + if ret != 0: + g.log.error("Unable to kill the self heal daemon " + "process on %s" % node) + failed_nodes.append(node) + + if failed_nodes: + g.log.info("Unable to kill the self heal daemon " + "process on nodes %s" % nodes) + _rc = False + + return _rc -- cgit