diff options
author | ShwethaHP <spandura@redhat.com> | 2017-12-15 14:58:06 +0530 |
---|---|---|
committer | Jonathan Holloway <jholloway@redhat.com> | 2018-01-11 06:47:49 +0000 |
commit | faf5077586ab5c631524a434533da4e46f25abae (patch) | |
tree | e7c77a998aa2656f0728acffc4d20d4e313b1834 /glustolibs-gluster/glustolibs/gluster/brick_libs.py | |
parent | d6d816ef4013f754c75c29158b46644823daec4f (diff) |
Adding functions for:
1. Waiting for all bricks to be online
2. Waiting for all self-heal-daemons to be online
3. Waiting for all volume processes to be online
Change-Id: I01a8711838227eb167e69710ecbd3abd0fecb9e6
Signed-off-by: ShwethaHP <spandura@redhat.com>
Diffstat (limited to 'glustolibs-gluster/glustolibs/gluster/brick_libs.py')
-rw-r--r-- | glustolibs-gluster/glustolibs/gluster/brick_libs.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/glustolibs-gluster/glustolibs/gluster/brick_libs.py b/glustolibs-gluster/glustolibs/gluster/brick_libs.py index 6c32fe5b9..4d79703d0 100644 --- a/glustolibs-gluster/glustolibs/gluster/brick_libs.py +++ b/glustolibs-gluster/glustolibs/gluster/brick_libs.py @@ -812,3 +812,42 @@ def get_bricks_to_bring_offline_from_disperse_volume(subvols_list, list_of_bricks_to_bring_offline.extend(bricks_to_bring_offline) return list_of_bricks_to_bring_offline + + +def wait_for_bricks_to_be_online(mnode, volname, timeout=300): + """Waits for the bricks to be online until timeout + + Args: + mnode (str): Node on which commands will be executed. + volname (str): Name of the volume. + + Kwargs: + timeout (int): timeout value in seconds to wait for bricks to be + online + + Returns: + True if all bricks are online within timeout, False otherwise + """ + all_bricks = get_all_bricks(mnode, volname) + if not all_bricks: + return False + + counter = 0 + flag = 0 + while counter < timeout: + status = are_bricks_online(mnode, volname, all_bricks) + + if status: + flag = 1 + break + if not status: + time.sleep(10) + counter = counter + 10 + + if not flag: + g.log.error("All Bricks of the volume '%s' are not online " + "even after %d minutes", (volname, timeout/60.0)) + return False + else: + g.log.info("All Bricks of the volume '%s' are online ", volname) + return True |