Sha256: 261dc3d8333d1f81b1e14a40ad047e6e2a57b96474125a17b40e61a10d3bf687

Contents?: true

Size: 652 Bytes

Versions: 8

Compression:

Stored size: 652 Bytes

Contents

# frozen_string_literal: true

module Facter
  module Resolvers
    class Vmware < BaseResolver
      @fact_list ||= {}

      class << self
        private

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

        def vmware_command(fact_name)
          output = Facter::Core::Execution.execute('vmware -v', logger: log)
          return if output.empty?

          parts = output.split("\s")
          return unless parts.size.equal?(2)

          @fact_list[:vm] = "#{parts[0].downcase}_#{parts[1].downcase}"
          @fact_list[fact_name]
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

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