commands/up: if all machines autostart:false, start none [GH-4552]

This commit is contained in:
Mitchell Hashimoto 2014-10-23 11:46:22 -07:00
parent 4827469dee
commit 06defb37c7
3 changed files with 25 additions and 7 deletions

View File

@ -26,6 +26,7 @@ BUG FIXES:
doesn't support byte ranges. [GH-4479] doesn't support byte ranges. [GH-4479]
- core: Box downloads recognize more complex content types that include - core: Box downloads recognize more complex content types that include
"application/json" [GH-4525] "application/json" [GH-4525]
- core: If all sub-machines are `autostart: false`, don't start any. [GH-4552]
- commands/box: `--cert` flag works properly. [GH-4691] - commands/box: `--cert` flag works properly. [GH-4691]
- command/docker-logs: Won't crash if container is removed. [GH-3990] - command/docker-logs: Won't crash if container is removed. [GH-3990]
- command/docker-run: Synced folders will be attached properly. [GH-3873] - command/docker-run: Synced folders will be attached properly. [GH-3873]

View File

@ -58,12 +58,19 @@ module VagrantPlugins
@env.batch(options[:parallel]) do |batch| @env.batch(options[:parallel]) do |batch|
names = argv names = argv
if names.empty? if names.empty?
autostart = false
@env.vagrantfile.machine_names_and_options.each do |n, o| @env.vagrantfile.machine_names_and_options.each do |n, o|
autostart = true if o.has_key?(:autostart)
o[:autostart] = true if !o.has_key?(:autostart) o[:autostart] = true if !o.has_key?(:autostart)
names << n.to_s if o[:autostart] names << n.to_s if o[:autostart]
end end
# If we have an autostart key but no names, it means that
# all machines are autostart: false and we don't start anything.
names = nil if autostart && names.empty?
end end
if names
with_target_vms(names, provider: options[:provider]) do |machine| with_target_vms(names, provider: options[:provider]) do |machine|
@env.ui.info(I18n.t( @env.ui.info(I18n.t(
"vagrant.commands.up.upping", "vagrant.commands.up.upping",
@ -75,6 +82,12 @@ module VagrantPlugins
batch.action(machine, :up, options) batch.action(machine, :up, options)
end end
end end
end
if machines.empty?
@env.ui.info(I18n.t("vagrant.up_no_machines"))
return 0
end
# Output the post-up messages that we have, if any # Output the post-up messages that we have, if any
machines.each do |m| machines.each do |m|

View File

@ -216,6 +216,10 @@ en:
Error! Your console doesn't support hiding input. We'll ask for Error! Your console doesn't support hiding input. We'll ask for
input again below, but we WILL NOT be able to hide input. If this input again below, but we WILL NOT be able to hide input. If this
is a problem for you, ctrl-C to exit and fix your stdin. is a problem for you, ctrl-C to exit and fix your stdin.
up_no_machines: |-
No machines to bring up. This is usually because all machines are
set to `autostart: false`, which means you have to explicitly specify
the name of the machine to bring up.
upgrading_home_path_v1_5: |- upgrading_home_path_v1_5: |-
Vagrant is upgrading some internal state for the latest version. Vagrant is upgrading some internal state for the latest version.
Please do not quit Vagrant at this time. While upgrading, Vagrant Please do not quit Vagrant at this time. While upgrading, Vagrant