Sha256: 261af1ca68cc62efaca83c428c0e2a82e9789e6d7c5e5890de1e02a86f99799a

Contents?: true

Size: 1.11 KB

Versions: 25

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

module Facts
  module Linux
    class Disks
      FACT_NAME = 'disks'
      ALIASES = %w[blockdevices blockdevice_.*_model blockdevice_.*_size blockdevice_.*_vendor].freeze

      def call_the_resolver
        facts = []
        disks = Facter::Resolvers::Linux::Disks.resolve(:disks)

        return Facter::ResolvedFact.new(FACT_NAME, nil) if disks.nil? || disks.empty?

        blockdevices = disks.keys.join(',')
        facts.push(Facter::ResolvedFact.new(FACT_NAME, disks))
        facts.push(Facter::ResolvedFact.new('blockdevices', blockdevices, :legacy))
        add_legacy_facts(disks, facts)

        facts
      end

      private

      def add_legacy_facts(disks, facts)
        disks.each do |disk_name, disk_info|
          facts.push(Facter::ResolvedFact.new("blockdevice_#{disk_name}_model", disk_info[:model], :legacy))
          facts.push(Facter::ResolvedFact.new("blockdevice_#{disk_name}_size", disk_info[:size_bytes], :legacy))
          facts.push(Facter::ResolvedFact.new("blockdevice_#{disk_name}_vendor", disk_info[:vendor], :legacy))
        end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
facter-4.10.0 lib/facter/facts/linux/disks.rb
facter-4.9.0 lib/facter/facts/linux/disks.rb
facter-4.8.0 lib/facter/facts/linux/disks.rb
facter-4.7.1 lib/facter/facts/linux/disks.rb
facter-4.7.0 lib/facter/facts/linux/disks.rb
facter-4.6.1 lib/facter/facts/linux/disks.rb
facter-4.6.0 lib/facter/facts/linux/disks.rb
facter-4.5.2 lib/facter/facts/linux/disks.rb
facter-4.5.1 lib/facter/facts/linux/disks.rb
facter-4.5.0 lib/facter/facts/linux/disks.rb
facter-4.4.3 lib/facter/facts/linux/disks.rb
facter-4.4.2 lib/facter/facts/linux/disks.rb
facter-4.4.1 lib/facter/facts/linux/disks.rb
facter-4.4.0 lib/facter/facts/linux/disks.rb
facter-4.3.1 lib/facter/facts/linux/disks.rb
facter-4.3.0 lib/facter/facts/linux/disks.rb
facter-4.2.14 lib/facter/facts/linux/disks.rb
facter-4.2.13 lib/facter/facts/linux/disks.rb
facter-4.2.12 lib/facter/facts/linux/disks.rb
facter-4.2.11 lib/facter/facts/linux/disks.rb