summaryrefslogtreecommitdiffstats
path: root/glustolibs-gluster/glustolibs/gluster
diff options
context:
space:
mode:
authorAkarsha <akrai@redhat.com>2018-04-12 14:57:41 +0530
committerNigel Babu <nigelb@redhat.com>2018-04-19 03:40:24 +0000
commit782449997a02271fcb5fcafbbaf38ab244e7b9a0 (patch)
tree22b1b13bef5f648a8d2262c4cb974e56574a02a9 /glustolibs-gluster/glustolibs/gluster
parent01bdb218a797d5035537e936dc3b7e345c6f7dae (diff)
Library to check brick pid matches pid of glusterfsd when brick mux feature is enabled
Change-Id: Id8d42c72548d618ac7bd1563ca2035018b7c2c99 Signed-off-by: Akarsha <akrai@redhat.com>
Diffstat (limited to 'glustolibs-gluster/glustolibs/gluster')
-rw-r--r--glustolibs-gluster/glustolibs/gluster/brickmux_ops.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/glustolibs-gluster/glustolibs/gluster/brickmux_ops.py b/glustolibs-gluster/glustolibs/gluster/brickmux_ops.py
index 6f5480890..2fa4687b9 100644
--- a/glustolibs-gluster/glustolibs/gluster/brickmux_ops.py
+++ b/glustolibs-gluster/glustolibs/gluster/brickmux_ops.py
@@ -20,6 +20,8 @@
"""
from glusto.core import Glusto as g
+from glustolibs.gluster.brick_libs import get_all_bricks
+from glustolibs.gluster.volume_ops import get_volume_status
def is_brick_mux_enabled(mnode):
@@ -54,3 +56,47 @@ def enable_brick_mux(mnode):
if "success" in out:
return True
return False
+
+
+def check_brick_pid_matches_glusterfsd_pid(mnode, volname):
+ # pylint: disable=invalid-name
+ """Checks for brick process(es) both volume status
+ and 'ps -eaf | grep glusterfsd' matches for
+ the given volume
+
+ Args:
+ mnode (str): Node on which cmd has to be executed.
+ volname (str): Name of the volume.
+
+ Returns:
+ bool : True if pid's matches. False otherwise.
+ """
+ _rc = True
+ bricks_list = get_all_bricks(mnode, volname)
+ for brick in bricks_list:
+ brick_node, brick_path = brick.split(":")
+ ret = get_volume_status(mnode, volname)
+ brick_pid = ret[volname][brick_node][brick_path]["pid"]
+ if brick_pid == "None":
+ g.log.error("Failed to get brick pid on node %s "
+ "of brick path %s", brick_node, brick_path)
+ _rc = False
+
+ cmd = ("ps -eaf | grep glusterfsd | "
+ "grep %s.%s | grep -v 'grep %s.%s'"
+ % (volname, brick_node,
+ volname, brick_node))
+ ret, pid, _ = g.run(brick_node, cmd)
+ if ret != 0:
+ g.log.error("Failed to run the command %s on "
+ "node %s", cmd, brick_node)
+ _rc = False
+ glusterfsd_pid = pid.split()[1]
+
+ if glusterfsd_pid != brick_pid:
+ g.log.eror("Brick pid %s doesn't macth glusterfsd "
+ "pid %s of the node %s", brick_pid,
+ glusterfsd_pid, brick_node)
+ _rc = False
+
+ return _rc