Sha256: be93bb18e996b55dea04e2476a0fc14c9222d7b53d75e36416cf6235531028ec

Contents?: true

Size: 1.22 KB

Versions: 5

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

module Facter
  module Resolvers
    module Openbsd
      class DmiBios < BaseResolver
        init_resolver

        class << self
          private

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

          CTL_HW = 6
          HW_VENDOR = 14
          HW_PRODUCT = 15
          HW_VERSION = 16
          HW_SERIALNO = 17
          HW_UUID = 18

          def read_facts(fact_name)
            require 'facter/resolvers/bsd/ffi/ffi_helper'

            @fact_list[:bios_vendor]  = Facter::Bsd::FfiHelper.sysctl(:string, [CTL_HW, HW_VENDOR])
            @fact_list[:bios_version] = Facter::Bsd::FfiHelper.sysctl(:string, [CTL_HW, HW_VERSION])

            @fact_list[:product_name]   = Facter::Bsd::FfiHelper.sysctl(:string, [CTL_HW, HW_PRODUCT])
            @fact_list[:product_serial] = Facter::Bsd::FfiHelper.sysctl(:string, [CTL_HW, HW_SERIALNO])
            @fact_list[:product_uuid]   = Facter::Bsd::FfiHelper.sysctl(:string, [CTL_HW, HW_UUID])

            @fact_list[:sys_vendor] = Facter::Bsd::FfiHelper.sysctl(:string, [CTL_HW, HW_VENDOR])

            @fact_list[fact_name]
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
facter-4.10.0 lib/facter/resolvers/openbsd/dmi.rb
facter-4.9.0 lib/facter/resolvers/openbsd/dmi.rb
facter-4.8.0 lib/facter/resolvers/openbsd/dmi.rb
facter-4.7.1 lib/facter/resolvers/openbsd/dmi.rb
facter-4.7.0 lib/facter/resolvers/openbsd/dmi.rb