From 5ee5298e7b77f9a522e4f7cc9ebdeeabe6c79551 Mon Sep 17 00:00:00 2001 From: Thomas Schoebel-Theuer Date: Sat, 9 May 2020 08:34:02 +0200 Subject: [PATCH] marsadm: new primitives nr-{attach,sync,fetch,replay,primary} --- userspace/marsadm | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/userspace/marsadm b/userspace/marsadm index f5b6b6f3..d4d5466c 100755 --- a/userspace/marsadm +++ b/userspace/marsadm @@ -5396,6 +5396,19 @@ sub eval_fn { $lnk = correct_path($lnk); return get_link($lnk, 1); } + if (/^nr[-_]?(attach|sync|fetch|replay|primary)$/) { + my $what = $1; + my $is = "is"; + $is = "has" if $what eq "emergency"; + my $glob = $$env{"resdir"} . "/actual-*/$is-$what"; + $glob = correct_path($glob); + my $nr = 0; + foreach my $lnk (glob($glob)) { + my $val = get_link($lnk, 1); + $nr++ if $val; + } + return $nr; + } if (/^does$/) { my $what = parse_macro($arg1, $env); my $is = "is"; @@ -6426,7 +6439,7 @@ my %trivial_globs = # intended for human use "{all,the}-{pretty-,}{global-,}{{err,wrn,inf}-,}msg" => "", - "{is,todo}-{attach,sync,fetch,replay,primary}" + "{is,todo,nr}-{attach,sync,fetch,replay,primary}" => "", "is-{split-brain,consistent,emergency,orphan}" => "",