Sha256: d311af3b99f04e8301e4f3b6c619a4c703640ef1f7b856548475eea46ceb4ded

Contents?: true

Size: 1.14 KB

Versions: 27

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

module Facter
  module Resolvers
    module Solaris
      class DmiSparc < BaseResolver
        init_resolver

        class << self
          private

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

          def read_facts(fact_name)
            output = exec_prtdiag
            return unless output

            matches = output.match(/System Configuration:\s+(.+?)\s+sun\d+\S+\s+(.+)/)&.captures

            @fact_list[:manufacturer] = matches[0]&.strip
            @fact_list[:product_name] = matches[1]&.strip

            sneep = exec_sneep&.strip
            @fact_list[:serial_number] = sneep

            @fact_list[fact_name]
          end

          def exec_prtdiag
            return unless File.executable?('/usr/sbin/prtdiag')

            Facter::Core::Execution.execute('/usr/sbin/prtdiag', logger: log)
          end

          def exec_sneep
            return unless File.executable?('/usr/sbin/sneep')

            Facter::Core::Execution.execute('/usr/sbin/sneep', logger: log)
          end
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
facter-4.5.0 lib/facter/resolvers/solaris/dmi_sparc.rb
facter-4.4.3 lib/facter/resolvers/solaris/dmi_sparc.rb
facter-4.4.2 lib/facter/resolvers/solaris/dmi_sparc.rb
facter-4.4.1 lib/facter/resolvers/solaris/dmi_sparc.rb
facter-4.4.0 lib/facter/resolvers/solaris/dmi_sparc.rb
facter-4.3.1 lib/facter/resolvers/solaris/dmi_sparc.rb
facter-4.3.0 lib/facter/resolvers/solaris/dmi_sparc.rb
facter-4.2.14 lib/facter/resolvers/solaris/dmi_sparc.rb
facter-4.2.13 lib/facter/resolvers/solaris/dmi_sparc.rb
facter-4.2.12 lib/facter/resolvers/solaris/dmi_sparc.rb
facter-4.2.11 lib/facter/resolvers/solaris/dmi_sparc.rb
facter-4.2.10 lib/facter/resolvers/solaris/dmi_sparc.rb
facter-4.2.9 lib/facter/resolvers/solaris/dmi_sparc.rb
facter-4.2.8 lib/facter/resolvers/solaris/dmi_sparc.rb
facter-4.2.7 lib/facter/resolvers/solaris/dmi_sparc.rb
facter-4.2.6 lib/facter/resolvers/solaris/dmi_sparc.rb
facter-4.2.5 lib/facter/resolvers/solaris/dmi_sparc.rb
facter-4.2.4 lib/facter/resolvers/solaris/dmi_sparc.rb
facter-4.2.3 lib/facter/resolvers/solaris/dmi_sparc.rb
facter-4.2.2 lib/facter/resolvers/solaris/dmi_sparc.rb