summaryrefslogtreecommitdiffstats
path: root/glustolibs-misc/glustolibs/misc/misc_libs.py
diff options
context:
space:
mode:
Diffstat (limited to 'glustolibs-misc/glustolibs/misc/misc_libs.py')
-rwxr-xr-x[-rw-r--r--]glustolibs-misc/glustolibs/misc/misc_libs.py60
1 files changed, 39 insertions, 21 deletions
diff --git a/glustolibs-misc/glustolibs/misc/misc_libs.py b/glustolibs-misc/glustolibs/misc/misc_libs.py
index 928599f44..e913becf3 100644..100755
--- a/glustolibs-misc/glustolibs/misc/misc_libs.py
+++ b/glustolibs-misc/glustolibs/misc/misc_libs.py
@@ -412,25 +412,16 @@ def are_nodes_online(nodes):
return ret, node_results
-def reboot_nodes_and_wait_to_come_online(nodes, timeout=300):
+def reboot_nodes(nodes):
"""
- reboot the node and wait for node to come online
+ reboot the nodes and checks whether nodes are offline or not
Args:
nodes ( str|list ) : Node/Nodes to reboot
- Kwargs:
- timeout (int): timeout value in seconds to wait for node
- to come online
-
Returns:
- tuple : Tuple containing two elements (_rc, reboot_results).
- The first element '_rc' is of type 'bool', True if all nodes
- comes online after reboot. False otherwise.
-
- The second element 'reboot_results' is of type dictonary and it
- contains the node and corresponding result for reboot. If reboot is
- successfull on node, then result contains True else False.
+ bool : '_rc' is of type 'bool', True if all nodes
+ comes offline after reboot. False otherwise.
"""
if isinstance(nodes, str):
nodes = [nodes]
@@ -438,8 +429,8 @@ def reboot_nodes_and_wait_to_come_online(nodes, timeout=300):
cmd = "reboot"
_rc = False
for node in nodes:
- g.log.info("Executing cmd: %s on node %s" % (cmd, node))
- g.log.info("Rebooting the node %s" % node)
+ g.log.info("Executing cmd: %s on node %s", cmd, node)
+ g.log.info("Rebooting the node %s", node)
ret = g.run(node, cmd)
halt = 120
@@ -447,20 +438,47 @@ def reboot_nodes_and_wait_to_come_online(nodes, timeout=300):
g.log.info("Wait for some seconds for the nodes to go offline")
while counter < halt:
- ret, reboot_time = are_nodes_offline(nodes)
+ ret, reboot_time = are_nodes_offline(nodes)
if not ret:
g.log.info("Nodes are online, Retry after 2 seconds .....")
time.sleep(2)
counter = counter + 2
else:
_rc = True
- g.log.info("All nodes %s are offline" % nodes)
+ g.log.info("All nodes %s are offline", nodes)
break
if not _rc:
- g.log.error("Some nodes %s are online" % reboot_time)
+ g.log.error("Some nodes %s are online", nodes)
+
+ return _rc
+
+
+def reboot_nodes_and_wait_to_come_online(nodes, timeout=300):
+ """
+ reboot the node and wait for node to come online
+
+ Args:
+ nodes ( str|list ) : Node/Nodes to reboot
+
+ Kwargs:
+ timeout (int): timeout value in seconds to wait for node
+ to come online
+
+ Returns:
+ tuple : Tuple containing two elements (_rc, reboot_results).
+ The first element '_rc' is of type 'bool', True if all nodes
+ comes online after reboot. False otherwise.
+
+ The second element 'reboot_results' is of type dictonary and it
+ contains the node and corresponding result for reboot. If reboot is
+ successfull on node, then result contains True else False.
+ """
+ _rc = reboot_nodes(nodes)
+ counter = 0
g.log.info("Wait for some seconds for the nodes to come online"
" after reboot")
+ reboot_results = {}
while counter < timeout:
ret, reboot_results = are_nodes_online(nodes)
if not ret:
@@ -474,12 +492,12 @@ def reboot_nodes_and_wait_to_come_online(nodes, timeout=300):
if not _rc:
for node in reboot_results:
if reboot_results[node]:
- g.log.info("Node %s is online" % node)
+ g.log.info("Node %s is online", node)
else:
g.log.error("Node %s is offline even after "
- "%d minutes" % (node, timeout/60.0))
+ "%d minutes", node, timeout/60.0)
else:
- g.log.info("All nodes %s are up and running" % nodes)
+ g.log.info("All nodes %s are up and running", nodes)
return _rc, reboot_results