Skip to content

Commit

Permalink
(FACT-3140) Include partition type uuid for GPT based systems
Browse files Browse the repository at this point in the history
  • Loading branch information
jcpunk committed Apr 18, 2024
1 parent 5335371 commit e7fd8f3
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions lib/facter/resolvers/partitions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def execute_and_extract_blkid_info
def populate_from_lsblk(partition_name, blkid_and_lsblk)
return {} unless available?('lsblk', blkid_and_lsblk)

blkid_and_lsblk[:lsblk] ||= Facter::Core::Execution.execute('lsblk -fp', logger: log)
blkid_and_lsblk[:lsblk] ||= Facter::Core::Execution.execute('lsblk -p -P -o NAME,FSTYPE,LABEL,UUID,PARTTYPE', logger: log)

part_info = blkid_and_lsblk[:lsblk].match(/#{partition_name}.*/).to_s.split(' ')
return {} if part_info.empty?
Expand All @@ -130,13 +130,21 @@ def populate_from_lsblk(partition_name, blkid_and_lsblk)
end

def parse_part_info(part_info)
result = { filesystem: part_info[1] }

if part_info.count.eql?(5)
result[:label] = part_info[2]
result[:uuid] = part_info[3]
else
result[:uuid] = part_info[2]
result = {}

part_info.each do |setting|
simple_string = setting.gsub('"','')
key, value = simple_string.split('=')
case key
when 'FSTYPE'
result['filesystem'] = value
when 'LABEL'
result['label'] = value
when 'UUID'
result['uuid'] = value
when 'PARTTYPE'
result['type_uuid'] = value
end
end

result
Expand Down

0 comments on commit e7fd8f3

Please sign in to comment.