line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# (c) Jan Gehring |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Rex::Hardware::Network; |
6
|
|
|
|
|
|
|
|
7
|
37
|
|
|
37
|
|
556
|
use v5.12.5; |
|
37
|
|
|
|
|
157
|
|
8
|
37
|
|
|
36
|
|
249
|
use warnings; |
|
36
|
|
|
|
|
71
|
|
|
36
|
|
|
|
|
1751
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '1.14.2.2'; # TRIAL VERSION |
11
|
|
|
|
|
|
|
|
12
|
36
|
|
|
36
|
|
230
|
use Data::Dumper; |
|
36
|
|
|
|
|
81
|
|
|
36
|
|
|
|
|
1798
|
|
13
|
|
|
|
|
|
|
|
14
|
36
|
|
|
36
|
|
227
|
use Rex::Commands::Gather; |
|
36
|
|
|
|
|
97
|
|
|
36
|
|
|
|
|
500
|
|
15
|
36
|
|
|
36
|
|
1190
|
use Rex::Logger; |
|
36
|
|
|
|
|
85
|
|
|
36
|
|
|
|
|
216
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
require Rex::Hardware; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub get { |
20
|
|
|
|
|
|
|
|
21
|
9
|
|
|
9
|
0
|
150
|
my $cache = Rex::get_cache(); |
22
|
9
|
|
|
|
|
128
|
my $cache_key_name = $cache->gen_key_name("hardware.network"); |
23
|
|
|
|
|
|
|
|
24
|
9
|
50
|
|
|
|
202
|
if ( $cache->valid($cache_key_name) ) { |
25
|
0
|
|
|
|
|
0
|
return $cache->get($cache_key_name); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
9
|
|
|
|
|
139
|
my $hw_class = _get_class(); |
29
|
9
|
50
|
|
|
|
88
|
unless ($hw_class) { |
30
|
0
|
|
|
|
|
0
|
return {}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
9
|
|
|
|
|
246
|
my $data = { |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
networkdevices => $hw_class->get_network_devices(), |
36
|
|
|
|
|
|
|
networkconfiguration => $hw_class->get_network_configuration(), |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
}; |
39
|
|
|
|
|
|
|
|
40
|
9
|
|
|
|
|
238
|
$cache->set( $cache_key_name, $data ); |
41
|
|
|
|
|
|
|
|
42
|
9
|
|
|
|
|
357
|
return $data; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub route { |
47
|
0
|
|
|
0
|
0
|
0
|
return _get_class()->route(); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub default_gateway { |
51
|
0
|
|
|
0
|
0
|
0
|
return _get_class()->default_gateway(@_); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub netstat { |
55
|
0
|
|
|
0
|
0
|
0
|
return _get_class()->netstat(); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub _get_class { |
59
|
9
|
|
|
9
|
|
130
|
my $os_type = Rex::Commands::Gather::get_operating_system(); |
60
|
|
|
|
|
|
|
|
61
|
9
|
50
|
|
|
|
171
|
$os_type = "Linux" if Rex::Commands::Gather::is_linux(); |
62
|
9
|
50
|
|
|
|
114
|
$os_type = "Solaris" if Rex::Commands::Gather::is_solaris(); |
63
|
|
|
|
|
|
|
|
64
|
9
|
|
|
|
|
165
|
my $hw_class = "Rex::Hardware::Network::$os_type"; |
65
|
9
|
|
|
2
|
|
1351
|
eval "use $hw_class;"; |
|
2
|
|
|
2
|
|
93
|
|
|
2
|
|
|
2
|
|
43
|
|
|
2
|
|
|
2
|
|
66
|
|
|
2
|
|
|
|
|
57
|
|
|
2
|
|
|
|
|
60
|
|
|
2
|
|
|
|
|
158
|
|
|
2
|
|
|
|
|
53
|
|
|
2
|
|
|
|
|
30
|
|
|
2
|
|
|
|
|
74
|
|
|
2
|
|
|
|
|
42
|
|
|
2
|
|
|
|
|
24
|
|
|
2
|
|
|
|
|
121
|
|
66
|
|
|
|
|
|
|
|
67
|
9
|
50
|
|
|
|
294
|
if ($@) { |
68
|
0
|
|
|
|
|
0
|
Rex::Logger::debug("No network information on $os_type"); |
69
|
0
|
|
|
|
|
0
|
return; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
9
|
|
|
|
|
192
|
return $hw_class; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |