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

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(app, env) ⇒ StopVm

Returns a new instance of StopVm.



20
21
22
23
24
# File 'lib/vagrant-skytap/action/stop_vm.rb', line 20

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.



18
19
20
# File 'lib/vagrant-skytap/action/stop_vm.rb', line 18

def env
  @env
end

Instance Method Details

#call(env) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/vagrant-skytap/action/stop_vm.rb', line 26

def call(env)
  vm = env[:environment].current_vm
  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