lib/Rex/Inventory/Hal/Object/Storage.pm

filter: Statementstmt 48.9% 23 / 47 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 58.3% 7 / 12 Podpod 0.0% 0 / 5 totaltotal 38.9% 30 / 77 CC 6 SCAR 13.7
CC
6
Cov
40%
new
6.0
is_cdrom
6.0
is_volume
6.0
CRAP 3.9
« lib/Rex/Service/Redhat/systemd.pm ↑ Summary lib/Rex/Commands/Network.pm »
1 #
2 # (c) Jan Gehring <jan.gehring@gmail.com>
3 #
4  
5 package Rex::Inventory::Hal::Object::Storage;
6  
7 1 ▶use v5.14.4;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 our $VERSION = '1.16.1'; # VERSION
12  
13 1 ▶use Rex::Inventory::Hal::Object;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use Rex::Commands::Gather;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use Rex::Commands::Run;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 1 ▶use base qw(Rex::Inventory::Hal::Object);
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 1 __PACKAGE__->has(
20 [
21  
22 { key => "block.device", accessor => "dev", },
23  
24 { key => "storage.size", accessor => "size", overwrite => 1, },
25 { key => "info.product", accessor => "product" },
26 { key => [ "storage.vendor", "info.vendor" ], accessor => "vendor" },
27 { key => "storage.bus", accessor => "bus" },
28  
29 ]
30 );
31  
32 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
33 0 my $that = shift;
34 0 ▶ my $proto = ref($that) || $that;
Condition0%0/3
ref $that || $that
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $that || $that
ref $that $that
Truth table0%0/3
A || B
A= ref $thatB= $that
ABresult
1X1
011
000
35 0 my $self = {@_};
36  
37 0 bless( $self, $proto );
38  
39 0 return $self;
40 }
41  
42 0 ▶sub is_cdrom {
Subroutine is_cdrom: not called CC=2 SCAR=17.9
Pod undocumented
43  
44 0 my ($self) = @_;
45 0 ▶ if ( grep { /^storage\.cdrom$/ } $self->get('info.capabilities') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {/^storage\.cdrom$/u;} $self->get("info.capabilities")) 0 0 0
46 0 return 1;
47 }
48  
49 }
50  
51 0 ▶sub is_volume {
Subroutine is_volume: not called CC=2 SCAR=17.9
Pod undocumented
52  
53 0 my ($self) = @_;
54 0 ▶ if ( grep { !/^false$/ } $self->get('block.is_volume') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {not /^false$/u;} $self->get("block.is_volume")) 0 0 0
55 0 return 1;
56 }
57  
58 }
59  
60 0 ▶sub is_floppy {
Subroutine is_floppy: not called CC=2 SCAR=17.9
Pod undocumented
61  
62 0 my ($self) = @_;
63 0 ▶ if ( grep { /^floppy$/ } $self->get('storage.drive_type') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {/^floppy$/u;} $self->get("storage.drive_type")) 0 0 0
64 0 return 1;
65 }
66  
67 }
68  
69 0 ▶sub get_size {
Subroutine get_size: not called CC=2 SCAR=17.9
Pod undocumented
70  
71 0 my ($self) = @_;
72  
73 0 my $os = get_operating_system();
74  
75 0 ▶ if ( $os =~ m/BSD/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($os =~ /BSD/u) { } 0 0 0
76 0 my ($info_line) = run "diskinfo " . $self->get_dev;
77 0 my ( $dev_name, $sector, $size, $sectors, $stripesize, $stripeoffset,
78 $cylinders, $heads )
79 = split( /\s+/, $info_line );
80  
81 0 return $size;
82 }
83 else {
84 0 return $self->get("storage.size");
85 }
86  
87 }
88  
89 1 1;
« lib/Rex/Service/Redhat/systemd.pm ↑ Summary lib/Rex/Commands/Network.pm »