summaryrefslogtreecommitdiffstats
path: root/glustolibs-gluster/glustolibs/gluster/brick_libs.py
diff options
context:
space:
mode:
authorkshithijiyer <kshithij.ki@gmail.com>2020-01-17 19:04:59 +0530
committerKshithij Iyer <kiyer@redhat.com>2020-01-17 13:47:49 +0000
commit7c7b15909f941ffe18018f8aebbae058d8098aee (patch)
tree1066150fbd2d9a416d5ce72d94e2b69e930f504c /glustolibs-gluster/glustolibs/gluster/brick_libs.py
parentaa7736fc0de7a9df121204878cd78f9eb3bfa6e1 (diff)
[lib] Adding function is_broken_symlinks_present_on_bricks to brick_libs
Adding function is_broken_symlinks_present_on_bricks() to brick_libs for checking if backend bricks have broken symlinks or not. Function added based on reviews on patch [1]. [1] https://review.gluster.org/#/c/glusto-tests/+/20460/8/tests/functional/bvt/test_verify_volume_sanity.py Change-Id: I1b512702ab6bc629bcd967ff34ad7ecfddfc1af1 Signed-off-by: kshithijiyer <kshithij.ki@gmail.com>
Diffstat (limited to 'glustolibs-gluster/glustolibs/gluster/brick_libs.py')
-rw-r--r--glustolibs-gluster/glustolibs/gluster/brick_libs.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/glustolibs-gluster/glustolibs/gluster/brick_libs.py b/glustolibs-gluster/glustolibs/gluster/brick_libs.py
index 0ec9e87..c3e5afe 100644
--- a/glustolibs-gluster/glustolibs/gluster/brick_libs.py
+++ b/glustolibs-gluster/glustolibs/gluster/brick_libs.py
@@ -902,3 +902,28 @@ def wait_for_bricks_to_be_online(mnode, volname, timeout=300):
else:
g.log.info("All Bricks of the volume '%s' are online ", volname)
return True
+
+
+def is_broken_symlinks_present_on_bricks(mnode, volname):
+ """ Checks if the backend bricks have broken symlinks.
+
+ Args:
+ mnode(str): Node on which command has to be executed
+ volname(str): Name of the volume
+
+ Retruns:
+ (bool):Returns True if present else returns False.
+ """
+ brick_list = get_all_bricks(mnode, volname)
+ for brick in brick_list:
+ brick_node, brick_path = brick.split(":")
+ cmd = ("find %s -xtype l | wc -l" % brick_path)
+ ret, out, _ = g.run(brick_node, cmd)
+ if ret:
+ g.log.error("Failed to run command on node %s", brick_node)
+ return True
+ if out:
+ g.log.error("Error: Broken symlink found on brick path: "
+ "%s on node %s.", (brick_path, brick_node))
+ return True
+ return False