Sha256: 0e78c0d3ff86abd061b63f7349ae45a560b5500ef9dcf4d56a06df865949163f

Contents?: true

Size: 919 Bytes

Versions: 7

Compression:

Stored size: 919 Bytes

Contents

# frozen_string_literal: true

module Facts
  module Macosx
    class Virtual
      FACT_NAME = 'virtual'

      def call_the_resolver
        fact_value = check_vmware || check_virtualbox || check_parallels || 'physical'

        Facter::ResolvedFact.new(FACT_NAME, fact_value)
      end

      private

      def check_vmware
        model_identifier = Facter::Resolvers::Macosx::SystemProfiler.resolve(:model_identifier)
        'vmware' if model_identifier&.start_with?('VMware')
      end

      def check_virtualbox
        boot_rom_version = Facter::Resolvers::Macosx::SystemProfiler.resolve(:boot_rom_version)
        'virtualbox' if boot_rom_version&.start_with?('VirtualBox')
      end

      def check_parallels
        subsystem_vendor_id = Facter::Resolvers::Macosx::SystemProfiler.resolve(:subsystem_vendor_id)
        'parallels' if subsystem_vendor_id&.start_with?('0x1ab8')
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
facter-4.10.0 lib/facter/facts/macosx/virtual.rb
facter-4.9.0 lib/facter/facts/macosx/virtual.rb
facter-4.8.0 lib/facter/facts/macosx/virtual.rb
facter-4.7.1 lib/facter/facts/macosx/virtual.rb
facter-4.7.0 lib/facter/facts/macosx/virtual.rb
facter-4.6.1 lib/facter/facts/macosx/virtual.rb
facter-4.6.0 lib/facter/facts/macosx/virtual.rb