From: Zack Cerza Date: Wed, 12 Feb 2014 17:01:37 +0000 (-0600) Subject: Move reboot() to teuthology.misc X-Git-Tag: 1.1.0~1646^2~17 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=61e9ac4db5700e17192752d8fe52b359c85e3113;p=teuthology.git Move reboot() to teuthology.misc Signed-off-by: Zack Cerza --- diff --git a/teuthology/misc.py b/teuthology/misc.py index 2f455d90c7..ea61c1208f 100644 --- a/teuthology/misc.py +++ b/teuthology/misc.py @@ -891,6 +891,31 @@ def wait_until_fuse_mounted(remote, fuse, mountpoint): log.info('ceph-fuse is mounted on %s', mountpoint) +def reboot(node, timeout=300, interval=30): + """ + Reboots a given system, then waits for it to come back up and + re-establishes the ssh connection. + + :param node: The teuthology.orchestra.remote.Remote object of the node + :param timeout: The amount of time, in seconds, after which to give up + waiting for the node to return + :param interval: The amount of time, in seconds, to wait between attempts + to re-establish with the node. This should not be set to + less than maybe 10, to make sure the node actually goes + down first. + """ + log.info("Rebooting {host}...".format(host=node.hostname)) + node.run(args=['sudo', 'shutdown', '-r', 'now']) + reboot_start_time = time.time() + while time.time() - reboot_start_time < timeout: + time.sleep(interval) + if node.is_online or node.reconnect(): + return + raise RuntimeError( + "{host} did not come up after reboot within {time}s".format( + host=node.hostname, time=timeout)) + + def reconnect(ctx, timeout, remotes=None): """ Connect to all the machines in ctx.cluster. diff --git a/teuthology/task/devstack.py b/teuthology/task/devstack.py index 07a7961e56..a249c8b45a 100644 --- a/teuthology/task/devstack.py +++ b/teuthology/task/devstack.py @@ -81,7 +81,7 @@ def configure_devstack_and_ceph(ctx, config, devstack_node, ceph_node): update_devstack_config_files(devstack_node, secret_uuid) set_apache_servername(devstack_node) # Rebooting is the most-often-used method of restarting devstack services - reboot(devstack_node) + misc.reboot(devstack_node) start_devstack(devstack_node) restart_apache(devstack_node) @@ -256,31 +256,6 @@ def set_apache_servername(node): "ServerName {name}".format(name=hostname)) -def reboot(node, timeout=300, interval=30): - """ - Reboots a given system, then waits for it to come back up and - re-establishes the ssh connection. - - :param node: The teuthology.orchestra.remote.Remote object of the node - :param timeout: The amount of time, in seconds, after which to give up - waiting for the node to return - :param interval: The amount of time, in seconds, to wait between attempts - to re-establish with the node. This should not be set to - less than maybe 10, to make sure the node actually goes - down first. - """ - log.info("Rebooting {host}...".format(host=node.hostname)) - node.run(args=['sudo', 'shutdown', '-r', 'now']) - reboot_start_time = time.time() - while time.time() - reboot_start_time < timeout: - time.sleep(interval) - if node.is_online or node.reconnect(): - return - raise RuntimeError( - "{host} did not come up after reboot within {time}s".format( - host=node.hostname, time=timeout)) - - def start_devstack(devstack_node): log.info("Patching devstack start script...") # This causes screen to start headless - otherwise rejoin-stack.sh fails