mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-30 23:54:04 +08:00
ktest.pl: Powercycle the box on reboot if no connection can be made
When performing a reboot of the test box, try to ssh to it. If it can't connect for 5 seconds, then powercycle the box. This is useful because the reboot is done via ssh, and if you can't ssh to the box because it is hung, the reboot fails to reboot. Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
This commit is contained in:
parent
6e98d1b441
commit
6474ace999
@ -1325,26 +1325,44 @@ sub wait_for_monitor;
|
||||
|
||||
sub reboot {
|
||||
my ($time) = @_;
|
||||
my $powercycle = 0;
|
||||
|
||||
# Make sure everything has been written to disk
|
||||
run_ssh("sync");
|
||||
# test if the machine can be connected to within 5 seconds
|
||||
my $stat = run_ssh("echo check machine status", 5);
|
||||
if (!$stat) {
|
||||
doprint("power cycle\n");
|
||||
$powercycle = 1;
|
||||
}
|
||||
|
||||
if ($powercycle) {
|
||||
run_command "$power_cycle";
|
||||
|
||||
if (defined($time)) {
|
||||
start_monitor;
|
||||
# flush out current monitor
|
||||
# May contain the reboot success line
|
||||
wait_for_monitor 1;
|
||||
}
|
||||
|
||||
# try to reboot normally
|
||||
if (run_command $reboot) {
|
||||
if (defined($powercycle_after_reboot)) {
|
||||
sleep $powercycle_after_reboot;
|
||||
} else {
|
||||
# Make sure everything has been written to disk
|
||||
run_ssh("sync");
|
||||
|
||||
if (defined($time)) {
|
||||
start_monitor;
|
||||
# flush out current monitor
|
||||
# May contain the reboot success line
|
||||
wait_for_monitor 1;
|
||||
}
|
||||
|
||||
# try to reboot normally
|
||||
if (run_command $reboot) {
|
||||
if (defined($powercycle_after_reboot)) {
|
||||
sleep $powercycle_after_reboot;
|
||||
run_command "$power_cycle";
|
||||
}
|
||||
} else {
|
||||
# nope? power cycle it.
|
||||
run_command "$power_cycle";
|
||||
}
|
||||
} else {
|
||||
# nope? power cycle it.
|
||||
run_command "$power_cycle";
|
||||
}
|
||||
|
||||
if (defined($time)) {
|
||||
|
Loading…
Reference in New Issue
Block a user