Sha256: dff520844bf295340c0c54aa72d0019f858afdbf3afdc21af5f6b49b422dd11a

Contents?: true

Size: 864 Bytes

Versions: 8

Compression:

Stored size: 864 Bytes

Contents

# frozen_string_literal: true

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

      class << self
        private

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

        def read_wpar(fact_name)
          output = Facter::Core::Execution.execute('/usr/bin/lparstat -W', logger: log)

          return if output.empty?

          output.each_line do |line|
            populate_wpar_data(line.split(':').map(&:strip))
          end
          @fact_list[fact_name]
        end

        def populate_wpar_data(key_value)
          @fact_list[:wpar_key]              = key_value[1].to_i if key_value[0] == 'WPAR Key'
          @fact_list[:wpar_configured_id]    = key_value[1].to_i if key_value[0] == 'WPAR Configured ID'
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

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