2010-07-08 22:01:35 -07:00

30 lines
610 B
Ruby

module Vagrant
class Action
module VM
class Halt
include ExceptionCatcher
def initialize(app, env)
@app = app
end
def call(env)
if env["vm"].vm.running?
if !env["force"]
catch_action_exception(env) { env["vm"].system.halt }
return if env.error?
end
if env["vm"].vm.state(true) != :powered_off
env.logger.info "Forcing shutdown of VM..."
env["vm"].vm.stop
end
end
@app.call(env)
end
end
end
end
end