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