summaryrefslogtreecommitdiffstats
path: root/glustolibs-gluster/glustolibs/gluster/gluster_init.py
diff options
context:
space:
mode:
authorShwethaHP <spandura@redhat.com>2017-11-30 13:19:11 +0530
committerJonathan Holloway <jholloway@redhat.com>2018-01-16 06:21:33 +0000
commit389862e34225430b06a1d494c1c1e3037f4b6d5d (patch)
treef762786f17070ac88d6ecc1859072d243955fa12 /glustolibs-gluster/glustolibs/gluster/gluster_init.py
parentc39a42140f328d12a605f5480d0e3c7a2d4c6308 (diff)
Check if servers/nodes which is expected to be passed as list
is str. i.e passing a single node to the function. If it is str, then convert it to list Change-Id: I1abacf62fdbe1ec56fe85c86d8e2a323a2c3971b Signed-off-by: ShwethaHP <spandura@redhat.com>
Diffstat (limited to 'glustolibs-gluster/glustolibs/gluster/gluster_init.py')
-rw-r--r--glustolibs-gluster/glustolibs/gluster/gluster_init.py35
1 files changed, 25 insertions, 10 deletions
diff --git a/glustolibs-gluster/glustolibs/gluster/gluster_init.py b/glustolibs-gluster/glustolibs/gluster/gluster_init.py
index 371e187..d45a186 100644
--- a/glustolibs-gluster/glustolibs/gluster/gluster_init.py
+++ b/glustolibs-gluster/glustolibs/gluster/gluster_init.py
@@ -26,13 +26,16 @@ def start_glusterd(servers):
"""Starts glusterd on specified servers if they are not running.
Args:
- servers (list): List of server hosts on which glusterd has to be
- started.
+ servers (str|list): A server|List of server hosts on which glusterd
+ has to be started.
Returns:
bool : True if starting glusterd is successful on all servers.
False otherwise.
"""
+ if isinstance(servers, str):
+ servers = [servers]
+
cmd = "pgrep glusterd || service glusterd start"
results = g.run_parallel(servers, cmd)
@@ -52,13 +55,16 @@ def stop_glusterd(servers):
"""Stops the glusterd on specified servers.
Args:
- servers (list): List of server hosts on which glusterd has to be
- stopped.
+ servers (str|list): A server|List of server hosts on which glusterd
+ has to be stopped.
Returns:
bool : True if stopping glusterd is successful on all servers.
False otherwise.
"""
+ if isinstance(servers, str):
+ servers = [servers]
+
cmd = "service glusterd stop"
results = g.run_parallel(servers, cmd)
@@ -78,13 +84,16 @@ def restart_glusterd(servers):
"""Restart the glusterd on specified servers.
Args:
- servers (list): List of server hosts on which glusterd has to be
- restarted.
+ servers (str|list): A server|List of server hosts on which glusterd
+ has to be restarted.
Returns:
bool : True if restarting glusterd is successful on all servers.
False otherwise.
"""
+ if isinstance(servers, str):
+ servers = [servers]
+
cmd = "service glusterd restart"
results = g.run_parallel(servers, cmd)
@@ -104,8 +113,8 @@ def is_glusterd_running(servers):
"""Checks the glusterd status on specified servers.
Args:
- servers (list): List of server hosts on which glusterd status has to
- be checked.
+ servers (str|list): A server|List of server hosts on which glusterd
+ status has to be checked.
Returns:
0 : if glusterd running
@@ -113,6 +122,9 @@ def is_glusterd_running(servers):
-1 : if glusterd not running and PID is alive
"""
+ if isinstance(servers, str):
+ servers = [servers]
+
cmd1 = "service glusterd status"
cmd2 = "pidof glusterd"
cmd1_results = g.run_parallel(servers, cmd1)
@@ -137,14 +149,17 @@ def env_setup_servers(servers):
"""Set up environment on all the specified servers.
Args:
- servers (list): List of server hosts on which environment has to be
- setup.
+ servers (str|list): A server|List of server hosts on which environment
+ has to be setup.
Returns:
bool : True if setting up environment is successful on all servers.
False otherwise.
"""
+ if isinstance(servers, str):
+ servers = [servers]
+
g.log.info("The function isn't implemented fully")
g.log.info("Please setup the bricks manually.")