File Coverage

blib/lib/FusionInventory/Agent/Task/Inventory/Generic/Dmidecode/Ports.pm
Criterion Covered Total %
statement 20 30 66.6
branch 2 6 33.3
condition n/a
subroutine 5 7 71.4
pod 0 2 0.0
total 27 45 60.0


line stmt bran cond sub pod time code
1             package FusionInventory::Agent::Task::Inventory::Generic::Dmidecode::Ports;
2              
3 2     2   150566809 use strict;
  2         10  
  2         92  
4 2     2   10 use warnings;
  2         9  
  2         97  
5              
6 2     2   677 use FusionInventory::Agent::Tools;
  2         5  
  2         412  
7 2     2   1300 use FusionInventory::Agent::Tools::Generic;
  2         4  
  2         667  
8              
9             sub isEnabled {
10 0     0 0 0 my (%params) = @_;
11 0 0       0 return 0 if $params{no_category}->{port};
12 0         0 return 1;
13             }
14              
15             sub doInventory {
16 0     0 0 0 my (%params) = @_;
17              
18 0         0 my $inventory = $params{inventory};
19 0         0 my $logger = $params{logger};
20              
21 0         0 my $ports = _getPorts(logger => $logger);
22              
23 0 0       0 return unless $ports;
24              
25 0         0 foreach my $port (@$ports) {
26 0         0 $inventory->addEntry(
27             section => 'PORTS',
28             entry => $port
29             );
30             }
31             }
32              
33             sub _getPorts {
34 19     19   6134 my $infos = getDmidecodeInfos(@_);
35              
36 19 100       224 return unless $infos->{8};
37              
38 18         25 my $ports;
39 18         27 foreach my $info (@{$infos->{8}}) {
  18         40  
40             my $port = {
41             CAPTION => $info->{'External Connector Type'},
42             DESCRIPTION => $info->{'Internal Connector Type'},
43             NAME => $info->{'Internal Reference Designator'},
44 209         787 TYPE => $info->{'Port Type'},
45             };
46              
47 209         368 push @$ports, $port;
48             }
49              
50 18         56 return $ports;
51             }
52              
53             1;