Sha256: c1ae971172ed3bba56fba7a9dcae8391c7bbb91a25cc345f66a14042c1f4c665

Contents?: true

Size: 1.02 KB

Versions: 54

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

module Facts
  module Linux
    module Hypervisors
      class Vmware
        FACT_NAME = 'hypervisors.vmware'

        def initialize
          @log = Facter::Log.new(self)
        end

        def call_the_resolver
          if vmware?
            @log.debug('Vmware hypervisor detected')
            fact_value = {}

            version = Facter::Resolvers::DmiDecode.resolve(:vmware_version)
            fact_value[:version] = version if version && !version.empty?

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

          @log.debug('No Vmware hypervisor detected.')
          []
        end

        private

        def vmware?
          Facter::Resolvers::VirtWhat.resolve(:vm) == 'vmware' ||
            Facter::Resolvers::Linux::DmiBios.resolve(:product_name) == 'VMware' ||
            Facter::Resolvers::Lspci.resolve(:vm) == 'vmware' ||
            Facter::Resolvers::Linux::DmiBios.resolve(:sys_vendor) == 'VMware, Inc.'
        end
      end
    end
  end
end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
facter-4.0.44 lib/facter/facts/linux/hypervisors/vmware.rb
facter-4.0.43 lib/facter/facts/linux/hypervisors/vmware.rb
facter-4.0.42 lib/facter/facts/linux/hypervisors/vmware.rb
facter-4.0.41 lib/facter/facts/linux/hypervisors/vmware.rb
facter-4.0.40 lib/facter/facts/linux/hypervisors/vmware.rb
facter-4.0.39 lib/facter/facts/linux/hypervisors/vmware.rb
facter-4.0.38 lib/facter/facts/linux/hypervisors/vmware.rb
facter-4.0.37 lib/facter/facts/linux/hypervisors/vmware.rb
facter-4.0.36 lib/facter/facts/linux/hypervisors/vmware.rb
facter-4.0.35 lib/facter/facts/linux/hypervisors/vmware.rb
facter-4.0.34 lib/facter/facts/linux/hypervisors/vmware.rb
facter-4.0.33 lib/facter/facts/linux/hypervisors/vmware.rb
facter-4.0.32 lib/facter/facts/linux/hypervisors/vmware.rb
facter-4.0.31 lib/facter/facts/linux/hypervisors/vmware.rb