line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
5
|
|
|
5
|
|
2053
|
use strict; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
113
|
|
2
|
5
|
|
|
5
|
|
20
|
use warnings; |
|
5
|
|
|
|
|
48
|
|
|
5
|
|
|
|
|
197
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Footprintless::App::Command::service; |
5
|
|
|
|
|
|
|
$Footprintless::App::Command::service::VERSION = '1.26'; |
6
|
5
|
|
|
5
|
|
21
|
use Footprintless::App -command; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
24
|
|
7
|
5
|
|
|
5
|
|
1443
|
use Footprintless::Util qw(exit_due_to); |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
250
|
|
8
|
5
|
|
|
5
|
|
29
|
use Log::Any; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
20
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $logger = Log::Any->get_logger(); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# ABSTRACT: Performs an action on one or more services. |
13
|
|
|
|
|
|
|
# PODNAME: Footprintless::App::Command::service |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub execute { |
16
|
3
|
|
|
3
|
1
|
15
|
my ( $self, $opts, $args ) = @_; |
17
|
3
|
|
|
|
|
8
|
my ( $coordinate, $action ) = @$args; |
18
|
|
|
|
|
|
|
|
19
|
3
|
|
|
|
|
7
|
foreach my $target ( @{ $self->{targets} } ) { |
|
3
|
|
|
|
|
9
|
|
20
|
4
|
|
|
|
|
17
|
$logger->debugf( 'executing %s for %s', $action, $target->{coordinate} ); |
21
|
4
|
|
|
|
|
45
|
eval { $target->execute($action); }; |
|
4
|
|
|
|
|
13
|
|
22
|
4
|
50
|
|
|
|
53
|
if ($@) { |
23
|
0
|
0
|
0
|
|
|
0
|
if ( ref($@) && $@->isa('Footprintless::InvalidEntityException') ) { |
24
|
0
|
|
|
|
|
0
|
$self->usage_error($@); |
25
|
|
|
|
|
|
|
} |
26
|
0
|
|
|
|
|
0
|
exit_due_to( $@, 1 ); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub usage_desc { |
32
|
3
|
|
|
3
|
1
|
161
|
return "fpl service SERVICE_COORD ACTION"; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub validate_args { |
36
|
3
|
|
|
3
|
1
|
1167
|
my ( $self, $opt, $args ) = @_; |
37
|
3
|
|
|
|
|
8
|
my ( $coordinate, $action, @sub_coordinates ) = @$args; |
38
|
|
|
|
|
|
|
|
39
|
3
|
50
|
|
|
|
10
|
$self->usage_error("coordinate is required") unless ($coordinate); |
40
|
3
|
50
|
|
|
|
6
|
$self->usage_error("action is required") unless ($action); |
41
|
|
|
|
|
|
|
|
42
|
3
|
|
|
|
|
11
|
my $footprintless = $self->app()->footprintless(); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
my @target_coordinates = |
45
|
|
|
|
|
|
|
@sub_coordinates |
46
|
3
|
100
|
|
|
|
11
|
? map {"$coordinate.$_"} @sub_coordinates |
|
2
|
|
|
|
|
11
|
|
47
|
|
|
|
|
|
|
: ($coordinate); |
48
|
|
|
|
|
|
|
|
49
|
3
|
|
|
|
|
7
|
my @targets = (); |
50
|
3
|
|
|
|
|
8
|
foreach my $target_coordinate (@target_coordinates) { |
51
|
4
|
|
|
|
|
8
|
eval { push( @targets, $footprintless->service($target_coordinate) ); }; |
|
4
|
|
|
|
|
15
|
|
52
|
4
|
50
|
|
|
|
13
|
if ($@) { |
53
|
0
|
0
|
0
|
|
|
0
|
if ( ref($@) && $@->isa('Footprintless::InvalidEntityException') ) { |
54
|
0
|
|
|
|
|
0
|
$self->usage_error($@); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
else { |
57
|
0
|
|
|
|
|
0
|
$self->usage_error("invalid coordinate [$target_coordinate]: $@"); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
3
|
|
|
|
|
13
|
$self->{targets} = \@targets; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__END__ |