Class: HashiCorp::VagrantVMwareDesktop::Action::Halt

Inherits:
Object
  • Object
show all
Includes:
Common
Defined in:
lib/vagrant-vmware-desktop/action/halt.rb

Overview

This stops the VMware machine.

Instance Method Summary collapse

Methods included from Common

#to_s

Constructor Details

#initialize(app, env) ⇒ Halt

Returns a new instance of Halt.



13
14
15
16
# File 'lib/vagrant-vmware-desktop/action/halt.rb', line 13

def initialize(app, env)
  @app = app
  @logger = Log4r::Logger.new("hashicorp::provider::vmware::halt")
end

Instance Method Details

#call(env) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/vagrant-vmware-desktop/action/halt.rb', line 18

def call(env)
  if env[:machine].provider.state.id == :running
    env[:ui].info(I18n.t("hashicorp.vagrant_vmware_desktop.stopping"))
    stop_mode = env[:force_halt] ? "hard" : "soft"
    env[:machine].provider.driver.stop(stop_mode)
  end

  @app.call(env)
end