Catch remaining locations with action exceptions
This commit is contained in:
parent
a0a6230455
commit
65cd1afd4f
|
@ -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..."
|
||||
|
|
|
@ -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,10 +25,12 @@ module Vagrant
|
|||
@app.call(env)
|
||||
|
||||
if !env.error? && enable_network?
|
||||
@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|
|
||||
@env["vm"].system.enable_host_only_network(network_options)
|
||||
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|
|
||||
@env["vm"].system.enable_host_only_network(network_options)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,6 +2,8 @@ module Vagrant
|
|||
class Action
|
||||
module VM
|
||||
class ShareFolders
|
||||
include ExceptionCatcher
|
||||
|
||||
def initialize(app, env)
|
||||
@app = app
|
||||
@env = env
|
||||
|
@ -16,10 +18,12 @@ module Vagrant
|
|||
@app.call(env)
|
||||
|
||||
if !env.error?
|
||||
# Only mount and setup shared folders in the absense of an
|
||||
# error
|
||||
mount_shared_folders
|
||||
setup_unison
|
||||
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
|
||||
|
||||
|
|
Loading…
Reference in New Issue