File Coverage

blib/lib/FusionInventory/Agent/Task/Inventory/Generic/Dmidecode/Slots.pm
Criterion Covered Total %
statement 20 30 66.6
branch 4 8 50.0
condition n/a
subroutine 5 7 71.4
pod 0 2 0.0
total 29 47 61.7


line stmt bran cond sub pod time code
1             package FusionInventory::Agent::Task::Inventory::Generic::Dmidecode::Slots;
2              
3 2     2   124087433 use strict;
  2         6  
  2         61  
4 2     2   9 use warnings;
  2         6  
  2         90  
5              
6 2     2   431 use FusionInventory::Agent::Tools;
  2         3  
  2         252  
7 2     2   749 use FusionInventory::Agent::Tools::Generic;
  2         2  
  2         460  
8              
9             my %status = (
10             'Unknown' => undef,
11             'In Use' => 'used',
12             'Available' => 'free'
13             );
14              
15             sub isEnabled {
16 0     0 0 0 my (%params) = @_;
17 0 0       0 return 0 if $params{no_category}->{slot};
18 0         0 return 1;
19             }
20              
21             sub doInventory {
22 0     0 0 0 my (%params) = @_;
23              
24 0         0 my $inventory = $params{inventory};
25 0         0 my $logger = $params{logger};
26              
27 0         0 my $slots = _getSlots(logger => $logger);
28              
29 0 0       0 return unless $slots;
30              
31 0         0 foreach my $slot (@$slots) {
32 0         0 $inventory->addEntry(
33             section => 'SLOTS',
34             entry => $slot
35             );
36             }
37             }
38              
39             sub _getSlots {
40 19     19   6096 my $infos = getDmidecodeInfos(@_);
41              
42 19 100       204 return unless $infos->{9};
43              
44 18         14 my $slots;
45 18         23 foreach my $info (@{$infos->{9}}) {
  18         38  
46             my $slot = {
47             DESCRIPTION => $info->{'Type'},
48             DESIGNATION => $info->{'ID'},
49             NAME => $info->{'Designation'},
50             STATUS => $info->{'Current Usage'} ?
51 104 100       293 $status{$info->{'Current Usage'}} : undef,
52             };
53              
54 104         121 push @$slots, $slot;
55             }
56              
57 18         41 return $slots;
58             }
59              
60             1;