Class: Vagrant::Action::VM::Halt
- Inherits:
-
Object
- Object
- Vagrant::Action::VM::Halt
- Defined in:
- lib/vagrant/action/vm/halt.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env, options = nil) ⇒ Halt
constructor
A new instance of Halt.
Constructor Details
#initialize(app, env, options = nil) ⇒ Halt
Returns a new instance of Halt.
5 6 7 8 |
# File 'lib/vagrant/action/vm/halt.rb', line 5 def initialize(app, env, =nil) @app = app env.merge!( || {}) end |
Instance Method Details
#call(env) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/vagrant/action/vm/halt.rb', line 10 def call(env) if env[:vm].state == :running if !env["force"] env[:ui].info I18n.t("vagrant.actions.vm.halt.graceful") env[:vm].guest.halt end if env[:vm].state != :poweroff env[:ui].info I18n.t("vagrant.actions.vm.halt.force") env[:vm].driver.halt end # Sleep for a second to verify that the VM properly # cleans itself up sleep 1 if !env["vagrant.test"] end @app.call(env) end |