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]
- core: Box downloads recognize more complex content types that include
"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]
- command/docker-logs: Won't crash if container is removed. [GH-3990]
- command/docker-run: Synced folders will be attached properly. [GH-3873]

View File

@ -58,24 +58,37 @@ module VagrantPlugins
@env.batch(options[:parallel]) do |batch|
names = argv
if names.empty?
autostart = false
@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)
names << n.to_s if o[:autostart]
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
with_target_vms(names, provider: options[:provider]) do |machine|
@env.ui.info(I18n.t(
"vagrant.commands.up.upping",
name: machine.name,
provider: machine.provider_name))
if names
with_target_vms(names, provider: options[:provider]) do |machine|
@env.ui.info(I18n.t(
"vagrant.commands.up.upping",
name: machine.name,
provider: machine.provider_name))
machines << machine
machines << machine
batch.action(machine, :up, options)
batch.action(machine, :up, options)
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
machines.each do |m|
next if !m.config.vm.post_up_message

View File

@ -216,6 +216,10 @@ en:
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
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: |-
Vagrant is upgrading some internal state for the latest version.
Please do not quit Vagrant at this time. While upgrading, Vagrant