line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Target::Server; |
2
|
|
|
|
|
|
|
|
3
|
31
|
|
|
31
|
|
26132681
|
use strict; |
|
31
|
|
|
|
|
59
|
|
|
31
|
|
|
|
|
886
|
|
4
|
31
|
|
|
31
|
|
156
|
use warnings; |
|
31
|
|
|
|
|
55
|
|
|
31
|
|
|
|
|
875
|
|
5
|
31
|
|
|
31
|
|
171
|
use base 'FusionInventory::Agent::Target'; |
|
31
|
|
|
|
|
137
|
|
|
31
|
|
|
|
|
3279
|
|
6
|
|
|
|
|
|
|
|
7
|
31
|
|
|
31
|
|
161
|
use English qw(-no_match_vars); |
|
31
|
|
|
|
|
67
|
|
|
31
|
|
|
|
|
174
|
|
8
|
31
|
|
|
31
|
|
15233
|
use URI; |
|
31
|
|
|
|
|
5579
|
|
|
31
|
|
|
|
|
238
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $count = 0; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
8
|
|
|
8
|
1
|
4204
|
my ($class, %params) = @_; |
14
|
|
|
|
|
|
|
|
15
|
8
|
100
|
|
|
|
39
|
die "no url parameter" unless $params{url}; |
16
|
|
|
|
|
|
|
|
17
|
7
|
|
|
|
|
124
|
my $self = $class->SUPER::new(%params); |
18
|
|
|
|
|
|
|
|
19
|
6
|
|
|
|
|
21
|
$self->{url} = _getCanonicalURL($params{url}); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# compute storage subdirectory from url |
22
|
6
|
|
|
|
|
12
|
my $subdir = $self->{url}; |
23
|
6
|
|
|
|
|
24
|
$subdir =~ s/\//_/g; |
24
|
6
|
50
|
|
|
|
80
|
$subdir =~ s/:/../g if $OSNAME eq 'MSWin32'; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
$self->_init( |
27
|
|
|
|
|
|
|
id => 'server' . $count++, |
28
|
6
|
|
|
|
|
67
|
vardir => $params{basevardir} . '/' . $subdir |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
6
|
|
|
|
|
29
|
return $self; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub _getCanonicalURL { |
35
|
6
|
|
|
6
|
|
11
|
my ($string) = @_; |
36
|
|
|
|
|
|
|
|
37
|
6
|
|
|
|
|
33
|
my $url = URI->new($string); |
38
|
|
|
|
|
|
|
|
39
|
6
|
|
|
|
|
23551
|
my $scheme = $url->scheme(); |
40
|
6
|
100
|
|
|
|
526
|
if (!$scheme) { |
41
|
|
|
|
|
|
|
# this is likely a bare hostname |
42
|
|
|
|
|
|
|
# as parsing relies on scheme, host and path have to be set explicitely |
43
|
1
|
|
|
|
|
4
|
$url->scheme('http'); |
44
|
1
|
|
|
|
|
103
|
$url->host($string); |
45
|
1
|
|
|
|
|
211
|
$url->path('ocsinventory'); |
46
|
|
|
|
|
|
|
} else { |
47
|
5
|
50
|
33
|
|
|
25
|
die "invalid protocol for URL: $string" |
48
|
|
|
|
|
|
|
if $scheme ne 'http' && $scheme ne 'https'; |
49
|
|
|
|
|
|
|
# complete path if needed |
50
|
5
|
100
|
|
|
|
27
|
$url->path('ocsinventory') if !$url->path(); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
6
|
|
|
|
|
165
|
return $url; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub getUrl { |
57
|
23
|
|
|
23
|
1
|
975
|
my ($self) = @_; |
58
|
|
|
|
|
|
|
|
59
|
23
|
|
|
|
|
144
|
return $self->{url}; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub _getName { |
63
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
return $self->{url}; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub _getType { |
69
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
return 'server'; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
__END__ |