Class: VagrantPlugins::Skytap::Action::StopVm

Inherits:
Object
  • Object
show all
Includes:
ActionHelpers
Defined in:
lib/vagrant-skytap/action/stop_vm.rb

Overview

Stops the Skytap VM and waits until stopped.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ActionHelpers

#current_vm

Constructor Details

#initialize(app, env) ⇒ StopVm



45
46
47
48
49
# File 'lib/vagrant-skytap/action/stop_vm.rb', line 45

def initialize(app, env)
  @app = app
  @env = env
  @logger = Log4r::Logger.new("vagrant_skytap::action::stop_vm")
end

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env.



43
44
45
# File 'lib/vagrant-skytap/action/stop_vm.rb', line 43

def env
  @env
end

Instance Method Details

#call(env) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/vagrant-skytap/action/stop_vm.rb', line 51

def call(env)
  vm = current_vm(env)
  if env[:force_halt]
    vm.poweroff!
  else
    begin
      vm.stop!
    rescue Errors::InstanceReadyTimeout
      @logger.info(I18n.t("vagrant_skytap.graceful_halt_vm_failed"))
      vm.poweroff!
    end
  end
  @app.call(env)
end