Sha256: da858bc90fdd1aad0c0e818934ee0920bd1e9a72cedb44aa105ad5f8f8c4ed2b

Contents?: true

Size: 1014 Bytes

Versions: 4

Compression:

Stored size: 1014 Bytes

Contents

# frozen_string_literal: true

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

      def call_the_resolver
        facts = []
        disks = Facter::Resolvers::Solaris::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}_size", disk_info[:size_bytes].to_s, :legacy))
          facts.push(Facter::ResolvedFact.new("blockdevice_#{disk_name}_vendor", disk_info[:vendor], :legacy))
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
facter-4.0.39 lib/facter/facts/solaris/disks.rb
facter-4.0.38 lib/facter/facts/solaris/disks.rb
facter-4.0.37 lib/facter/facts/solaris/disks.rb
facter-4.0.36 lib/facter/facts/solaris/disks.rb