sleep($to);
}
-sub power_cycle ($) {
- my ($ho) = @_;
+sub power_cycle ($;$) {
+ my ($ho, $approach_re) = @_;
$mjobdb->host_check_allocated($ho);
die "refusing to set power state for host $ho->{Name}".
" possibly shared with other jobs\n"
if $ho->{SharedMaybeOthers};
- power_state($ho, 0);
+ power_state($ho, 0, $approach_re);
power_cycle_sleep($ho);
- power_state($ho, 1);
+ power_state($ho, 1, $approach_re);
}
sub power_approach_invoke ($$$) {
# of osstest. Will use "sudo". The HOST(s) must be
# allocated (via mg-allocate HOST).
#
-# ./mg-hosts power HOST ACTION
+# ./mg-hosts power HOST ACTION [APPROACH_RE]
# Power cycles the host. Host must be allocated to the current
# user. Actions are:
# "0" or "on" : power on
# "1" or "off" : power off
# "c" or "r" : reboot
+# APPROACH_RE is a regexp specifying which method to
+# use. Methods are: Only ILOM PDU SSH
+# and the lightest method which matches will be used.
+# If not specified, the most reliable method will be used.
#
# ./mg-hosts create-like SOURCE-HOST NEW-HOST[,NEW-HOST...]
# Create new host(s). This does NOT copy the
}
sub cmd_power () {
- die unless @ARGV==2;
- my ($host,$power) = @ARGV;
+ die unless @ARGV==2 || @ARGV==3;
+ my ($host,$power,$approach_re) = @ARGV;
$_ = $power;
$power = m/^1|^on/ ? 1 : m/^0|^off/ ? 0 : m/^r|^c/ ? -1 : die;
my $ho= selecthost("host=$host");
if ($power >= 0) {
- power_state($ho, $power);
+ power_state($ho, $power, $approach_re);
} else {
- power_cycle($ho);
+ power_cycle($ho, $approach_re);
}
}