Class: VagrantPlugins::ProviderVeertu::Action::ForcedHalt

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-veertu/action/forced_halt.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ ForcedHalt

Returns a new instance of ForcedHalt.



5
6
7
# File 'lib/vagrant-veertu/action/forced_halt.rb', line 5

def initialize(app, env)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/vagrant-veertu/action/forced_halt.rb', line 9

def call(env)
  current_state = env[:machine].state.id
  if current_state == :running || current_state == :gurumeditation
    env[:ui].info I18n.t("vagrant.actions.vm.halt.force")
    env[:machine].provider.driver.halt
  end

  # Sleep for a second to verify that the VM properly
  # cleans itself up. Silly Veertu.
  sleep 1 if !env["vagrant.test"]

  @app.call(env)
end