File Coverage

blib/lib/FusionInventory/Agent/Task/Inventory/Generic/Dmidecode/Bios.pm
Criterion Covered Total %
statement 28 36 77.7
branch 0 6 0.0
condition 8 15 53.3
subroutine 5 7 71.4
pod 0 2 0.0
total 41 66 62.1


line stmt bran cond sub pod time code
1             package FusionInventory::Agent::Task::Inventory::Generic::Dmidecode::Bios;
2              
3 2     2   126236554 use strict;
  2         3  
  2         75  
4 2     2   9 use warnings;
  2         2  
  2         73  
5              
6 2     2   696 use FusionInventory::Agent::Tools;
  2         4  
  2         248  
7 2     2   727 use FusionInventory::Agent::Tools::Generic;
  2         4  
  2         549  
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   39572 my $infos = getDmidecodeInfos(@_);
27              
28 21         162 my $bios_info = $infos->{0}->[0];
29 21         29 my $system_info = $infos->{1}->[0];
30 21         18 my $base_info = $infos->{2}->[0];
31 21         22 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         77 ASSETTAG => $chassis_info->{'Asset Tag'}
38             };
39              
40             $bios->{SMODEL} =
41             $system_info->{'Product'} ||
42 21   66     52 $system_info->{'Product Name'};
43 21         25 $bios->{MMODEL} = $base_info->{'Product Name'};
44 21         19 $bios->{SKUNUMBER} = $system_info->{'SKU Number'};
45              
46             $bios->{SMANUFACTURER} =
47             $system_info->{'Manufacturer'} ||
48 21   66     55 $system_info->{'Vendor'};
49 21         21 $bios->{MMANUFACTURER} = $base_info->{'Manufacturer'};
50              
51 21         20 $bios->{SSN} = $system_info->{'Serial Number'};
52 21         25 $bios->{MSN} = $base_info->{'Serial Number'};
53              
54 21 0 66     68 if ($bios->{MMODEL} && $bios->{MMODEL} eq "VirtualBox" &&
      33        
      33        
55             $bios->{SSN} eq "0" &&
56             $bios->{MSN} eq "0") {
57 0         0 $bios->{SSN} = $system_info->{'UUID'}
58             }
59             my $hardware = {
60             UUID => $system_info->{'UUID'},
61 21         42 CHASSIS_TYPE => $chassis_info->{'Type'}
62             };
63              
64 21         51 return $bios, $hardware;
65             }
66              
67             1;