Skip to content

Commit

Permalink
use 1024 base, and take unit into account
Browse files Browse the repository at this point in the history
Closes: 1807
  • Loading branch information
guillomovitch committed Sep 11, 2012
1 parent 9fda6c2 commit 09765da
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Expand Up @@ -126,8 +126,7 @@ sub _getStorage {
my $storage = {
DESCRIPTION => $data{'Interface Type'},
SERIALNUMBER => $data{'Serial Number'},
FIRMWARE => $data{'Firmware Revision'},
DISKSIZE => $data{'Size'} * 1000
FIRMWARE => $data{'Firmware Revision'}
};

my $model = $data{'Model'};
Expand All @@ -140,6 +139,12 @@ sub _getStorage {
$storage->{TYPE} = $data{'Drive Type'} eq 'Data Drive' ?
'disk' : $data{'Drive Type'};

my ($size, $unit) = $data{'Size'} =~ /(\d+) \s (\S+)/x;
$storage->{DISKSIZE} =
$unit eq 'TB' ? $size * 1024 * 1024 * 1024 :
$unit eq 'GB' ? $size * 1024 * 1024 :
$unit eq 'MB' ? $size * 1024 :
$size ;
return $storage;
}

Expand Down
4 changes: 2 additions & 2 deletions t/inventory/generic/storages/hp.t
Expand Up @@ -23,7 +23,7 @@ my %storage_tests = (
FIRMWARE => '21.07QR4',
SERIALNUMBER => 'WD-WMANS1732855',
TYPE => 'disk',
DISKSIZE => '74300',
DISKSIZE => '3145728',
DESCRIPTION => 'SATA',
MODEL => 'WDC WD740ADFD-00',
MANUFACTURER => 'Western Digital'
Expand All @@ -32,7 +32,7 @@ my %storage_tests = (
NAME => 'Hitachi HUA72201',
MODEL => 'Hitachi HUA72201',
FIRMWARE => 'JP4OA3MA',
DISKSIZE => 1000,
DISKSIZE => '1073741824',
MANUFACTURER => 'Hitachi',
SERIALNUMBER => 'JPW9K0N02UPXHL',
DESCRIPTION => 'SATA',
Expand Down

0 comments on commit 09765da

Please sign in to comment.