Sha256: 9bae0832ff3f97603d7c1f85c5de4a6ef606f9fa9c7257ee37e3b85eeea00733

Contents?: true

Size: 932 Bytes

Versions: 5

Compression:

Stored size: 932 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 = []
    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, _stderr, _s = Open3.capture3("#{query} #{repo}")
      end
      result
    end

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
facter-4.0.20 lib/resolvers/aix/utils/odm_query.rb
facter-4.0.19 lib/resolvers/aix/utils/odm_query.rb
facter-4.0.18 lib/resolvers/aix/utils/odm_query.rb
facter-4.0.17 lib/resolvers/aix/utils/odm_query.rb
facter-4.0.16 lib/resolvers/aix/utils/odm_query.rb