selecthost get_hostflags get_host_property
get_target_property get_host_native_linux_console
hostnamepath hostnamepath_list set_runtime_hostflag
- power_state power_cycle power_cycle_sleep
+ power_state power_cycle power_reboot_attempts
serial_fetch_logs set_host_property
propname_massage propname_check
hostprop_putative_record
$ho->{PowerMethobjs} = power_cycle_parse_method($ho,$spec);
}
+sub power_reboot_attempts ($$$) {
+ my ($ho, $setup, $await) = @_;
+ # Power cycles $ho, calling $setup->() while it is (supposedly) off.
+ # Then, just after turning $ho on, calls $await->().
+ # If $await->() succeeds, great: returns.
+ #
+ # If it fails (dies), power_reboot_attempts will attempt to power
+ # cycle $ho using a more certain method and call $fn again. This
+ # may occur multiple times.
+ #
+ # All but the last method used for power cycling are not certain
+ # to work. $setup and $await should tolerate this situation; in
+ # particular $await must only succeed if the host really did reboot
+ # into the boot environment that $await expects.
+ power_state($ho, 0);
+ $setup->();
+ power_cycle_sleep($ho);
+ power_state($ho, 1);
+ $await->();
+}
+
sub power_cycle_sleep ($) {
my ($ho) = @_;
my $to = get_host_property($ho, 'power-cycle-time', 5);
Sshd 2400);
sub install () {
- power_state($ho, 0);
-
my ($ps_url,$ps_file)= preseed_create
($ho, '',
DiskDevice => $ho->{DiskDevice},
d-i netcfg/get_ipaddress string $ho->{Ip}
END
- setup_netboot_firstboot($ps_url);
- power_cycle_sleep($ho);
-
- my $logtailer= Osstest::Logtailer->new($c{WebspaceLog});
- power_state($ho, 1);
-
- await_webspace_fetch_byleaf(get_timeout($ho,'reboot',$timeout{ReadPreseed})
- , 1,
- $logtailer, $ho, $ps_url);
+ power_reboot_attempts($ho, sub {
+ setup_netboot_firstboot($ps_url);
+ }, sub {
+ my $logtailer= Osstest::Logtailer->new($c{WebspaceLog});
+ my $timeout = get_timeout($ho,'reboot',$timeout{ReadPreseed});
+ await_webspace_fetch_byleaf($timeout, 1, $logtailer, $ho, $ps_url);
+ });
if ($poweron_test_only) {
logm("Hooray, power on worked.");
- power_state($ho, 0);
exit 0;
}