lib/Rex/Hardware/Network.pm

filter: Statementstmt 86.2% 44 / 51 Branchbran 50.0% 5 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 78.5% 11 / 14 Podpod 0.0% 0 / 4 totaltotal 75.9% 60 / 79 CC 6 SCAR 7.4
CC
6
Cov
80%
_get_class
4.1
get
3.2
route
2.0
CRAP 2.1
« lib/Rex/Cron/SunOS.pm ↑ Summary blib/lib/Rex/Group/Lookup/XML.pm »
1 #
2 # (c) Jan Gehring <jan.gehring@gmail.com>
3 #
4  
5 package Rex::Hardware::Network;
6  
7 37 ▶use v5.14.4;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 37 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 36 our $VERSION = '1.16.1'; # VERSION
11  
12 36 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 36 ▶use Rex::Commands::Gather;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 36 ▶use Rex::Logger;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 36 require Rex::Hardware;
18  
19 9 ▶sub get {
Subroutine get: called CC=3 SCAR=11.7
Pod undocumented
20  
21 9 my $cache = Rex::get_cache();
22 9 my $cache_key_name = $cache->gen_key_name("hardware.network");
23  
24 9 ▶ if ( $cache->valid($cache_key_name) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cache->valid($cache_key_name)) 0 9 9
25 0 return $cache->get($cache_key_name);
26 }
27  
28 9 my $hw_class = _get_class();
29 9 ▶ unless ($hw_class) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($hw_class) 0 9 9
30 0 return {};
31 }
32  
33 9 my $data = {
34  
35 networkdevices => $hw_class->get_network_devices(),
36 networkconfiguration => $hw_class->get_network_configuration(),
37  
38 };
39  
40 9 $cache->set( $cache_key_name, $data );
41  
42 9 return $data;
43  
44 }
45  
46 0 ▶sub route {
Subroutine route: not called CC=1 SCAR=6.9
Pod undocumented
47 0 return _get_class()->route();
48 }
49  
50 0 ▶sub default_gateway {
Subroutine default_gateway: not called CC=1 SCAR=6.9
Pod undocumented
51 0 return _get_class()->default_gateway(@_);
52 }
53  
54 0 ▶sub netstat {
Subroutine netstat: not called CC=1 SCAR=6.9
Pod undocumented
55 0 return _get_class()->netstat();
56 }
57  
58 9 ▶sub _get_class {
Subroutine _get_class: called CC=4 SCAR=14.1
59 9 my $os_type = Rex::Commands::Gather::get_operating_system();
60  
61 9 ▶ $os_type = "Linux" if Rex::Commands::Gather::is_linux();
Branch: 1 branch
BranchTrueFalseTotal
if Rex::Commands::Gather::is_linux() 9 0 9
62 9 ▶ $os_type = "Solaris" if Rex::Commands::Gather::is_solaris();
Branch: 1 branch
BranchTrueFalseTotal
if Rex::Commands::Gather::is_solaris() 0 9 9
63  
64 9 my $hw_class = "Rex::Hardware::Network::$os_type";
65 9 ▶ eval "use $hw_class;";
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
66  
67 9 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 9 9
68 0 Rex::Logger::debug("No network information on $os_type");
69 0 return;
70 }
71  
72 9 return $hw_class;
73 }
74  
75 36 1;
« lib/Rex/Cron/SunOS.pm ↑ Summary blib/lib/Rex/Group/Lookup/XML.pm »