Skip to content

Commit

Permalink
Improved Task::Inventory::Generic::Storages::HP and tests (#758)
Browse files Browse the repository at this point in the history
  • Loading branch information
po1vo authored and g-bougard committed Dec 3, 2019
1 parent 1bbe0d9 commit 22ab158
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 7 deletions.
24 changes: 19 additions & 5 deletions lib/FusionInventory/Agent/Task/Inventory/Generic/Storages/HP.pm
Expand Up @@ -17,6 +17,10 @@ use FusionInventory::Agent::Tools;
#
# HP Array Configuration Utility CLI 7.85-18.0

# This speeds up hpacucli startup by skipping non-local (iSCSI, Fibre) storages.
# See https://support.hpe.com/hpsc/doc/public/display?docId=emr_na-c03696601
$ENV{INFOMGR_BYPASS_NONSA} = "1";

sub _getHpacuacliFromWinRegistry {

my $Registry;
Expand Down Expand Up @@ -120,8 +124,9 @@ sub _getStorage {

my %data;
while (my $line = <$handle>) {
next unless $line =~ /(\S[^:]+) : \s+ (.+)/x;
next unless $line =~ /^\s*(\S[^:]+):\s+(.+)$/x;
$data{$1} = $2;
$data{$1} =~ s/\s+$//;
}
close $handle;

Expand All @@ -131,13 +136,22 @@ sub _getStorage {
FIRMWARE => $data{'Firmware Revision'}
};

# Possible models:
# HP EG0300FBDBR
# ATA WDC WD740ADFD-00
my $model = $data{'Model'};
$model =~ s/^ATA\s+//; # ex: ATA WDC WD740ADFD-00
$model =~ s/^ATA\s+//;
$model =~ s/\s+/ /;
$storage->{NAME} = $model;
$storage->{MODEL} = $model;
$storage->{NAME} = $model;

if ($model =~ /^(\S+)\s+(\S+)$/) {
$storage->{MANUFACTURER} = getCanonicalManufacturer($1);
$storage->{MODEL} = $2;
} else {
$storage->{MANUFACTURER} = getCanonicalManufacturer($model);
$storage->{MODEL} = $model;
}

$storage->{MANUFACTURER} = getCanonicalManufacturer($model);
$storage->{DISKSIZE} = getCanonicalSize($data{'Size'});

$storage->{TYPE} = $data{'Drive Type'} eq 'Data Drive' ?
Expand Down
7 changes: 7 additions & 0 deletions resources/generic/hpacucli/sample3-drives
@@ -0,0 +1,7 @@

Smart Array P420i in Slot 0 (Embedded)

array A

physicaldrive 1I:1:1 (port 1I:box 1:bay 1, SAS, 300 GB, OK)

3 changes: 3 additions & 0 deletions resources/generic/hpacucli/sample3-slots
@@ -0,0 +1,3 @@

Smart Array P420i in Slot 0 (Embedded) (sn: 001438022006330)

26 changes: 26 additions & 0 deletions resources/generic/hpacucli/sample3-storage
@@ -0,0 +1,26 @@

Smart Array P420i in Slot 0 (Embedded)

array A

physicaldrive 1I:1:1
Port: 1I
Box: 1
Bay: 1
Status: OK
Drive Type: Data Drive
Interface Type: SAS
Size: 300 GB
Rotational Speed: 10000
Firmware Revision: HPD7
Serial Number: PMVXYSZB
Model: HP EG0300FBDBR
Current Temperature (C): 23
Maximum Temperature (C): 44
PHY Count: 2
PHY Transfer Rate: 6.0Gbps, Unknown
Drive Authentication Status: OK
Carrier Application Version: 11
Carrier Bootloader Version: 6


14 changes: 12 additions & 2 deletions t/tasks/inventory/generic/storages/hp.t
Expand Up @@ -30,18 +30,28 @@ my %storage_tests = (
TYPE => 'disk',
DISKSIZE => '74300',
DESCRIPTION => 'SATA',
MODEL => 'WDC WD740ADFD-00',
MODEL => 'WD740ADFD-00',
MANUFACTURER => 'Western Digital'
},
sample2 => {
NAME => 'Hitachi HUA72201',
MODEL => 'Hitachi HUA72201',
MODEL => 'HUA72201',
FIRMWARE => 'JP4OA3MA',
DISKSIZE => '1000000',
MANUFACTURER => 'Hitachi',
SERIALNUMBER => 'JPW9K0N02UPXHL',
DESCRIPTION => 'SATA',
TYPE => 'disk'
},
sample3 => {
NAME => 'HP EG0300FBDBR',
MODEL => 'EG0300FBDBR',
FIRMWARE => 'HPD7',
DISKSIZE => '300000',
MANUFACTURER => 'Hewlett-Packard',
SERIALNUMBER => 'PMVXYSZB',
DESCRIPTION => 'SAS',
TYPE => 'disk'
}
);

Expand Down

0 comments on commit 22ab158

Please sign in to comment.