Mitchell Hashimoto 9cb0578c64 VM halt works.
2011-12-21 13:41:10 -08:00

30 lines
674 B
Ruby

module Vagrant
module Action
module VM
class Halt
def initialize(app, env, options=nil)
@app = app
env.merge!(options || {})
end
def call(env)
if env[:vm].state == :running
env[:vm].guest.halt if !env["force"]
if env[:vm].state != :poweredoff
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
end
end
end
end