line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task; |
2
|
|
|
|
|
|
|
|
3
|
23
|
|
|
23
|
|
1751109
|
use strict; |
|
23
|
|
|
|
|
52
|
|
|
23
|
|
|
|
|
847
|
|
4
|
23
|
|
|
23
|
|
110
|
use warnings; |
|
23
|
|
|
|
|
23
|
|
|
23
|
|
|
|
|
714
|
|
5
|
|
|
|
|
|
|
|
6
|
23
|
|
|
23
|
|
180
|
use English qw(-no_match_vars); |
|
23
|
|
|
|
|
96
|
|
|
23
|
|
|
|
|
225
|
|
7
|
23
|
|
|
23
|
|
9983
|
use File::Find; |
|
23
|
|
|
|
|
108
|
|
|
23
|
|
|
|
|
1656
|
|
8
|
|
|
|
|
|
|
|
9
|
23
|
|
|
23
|
|
3758
|
use FusionInventory::Agent::Tools; |
|
23
|
|
|
|
|
44
|
|
|
23
|
|
|
|
|
3436
|
|
10
|
23
|
|
|
23
|
|
2617
|
use FusionInventory::Agent::Logger; |
|
23
|
|
|
|
|
35
|
|
|
23
|
|
|
|
|
8544
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
0
|
|
|
0
|
1
|
|
my ($class, %params) = @_; |
14
|
|
|
|
|
|
|
|
15
|
0
|
0
|
|
|
|
|
die 'no target parameter' unless $params{target}; |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
0
|
|
|
|
my $self = { |
18
|
|
|
|
|
|
|
logger => $params{logger} || |
19
|
|
|
|
|
|
|
FusionInventory::Agent::Logger->new(), |
20
|
|
|
|
|
|
|
config => $params{config}, |
21
|
|
|
|
|
|
|
confdir => $params{confdir}, |
22
|
|
|
|
|
|
|
datadir => $params{datadir}, |
23
|
|
|
|
|
|
|
target => $params{target}, |
24
|
|
|
|
|
|
|
deviceid => $params{deviceid}, |
25
|
|
|
|
|
|
|
}; |
26
|
0
|
|
|
|
|
|
bless $self, $class; |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
return $self; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub abort { |
32
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
33
|
0
|
|
|
|
|
|
$self->{logger}->info("aborting task"); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub getModules { |
37
|
0
|
|
|
0
|
1
|
|
my ($class, $prefix) = @_; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# allow to be called as an instance method |
40
|
0
|
0
|
|
|
|
|
$class = ref $class ? ref $class : $class; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# use %INC to retrieve the root directory for this task |
43
|
0
|
|
|
|
|
|
my $file = module2file($class); |
44
|
0
|
|
|
|
|
|
my $rootdir = $INC{$file}; |
45
|
0
|
|
|
|
|
|
$rootdir =~ s/.pm$//; |
46
|
0
|
0
|
|
|
|
|
return unless -d $rootdir; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# find a list of modules from files in this directory |
49
|
0
|
|
|
|
|
|
my $root = $file; |
50
|
0
|
|
|
|
|
|
$root =~ s/.pm$//; |
51
|
0
|
0
|
|
|
|
|
$root .= "/$prefix" if $prefix; |
52
|
0
|
|
|
|
|
|
my @modules; |
53
|
|
|
|
|
|
|
my $wanted = sub { |
54
|
0
|
0
|
|
0
|
|
|
return unless -f $_; |
55
|
0
|
0
|
|
|
|
|
return unless $File::Find::name =~ m{($root/\S+\.pm)$}; |
56
|
0
|
|
|
|
|
|
my $module = file2module($1); |
57
|
0
|
|
|
|
|
|
push(@modules, $module); |
58
|
0
|
|
|
|
|
|
}; |
59
|
0
|
|
|
|
|
|
File::Find::find($wanted, $rootdir); |
60
|
|
|
|
|
|
|
return @modules |
61
|
0
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
__END__ |