marsadm: fix primary checks

This commit is contained in:
Thomas Schoebel-Theuer 2013-04-19 10:30:34 +02:00
parent 20166b6c01
commit 78c7c307ea
1 changed files with 7 additions and 5 deletions

View File

@ -159,6 +159,9 @@ sub check_primary {
my $lnk = "$mars/resource-$res/actual-$host/is-primary";
my $is_primary = readlink($lnk);
ldie "for operation '$cmd' I need to be primary\n" unless $is_primary;
$lnk = "$mars/resource-$res/primary";
my $primary = readlink($lnk) or ldie "cannot determine primary\n";
ldie "for operation '$cmd', I also must be the designated primary\n" unless $primary eq $host;
}
sub check_not_primary {
@ -168,11 +171,10 @@ sub check_not_primary {
if ($is_primary) {
ldie "operation '$cmd' cannot be executed on primary\n";
}
else { # also check whether we intend to become primary
$lnk = "$mars/resource-$res/primary";
my $primary = readlink($lnk) or ldie "cannot determine primary\n";
ldie "operation '$cmd' cannot be executed on designated primary\n";
}
# also check whether we intend to become primary
$lnk = "$mars/resource-$res/primary";
my $primary = readlink($lnk) or ldie "cannot determine primary\n";
ldie "operation '$cmd' cannot be executed on designated primary\n" if $primary eq $host;
}
sub check_primary_gone {