line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# (c) Jan Gehring |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Rex::Report::Base; |
6
|
|
|
|
|
|
|
|
7
|
67
|
|
|
67
|
|
1066
|
use v5.12.5; |
|
67
|
|
|
|
|
328
|
|
8
|
67
|
|
|
67
|
|
463
|
use warnings; |
|
67
|
|
|
|
|
208
|
|
|
67
|
|
|
|
|
3608
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '1.14.2.2'; # TRIAL VERSION |
11
|
|
|
|
|
|
|
|
12
|
67
|
|
|
67
|
|
548
|
use Data::Dumper; |
|
67
|
|
|
|
|
189
|
|
|
67
|
|
|
|
|
5612
|
|
13
|
67
|
|
|
67
|
|
521
|
use Rex::Logger; |
|
67
|
|
|
|
|
222
|
|
|
67
|
|
|
|
|
541
|
|
14
|
67
|
|
|
67
|
|
2659
|
use Time::HiRes qw(time); |
|
67
|
|
|
|
|
1746
|
|
|
67
|
|
|
|
|
1363
|
|
15
|
67
|
|
|
67
|
|
12025
|
use Carp; |
|
67
|
|
|
|
|
236
|
|
|
67
|
|
|
|
|
52475
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub new { |
18
|
103
|
|
|
103
|
0
|
304
|
my $that = shift; |
19
|
103
|
|
33
|
|
|
684
|
my $proto = ref($that) || $that; |
20
|
103
|
|
|
|
|
300
|
my $self = {@_}; |
21
|
|
|
|
|
|
|
|
22
|
103
|
|
|
|
|
322
|
bless( $self, $proto ); |
23
|
|
|
|
|
|
|
|
24
|
103
|
|
|
|
|
672
|
$self->{__reports__} = {}; |
25
|
103
|
|
|
|
|
447
|
$self->{__current_resource__} = []; |
26
|
|
|
|
|
|
|
|
27
|
103
|
|
|
|
|
468
|
return $self; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub report { |
31
|
138
|
|
|
138
|
0
|
3038
|
my ( $self, %option ) = @_; |
32
|
|
|
|
|
|
|
|
33
|
138
|
50
|
|
|
|
998
|
confess "not inside a resource." if ( !$self->{__current_resource__}->[-1] ); |
34
|
|
|
|
|
|
|
|
35
|
138
|
50
|
66
|
|
|
2942
|
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
|
28
|
|
|
|
|
307
|
$option{message} = "Resource already up-to-date."; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# update all stacked resources |
43
|
138
|
|
|
|
|
467
|
for my $res ( @{ $self->{__current_resource__} } ) { |
|
138
|
|
|
|
|
1310
|
|
44
|
183
|
|
100
|
|
|
2997
|
$self->{__reports__}->{$res}->{changed} ||= $option{changed} || 0; |
|
|
|
100
|
|
|
|
|
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
push |
48
|
|
|
|
|
|
|
@{ $self->{__reports__}->{ $self->{__current_resource__}->[-1] }->{messages} |
49
|
138
|
|
|
|
|
1930
|
}, |
50
|
138
|
|
|
|
|
635
|
$option{message}; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub report_task_execution { |
54
|
36
|
|
|
36
|
0
|
690
|
my ( $self, %option ) = @_; |
55
|
36
|
|
|
|
|
458
|
$self->{__reports__}->{task} = \%option; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub report_resource_start { |
59
|
130
|
|
|
130
|
0
|
2376
|
my ( $self, %option ) = @_; |
60
|
|
|
|
|
|
|
|
61
|
130
|
|
|
|
|
463
|
push @{ $self->{__current_resource__} }, $self->_gen_res_name(%option); |
|
130
|
|
|
|
|
1475
|
|
62
|
130
|
|
|
|
|
4908
|
$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
|
2292
|
my ( $self, %option ) = @_; |
71
|
|
|
|
|
|
|
|
72
|
130
|
50
|
|
|
|
988
|
confess "not inside a resource." if ( !$self->{__current_resource__}->[-1] ); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
$self->{__reports__}->{ $self->{__current_resource__}->[-1] }->{end_time} = |
75
|
130
|
|
|
|
|
1867
|
time; |
76
|
130
|
|
|
|
|
478
|
pop @{ $self->{__current_resource__} }; |
|
130
|
|
|
|
|
2341
|
|
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub report_resource_failed { |
80
|
7
|
|
|
7
|
0
|
94
|
my ( $self, %opt ) = @_; |
81
|
|
|
|
|
|
|
|
82
|
7
|
50
|
|
|
|
65
|
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
|
201
|
my ($self) = @_; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub _gen_res_name { |
99
|
130
|
|
|
130
|
|
1014
|
my ( $self, %option ) = @_; |
100
|
130
|
|
|
|
|
1378
|
return $option{type} . "[" . $option{name} . "]"; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
1; |