Skip to content

Commit f065e53

Browse files
authored
Merge pull request #2633 from joshcooper/facter-aix-sizes-blockdevice-partitions-fix
(FACT-3160) Fix size calculations for AIX blockdevice and partitions
2 parents a3d61a3 + 3ccc92a commit f065e53

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

lib/facter/resolvers/aix/disks.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def find_size(name)
4747
end
4848

4949
def compute_size(size_hash)
50-
physical_partitions = size_hash['TOTAL PPs'].to_i + size_hash['FREE PPs'].to_i
50+
physical_partitions = size_hash['TOTAL PPs'].to_i
5151
size_physical_partition = size_hash['PP SIZE']
5252
exp = if size_physical_partition[/mega/]
5353
Facter::Util::Aix::InfoExtractor::MEGABYTES_EXPONENT

lib/facter/resolvers/aix/partitions.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@ def populate_from_lslv(name)
5656
end
5757

5858
def compute_size(info_hash)
59-
physical_partitions = info_hash['PPs'].to_i
59+
logical_partitions = info_hash['LPs'].to_i
6060
size_physical_partition = info_hash['PP SIZE']
6161
exp = if size_physical_partition[/mega/]
6262
Facter::Util::Aix::InfoExtractor::MEGABYTES_EXPONENT
6363
else
6464
Facter::Util::Aix::InfoExtractor::GIGABYTES_EXPONENT
6565
end
66-
size_physical_partition.to_i * physical_partitions * exp
66+
size_physical_partition.to_i * logical_partitions * exp
6767
end
6868
end
6969
end

lib/facter/util/aix/info_extractor.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def self.extract(content, cmd)
6161
properties = PROPERTIES[cmd]
6262
properties.each do |property|
6363
str = (properties - [property]).join('|')
64-
matcher = content.match(/#{Regexp.escape(property)}([^\n]*?)(#{str}|\n|$)/s)
64+
matcher = content.match(/(?:^|^[^:]+:[^:]+)#{Regexp.escape(property)}([^\n]*?)(#{str}|\n|$)/s)
6565
if matcher
6666
value = matcher[1].strip
6767
property_hash[property.split(':').first] = value

spec/facter/resolvers/aix/disks_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
let(:result) { load_fixture('lspv_output').read }
2929

3030
let(:disks) do
31-
{ 'hdisk0' => { size: '30.00 GiB', size_bytes: 32_212_254_720 } }
31+
{ 'hdisk0' => { size: '29.97 GiB', size_bytes: 32_178_700_288 } }
3232
end
3333

3434
before do

0 commit comments

Comments
 (0)