line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::Generic::Storages::HP; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
158460558
|
use strict; |
|
2
|
|
|
|
|
13
|
|
|
2
|
|
|
|
|
118
|
|
4
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
143
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
12
|
use English qw(-no_match_vars); |
|
2
|
|
|
|
|
90
|
|
|
2
|
|
|
|
|
37
|
|
7
|
2
|
|
|
2
|
|
1852
|
use UNIVERSAL::require; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
31
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
953
|
use FusionInventory::Agent::Tools; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
2503
|
|
10
|
|
|
|
|
|
|
# Tested on 2.6.* kernels |
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
# Cards tested : |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
# Smart Array E200 |
15
|
|
|
|
|
|
|
# |
16
|
|
|
|
|
|
|
# HP Array Configuration Utility CLI 7.85-18.0 |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub _getHpacuacliFromWinRegistry { |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
0
|
|
0
|
my $Registry; |
21
|
0
|
|
|
|
|
0
|
Win32::TieRegistry->require(); |
22
|
0
|
|
|
|
|
0
|
Win32::TieRegistry->import( |
23
|
|
|
|
|
|
|
Delimiter => '/', |
24
|
|
|
|
|
|
|
ArrayValues => 0, |
25
|
|
|
|
|
|
|
TiedRef => \$Registry, |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
0
|
0
|
|
|
|
0
|
my $machKey = $Registry->Open('LMachine', { |
29
|
|
|
|
|
|
|
Access => Win32::TieRegistry::KEY_READ(), |
30
|
|
|
|
|
|
|
}) or die "Can't open HKEY_LOCAL_MACHINE key: $EXTENDED_OS_ERROR"; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $uninstallValues = |
33
|
0
|
|
|
|
|
0
|
$machKey->{'SOFTWARE/Microsoft/Windows/CurrentVersion/Uninstall/HP ACUCLI'}; |
34
|
0
|
0
|
|
|
|
0
|
return unless $uninstallValues; |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
0
|
my $uninstallString = $uninstallValues->{'/UninstallString'}; |
37
|
0
|
0
|
|
|
|
0
|
return unless $uninstallString; |
38
|
|
|
|
|
|
|
|
39
|
0
|
0
|
|
|
|
0
|
return unless $uninstallString =~ /(.*\\)hpuninst\.exe/; |
40
|
0
|
|
|
|
|
0
|
my $hpacuacliPath = $1 . 'bin\\hpacucli.exe'; |
41
|
0
|
0
|
|
|
|
0
|
return unless -f $hpacuacliPath; |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
0
|
return $hpacuacliPath; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub isEnabled { |
47
|
|
|
|
|
|
|
return |
48
|
0
|
|
0
|
0
|
0
|
0
|
canRun('hpacucli') || |
49
|
|
|
|
|
|
|
($OSNAME eq 'MSWin32' && _getHpacuacliFromWinRegistry()); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub doInventory { |
53
|
0
|
|
|
0
|
0
|
0
|
my (%params) = @_; |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
0
|
my $inventory = $params{inventory}; |
56
|
0
|
|
|
|
|
0
|
my $logger = $params{logger}; |
57
|
|
|
|
|
|
|
|
58
|
0
|
0
|
|
|
|
0
|
my $path = canRun('hpacucli') ? |
59
|
|
|
|
|
|
|
"hpacucli": |
60
|
|
|
|
|
|
|
_getHpacuacliFromWinRegistry($logger); |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
0
|
foreach my $slot (_getSlots(path => $path)) { |
63
|
0
|
|
|
|
|
0
|
foreach my $drive (_getDrives(path => $path, slot => $slot)) { |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
0
|
$inventory->addEntry( |
66
|
|
|
|
|
|
|
section => 'STORAGES', |
67
|
|
|
|
|
|
|
entry => _getStorage( |
68
|
|
|
|
|
|
|
path => $path, slot => $slot, drive => $drive |
69
|
|
|
|
|
|
|
) |
70
|
|
|
|
|
|
|
); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub _getSlots { |
76
|
2
|
|
|
2
|
|
11164
|
my %params = @_; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
my $command = $params{path} ? |
79
|
2
|
50
|
|
|
|
7
|
"$params{path} ctrl all show" : undef; |
80
|
2
|
|
|
|
|
11
|
my $handle = getFileHandle(%params, command => $command); |
81
|
2
|
50
|
|
|
|
6
|
return unless $handle; |
82
|
|
|
|
|
|
|
|
83
|
2
|
|
|
|
|
4
|
my @slots; |
84
|
2
|
|
|
|
|
29
|
while (my $line = <$handle>) { |
85
|
3
|
50
|
|
|
|
16
|
next unless $line =~ /Slot (\d+)/; |
86
|
3
|
|
|
|
|
21
|
push @slots, $1; |
87
|
|
|
|
|
|
|
} |
88
|
2
|
|
|
|
|
14
|
close $handle; |
89
|
|
|
|
|
|
|
|
90
|
2
|
|
|
|
|
19
|
return @slots; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub _getDrives { |
94
|
2
|
|
|
2
|
|
2743
|
my %params = @_; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
my $command = $params{path} && defined $params{slot} ? |
97
|
2
|
50
|
33
|
|
|
11
|
"$params{path} ctrl slot=$params{slot} pd all show" : undef; |
98
|
2
|
|
|
|
|
9
|
my $handle = getFileHandle(%params, command => $command); |
99
|
2
|
50
|
|
|
|
6
|
next unless $handle; |
100
|
|
|
|
|
|
|
|
101
|
2
|
|
|
|
|
4
|
my @drives; |
102
|
2
|
|
|
|
|
23
|
while (my $line = <$handle>) { |
103
|
8
|
100
|
|
|
|
37
|
next unless $line =~ /physicaldrive (\S+)/; |
104
|
4
|
|
|
|
|
56
|
push @drives, $1; |
105
|
|
|
|
|
|
|
} |
106
|
2
|
|
|
|
|
15
|
close $handle; |
107
|
|
|
|
|
|
|
|
108
|
2
|
|
|
|
|
17
|
return @drives; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub _getStorage { |
112
|
2
|
|
|
2
|
|
1797
|
my %params = @_; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
my $command = $params{path} && defined $params{slot} && defined $params{drive} ? |
115
|
2
|
50
|
33
|
|
|
17
|
"$params{path} ctrl slot=$params{slot} pd $params{drive} show" : undef; |
116
|
2
|
|
|
|
|
10
|
my $handle = getFileHandle(%params, command => $command); |
117
|
2
|
50
|
|
|
|
6
|
next unless $handle; |
118
|
|
|
|
|
|
|
|
119
|
2
|
|
|
|
|
3
|
my %data; |
120
|
2
|
|
|
|
|
33
|
while (my $line = <$handle>) { |
121
|
34
|
100
|
|
|
|
149
|
next unless $line =~ /(\S[^:]+) : \s+ (.+)/x; |
122
|
28
|
|
|
|
|
202
|
$data{$1} = $2; |
123
|
|
|
|
|
|
|
} |
124
|
2
|
|
|
|
|
16
|
close $handle; |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
my $storage = { |
127
|
|
|
|
|
|
|
DESCRIPTION => $data{'Interface Type'}, |
128
|
|
|
|
|
|
|
SERIALNUMBER => $data{'Serial Number'}, |
129
|
2
|
|
|
|
|
50
|
FIRMWARE => $data{'Firmware Revision'} |
130
|
|
|
|
|
|
|
}; |
131
|
|
|
|
|
|
|
|
132
|
2
|
|
|
|
|
5
|
my $model = $data{'Model'}; |
133
|
2
|
|
|
|
|
9
|
$model =~ s/^ATA\s+//; # ex: ATA WDC WD740ADFD-00 |
134
|
2
|
|
|
|
|
7
|
$model =~ s/\s+/ /; |
135
|
2
|
|
|
|
|
7
|
$storage->{NAME} = $model; |
136
|
2
|
|
|
|
|
5
|
$storage->{MODEL} = $model; |
137
|
|
|
|
|
|
|
|
138
|
2
|
|
|
|
|
8
|
$storage->{MANUFACTURER} = getCanonicalManufacturer($model); |
139
|
2
|
|
|
|
|
7
|
$storage->{DISKSIZE} = getCanonicalSize($data{'Size'}); |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
$storage->{TYPE} = $data{'Drive Type'} eq 'Data Drive' ? |
142
|
2
|
50
|
|
|
|
11
|
'disk' : $data{'Drive Type'}; |
143
|
|
|
|
|
|
|
|
144
|
2
|
|
|
|
|
14
|
return $storage; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
1; |