Sha256: 4a03cd988052c621322abfabb859218afa9f5e93e376eb7fd5e45cb1fbcca289

Contents?: true

Size: 985 Bytes

Versions: 29

Compression:

Stored size: 985 Bytes

Contents

# frozen_string_literal: true

module Facter
  module Resolvers
    class DMIBios < BaseResolver
      @log = Facter::Log.new(self)
      @semaphore = Mutex.new
      @fact_list ||= {}

      class << self
        # Manufacturer
        # SerialNumber

        private

        def post_resolve(fact_name)
          @fact_list.fetch(fact_name) { read_fact_from_bios(fact_name) }
        end

        def read_fact_from_bios(fact_name)
          win = Win32Ole.new

          bios = win.return_first('SELECT Manufacturer,SerialNumber from Win32_BIOS')
          unless bios
            @log.debug 'WMI query returned no results for Win32_BIOS with values Manufacturer and SerialNumber.'
            return
          end

          build_fact_list(bios)

          @fact_list[fact_name]
        end

        def build_fact_list(bios)
          @fact_list[:manufacturer] = bios.Manufacturer
          @fact_list[:serial_number] = bios.SerialNumber
        end
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
facter-4.0.36 lib/facter/resolvers/windows/dmi_bios_resolver.rb
facter-4.0.35 lib/facter/resolvers/windows/dmi_bios_resolver.rb
facter-4.0.34 lib/facter/resolvers/windows/dmi_bios_resolver.rb
facter-4.0.33 lib/facter/resolvers/windows/dmi_bios_resolver.rb
facter-4.0.32 lib/facter/resolvers/windows/dmi_bios_resolver.rb
facter-4.0.31 lib/facter/resolvers/windows/dmi_bios_resolver.rb
facter-4.0.30 lib/facter/resolvers/windows/dmi_bios_resolver.rb
facter-4.0.29 lib/resolvers/windows/dmi_bios_resolver.rb
facter-4.0.28 lib/resolvers/windows/dmi_bios_resolver.rb
facter-4.0.26 lib/resolvers/windows/dmi_bios_resolver.rb
facter-4.0.25 lib/resolvers/windows/dmi_bios_resolver.rb
facter-4.0.24 lib/resolvers/windows/dmi_bios_resolver.rb
facter-4.0.23 lib/resolvers/windows/dmi_bios_resolver.rb
facter-4.0.22 lib/resolvers/windows/dmi_bios_resolver.rb
facter-4.0.21 lib/resolvers/windows/dmi_bios_resolver.rb
facter-4.0.20 lib/resolvers/windows/dmi_bios_resolver.rb
facter-4.0.19 lib/resolvers/windows/dmi_bios_resolver.rb
facter-4.0.18 lib/resolvers/windows/dmi_bios_resolver.rb
facter-4.0.17 lib/resolvers/windows/dmi_bios_resolver.rb
facter-4.0.16 lib/resolvers/windows/dmi_bios_resolver.rb