Skip to content

Commit

Permalink
Merge pull request #2633 from joshcooper/facter-aix-sizes-blockdevice…
Browse files Browse the repository at this point in the history
…-partitions-fix

(FACT-3160) Fix size calculations for AIX blockdevice and partitions
  • Loading branch information
joshcooper authored Nov 4, 2023
2 parents a3d61a3 + 3ccc92a commit f065e53
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/facter/resolvers/aix/disks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def find_size(name)
end

def compute_size(size_hash)
physical_partitions = size_hash['TOTAL PPs'].to_i + size_hash['FREE PPs'].to_i
physical_partitions = size_hash['TOTAL PPs'].to_i
size_physical_partition = size_hash['PP SIZE']
exp = if size_physical_partition[/mega/]
Facter::Util::Aix::InfoExtractor::MEGABYTES_EXPONENT
Expand Down
4 changes: 2 additions & 2 deletions lib/facter/resolvers/aix/partitions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ def populate_from_lslv(name)
end

def compute_size(info_hash)
physical_partitions = info_hash['PPs'].to_i
logical_partitions = info_hash['LPs'].to_i
size_physical_partition = info_hash['PP SIZE']
exp = if size_physical_partition[/mega/]
Facter::Util::Aix::InfoExtractor::MEGABYTES_EXPONENT
else
Facter::Util::Aix::InfoExtractor::GIGABYTES_EXPONENT
end
size_physical_partition.to_i * physical_partitions * exp
size_physical_partition.to_i * logical_partitions * exp
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/facter/util/aix/info_extractor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def self.extract(content, cmd)
properties = PROPERTIES[cmd]
properties.each do |property|
str = (properties - [property]).join('|')
matcher = content.match(/#{Regexp.escape(property)}([^\n]*?)(#{str}|\n|$)/s)
matcher = content.match(/(?:^|^[^:]+:[^:]+)#{Regexp.escape(property)}([^\n]*?)(#{str}|\n|$)/s)
if matcher
value = matcher[1].strip
property_hash[property.split(':').first] = value
Expand Down
2 changes: 1 addition & 1 deletion spec/facter/resolvers/aix/disks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
let(:result) { load_fixture('lspv_output').read }

let(:disks) do
{ 'hdisk0' => { size: '30.00 GiB', size_bytes: 32_212_254_720 } }
{ 'hdisk0' => { size: '29.97 GiB', size_bytes: 32_178_700_288 } }
end

before do
Expand Down

0 comments on commit f065e53

Please sign in to comment.