File Coverage

blib/lib/FusionInventory/Agent/Task/Inventory/MacOS/Bios.pm
Criterion Covered Total %
statement 12 21 57.1
branch n/a
condition 0 11 0.0
subroutine 4 6 66.6
pod 0 2 0.0
total 16 40 40.0


line stmt bran cond sub pod time code
1             package FusionInventory::Agent::Task::Inventory::MacOS::Bios;
2              
3 1     1   78365065 use strict;
  1         10  
  1         41  
4 1     1   5 use warnings;
  1         1  
  1         62  
5              
6 1     1   370 use FusionInventory::Agent::Tools;
  1         1  
  1         128  
7 1     1   351 use FusionInventory::Agent::Tools::MacOS;
  1         2  
  1         167  
8              
9             sub isEnabled {
10 0     0 0   return canRun('/usr/sbin/system_profiler');
11             }
12              
13             sub doInventory {
14 0     0 0   my (%params) = @_;
15              
16 0           my $inventory = $params{inventory};
17 0           my $logger = $params{logger};
18              
19 0           my $infos = getSystemProfilerInfos(type => 'SPHardwareDataType', logger => $logger);
20 0           my $info = $infos->{'Hardware'}->{'Hardware Overview'};
21              
22 0           my ($device) = getIODevices(
23             class => 'IOPlatformExpertDevice',
24             logger => $logger
25             );
26              
27             # set the bios informaiton from the apple system profiler
28             $inventory->setBios({
29             SMANUFACTURER => $device->{'manufacturer'} || 'Apple Inc', # duh
30             SMODEL => $info->{'Model Identifier'} ||
31             $info->{'Machine Model'},
32             # New method to get the SSN, because of MacOS 10.5.7 update
33             # system_profiler gives 'Serial Number (system): XXXXX' where 10.5.6
34             # and lower give 'Serial Number: XXXXX'
35             SSN => $info->{'Serial Number'} ||
36             $info->{'Serial Number (system)'} ||
37             $device->{'serial-number'},
38 0   0       BVERSION => $info->{'Boot ROM Version'},
      0        
      0        
39             });
40              
41             $inventory->setHardware({
42 0   0       UUID => $info->{'Hardware UUID'} || $device->{'IOPlatformUUID'}
43             });
44             }
45              
46             1;