Sha256: ce1bced8290cf904982fbeaa54e600c3370819265e24a0f2e017c3b93649dc9e

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

module Facter
  module Resolvers
    module Solaris
      class ZPool < BaseResolver
        @log = Facter::Log.new(self)
        @semaphore = Mutex.new
        @fact_list ||= {}
        class << self
          private

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

          def zpool_fact(fact_name)
            build_zpool_facts
            @fact_list[fact_name]
          end

          def build_zpool_facts
            output, _status = Open3.capture2('zpool upgrade -v')
            features_list = output.scan(/^\s+(\d+)/).flatten
            features_flags = output.scan(/^([a-z0-9_]+)[[:blank:]]*(\(read-only compatible\))?$/).map(&:first)

            return if features_list.empty?

            @fact_list[:zpool_featurenumbers] = features_list.join(',')
            @fact_list[:zpool_featureflags] = features_flags.join(',')
            @fact_list[:zpool_version] = features_flags.any? ? '5000' : features_list.last
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facter-4.0.20 lib/resolvers/solaris/zpool_resolver.rb
facter-4.0.19 lib/resolvers/solaris/zpool_resolver.rb
facter-4.0.18 lib/resolvers/solaris/zpool_resolver.rb