summaryrefslogtreecommitdiffstats
path: root/glustolibs-gluster/glustolibs/gluster/gluster_init.py
diff options
context:
space:
mode:
authorSri Vignesh <sselvan@redhat.com>2020-01-06 14:11:48 +0530
committerBala Konda Reddy M <bmekala@redhat.com>2020-01-21 09:43:29 +0000
commit674277c7c6e66f00bf15b50d223b7b2ec0b8675c (patch)
tree467175be2af08bbb18c3bdafabd02b7bfdee3f69 /glustolibs-gluster/glustolibs/gluster/gluster_init.py
parent1a6c15c9d2721b94ebfa05e399dd3b7719d4843d (diff)
[libfix][testfix] Add waiter function for glusterd and peer connected library files
Moving waiters from testcase and adding it as function in library in gluster_init and peer_ops. Change-Id: I5ab1e42a5a0366fadb399789da1c156d8d96ec18 Signed-off-by: Sri Vignesh <sselvan@redhat.com>
Diffstat (limited to 'glustolibs-gluster/glustolibs/gluster/gluster_init.py')
-rw-r--r--glustolibs-gluster/glustolibs/gluster/gluster_init.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/glustolibs-gluster/glustolibs/gluster/gluster_init.py b/glustolibs-gluster/glustolibs/gluster/gluster_init.py
index 7467479b4..047046737 100644
--- a/glustolibs-gluster/glustolibs/gluster/gluster_init.py
+++ b/glustolibs-gluster/glustolibs/gluster/gluster_init.py
@@ -19,6 +19,7 @@
Description: This file contains the methods for starting/stopping glusterd
and other initial gluster environment setup helpers.
"""
+from time import sleep
from glusto.core import Glusto as g
@@ -222,3 +223,31 @@ def get_glusterd_pids(nodes):
glusterd_pids[node] = ['-1']
return _rc, glusterd_pids
+
+
+def wait_for_glusterd_to_start(servers, glusterd_start_wait_timeout=80):
+ """Checks glusterd is running on nodes with timeout.
+
+ Args:
+ servers (str|list): A server|List of server hosts on which glusterd
+ status has to be checked.
+ glusterd_start_wait_timeout: timeout to retry glusterd running
+ check in node.
+
+ Returns:
+ bool : True if glusterd is running on servers.
+ False otherwise.
+
+ """
+ if not isinstance(servers, list):
+ servers = [servers]
+ count = 0
+ while count <= glusterd_start_wait_timeout:
+ ret = is_glusterd_running(servers)
+ if not ret:
+ g.log.info("glusterd is running on %s", servers)
+ return True
+ sleep(1)
+ count += 1
+ g.log.error("glusterd is not running on %s", servers)
+ return False