Sha256: 88285d3b5eef2d8fa17a1d560c5c3399afa451198b7638eb25c2155a20918e18

Contents?: true

Size: 985 Bytes

Versions: 32

Compression:

Stored size: 985 Bytes

Contents

# frozen_string_literal: true

module Facter
  module Resolvers
    class DMIBios < BaseResolver
      @log = Facter::Log.new(self)
      init_resolver

      class << self
        # Manufacturer
        # SerialNumber

        private

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

        def read_fact_from_bios(fact_name)
          win = Facter::Util::Windows::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

32 entries across 32 versions & 1 rubygems

Version Path
facter-4.2.6 lib/facter/resolvers/windows/dmi_bios.rb
facter-4.2.5 lib/facter/resolvers/windows/dmi_bios.rb
facter-4.2.4 lib/facter/resolvers/windows/dmi_bios.rb
facter-4.2.3 lib/facter/resolvers/windows/dmi_bios.rb
facter-4.2.2 lib/facter/resolvers/windows/dmi_bios.rb
facter-4.2.1 lib/facter/resolvers/windows/dmi_bios.rb
facter-4.2.0 lib/facter/resolvers/windows/dmi_bios.rb
facter-4.1.1 lib/facter/resolvers/windows/dmi_bios.rb
facter-4.1.0 lib/facter/resolvers/windows/dmi_bios.rb
facter-4.0.52 lib/facter/resolvers/windows/dmi_bios.rb
facter-4.0.51 lib/facter/resolvers/windows/dmi_bios.rb
facter-4.0.50 lib/facter/resolvers/windows/dmi_bios.rb