File Coverage

blib/lib/FusionInventory/Agent/Task/Inventory/Generic/Dmidecode/Bios.pm
Criterion Covered Total %
statement 27 34 79.4
branch 0 4 0.0
condition 4 6 66.6
subroutine 5 7 71.4
pod 0 2 0.0
total 36 53 67.9


line stmt bran cond sub pod time code
1             package FusionInventory::Agent::Task::Inventory::Generic::Dmidecode::Bios;
2              
3 2     2   153312002 use strict;
  2         14  
  2         125  
4 2     2   13 use warnings;
  2         2  
  2         98  
5              
6 2     2   1281 use FusionInventory::Agent::Tools;
  2         5  
  2         402  
7 2     2   1276 use FusionInventory::Agent::Tools::Generic;
  2         6  
  2         781  
8              
9             sub isEnabled {
10 0     0 0 0 return 1;
11             }
12              
13             sub doInventory {
14 0     0 0 0 my (%params) = @_;
15              
16 0         0 my $inventory = $params{inventory};
17 0         0 my $logger = $params{logger};
18              
19 0         0 my ($bios, $hardware) = _getBiosHardware(logger => $logger);
20              
21 0 0       0 $inventory->setBios($bios) if $bios;
22 0 0       0 $inventory->setHardware($hardware) if $hardware;
23             }
24              
25             sub _getBiosHardware {
26 21     21   66170 my $infos = getDmidecodeInfos(@_);
27              
28 21         272 my $bios_info = $infos->{0}->[0];
29 21         44 my $system_info = $infos->{1}->[0];
30 21         46 my $base_info = $infos->{2}->[0];
31 21         32 my $chassis_info = $infos->{3}->[0];
32              
33             my $bios = {
34             BMANUFACTURER => $bios_info->{'Vendor'},
35             BDATE => $bios_info->{'Release Date'},
36             BVERSION => $bios_info->{'Version'},
37 21         126 ASSETTAG => $chassis_info->{'Asset Tag'}
38             };
39              
40             $bios->{SMODEL} =
41             $system_info->{'Product'} ||
42 21   66     111 $system_info->{'Product Name'};
43 21         50 $bios->{MMODEL} = $base_info->{'Product Name'};
44 21         43 $bios->{SKUNUMBER} = $system_info->{'SKU Number'};
45              
46             $bios->{SMANUFACTURER} =
47             $system_info->{'Manufacturer'} ||
48 21   66     81 $system_info->{'Vendor'};
49 21         44 $bios->{MMANUFACTURER} = $base_info->{'Manufacturer'};
50              
51 21         36 $bios->{SSN} = $system_info->{'Serial Number'};
52 21         42 $bios->{MSN} = $base_info->{'Serial Number'};
53              
54             my $hardware = {
55             UUID => $system_info->{'UUID'},
56 21         76 CHASSIS_TYPE => $chassis_info->{'Type'}
57             };
58              
59 21         70 return $bios, $hardware;
60             }
61              
62             1;