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.46 lib/facter/resolvers/aix/utils/odm_query.rb
facter-4.0.44 lib/facter/resolvers/aix/utils/odm_query.rb
facter-4.0.43 lib/facter/resolvers/aix/utils/odm_query.rb
facter-4.0.42 lib/facter/resolvers/aix/utils/odm_query.rb
facter-4.0.41 lib/facter/resolvers/aix/utils/odm_query.rb
facter-4.0.40 lib/facter/resolvers/aix/utils/odm_query.rb
facter-4.0.39 lib/facter/resolvers/aix/utils/odm_query.rb
facter-4.0.38 lib/facter/resolvers/aix/utils/odm_query.rb
facter-4.0.37 lib/facter/resolvers/aix/utils/odm_query.rb
facter-4.0.36 lib/facter/resolvers/aix/utils/odm_query.rb
facter-4.0.35 lib/facter/resolvers/aix/utils/odm_query.rb
facter-4.0.34 lib/facter/resolvers/aix/utils/odm_query.rb
facter-4.0.33 lib/facter/resolvers/aix/utils/odm_query.rb
facter-4.0.32 lib/facter/resolvers/aix/utils/odm_query.rb
facter-4.0.31 lib/facter/resolvers/aix/utils/odm_query.rb
facter-4.0.30 lib/facter/resolvers/aix/utils/odm_query.rb
facter-4.0.29 lib/resolvers/aix/utils/odm_query.rb
facter-4.0.28 lib/resolvers/aix/utils/odm_query.rb
facter-4.0.26 lib/resolvers/aix/utils/odm_query.rb
facter-4.0.25 lib/resolvers/aix/utils/odm_query.rb