Skip to content

Commit dbc3ebe

Browse files
committed
(FACT-3160) Fix size calculations for AIX blockdevice and partitions
* disks.rb: TOTAL PPs = USED PPs + FREE PPs. Therefor adding FREE PPs to TOTAL PPs produces incorrect disk sizes. * partitions.rb: Using physical_partitions (PPs) to calculate LV sizes are not suitable if there is more than one mirror (can be two or three). LPs * nr_of_mirrors = PPs. * info_extractor.rb: Adjusted regexp because using property LPs also matched MAX LPs.
1 parent 8e38ac9 commit dbc3ebe

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

lib/facter/resolvers/aix/disks.rb

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

0 commit comments

Comments
 (0)