Sha256: 1a2c623589f6f415bef4f9c7790d84cedf3630bb1f25ba01a709fee9937dd974

Contents?: true

Size: 1.11 KB

Versions: 32

Compression:

Stored size: 1.11 KB

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
  module Util
    module Aix
      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
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
facter-4.5.2 lib/facter/util/aix/odm_query.rb
facter-4.5.1 lib/facter/util/aix/odm_query.rb
facter-4.5.0 lib/facter/util/aix/odm_query.rb
facter-4.4.3 lib/facter/util/aix/odm_query.rb
facter-4.4.2 lib/facter/util/aix/odm_query.rb
facter-4.4.1 lib/facter/util/aix/odm_query.rb
facter-4.4.0 lib/facter/util/aix/odm_query.rb
facter-4.3.1 lib/facter/util/aix/odm_query.rb
facter-4.3.0 lib/facter/util/aix/odm_query.rb
facter-4.2.14 lib/facter/util/aix/odm_query.rb
facter-4.2.13 lib/facter/util/aix/odm_query.rb
facter-4.2.12 lib/facter/util/aix/odm_query.rb
facter-4.2.11 lib/facter/util/aix/odm_query.rb
facter-4.2.10 lib/facter/util/aix/odm_query.rb
facter-4.2.9 lib/facter/util/aix/odm_query.rb
facter-4.2.8 lib/facter/util/aix/odm_query.rb
facter-4.2.7 lib/facter/util/aix/odm_query.rb
facter-4.2.6 lib/facter/util/aix/odm_query.rb
facter-4.2.5 lib/facter/util/aix/odm_query.rb
facter-4.2.4 lib/facter/util/aix/odm_query.rb