Sha256: 8559f2f901f091d0bd1a3a0e272aeb20f2eac3db11f4932efdd94c8924f08c40

Contents?: true

Size: 985 Bytes

Versions: 24

Compression:

Stored size: 985 Bytes

Contents

# frozen_string_literal: true

# CuAt (Customized Attributes) non-default attribute values
# CuDv (Customized Devices) the devices present on this machine
# PdAt (Predefined Attributes) default values for all device attributes
# PdDv (Predefined Devices) the list of all devices supported by this release of AIX

module Facter
  class ODMQuery
    REPOS = %w[CuAt CuDv PdAt PdDv].freeze

    def initialize
      @query = ''
      @conditions = []
      @log = Facter::Log.new(self)
    end

    def equals(field, value)
      @conditions << "#{field}='#{value}'"
      self
    end

    def like(field, value)
      @conditions << "#{field} like '#{value}'"
      self
    end

    def execute
      result = nil
      REPOS.each do |repo|
        break if result && !result.empty?

        result = Facter::Core::Execution.execute("#{query} #{repo}", logger: @log)
      end
      result
    end

    def query
      'odmget -q "' + @conditions.join(' AND ') + '"'
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
facter-4.0.24 lib/resolvers/aix/utils/odm_query.rb
facter-4.0.23 lib/resolvers/aix/utils/odm_query.rb
facter-4.0.22 lib/resolvers/aix/utils/odm_query.rb
facter-4.0.21 lib/resolvers/aix/utils/odm_query.rb