From 7c7b15909f941ffe18018f8aebbae058d8098aee Mon Sep 17 00:00:00 2001 From: kshithijiyer Date: Fri, 17 Jan 2020 19:04:59 +0530 Subject: [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 --- .../glustolibs/gluster/brick_libs.py | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/glustolibs-gluster/glustolibs/gluster/brick_libs.py b/glustolibs-gluster/glustolibs/gluster/brick_libs.py index 0ec9e879f..c3e5afed8 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 -- cgit