Sha256: 6e616a7cbf1fb04c3acf06df96943225c26d6b0e6d9f2298c352a3d5ff5cf789

Contents?: true

Size: 1.12 KB

Versions: 15

Compression:

Stored size: 1.12 KB

Contents

require "log4r"
#require 'vagrant'
require 'vagrant-skytap/api/vm'

module VagrantPlugins
  module Skytap
    module Action
      # This action reads the SSH info for the machine and puts it into the
      # `:machine_ssh_info` key in the environment.
      class UpdateHardware
        def initialize(app, env)
          @app    = app
          @logger = Log4r::Logger.new("vagrant_skytap::action::update_hardware")
        end

        def call(env)
          if vm = env[:environment].current_vm
            provider_config = vm.machine.provider_config
            hardware_info = {
              cpus:            provider_config.cpus,
              cpus_per_socket: provider_config.cpuspersocket,
              ram:             provider_config.ram,
              guestOS:         provider_config.guestos,
            }.reject{|k, v| v.nil? || v == vm.hardware[k.to_s]}

            if hardware_info.present?
              @logger.info("Updating hardware properties: #{hardware_info}")
              vm.update_with_retry(hardware: hardware_info)
            end
          end

          @app.call(env)
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
vagrant-skytap-0.2.3 lib/vagrant-skytap/action/update_hardware.rb
vagrant-skytap-0.2.2 lib/vagrant-skytap/action/update_hardware.rb
vagrant-skytap-0.2.1 lib/vagrant-skytap/action/update_hardware.rb
vagrant-skytap-0.2.0 lib/vagrant-skytap/action/update_hardware.rb
vagrant-skytap-0.1.11 lib/vagrant-skytap/action/update_hardware.rb
vagrant-skytap-0.1.10 lib/vagrant-skytap/action/update_hardware.rb
vagrant-skytap-0.1.9 lib/vagrant-skytap/action/update_hardware.rb
vagrant-skytap-0.1.8 lib/vagrant-skytap/action/update_hardware.rb
vagrant-skytap-0.1.7 lib/vagrant-skytap/action/update_hardware.rb
vagrant-skytap-0.1.6 lib/vagrant-skytap/action/update_hardware.rb
vagrant-skytap-0.1.5 lib/vagrant-skytap/action/update_hardware.rb
vagrant-skytap-0.1.4 lib/vagrant-skytap/action/update_hardware.rb
vagrant-skytap-0.1.3 lib/vagrant-skytap/action/update_hardware.rb
vagrant-skytap-0.1.2 lib/vagrant-skytap/action/update_hardware.rb
vagrant-skytap-0.1.1a lib/vagrant-skytap/action/update_hardware.rb