Catch remaining locations with action exceptions

This commit is contained in:
Mitchell Hashimoto 2010-07-08 22:01:35 -07:00
parent a0a6230455
commit 65cd1afd4f
3 changed files with 22 additions and 9 deletions

View File

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

View File

@ -4,6 +4,8 @@ module Vagrant
# Networking middleware for Vagrant. This enables host only # Networking middleware for Vagrant. This enables host only
# networking on VMs if configured as such. # networking on VMs if configured as such.
class Network class Network
include ExceptionCatcher
def initialize(app, env) def initialize(app, env)
@app = app @app = app
@env = env @env = env
@ -23,10 +25,12 @@ module Vagrant
@app.call(env) @app.call(env)
if !env.error? && enable_network? if !env.error? && enable_network?
@env.logger.info "Enabling host only network..." catch_action_exception(env) do
@env["vm"].system.prepare_host_only_network @env.logger.info "Enabling host only network..."
@env.env.config.vm.network_options.compact.each do |network_options| @env["vm"].system.prepare_host_only_network
@env["vm"].system.enable_host_only_network(network_options) @env.env.config.vm.network_options.compact.each do |network_options|
@env["vm"].system.enable_host_only_network(network_options)
end
end end
end end
end end

View File

@ -2,6 +2,8 @@ module Vagrant
class Action class Action
module VM module VM
class ShareFolders class ShareFolders
include ExceptionCatcher
def initialize(app, env) def initialize(app, env)
@app = app @app = app
@env = env @env = env
@ -16,10 +18,12 @@ module Vagrant
@app.call(env) @app.call(env)
if !env.error? if !env.error?
# Only mount and setup shared folders in the absense of an catch_action_exception(env) do
# error # Only mount and setup shared folders in the absense of an
mount_shared_folders # error
setup_unison mount_shared_folders
setup_unison
end
end end
end end