script/es-open.pl untested

filter: Statementstmt 0.0% 0 / 30 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod n/a totaltotal 0.0% 0 / 40 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #!/usr/local/bin/perl
2 # PODNAME: es-open.pl
3 # ABSTRACT: Open any closed indices matching your paramters.
4 use strict;
5 use warnings;
6  
7 use App::ElasticSearch::Utilities qw(es_indices es_request);
8 use CLI::Helpers qw(:output);
9 use Getopt::Long qw(:config no_ignore_case no_ignore_case_always);
10 use Pod::Usage;
11  
12 #------------------------------------------------------------------------#
13 # Argument Parsing
14 my %OPT;
15 GetOptions(\%OPT,
16 'help|h',
17 'manual|m',
18 );
19  
20 #------------------------------------------------------------------------#
21 # Documentation
22 pod2usage(1) if $OPT{help};
23 pod2usage(-exitval => 0, -verbose => 2) if $OPT{manual};
24  
25 # Return all closed indexes within our constraints.
26 my @indices = es_indices(state => 'closed');
27  
28 foreach my $idx (reverse sort @indices) {
29 verbose("Opening index: $idx");
30 my $result = es_request('_open', { index=>$idx, method => 'POST'});
31 debug_var($result);
32 my $color = 'green';
33 output({color=>$color}, "+ Opened '$idx'");
34 }
35  
36 __END__