File Coverage

lib/Rex/Inventory/Hal/Object/Storage.pm
Criterion Covered Total %
statement 20 44 45.4
branch 0 8 0.0
condition 0 3 0.0
subroutine 7 12 58.3
pod 0 5 0.0
total 27 72 37.5


line stmt bran cond sub pod time code
1             #
2             # (c) Jan Gehring
3             #
4              
5             package Rex::Inventory::Hal::Object::Storage;
6              
7 1     1   13 use v5.12.5;
  1         4  
8 1     1   5 use warnings;
  1         2  
  1         31  
9 1     1   5 use Data::Dumper;
  1         2  
  1         64  
10              
11             our $VERSION = '1.14.3'; # VERSION
12              
13 1     1   6 use Rex::Inventory::Hal::Object;
  1         4  
  1         8  
14 1     1   20 use Rex::Commands::Gather;
  1         2  
  1         6  
15 1     1   6 use Rex::Commands::Run;
  1         2  
  1         8  
16              
17 1     1   7 use base qw(Rex::Inventory::Hal::Object);
  1         2  
  1         563  
18              
19             __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             sub new {
33 0     0 0   my $that = shift;
34 0   0       my $proto = ref($that) || $that;
35 0           my $self = {@_};
36              
37 0           bless( $self, $proto );
38              
39 0           return $self;
40             }
41              
42             sub is_cdrom {
43              
44 0     0 0   my ($self) = @_;
45 0 0         if ( grep { /^storage\.cdrom$/ } $self->get('info.capabilities') ) {
  0            
46 0           return 1;
47             }
48              
49             }
50              
51             sub is_volume {
52              
53 0     0 0   my ($self) = @_;
54 0 0         if ( grep { !/^false$/ } $self->get('block.is_volume') ) {
  0            
55 0           return 1;
56             }
57              
58             }
59              
60             sub is_floppy {
61              
62 0     0 0   my ($self) = @_;
63 0 0         if ( grep { /^floppy$/ } $self->get('storage.drive_type') ) {
  0            
64 0           return 1;
65             }
66              
67             }
68              
69             sub get_size {
70              
71 0     0 0   my ($self) = @_;
72              
73 0           my $os = get_operating_system();
74              
75 0 0         if ( $os =~ m/BSD/ ) {
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;