From 54a2f6b89ec6e872df5f861d76a1af6ed5173575 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 25 Dec 2012 09:00:06 -0800 Subject: [PATCH] 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 --- config/default.rb | 1 - plugins/kernel_v1/config/vm.rb | 6 +++++- plugins/kernel_v2/config/vm.rb | 2 -- plugins/providers/virtualbox/action/boot.rb | 5 +++-- plugins/providers/virtualbox/config.rb | 4 ++++ templates/locales/en.yml | 1 - 6 files changed, 12 insertions(+), 7 deletions(-) diff --git a/config/default.rb b/config/default.rb index db39c9d0e..f2108d8a1 100644 --- a/config/default.rb +++ b/config/default.rb @@ -16,7 +16,6 @@ Vagrant.configure("2") do |config| config.vm.box_url = nil config.vm.base_mac = nil config.vm.forward_port 22, 2222, :name => "ssh", :auto => true - config.vm.boot_mode = "headless" config.vm.guest = :linux # Share the root folder. This can then be overridden by diff --git a/plugins/kernel_v1/config/vm.rb b/plugins/kernel_v1/config/vm.rb index 9ea77a880..fd641bcc0 100644 --- a/plugins/kernel_v1/config/vm.rb +++ b/plugins/kernel_v1/config/vm.rb @@ -85,12 +85,16 @@ module VagrantPlugins def upgrade(new) 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.boot_mode = self.boot_mode if self.boot_mode new.vm.box = self.box if self.box new.vm.box_url = self.box_url if self.box_url new.vm.guest = self.guest if self.guest 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 # VirtualBox provider on the new VM. self.customizations.each do |customization| diff --git a/plugins/kernel_v2/config/vm.rb b/plugins/kernel_v2/config/vm.rb index d59aea96e..7178c3778 100644 --- a/plugins/kernel_v2/config/vm.rb +++ b/plugins/kernel_v2/config/vm.rb @@ -13,7 +13,6 @@ module VagrantPlugins attr_accessor :auto_port_range attr_accessor :base_mac - attr_accessor :boot_mode attr_accessor :box attr_accessor :box_url attr_accessor :guest @@ -122,7 +121,6 @@ module VagrantPlugins def validate(env, errors) 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.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 shared_folders.each do |name, options| diff --git a/plugins/providers/virtualbox/action/boot.rb b/plugins/providers/virtualbox/action/boot.rb index 7c4c18f0e..26a06ed7d 100644 --- a/plugins/providers/virtualbox/action/boot.rb +++ b/plugins/providers/virtualbox/action/boot.rb @@ -9,9 +9,11 @@ module VagrantPlugins def call(env) @env = env + boot_mode = @env[:machine].provider_config.gui ? "gui" : "headless" + # Start up the VM and wait for it to boot. 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 @app.call(env) @@ -41,7 +43,6 @@ module VagrantPlugins @env[:ui].error I18n.t("vagrant.actions.vm.boot.failed") false end - end end end diff --git a/plugins/providers/virtualbox/config.rb b/plugins/providers/virtualbox/config.rb index bc7f3a5bc..0428a1136 100644 --- a/plugins/providers/virtualbox/config.rb +++ b/plugins/providers/virtualbox/config.rb @@ -3,8 +3,12 @@ module VagrantPlugins class Config < Vagrant.plugin("2", :config) attr_reader :customizations + # If set to `true`, then VirtualBox will be launched with a GUI. + attr_accessor :gui + def initialize @customizations = [] + @gui = UNSET_VALUE end # Customize the VM by calling `VBoxManage` with the given diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 699a1ab43..8712e41fd 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -271,7 +271,6 @@ en: private_key_missing: "`private_key_path` file must exist: %{path}" vm: 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_not_found: "The box '%{name}' could not be found." network_invalid: |-