Sha256: f0fd1366972155c1b9747b0e2940771e351944de47eab69c54ac3c6944768c74

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true

module Facter
  module Resolvers
    class Architecture < BaseResolver
      # :architecture
      init_resolver

      class << self
        private

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

        def read_architecture(fact_name)
          require_relative 'utils/odm_query'

          proc_number = read_proc
          odmquery = ODMQuery.new
          odmquery
            .equals('name', proc_number)
            .equals('attribute', 'type')

          result = odmquery.execute

          return unless result

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

          @fact_list[fact_name]
        end

        def read_proc
          odmquery = ODMQuery.new
          odmquery
            .equals('PdDvLn', 'processor/sys/proc_rspc')
            .equals('status', '1')

          result = odmquery.execute
          result.each_line do |line|
            return line.split('=')[1].strip.delete('\"') if line.include?('name')
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
facter-4.0.46 lib/facter/resolvers/aix/architecture_resolver.rb