line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# (c) Jan Gehring |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Rex::Report::Base; |
6
|
|
|
|
|
|
|
|
7
|
67
|
|
|
67
|
|
957
|
use v5.12.5; |
|
67
|
|
|
|
|
323
|
|
8
|
67
|
|
|
67
|
|
457
|
use warnings; |
|
67
|
|
|
|
|
241
|
|
|
67
|
|
|
|
|
3689
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '1.14.3'; # VERSION |
11
|
|
|
|
|
|
|
|
12
|
67
|
|
|
67
|
|
540
|
use Data::Dumper; |
|
67
|
|
|
|
|
198
|
|
|
67
|
|
|
|
|
5368
|
|
13
|
67
|
|
|
67
|
|
487
|
use Rex::Logger; |
|
67
|
|
|
|
|
234
|
|
|
67
|
|
|
|
|
485
|
|
14
|
67
|
|
|
67
|
|
2557
|
use Time::HiRes qw(time); |
|
67
|
|
|
|
|
1794
|
|
|
67
|
|
|
|
|
1322
|
|
15
|
67
|
|
|
67
|
|
11784
|
use Carp; |
|
67
|
|
|
|
|
169
|
|
|
67
|
|
|
|
|
52024
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub new { |
18
|
103
|
|
|
103
|
0
|
274
|
my $that = shift; |
19
|
103
|
|
33
|
|
|
682
|
my $proto = ref($that) || $that; |
20
|
103
|
|
|
|
|
327
|
my $self = {@_}; |
21
|
|
|
|
|
|
|
|
22
|
103
|
|
|
|
|
269
|
bless( $self, $proto ); |
23
|
|
|
|
|
|
|
|
24
|
103
|
|
|
|
|
702
|
$self->{__reports__} = {}; |
25
|
103
|
|
|
|
|
371
|
$self->{__current_resource__} = []; |
26
|
|
|
|
|
|
|
|
27
|
103
|
|
|
|
|
449
|
return $self; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub report { |
31
|
138
|
|
|
138
|
0
|
2624
|
my ( $self, %option ) = @_; |
32
|
|
|
|
|
|
|
|
33
|
138
|
50
|
|
|
|
897
|
confess "not inside a resource." if ( !$self->{__current_resource__}->[-1] ); |
34
|
|
|
|
|
|
|
|
35
|
138
|
50
|
66
|
|
|
2391
|
if ( $option{changed} && !exists $option{message} ) { |
|
|
100
|
100
|
|
|
|
|
36
|
0
|
|
|
|
|
0
|
$option{message} = "Resource updated."; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
elsif ( $option{changed} == 0 && !exists $option{message} ) { |
39
|
27
|
|
|
|
|
329
|
$option{message} = "Resource already up-to-date."; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# update all stacked resources |
43
|
138
|
|
|
|
|
404
|
for my $res ( @{ $self->{__current_resource__} } ) { |
|
138
|
|
|
|
|
1105
|
|
44
|
183
|
|
100
|
|
|
2435
|
$self->{__reports__}->{$res}->{changed} ||= $option{changed} || 0; |
|
|
|
100
|
|
|
|
|
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
push |
48
|
|
|
|
|
|
|
@{ $self->{__reports__}->{ $self->{__current_resource__}->[-1] }->{messages} |
49
|
138
|
|
|
|
|
1757
|
}, |
50
|
138
|
|
|
|
|
416
|
$option{message}; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub report_task_execution { |
54
|
36
|
|
|
36
|
0
|
603
|
my ( $self, %option ) = @_; |
55
|
36
|
|
|
|
|
420
|
$self->{__reports__}->{task} = \%option; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub report_resource_start { |
59
|
130
|
|
|
130
|
0
|
1846
|
my ( $self, %option ) = @_; |
60
|
|
|
|
|
|
|
|
61
|
130
|
|
|
|
|
360
|
push @{ $self->{__current_resource__} }, $self->_gen_res_name(%option); |
|
130
|
|
|
|
|
1130
|
|
62
|
130
|
|
|
|
|
3942
|
$self->{__reports__}->{ $self->{__current_resource__}->[-1] } = { |
63
|
|
|
|
|
|
|
changed => 0, |
64
|
|
|
|
|
|
|
messages => [], |
65
|
|
|
|
|
|
|
start_time => time, |
66
|
|
|
|
|
|
|
}; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub report_resource_end { |
70
|
130
|
|
|
130
|
0
|
1935
|
my ( $self, %option ) = @_; |
71
|
|
|
|
|
|
|
|
72
|
130
|
50
|
|
|
|
749
|
confess "not inside a resource." if ( !$self->{__current_resource__}->[-1] ); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
$self->{__reports__}->{ $self->{__current_resource__}->[-1] }->{end_time} = |
75
|
130
|
|
|
|
|
1569
|
time; |
76
|
130
|
|
|
|
|
366
|
pop @{ $self->{__current_resource__} }; |
|
130
|
|
|
|
|
2435
|
|
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub report_resource_failed { |
80
|
7
|
|
|
7
|
0
|
61
|
my ( $self, %opt ) = @_; |
81
|
|
|
|
|
|
|
|
82
|
7
|
50
|
|
|
|
60
|
return if ( !$self->{__current_resource__}->[-1] ); |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# update all stacked resources |
85
|
0
|
|
|
|
|
0
|
for my $res ( @{ $self->{__current_resource__} } ) { |
|
0
|
|
|
|
|
0
|
|
86
|
0
|
|
|
|
|
0
|
$self->{__reports__}->{$res}->{failed} = 1; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
push @{ $self->{__reports__}->{ $self->{__current_resource__} > [-1] } |
90
|
0
|
|
|
|
|
0
|
->{messages} }, |
91
|
0
|
|
|
|
|
0
|
$opt{message}; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub write_report { |
95
|
34
|
|
|
34
|
0
|
169
|
my ($self) = @_; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub _gen_res_name { |
99
|
130
|
|
|
130
|
|
793
|
my ( $self, %option ) = @_; |
100
|
130
|
|
|
|
|
1229
|
return $option{type} . "[" . $option{name} . "]"; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
1; |