line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# (c) Jan Gehring |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Rex::Hardware::Network; |
6
|
|
|
|
|
|
|
|
7
|
37
|
|
|
37
|
|
548
|
use v5.12.5; |
|
37
|
|
|
|
|
148
|
|
8
|
37
|
|
|
36
|
|
250
|
use warnings; |
|
36
|
|
|
|
|
87
|
|
|
36
|
|
|
|
|
1688
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '1.14.2.3'; # TRIAL VERSION |
11
|
|
|
|
|
|
|
|
12
|
36
|
|
|
36
|
|
226
|
use Data::Dumper; |
|
36
|
|
|
|
|
106
|
|
|
36
|
|
|
|
|
1818
|
|
13
|
|
|
|
|
|
|
|
14
|
36
|
|
|
36
|
|
260
|
use Rex::Commands::Gather; |
|
36
|
|
|
|
|
94
|
|
|
36
|
|
|
|
|
527
|
|
15
|
36
|
|
|
36
|
|
1248
|
use Rex::Logger; |
|
36
|
|
|
|
|
94
|
|
|
36
|
|
|
|
|
216
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
require Rex::Hardware; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub get { |
20
|
|
|
|
|
|
|
|
21
|
9
|
|
|
9
|
0
|
140
|
my $cache = Rex::get_cache(); |
22
|
9
|
|
|
|
|
182
|
my $cache_key_name = $cache->gen_key_name("hardware.network"); |
23
|
|
|
|
|
|
|
|
24
|
9
|
50
|
|
|
|
145
|
if ( $cache->valid($cache_key_name) ) { |
25
|
0
|
|
|
|
|
0
|
return $cache->get($cache_key_name); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
9
|
|
|
|
|
136
|
my $hw_class = _get_class(); |
29
|
9
|
50
|
|
|
|
67
|
unless ($hw_class) { |
30
|
0
|
|
|
|
|
0
|
return {}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
9
|
|
|
|
|
185
|
my $data = { |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
networkdevices => $hw_class->get_network_devices(), |
36
|
|
|
|
|
|
|
networkconfiguration => $hw_class->get_network_configuration(), |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
}; |
39
|
|
|
|
|
|
|
|
40
|
9
|
|
|
|
|
226
|
$cache->set( $cache_key_name, $data ); |
41
|
|
|
|
|
|
|
|
42
|
9
|
|
|
|
|
376
|
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
|
|
101
|
my $os_type = Rex::Commands::Gather::get_operating_system(); |
60
|
|
|
|
|
|
|
|
61
|
9
|
50
|
|
|
|
189
|
$os_type = "Linux" if Rex::Commands::Gather::is_linux(); |
62
|
9
|
50
|
|
|
|
113
|
$os_type = "Solaris" if Rex::Commands::Gather::is_solaris(); |
63
|
|
|
|
|
|
|
|
64
|
9
|
|
|
|
|
178
|
my $hw_class = "Rex::Hardware::Network::$os_type"; |
65
|
9
|
|
|
2
|
|
1197
|
eval "use $hw_class;"; |
|
2
|
|
|
2
|
|
99
|
|
|
2
|
|
|
2
|
|
26
|
|
|
2
|
|
|
2
|
|
46
|
|
|
2
|
|
|
|
|
32
|
|
|
2
|
|
|
|
|
25
|
|
|
2
|
|
|
|
|
78
|
|
|
2
|
|
|
|
|
49
|
|
|
2
|
|
|
|
|
34
|
|
|
2
|
|
|
|
|
87
|
|
|
2
|
|
|
|
|
36
|
|
|
2
|
|
|
|
|
26
|
|
|
2
|
|
|
|
|
57
|
|
66
|
|
|
|
|
|
|
|
67
|
9
|
50
|
|
|
|
245
|
if ($@) { |
68
|
0
|
|
|
|
|
0
|
Rex::Logger::debug("No network information on $os_type"); |
69
|
0
|
|
|
|
|
0
|
return; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
9
|
|
|
|
|
175
|
return $hw_class; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |