marsadm: add list inquiry functions

This commit is contained in:
Thomas Schoebel-Theuer 2015-03-17 17:34:28 +01:00
parent 8d60cb304c
commit f43d5fd58e
2 changed files with 96 additions and 0 deletions

View File

@ -8502,6 +8502,62 @@ In the following, shell glob notation
(excluding the braces).
\end_layout
\begin_layout Subparagraph
Name Querying
\end_layout
\begin_layout Labeling
\labelwidthstring 00.00.0000
\family typewriter
cluster-members
\family default
Show a newline-separated list of all host names participating in the cluster.
\end_layout
\begin_layout Labeling
\labelwidthstring 00.00.0000
\family typewriter
resource-members
\family default
Show a newline-separated list of all host names participating in the particular
resource
\family typewriter
%{res}
\family default
.
Notice that this may be a subset of
\family typewriter
%cluster-members{}
\family default
.
\end_layout
\begin_layout Labeling
\labelwidthstring 00.00.0000
\family typewriter
{my,all}-resources
\family default
Show a newline-separated list of either all resource names existing in
the cluster, or only those where the current host
\family typewriter
%{host}
\family default
is member.
Optionally, you may specify the hostname as a parameter, e.g.
\family typewriter
%my-resources{
\emph on
otherhost
\emph default
}
\family default
.
\end_layout
\begin_layout Subparagraph
Amounts of Data Inquiry
\end_layout

View File

@ -2769,6 +2769,42 @@ sub eval_fn {
my $result = -d $path;
return defined($result) && $result;
}
# list objects
if (/^cluster[-_]?members$/) {
my @peers = glob("$mars/ips/ip-*");
my $list = "";
foreach my $peer (sort(@peers)) {
$peer =~ s:^$mars/ips/ip-::;
$list .= "$peer\n";
}
return $list;
}
if (/^resource[-_]?members$/) {
my @peers = glob($$env{"resdir"} . "/data-*");
my $list = "";
foreach my $peer (sort(@peers)) {
$peer =~ s:^.*/data-::;
$list .= "$peer\n";
}
return $list;
}
if (/^(my|all)[-_]?resources$/) {
my $what = $1;
my $peer = "*";
if ($what eq "my") {
$peer = parse_macro($arg1, $env);
$peer = $$env{"host"} unless $peer;
}
my @list = glob("$mars/resource-*/data-$peer");
map { s:^$mars/resource-(.*?)/data-.*:$1:; } @list;
my $list = "";
my $old = "";
foreach my $item (sort(@list)) {
$list .= "$item\n" if $item ne $old;
$old = $item;
}
return $list;
}
# low-level symlink access
if (/^readlink$/) {
my $path = parse_macro($arg1, $env);
@ -3903,6 +3939,10 @@ my %trivial_globs =
=> "",
# intended for scripting
"{my,all}-resources"
=> "",
"{cluster,resource}-members"
=> "",
"{disk,resource,device}-size"
=> "",
"deletable-size"