Sha256: 040f42c1f7faff142ed0dbc9cb383e798f1758f89af2a5060035c723e2aeed98

Contents?: true

Size: 894 Bytes

Versions: 2

Compression:

Stored size: 894 Bytes

Contents

# frozen_string_literal: true

module Facter
  module Windows
    class HypervisorsKvm
      FACT_NAME = 'hypervisors.kvm'

      def call_the_resolver
        fact_value = discover_provider || {} if kvm?

        ResolvedFact.new(FACT_NAME, fact_value)
      end

      private

      def kvm?
        product_name = Resolvers::DMIComputerSystem.resolve(:name)

        (Resolvers::Virtualization.resolve(:virtual) == 'kvm' || Resolvers::NetKVM.resolve(:kvm)) &&
          product_name != 'VirtualBox' && !product_name.match(/^Parallels/)
      end

      def discover_provider
        manufacturer = Resolvers::DMIBios.resolve(:manufacturer)

        return { google: true } if manufacturer == 'Google'

        return { openstack: true } if Resolvers::DMIComputerSystem.resolve(:name) =~ /^OpenStack/

        return { amazon: true } if manufacturer =~ /^Amazon/
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
facter-4.0.8.pre lib/facts/windows/hypervisors/kvm.rb
facter-4.0.7.pre lib/facts/windows/hypervisors/kvm.rb