Sha256: 01c016fdc0691382e0ada74892a49a7d21b872d59538e2620c417eedaa45facc

Contents?: true

Size: 804 Bytes

Versions: 8

Compression:

Stored size: 804 Bytes

Contents

# frozen_string_literal: true

require 'win32/registry'

module Facter
  module Resolvers
    class NetKVM < BaseResolver
      @fact_list ||= {}
      class << self
        private

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

        def read_fact_from_registry(fact_name)
          reg = ::Win32::Registry::HKEY_LOCAL_MACHINE.open('SYSTEM\\CurrentControlSet\\Services')
          build_fact_list(reg)
          reg.close

          @fact_list[fact_name]
        end

        def build_fact_list(reg)
          # rubocop:disable Performance/InefficientHashSearch
          @fact_list[:kvm] = reg.keys.include?('netkvm')
          # rubocop:enable Performance/InefficientHashSearch
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
facter-4.0.44 lib/facter/resolvers/windows/netkvm_resolver.rb
facter-4.0.43 lib/facter/resolvers/windows/netkvm_resolver.rb
facter-4.0.42 lib/facter/resolvers/windows/netkvm_resolver.rb
facter-4.0.41 lib/facter/resolvers/windows/netkvm_resolver.rb
facter-4.0.40 lib/facter/resolvers/windows/netkvm_resolver.rb
facter-4.0.39 lib/facter/resolvers/windows/netkvm_resolver.rb
facter-4.0.38 lib/facter/resolvers/windows/netkvm_resolver.rb
facter-4.0.37 lib/facter/resolvers/windows/netkvm_resolver.rb