Class: VagrantPlugins::Utm::Action::ForcedHalt

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant_utm/action/forced_halt.rb

Overview

This action is responsible for halting (stopping) the VM.

Instance Method Summary collapse

Constructor Details

#initialize(app, _env) ⇒ ForcedHalt

Returns a new instance of ForcedHalt.



8
9
10
# File 'lib/vagrant_utm/action/forced_halt.rb', line 8

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

Instance Method Details

#call(env) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/vagrant_utm/action/forced_halt.rb', line 12

def call(env)
  current_state = env[:machine].state.id
  if current_state == :started
    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.
  sleep 1 unless env["vagrant.test"]

  @app.call(env)
end