marsadm: augment 'wait-resource' with specific wait conditions

This commit is contained in:
Thomas Schoebel-Theuer 2013-05-14 15:05:31 +02:00
parent faa1c8d802
commit 2ab837cf09
1 changed files with 30 additions and 0 deletions

View File

@ -187,8 +187,38 @@ sub sleep_timeout {
$timeout -= $rest; $timeout -= $rest;
} }
# wait for some condition
sub wait_cond {
my ($cmd, $res, $specific) = @_;
my $is_actual = ($specific =~ s/^is-//);
my $is_on = !($specific =~ s/-off$//);
$specific =~ s/-on$//;
if ($is_actual) {
my %table =
(
"attach" => "is-attached",
"primary" => "is-primary",
"device" => "device-$res",
);
my $name = $table{$specific};
ldie "actual indicator '$specific' does not exist\n" unless exists($table{$specific});
check_status($cmd, $res, $name, $is_on ? 1 : 0, 1);
} else {
my %table =
(
"attach" => "attach",
"connect" => "connect",
"replay" => "allow-replay",
"sync" => "sync",
);
my $name = $table{$specific};
ldie "button '$specific' does not exist\n" unless exists($table{$specific});
check_todo($cmd, $res, $name, $is_on ? 1 : 0, 1);
}
}
# wait until some communication has occurred # wait until some communication has occurred
sub wait_cluster { sub wait_cluster {
return wait_cond(@_) if int(@_) >= 3;
my $cmd = shift; my $cmd = shift;
my $res = shift || "all"; my $res = shift || "all";
my $start_time = mars_time(); my $start_time = mars_time();