commands/up: flag --no-destroy-on-error [GH-2011]

This commit is contained in:
Mitchell Hashimoto 2013-08-29 12:12:53 -07:00
parent 9e476330f4
commit c2012ff944
3 changed files with 11 additions and 0 deletions

View File

@ -11,6 +11,8 @@ FEATURES:
`vagrant destroy`. [GH-1302] `vagrant destroy`. [GH-1302]
- Chef Client provisioner will now clean up the node/client using - Chef Client provisioner will now clean up the node/client using
`knife` if configured to do so. `knife` if configured to do so.
- `vagrant up` has a `--no-destroy-on-error` flag that will not destroy
the VM if a fatal error occurs. [GH-2011]
IMPROVEMENTS: IMPROVEMENTS:

View File

@ -11,6 +11,7 @@ module VagrantPlugins
def execute def execute
options = {} options = {}
options[:destroy_on_error] = true
options[:parallel] = true options[:parallel] = true
opts = OptionParser.new do |o| opts = OptionParser.new do |o|
@ -19,6 +20,11 @@ module VagrantPlugins
build_start_options(o, options) build_start_options(o, options)
o.on("--[no-]destroy-on-error",
"Destroy machine if any fatal error happens (default to true).") do |destroy|
options[:destroy_on_error] = destroy
end
o.on("--[no-]parallel", o.on("--[no-]parallel",
"Enable or disable parallelism if provider supports it.") do |parallel| "Enable or disable parallelism if provider supports it.") do |parallel|
options[:parallel] = parallel options[:parallel] = parallel

View File

@ -36,6 +36,9 @@ module VagrantPlugins
if env[:machine].provider.state.id != :not_created if env[:machine].provider.state.id != :not_created
return if env["vagrant.error"].is_a?(Vagrant::Errors::VagrantError) return if env["vagrant.error"].is_a?(Vagrant::Errors::VagrantError)
# If we're not supposed to destroy on error then just return
return if !env[:destroy_on_error]
# Interrupted, destroy the VM. We note that we don't want to # Interrupted, destroy the VM. We note that we don't want to
# validate the configuration here, and we don't want to confirm # validate the configuration here, and we don't want to confirm
# we want to destroy. # we want to destroy.