summaryrefslogtreecommitdiffstats
path: root/glustolibs-gluster/glustolibs/gluster
diff options
context:
space:
mode:
authorPrasad Desala <tdesala@redhat.com>2018-01-20 22:47:15 +0530
committerPrasad Desala <tdesala@redhat.com>2018-01-20 22:48:52 +0530
commitf7f48bcf66e73f96ece8ccd18420f2fea7ecb686 (patch)
tree123fa555e3804fff674be67273de68f7f4885283 /glustolibs-gluster/glustolibs/gluster
parentde5a300cb17c2ab646ff0e6bca7ef791f4637798 (diff)
rebalance_ops: Adding a function wait_for_fix_layout_to_completes
Change-Id: Id33b1de7c01cd7774d3c4cce3c40ddfe2dc0d884 Signed-off-by: Prasad Desala <tdesala@redhat.com>
Diffstat (limited to 'glustolibs-gluster/glustolibs/gluster')
-rw-r--r--glustolibs-gluster/glustolibs/gluster/rebalance_ops.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/glustolibs-gluster/glustolibs/gluster/rebalance_ops.py b/glustolibs-gluster/glustolibs/gluster/rebalance_ops.py
index a4cd57e..99beb1a 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