From f7f48bcf66e73f96ece8ccd18420f2fea7ecb686 Mon Sep 17 00:00:00 2001 From: Prasad Desala Date: Sat, 20 Jan 2018 22:47:15 +0530 Subject: rebalance_ops: Adding a function wait_for_fix_layout_to_completes Change-Id: Id33b1de7c01cd7774d3c4cce3c40ddfe2dc0d884 Signed-off-by: Prasad Desala --- .../glustolibs/gluster/rebalance_ops.py | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'glustolibs-gluster/glustolibs') diff --git a/glustolibs-gluster/glustolibs/gluster/rebalance_ops.py b/glustolibs-gluster/glustolibs/gluster/rebalance_ops.py index a4cd57e99..99beb1a12 100644 --- a/glustolibs-gluster/glustolibs/gluster/rebalance_ops.py +++ b/glustolibs-gluster/glustolibs/gluster/rebalance_ops.py @@ -263,6 +263,46 @@ def rebalance_stop_and_get_status(mnode, volname): return rebal_status +def wait_for_fix_layout_to_complete(mnode, volname, timeout=300): + """Waits for the fix-layout to complete + + Args: + mnode (str): Node on which command has to be executed. + volname (str): volume name + + Kwargs: + timeout (int): timeout value in seconds to wait for rebalance + to complete + + Returns: + True on success, False otherwise + + Examples: + >>> wait_for_fix_layout_to_complete("abc.com", "testvol") + """ + + count = 0 + flag = 0 + while (count < timeout): + status_info = get_rebalance_status(mnode, volname) + if status_info is None: + return False + + status = status_info['aggregate']['statusStr'] + if status == 'fix-layout completed': + flag = 1 + break + + time.sleep(10) + count = count + 10 + if not flag: + g.log.error("Fix-layout is not completed") + return False + else: + g.log.info("Fix-layout is successfully completed") + return True + + def wait_for_rebalance_to_complete(mnode, volname, timeout=300): """Waits for the rebalance to complete -- cgit