summaryrefslogtreecommitdiffstats
path: root/glustolibs-misc
diff options
context:
space:
mode:
authorVitalii Koriakov <vkoriako@redhat.com>2018-04-24 13:45:44 +0300
committerNigel Babu <nigelb@redhat.com>2018-04-25 08:49:55 +0000
commitfb1f00022716df511dc16c6a532b83c5e230e245 (patch)
tree8ce347fc9af02f62c84224db10d9485b69997661 /glustolibs-misc
parent2e6efad63a23b4b1a0544c1f0a08915d61070e2d (diff)
Added reboot_nodes method
Change-Id: I72e9023125f654f3a04e96243a94218461c934da Signed-off-by: Vitalii Koriakov <vkoriako@redhat.com>
Diffstat (limited to 'glustolibs-misc')
-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 928599f..e913bec 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