From 2ab837cf0939a928d2be404295178cabd1a09bf2 Mon Sep 17 00:00:00 2001 From: Thomas Schoebel-Theuer Date: Tue, 14 May 2013 15:05:31 +0200 Subject: [PATCH] marsadm: augment 'wait-resource' with specific wait conditions --- userspace/marsadm | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/userspace/marsadm b/userspace/marsadm index c44765a9..0d8abe4b 100755 --- a/userspace/marsadm +++ b/userspace/marsadm @@ -187,8 +187,38 @@ sub sleep_timeout { $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 sub wait_cluster { + return wait_cond(@_) if int(@_) >= 3; my $cmd = shift; my $res = shift || "all"; my $start_time = mars_time();