Sha256: 41082599b3f66fef9757f13c39fd2e05167b525f3c164577faf2c0fc87db591c

Contents?: true

Size: 865 Bytes

Versions: 3

Compression:

Stored size: 865 Bytes

Contents

# frozen_string_literal: true

module Facter
  module Resolvers
    module Aix
      class Serialnumber < BaseResolver
        init_resolver

        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::Util::Aix::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

3 entries across 3 versions & 1 rubygems

Version Path
facter-4.0.49 lib/facter/resolvers/aix/serialnumber.rb
facter-4.0.48 lib/facter/resolvers/aix/serialnumber.rb
facter-4.0.47 lib/facter/resolvers/aix/serialnumber.rb