Change boot_mode to a provider config `gui`.

OLD:

config.vm.boot_mode = :gui

NEW:

config.vm.provider :virtualbox do |vb|
  vb.gui = true
end
This commit is contained in:
Mitchell Hashimoto 2012-12-25 09:00:06 -08:00
parent 2cfc5986d2
commit 54a2f6b89e
6 changed files with 12 additions and 7 deletions

View File

@ -16,7 +16,6 @@ Vagrant.configure("2") do |config|
config.vm.box_url = nil config.vm.box_url = nil
config.vm.base_mac = nil config.vm.base_mac = nil
config.vm.forward_port 22, 2222, :name => "ssh", :auto => true config.vm.forward_port 22, 2222, :name => "ssh", :auto => true
config.vm.boot_mode = "headless"
config.vm.guest = :linux config.vm.guest = :linux
# Share the root folder. This can then be overridden by # Share the root folder. This can then be overridden by

View File

@ -85,12 +85,16 @@ module VagrantPlugins
def upgrade(new) def upgrade(new)
new.vm.auto_port_range = self.auto_port_range if self.auto_port_range new.vm.auto_port_range = self.auto_port_range if self.auto_port_range
new.vm.base_mac = self.base_mac if self.base_mac new.vm.base_mac = self.base_mac if self.base_mac
new.vm.boot_mode = self.boot_mode if self.boot_mode
new.vm.box = self.box if self.box new.vm.box = self.box if self.box
new.vm.box_url = self.box_url if self.box_url new.vm.box_url = self.box_url if self.box_url
new.vm.guest = self.guest if self.guest new.vm.guest = self.guest if self.guest
new.vm.host_name = self.host_name if self.host_name new.vm.host_name = self.host_name if self.host_name
if self.boot_mode
# Enable the GUI if the boot mode is GUI.
new.vm.providers[:virtualbox].config.gui = (self.boot_mode.to_s == "gui")
end
# If we have VM customizations, then we enable them on the # If we have VM customizations, then we enable them on the
# VirtualBox provider on the new VM. # VirtualBox provider on the new VM.
self.customizations.each do |customization| self.customizations.each do |customization|

View File

@ -13,7 +13,6 @@ module VagrantPlugins
attr_accessor :auto_port_range attr_accessor :auto_port_range
attr_accessor :base_mac attr_accessor :base_mac
attr_accessor :boot_mode
attr_accessor :box attr_accessor :box
attr_accessor :box_url attr_accessor :box_url
attr_accessor :guest attr_accessor :guest
@ -122,7 +121,6 @@ module VagrantPlugins
def validate(env, errors) def validate(env, errors)
errors.add(I18n.t("vagrant.config.vm.box_missing")) if !box errors.add(I18n.t("vagrant.config.vm.box_missing")) if !box
errors.add(I18n.t("vagrant.config.vm.box_not_found", :name => box)) if box && !box_url && !env.boxes.find(box, :virtualbox) errors.add(I18n.t("vagrant.config.vm.box_not_found", :name => box)) if box && !box_url && !env.boxes.find(box, :virtualbox)
errors.add(I18n.t("vagrant.config.vm.boot_mode_invalid")) if ![:headless, :gui].include?(boot_mode.to_sym)
errors.add(I18n.t("vagrant.config.vm.base_mac_invalid")) if env.boxes.find(box, :virtualbox) && !base_mac errors.add(I18n.t("vagrant.config.vm.base_mac_invalid")) if env.boxes.find(box, :virtualbox) && !base_mac
shared_folders.each do |name, options| shared_folders.each do |name, options|

View File

@ -9,9 +9,11 @@ module VagrantPlugins
def call(env) def call(env)
@env = env @env = env
boot_mode = @env[:machine].provider_config.gui ? "gui" : "headless"
# Start up the VM and wait for it to boot. # Start up the VM and wait for it to boot.
env[:ui].info I18n.t("vagrant.actions.vm.boot.booting") env[:ui].info I18n.t("vagrant.actions.vm.boot.booting")
env[:machine].provider.driver.start(@env[:machine].config.vm.boot_mode) env[:machine].provider.driver.start(boot_mode)
raise Errors::VMFailedToBoot if !wait_for_boot raise Errors::VMFailedToBoot if !wait_for_boot
@app.call(env) @app.call(env)
@ -41,7 +43,6 @@ module VagrantPlugins
@env[:ui].error I18n.t("vagrant.actions.vm.boot.failed") @env[:ui].error I18n.t("vagrant.actions.vm.boot.failed")
false false
end end
end end
end end
end end

View File

@ -3,8 +3,12 @@ module VagrantPlugins
class Config < Vagrant.plugin("2", :config) class Config < Vagrant.plugin("2", :config)
attr_reader :customizations attr_reader :customizations
# If set to `true`, then VirtualBox will be launched with a GUI.
attr_accessor :gui
def initialize def initialize
@customizations = [] @customizations = []
@gui = UNSET_VALUE
end end
# Customize the VM by calling `VBoxManage` with the given # Customize the VM by calling `VBoxManage` with the given

View File

@ -271,7 +271,6 @@ en:
private_key_missing: "`private_key_path` file must exist: %{path}" private_key_missing: "`private_key_path` file must exist: %{path}"
vm: vm:
base_mac_invalid: "Base MAC address for eth0/NAT must be set. Contact box maintainer for more information." base_mac_invalid: "Base MAC address for eth0/NAT must be set. Contact box maintainer for more information."
boot_mode_invalid: "Boot mode must be one of: headless or gui"
box_missing: "A box must be specified." box_missing: "A box must be specified."
box_not_found: "The box '%{name}' could not be found." box_not_found: "The box '%{name}' could not be found."
network_invalid: |- network_invalid: |-