line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Target::Server; |
2
|
|
|
|
|
|
|
|
3
|
21
|
|
|
21
|
|
19106576
|
use strict; |
|
21
|
|
|
|
|
36
|
|
|
21
|
|
|
|
|
803
|
|
4
|
21
|
|
|
21
|
|
104
|
use warnings; |
|
21
|
|
|
|
|
30
|
|
|
21
|
|
|
|
|
617
|
|
5
|
21
|
|
|
21
|
|
101
|
use base 'FusionInventory::Agent::Target'; |
|
21
|
|
|
|
|
81
|
|
|
21
|
|
|
|
|
2188
|
|
6
|
|
|
|
|
|
|
|
7
|
21
|
|
|
21
|
|
96
|
use English qw(-no_match_vars); |
|
21
|
|
|
|
|
29
|
|
|
21
|
|
|
|
|
102
|
|
8
|
21
|
|
|
21
|
|
9411
|
use URI; |
|
21
|
|
|
|
|
6721
|
|
|
21
|
|
|
|
|
156
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $count = 0; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
0
|
|
|
0
|
1
|
|
my ($class, %params) = @_; |
14
|
|
|
|
|
|
|
|
15
|
0
|
0
|
|
|
|
|
die "no url parameter" unless $params{url}; |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new(%params); |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
$self->{url} = _getCanonicalURL($params{url}); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# compute storage subdirectory from url |
22
|
0
|
|
|
|
|
|
my $subdir = $self->{url}; |
23
|
0
|
|
|
|
|
|
$subdir =~ s/\//_/g; |
24
|
0
|
0
|
|
|
|
|
$subdir =~ s/:/../g if $OSNAME eq 'MSWin32'; |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
$self->_init( |
27
|
|
|
|
|
|
|
id => 'server' . $count++, |
28
|
|
|
|
|
|
|
vardir => $params{basevardir} . '/' . $subdir |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
return $self; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub _getCanonicalURL { |
35
|
0
|
|
|
0
|
|
|
my ($string) = @_; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
my $url = URI->new($string); |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
my $scheme = $url->scheme(); |
40
|
0
|
0
|
|
|
|
|
if (!$scheme) { |
41
|
|
|
|
|
|
|
# this is likely a bare hostname |
42
|
|
|
|
|
|
|
# as parsing relies on scheme, host and path have to be set explicitely |
43
|
0
|
|
|
|
|
|
$url->scheme('http'); |
44
|
0
|
|
|
|
|
|
$url->host($string); |
45
|
0
|
|
|
|
|
|
$url->path('ocsinventory'); |
46
|
|
|
|
|
|
|
} else { |
47
|
0
|
0
|
0
|
|
|
|
die "invalid protocol for URL: $string" |
48
|
|
|
|
|
|
|
if $scheme ne 'http' && $scheme ne 'https'; |
49
|
|
|
|
|
|
|
# complete path if needed |
50
|
0
|
0
|
|
|
|
|
$url->path('ocsinventory') if !$url->path(); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
return $url; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub getUrl { |
57
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
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__ |