commands/destroy: change exit codes [GH-811]

This commit is contained in:
Mitchell Hashimoto 2014-04-15 21:29:12 -07:00
parent e78d087c27
commit 7da9ad0fa6
2 changed files with 14 additions and 4 deletions

View File

@ -24,6 +24,8 @@ FEATURES:
IMPROVEMENTS:
- commands/destroy: Exit codes changes. 0 means everything succeeded.
1 means everything was declined. 2 means some were declined. [GH-811]
- commands/ssh-config: Works without a target in multi-machine envs [GH-2844]
- guests/freebsd: Support for virtio interfaces. [GH-3082]
- guests/openbsd: Support for virtio interfaces. [GH-3082]

View File

@ -25,17 +25,25 @@ module VagrantPlugins
return if !argv
@logger.debug("'Destroy' each target VM...")
declined = false
declined = 0
total = 0
with_target_vms(argv, :reverse => true) do |vm|
action_env = vm.action(
:destroy, :force_confirm_destroy => options[:force])
declined = true if action_env.has_key?(:force_confirm_destroy_result) &&
total += 1
declined += 1 if action_env.has_key?(:force_confirm_destroy_result) &&
action_env[:force_confirm_destroy_result] == false
end
# Success if no confirms were declined
declined ? 1 : 0
# Nothing was declined
return 0 if declined == 0
# Everything was declined
return 1 if declined == total
# Some was declined
return 2
end
end
end