Sha256: b4d4532eccd2fa1671058df694732a850fdde14fe06a727e64a784bfc77bbdfa

Contents?: true

Size: 858 Bytes

Versions: 8

Compression:

Stored size: 858 Bytes

Contents

# frozen_string_literal: true

module Facter
  module Resolvers
    module Aix
      class Serialnumber < BaseResolver
        @fact_list ||= {}

        class << self
          private

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

          def read_serialnumber(fact_name)
            odmquery = Facter::ODMQuery.new
            odmquery
              .equals('name', 'sys0')
              .equals('attribute', 'systemid')
            result = odmquery.execute

            result.each_line do |line|
              if line.include?('value')
                @fact_list[:serialnumber] = line.split('=')[1].strip.delete('\"')[6..-1]
                break
              end
            end

            @fact_list[fact_name]
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
facter-4.0.44 lib/facter/resolvers/aix/serialnumber.rb
facter-4.0.43 lib/facter/resolvers/aix/serialnumber.rb
facter-4.0.42 lib/facter/resolvers/aix/serialnumber.rb
facter-4.0.41 lib/facter/resolvers/aix/serialnumber.rb
facter-4.0.40 lib/facter/resolvers/aix/serialnumber.rb
facter-4.0.39 lib/facter/resolvers/aix/serialnumber.rb
facter-4.0.38 lib/facter/resolvers/aix/serialnumber.rb
facter-4.0.37 lib/facter/resolvers/aix/serialnumber.rb