anointments: Provide ./mg-anoint list-prepared
PATCH 1/1 anointments: Provide ./mg-anoint list-prepared
CC Roger Pau Monne <[email protected]>
Signed-off-by Ian Jackson <[email protected]>
--- mg-anoint | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
mg-anoint +29 -0
@@ -20,6 +20,9 @@ # if nothing anointed yet, prints nothing and exits 0 # if anointment not prepared, fails # +# ./mg-anoint list-prepared REFKEY-GLOB +# => possibly empty list of REFKEYs +# # ./mg-anoint list # => human-readable output
@@ -65,6 +68,7 @@ use Osstest; use Osstest::TestSupport; use Osstest::Executive; use IO::Handle; +use Text::Glob qw(glob_to_regex); csreadconfig();
@@ -337,6 +341,31 @@ END pr_o(); } +sub cmd_list_prepared { + die unless @ARGV==1; + die if $ARGV[0] =~ m/^-/; + my ($pat) = @ARGV; + my $re = glob_to_regex $pat; + + my $tq = $dbh_tests->prepare(<<END); + SELECT * + FROM tasks + WHERE type = 'anoint' + ORDER BY refkey +END + + db_retry($dbh_tests, [], sub { + @o = (); + db_readonly_report(); + $tq->execute(); + while (my $t = $tq->fetchrow_hashref()) { + next unless $t->{refkey} =~ m{$re}o; + push @o, $t->{refkey}; + } + }); + pr_o(); +} + die 'need operation' unless @ARGV; die 'no global options understood' if $ARGV[0] =~ m/^-/;
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel