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
module VM
class Halt
include ExceptionCatcher
def initialize(app, env)
@app = app
end
def call(env)
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
env.logger.info "Forcing shutdown of VM..."

View File

@ -4,6 +4,8 @@ module Vagrant
# Networking middleware for Vagrant. This enables host only
# networking on VMs if configured as such.
class Network
include ExceptionCatcher
def initialize(app, env)
@app = app
@env = env
@ -23,6 +25,7 @@ module Vagrant
@app.call(env)
if !env.error? && enable_network?
catch_action_exception(env) do
@env.logger.info "Enabling host only network..."
@env["vm"].system.prepare_host_only_network
@env.env.config.vm.network_options.compact.each do |network_options|
@ -30,6 +33,7 @@ module Vagrant
end
end
end
end
# Verifies that there is no collision with a bridged network interface
# for the given network options.

View File

@ -2,6 +2,8 @@ module Vagrant
class Action
module VM
class ShareFolders
include ExceptionCatcher
def initialize(app, env)
@app = app
@env = env
@ -16,12 +18,14 @@ module Vagrant
@app.call(env)
if !env.error?
catch_action_exception(env) do
# Only mount and setup shared folders in the absense of an
# error
mount_shared_folders
setup_unison
end
end
end
# This method returns an actual list of VirtualBox shared
# folders to create and their proper path.