diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c19ace27..213645303 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,24 @@ -## 0.6.9 (unreleased) +## 0.7.0.beta2 (unreleased) + + - Use numeric uid/gid in mounting shared folders to increase portability. [GH-252] + - HTTP downloading follows redirects. [GH-163] + - Downloaders have clearer output to note what they're doing. + - Shared folders with no guest path are not automounted. [GH-184] + - Boxes downloaded during `vagrant up` reload the Vagrantfile config, which + fixes a problem with box settings not being properly loaded. [GH-231] + +## 0.7.0.beta (December 24, 2010) + + - VirtualBox 4.0 support. Support for VirtualBox 3.2 is _dropped_, since + the API is so different. Stay with the 0.6.x series if you have VirtualBox + 3.2.x. + - Changed the unused host only network destroy mechanism to check for + uselessness after the VM is destroyed. This should result in more accurate + checks. + - Networks are no longer disabled upon halt/destroy. With the above + change, its unnecessary. + +## 0.6.9 (December 21, 2010) - Puppet provisioner. [GH-223] - Solaris system configurable to use `sudo`. @@ -10,6 +30,8 @@ - Enumerate VMs in a multi-VM environment in order they were defined. [GH-244] - Check for VM boot changed to use `timeout` library, which works better with Windows. - Show special error if VirtualBox not detected on 64-bit Windows. + - Show error to Windows users attempting to use host only networking since + it doesn't work yet. ## 0.6.8 (November 30, 2010) diff --git a/README.md b/README.md index 308e48cc5..443b9b615 100644 --- a/README.md +++ b/README.md @@ -54,3 +54,8 @@ be installed with a simple `gem install bundler --pre`. Afterwords, do the follo rake This will run the test suite, which should come back all green! Then you're good to go! + +If you want to run Vagrant without having to install the gem, you may use `bundle exec`, +like so: + + bundle exec bin/vagrant help diff --git a/lib/vagrant/action.rb b/lib/vagrant/action.rb index 4f967f635..367d93492 100644 --- a/lib/vagrant/action.rb +++ b/lib/vagrant/action.rb @@ -94,7 +94,7 @@ module Vagrant callable = callable_id callable = Builder.new.use(callable_id) if callable_id.kind_of?(Class) callable = self.class.actions[callable_id] if callable_id.kind_of?(Symbol) - raise ArgumentError.new("Argument to run must be a callable object or registered action.") if !callable || !callable.respond_to?(:call) + raise ArgumentError, "Argument to run must be a callable object or registered action." if !callable || !callable.respond_to?(:call) action_environment = Action::Environment.new(env) action_environment.merge!(options || {}) diff --git a/lib/vagrant/action/box/download.rb b/lib/vagrant/action/box/download.rb index 7b0774594..32b008bc9 100644 --- a/lib/vagrant/action/box/download.rb +++ b/lib/vagrant/action/box/download.rb @@ -33,7 +33,7 @@ module Vagrant end end - raise Errors::BoxDownloadUnknownType.new if !@downloader + raise Errors::BoxDownloadUnknownType if !@downloader @downloader.prepare(@env["box"].uri) true @@ -64,7 +64,6 @@ module Vagrant end def download_to(f) - @env.ui.info I18n.t("vagrant.actions.box.download.copying") @downloader.download!(@env["box"].uri, f) end end diff --git a/lib/vagrant/action/box/unpackage.rb b/lib/vagrant/action/box/unpackage.rb index 49be2ce6b..d4b630b19 100644 --- a/lib/vagrant/action/box/unpackage.rb +++ b/lib/vagrant/action/box/unpackage.rb @@ -37,7 +37,7 @@ module Vagrant end def setup_box_directory - raise Errors::BoxAlreadyExists.new(:name => @env["box"].name) if File.directory?(@env["box"].directory) + raise Errors::BoxAlreadyExists, :name => @env["box"].name if File.directory?(@env["box"].directory) FileUtils.mkdir_p(@env["box"].directory) @box_directory = @env["box"].directory diff --git a/lib/vagrant/action/box/verify.rb b/lib/vagrant/action/box/verify.rb index 40ed305f2..716fa398f 100644 --- a/lib/vagrant/action/box/verify.rb +++ b/lib/vagrant/action/box/verify.rb @@ -12,7 +12,7 @@ module Vagrant env.ui.info I18n.t("vagrant.actions.box.verify.verifying") VirtualBox::Appliance.new(env["box"].ovf_file.to_s) rescue Exception - raise Errors::BoxVerificationFailed.new + raise Errors::BoxVerificationFailed end @app.call(env) diff --git a/lib/vagrant/action/builtin.rb b/lib/vagrant/action/builtin.rb index f1aef3892..132701787 100644 --- a/lib/vagrant/action/builtin.rb +++ b/lib/vagrant/action/builtin.rb @@ -30,7 +30,6 @@ module Vagrant register(:halt, Builder.new do use VM::DiscardState use VM::Halt - use VM::DisableNetworks end) # suspend - Suspends the VM @@ -62,9 +61,9 @@ module Vagrant register(:destroy, Builder.new do use Action[:halt], :force => true use VM::ClearNFSExports - use VM::DestroyUnusedNetworkInterfaces use VM::Destroy use VM::CleanMachineFolder + use VM::DestroyUnusedNetworkInterfaces end) # package - Export and package the VM diff --git a/lib/vagrant/action/general/package.rb b/lib/vagrant/action/general/package.rb index 58b36b540..a53cecda7 100644 --- a/lib/vagrant/action/general/package.rb +++ b/lib/vagrant/action/general/package.rb @@ -28,8 +28,8 @@ module Vagrant def call(env) @env = env - raise Errors::PackageOutputExists.new if File.exist?(tar_path) - raise Errors::PackageRequiresDirectory.new if !@env["package.directory"] || !File.directory?(@env["package.directory"]) + raise Errors::PackageOutputExists if File.exist?(tar_path) + raise Errors::PackageRequiresDirectory if !@env["package.directory"] || !File.directory?(@env["package.directory"]) verify_files_to_copy compress @@ -57,7 +57,7 @@ module Vagrant def verify_files_to_copy files_to_copy.each do |file, _| - raise Errors::PackageIncludeMissing.new(:file => file) if !File.exist?(file) + raise Errors::PackageIncludeMissing, :file => file if !File.exist?(file) end end diff --git a/lib/vagrant/action/vm/boot.rb b/lib/vagrant/action/vm/boot.rb index ed801f538..a55eafdd1 100644 --- a/lib/vagrant/action/vm/boot.rb +++ b/lib/vagrant/action/vm/boot.rb @@ -12,7 +12,7 @@ module Vagrant # Start up the VM and wait for it to boot. boot - raise Errors::VMFailedToBoot.new if !wait_for_boot + raise Errors::VMFailedToBoot if !wait_for_boot @app.call(env) end diff --git a/lib/vagrant/action/vm/check_box.rb b/lib/vagrant/action/vm/check_box.rb index 7f80efe49..e9838a356 100644 --- a/lib/vagrant/action/vm/check_box.rb +++ b/lib/vagrant/action/vm/check_box.rb @@ -8,15 +8,16 @@ module Vagrant def call(env) box_name = env["config"].vm.box - raise Errors::BoxNotSpecified.new if !box_name + raise Errors::BoxNotSpecified if !box_name if !env.env.boxes.find(box_name) box_url = env["config"].vm.box_url - raise Errors::BoxSpecifiedDoesntExist.new(:name => box_name) if !box_url + raise Errors::BoxSpecifiedDoesntExist, :name => box_name if !box_url env.ui.info I18n.t("vagrant.actions.vm.check_box.not_found", :name => box_name) Vagrant::Box.add(env.env, box_name, box_url) env["boxes"].reload! + env.env.reload_config! end @app.call(env) diff --git a/lib/vagrant/action/vm/clean_machine_folder.rb b/lib/vagrant/action/vm/clean_machine_folder.rb index 86975bc12..5df3cf6fe 100644 --- a/lib/vagrant/action/vm/clean_machine_folder.rb +++ b/lib/vagrant/action/vm/clean_machine_folder.rb @@ -31,7 +31,7 @@ module Vagrant keep = Dir["#{f}/**/*"].find do |d| # Find a file that doesn't have ".xml-prev" as the suffix, # which signals that we want to keep this folder - File.file?(d) && !(File.basename(d) =~ /\.xml-prev$/) + File.file?(d) && !(File.basename(d) =~ /\.vbox-prev$/) end FileUtils.rm_rf(f) if !keep diff --git a/lib/vagrant/action/vm/destroy.rb b/lib/vagrant/action/vm/destroy.rb index eb9bba409..9d3be98df 100644 --- a/lib/vagrant/action/vm/destroy.rb +++ b/lib/vagrant/action/vm/destroy.rb @@ -8,7 +8,7 @@ module Vagrant def call(env) env.ui.info I18n.t("vagrant.actions.vm.destroy.destroying") - env["vm"].vm.destroy(:destroy_medium => :delete) + env["vm"].vm.destroy env["vm"].vm = nil @app.call(env) diff --git a/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb b/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb index 66b903146..0730d1ab6 100644 --- a/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb +++ b/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb @@ -9,20 +9,15 @@ module Vagrant end def call(env) - # We need to check if the host only network specified by any - # of the adapters would not have any more clients if it was - # destroyed. And if so, then destroy the host only network - # itself. - interfaces = env["vm"].vm.network_adapters.collect do |adapter| - adapter.host_interface_object - end + # Destroy all the host only network adapters which are empty. + VirtualBox::Global.global(true).host.network_interfaces.each do |iface| + # We only care about host only interfaces + next if iface.interface_type != :host_only - interfaces.compact.uniq.each do |interface| - # Destroy the network interface if there is only one - # attached VM (which must be this VM) - if interface.attached_vms.length == 1 + # Destroy it if there is nothing attached + if iface.attached_vms.empty? env.ui.info I18n.t("vagrant.actions.vm.destroy_network.destroying") - interface.destroy + iface.destroy end end diff --git a/lib/vagrant/action/vm/disable_networks.rb b/lib/vagrant/action/vm/disable_networks.rb deleted file mode 100644 index d8764d6dc..000000000 --- a/lib/vagrant/action/vm/disable_networks.rb +++ /dev/null @@ -1,34 +0,0 @@ -module Vagrant - class Action - module VM - # Middleware to disable all host only networks on the - # VM - class DisableNetworks - def initialize(app, env) - @app = app - @env = env - end - - def call(env) - if env["vm"].created? - logged = false - - env["vm"].vm.network_adapters.each do |adapter| - next if adapter.attachment_type != :host_only - - if !logged - env.ui.info I18n.t("vagrant.actions.vm.disable_networks.disabling") - logged = true - end - - adapter.enabled = false - adapter.save - end - end - - @app.call(env) - end - end - end - end -end diff --git a/lib/vagrant/action/vm/export.rb b/lib/vagrant/action/vm/export.rb index 98f6ffe84..3b99389b0 100644 --- a/lib/vagrant/action/vm/export.rb +++ b/lib/vagrant/action/vm/export.rb @@ -14,7 +14,7 @@ module Vagrant def call(env) @env = env - raise Errors::VMPowerOffToPackage.new if !@env["vm"].vm.powered_off? + raise Errors::VMPowerOffToPackage if !@env["vm"].vm.powered_off? setup_temp_dir export diff --git a/lib/vagrant/action/vm/forward_ports.rb b/lib/vagrant/action/vm/forward_ports.rb index 4f6ba1d6b..d5f38dced 100644 --- a/lib/vagrant/action/vm/forward_ports.rb +++ b/lib/vagrant/action/vm/forward_ports.rb @@ -23,7 +23,7 @@ module Vagrant # 1024, which causes the forwarded ports to fail. def threshold_check @env.env.config.vm.forwarded_ports.each do |name, options| - raise Errors::ForwardPortBelowThreshold.new if options[:hostport] <= 1024 + raise Errors::ForwardPortBelowThreshold if options[:hostport] <= 1024 end end @@ -47,9 +47,9 @@ module Vagrant if !options[:auto] # Auto fixing is disabled for this port forward, so we # must throw an error so the user can fix it. - raise Errors::ForwardPortCollision.new(:name => name, - :host_port => options[:hostport].to_s, - :guest_port => options[:guestport].to_s) + raise Errors::ForwardPortCollision, :name => name, + :host_port => options[:hostport].to_s, + :guest_port => options[:guestport].to_s end # Get the auto port range and get rid of the used ports and @@ -60,10 +60,10 @@ module Vagrant range -= existing_ports if range.empty? - raise Errors::ForwardPortAutolistEmpty.new(:vm_name => @env["vm"].name, - :name => name, - :host_port => options[:hostport].to_s, - :guest_port => options[:guestport].to_s) + raise Errors::ForwardPortAutolistEmpty, :vm_name => @env["vm"].name, + :name => name, + :host_port => options[:hostport].to_s, + :guest_port => options[:guestport].to_s end # Set the port up to be the first one and add that port to diff --git a/lib/vagrant/action/vm/import.rb b/lib/vagrant/action/vm/import.rb index 33e781a2f..7ee053780 100644 --- a/lib/vagrant/action/vm/import.rb +++ b/lib/vagrant/action/vm/import.rb @@ -15,7 +15,7 @@ module Vagrant end # Flag as erroneous and return if import failed - raise Errors::VMImportFailure.new if !env["vm"].vm + raise Errors::VMImportFailure if !env["vm"].vm # Import completed successfully. Continue the chain @app.call(env) diff --git a/lib/vagrant/action/vm/network.rb b/lib/vagrant/action/vm/network.rb index c49a1a7f3..afed943cc 100644 --- a/lib/vagrant/action/vm/network.rb +++ b/lib/vagrant/action/vm/network.rb @@ -8,8 +8,12 @@ module Vagrant @app = app @env = env + if enable_network? && Util::Platform.windows? + raise Errors::NetworkNotImplemented + end + env["config"].vm.network_options.compact.each do |network_options| - raise Errors::NetworkCollision.new if !verify_no_bridge_collision(network_options) + raise Errors::NetworkCollision if !verify_no_bridge_collision(network_options) end end @@ -83,7 +87,7 @@ module Vagrant end end - raise Errors::NetworkNotFound.new(:name => net_options[:name]) if net_options[:name] + raise Errors::NetworkNotFound, :name => net_options[:name] if net_options[:name] # One doesn't exist, create it. @env.ui.info I18n.t("vagrant.actions.vm.network.creating") diff --git a/lib/vagrant/action/vm/nfs.rb b/lib/vagrant/action/vm/nfs.rb index d44e3d7d2..020036b93 100644 --- a/lib/vagrant/action/vm/nfs.rb +++ b/lib/vagrant/action/vm/nfs.rb @@ -113,7 +113,9 @@ module Vagrant def mount_folders @env.ui.info I18n.t("vagrant.actions.vm.nfs.mounting") - @env["vm"].system.mount_nfs(host_ip, folders) + # Only mount the folders which have a guest path specified + am_folders = folders.select { |folder| folder[:guestpath] } + @env["vm"].system.mount_nfs(host_ip, am_folders) end # Returns the IP address of the first host only network adapter @@ -147,9 +149,9 @@ module Vagrant # Verifies that the host is set and supports NFS. def verify_settings - raise Errors::NFSHostRequired.new if @env["host"].nil? - raise Errors::NFSNotSupported.new if !@env["host"].nfs? - raise Errors::NFSNoHostNetwork.new if @env["config"].vm.network_options.empty? + raise Errors::NFSHostRequired if @env["host"].nil? + raise Errors::NFSNotSupported if !@env["host"].nfs? + raise Errors::NFSNoHostNetwork if @env["config"].vm.network_options.empty? end end end diff --git a/lib/vagrant/action/vm/provision.rb b/lib/vagrant/action/vm/provision.rb index 3fdc5afc3..662cc9a68 100644 --- a/lib/vagrant/action/vm/provision.rb +++ b/lib/vagrant/action/vm/provision.rb @@ -28,7 +28,7 @@ module Vagrant if provisioner.is_a?(Class) @provisioner = provisioner.new(@env) - raise Errors::ProvisionInvalidClass.new if !@provisioner.is_a?(Provisioners::Base) + raise Errors::ProvisionInvalidClass if !@provisioner.is_a?(Provisioners::Base) elsif provisioner.is_a?(Symbol) # We have a few hard coded provisioners for built-ins mapping = { @@ -38,7 +38,7 @@ module Vagrant } provisioner_klass = mapping[provisioner] - raise Errors::ProvisionUnknownType.new(:provisioner => provisioner.to_s) if provisioner_klass.nil? + raise Errors::ProvisionUnknownType, :provisioner => provisioner.to_s if provisioner_klass.nil? @provisioner = provisioner_klass.new(@env) end diff --git a/lib/vagrant/action/vm/share_folders.rb b/lib/vagrant/action/vm/share_folders.rb index 36bd451a6..197334607 100644 --- a/lib/vagrant/action/vm/share_folders.rb +++ b/lib/vagrant/action/vm/share_folders.rb @@ -50,10 +50,17 @@ module Vagrant @env["vm"].ssh.execute do |ssh| shared_folders.each do |name, data| - @env.ui.info(I18n.t("vagrant.actions.vm.share_folders.mounting_entry", - :name => name, - :guest_path => data[:guestpath])) - @env["vm"].system.mount_shared_folder(ssh, name, data[:guestpath]) + if data[:guestpath] + # Guest path specified, so mount the folder to specified point + @env.ui.info(I18n.t("vagrant.actions.vm.share_folders.mounting_entry", + :name => name, + :guest_path => data[:guestpath])) + @env["vm"].system.mount_shared_folder(ssh, name, data[:guestpath]) + else + # If no guest path is specified, then automounting is disabled + @env.ui.info(I18n.t("vagrant.actions.vm.share_folders.nomount_entry", + :name => name)) + end end end end diff --git a/lib/vagrant/action/warden.rb b/lib/vagrant/action/warden.rb index 7b8c4f80f..68e5dbc99 100644 --- a/lib/vagrant/action/warden.rb +++ b/lib/vagrant/action/warden.rb @@ -24,9 +24,9 @@ module Vagrant begin # Call the next middleware in the sequence, appending to the stack # of "recoverable" middlewares in case something goes wrong! - raise Errors::VagrantInterrupt.new if env.interrupted? + raise Errors::VagrantInterrupt if env.interrupted? @stack.unshift(@actions.shift).first.call(env) - raise Errors::VagrantInterrupt.new if env.interrupted? + raise Errors::VagrantInterrupt if env.interrupted? rescue SystemExit # This means that an "exit" or "abort" was called. In these cases, # we just exit immediately. diff --git a/lib/vagrant/box.rb b/lib/vagrant/box.rb index 883ee9def..f6ba478ad 100644 --- a/lib/vagrant/box.rb +++ b/lib/vagrant/box.rb @@ -57,7 +57,7 @@ module Vagrant # method requires that `name` and `uri` be set. The logic of this method # is kicked out to the `box_add` registered middleware. def add - raise Errors::BoxAlreadyExists.new(:name => name) if File.directory?(directory) + raise Errors::BoxAlreadyExists, :name => name if File.directory?(directory) env.actions.run(:box_add, { "box" => self, "validate" => false }) end diff --git a/lib/vagrant/command/box.rb b/lib/vagrant/command/box.rb index 81e361555..a2908ff9f 100644 --- a/lib/vagrant/command/box.rb +++ b/lib/vagrant/command/box.rb @@ -11,14 +11,14 @@ module Vagrant desc "remove NAME", "Remove a box from the system" def remove(name) b = env.boxes.find(name) - raise Errors::BoxNotFound.new(:name => name) if !b + raise Errors::BoxNotFound, :name => name if !b b.destroy end desc "repackage NAME", "Repackage an installed box into a `.box` file." def repackage(name) b = env.boxes.find(name) - raise Errors::BoxNotFound.new(:name => name) if !b + raise Errors::BoxNotFound, :name => name if !b b.repackage end diff --git a/lib/vagrant/command/helpers.rb b/lib/vagrant/command/helpers.rb index 6fb9dadd2..678faed5a 100644 --- a/lib/vagrant/command/helpers.rb +++ b/lib/vagrant/command/helpers.rb @@ -4,14 +4,14 @@ module Vagrant # Initializes the environment by pulling the environment out of # the configuration hash and sets up the UI if necessary. def initialize_environment(args, options, config) - raise Errors::CLIMissingEnvironment.new if !config[:env] + raise Errors::CLIMissingEnvironment if !config[:env] @env = config[:env] end # This returns an array of {VM} objects depending on the arguments # given to the command. def target_vms(name=nil) - raise Errors::NoEnvironmentError.new if !env.root_path + raise Errors::NoEnvironmentError if !env.root_path name ||= self.name rescue nil @@ -19,9 +19,9 @@ module Vagrant if env.multivm? return env.vms_ordered if !name vm = env.vms[name.to_sym] - raise Errors::VMNotFoundError.new(:name => name) if !vm + raise Errors::VMNotFoundError, :name => name if !vm else - raise Errors::MultiVMEnvironmentRequired.new if name + raise Errors::MultiVMEnvironmentRequired if name vm = env.vms.values.first end diff --git a/lib/vagrant/command/package.rb b/lib/vagrant/command/package.rb index 7ecfd5a78..78bbb58ae 100644 --- a/lib/vagrant/command/package.rb +++ b/lib/vagrant/command/package.rb @@ -16,14 +16,14 @@ module Vagrant def package_base vm = VM.find(options[:base], env) - raise Errors::BaseVMNotFound.new(:name => options[:base]) if !vm.created? + raise Errors::BaseVMNotFound, :name => options[:base] if !vm.created? package_vm(vm) end def package_target - raise Errors::MultiVMTargetRequired.new(:command => "package") if target_vms.length > 1 + raise Errors::MultiVMTargetRequired, :command => "package" if target_vms.length > 1 vm = target_vms.first - raise Errors::VMNotCreatedError.new if !vm.created? + raise Errors::VMNotCreatedError if !vm.created? package_vm(vm) end diff --git a/lib/vagrant/command/ssh.rb b/lib/vagrant/command/ssh.rb index eec55009d..c249885b7 100644 --- a/lib/vagrant/command/ssh.rb +++ b/lib/vagrant/command/ssh.rb @@ -24,15 +24,15 @@ module Vagrant end def ssh_connect - raise Errors::VMNotCreatedError.new if !ssh_vm.created? - raise Errors::VMNotRunningError.new if !ssh_vm.vm.running? + raise Errors::VMNotCreatedError if !ssh_vm.created? + raise Errors::VMNotRunningError if !ssh_vm.vm.running? ssh_vm.ssh.connect end def ssh_vm @ssh_vm ||= begin vm = self.name.nil? && env.multivm? ? env.primary_vm : nil - raise Errors::MultiVMTargetRequired.new(:command => "ssh") if !vm && target_vms.length > 1 + raise Errors::MultiVMTargetRequired, :command => "ssh" if !vm && target_vms.length > 1 vm = target_vms.first if !vm vm end diff --git a/lib/vagrant/command/ssh_config.rb b/lib/vagrant/command/ssh_config.rb index 8cef4c0a8..a4b1343f0 100644 --- a/lib/vagrant/command/ssh_config.rb +++ b/lib/vagrant/command/ssh_config.rb @@ -5,9 +5,9 @@ module Vagrant register "ssh_config", "outputs .ssh/config valid syntax for connecting to this environment via ssh" def execute - raise Errors::MultiVMTargetRequired.new(:command => "ssh_config") if target_vms.length > 1 + raise Errors::MultiVMTargetRequired, :command => "ssh_config" if target_vms.length > 1 vm = target_vms.first - raise Errors::VMNotCreatedError.new if !vm.created? + raise Errors::VMNotCreatedError if !vm.created? $stdout.puts(Util::TemplateRenderer.render("ssh_config", { :host_key => options[:host] || "vagrant", diff --git a/lib/vagrant/config.rb b/lib/vagrant/config.rb index 5fd38185b..05ad481ea 100644 --- a/lib/vagrant/config.rb +++ b/lib/vagrant/config.rb @@ -95,7 +95,7 @@ module Vagrant load item rescue SyntaxError => e # Report syntax errors in a nice way for Vagrantfiles - raise Errors::VagrantfileSyntaxError.new(:file => e.message) + raise Errors::VagrantfileSyntaxError, :file => e.message end elsif item.is_a?(Proc) self.class.run(&item) @@ -159,7 +159,7 @@ module Vagrant end return if errors.empty? - raise Errors::ConfigValidationFailed.new(:messages => Util::TemplateRenderer.render("config/validation_failed", :errors => errors)) + raise Errors::ConfigValidationFailed, :messages => Util::TemplateRenderer.render("config/validation_failed", :errors => errors) end end end diff --git a/lib/vagrant/downloaders/file.rb b/lib/vagrant/downloaders/file.rb index d14b52368..e527dcec5 100644 --- a/lib/vagrant/downloaders/file.rb +++ b/lib/vagrant/downloaders/file.rb @@ -10,10 +10,11 @@ module Vagrant end def prepare(source_url) - raise Errors::DownloaderFileDoesntExist.new if !::File.file?(source_url) + raise Errors::DownloaderFileDoesntExist if !::File.file?(source_url) end def download!(source_url, destination_file) + env.ui.info I18n.t("vagrant.downloaders.file.download") FileUtils.cp(source_url, destination_file.path) end end diff --git a/lib/vagrant/downloaders/http.rb b/lib/vagrant/downloaders/http.rb index e525bd370..0cd042fec 100644 --- a/lib/vagrant/downloaders/http.rb +++ b/lib/vagrant/downloaders/http.rb @@ -25,7 +25,16 @@ module Vagrant end http.start do |h| + env.ui.info I18n.t("vagrant.downloaders.http.download", :url => source_url) + h.request_get(uri.request_uri) do |response| + if response.is_a?(Net::HTTPRedirection) + # Follow the HTTP redirect. + # TODO: Error on some redirect limit + download!(response["Location"], destination_file) + return + end + total = response.content_length progress = 0 segment_count = 0 @@ -48,7 +57,7 @@ module Vagrant end end rescue SocketError - raise Errors::DownloaderHTTPSocketError.new + raise Errors::DownloaderHTTPSocketError end end end diff --git a/lib/vagrant/environment.rb b/lib/vagrant/environment.rb index e2b450874..58df82928 100644 --- a/lib/vagrant/environment.rb +++ b/lib/vagrant/environment.rb @@ -31,9 +31,9 @@ module Vagrant # VirtualBox installed is high enough. def check_virtualbox! version = VirtualBox.version - raise Errors::VirtualBoxNotDetected.new if version.nil? - raise Errors::VirtualBoxInvalidVersion.new(:version => version.to_s) if version.to_f < 3.2 - raise Errors::VirtualBoxInvalidOSE.new(:version => version.to_s) if version.to_s.downcase.include?("ose") + raise Errors::VirtualBoxNotDetected if version.nil? + raise Errors::VirtualBoxInvalidVersion, :version => version.to_s if version.to_f < 4.0 + raise Errors::VirtualBoxInvalidOSE, :version => version.to_s if version.to_s.downcase.include?("ose") rescue Errors::VirtualBoxNotDetected # On 64-bit Windows, show a special error. This error is a subclass # of VirtualBoxNotDetected, so libraries which use Vagrant can just @@ -305,6 +305,13 @@ module Vagrant self end + # Reloads the configuration of this environment. + def reload_config! + @config = nil + load_config! + self + end + # Loads this environment's configuration and stores it in the {#config} # variable. The configuration loaded by this method is specified to # this environment, meaning that it will use the given root directory diff --git a/lib/vagrant/errors.rb b/lib/vagrant/errors.rb index cf1447ef0..08f537495 100644 --- a/lib/vagrant/errors.rb +++ b/lib/vagrant/errors.rb @@ -183,6 +183,13 @@ module Vagrant error_key(:not_found, "vagrant.actions.vm.network") end + # Note: This is a temporary error for Windows users while host-only + # networking doesn't quite work. + class NetworkNotImplemented < VagrantError + status_code(49) + error_key(:windows_not_implemented, "vagrant.actions.vm.network") + end + class NFSHostRequired < VagrantError status_code(31) error_key(:host_required, "vagrant.actions.vm.nfs") diff --git a/lib/vagrant/provisioners/chef.rb b/lib/vagrant/provisioners/chef.rb index b2e293fe8..1e6056dd3 100644 --- a/lib/vagrant/provisioners/chef.rb +++ b/lib/vagrant/provisioners/chef.rb @@ -5,7 +5,7 @@ module Vagrant # provisioner**. Instead, {ChefSolo} or {ChefServer} should be used. class Chef < Base def prepare - raise ChefError.new(:invalid_provisioner) + raise ChefError, :invalid_provisioner end def verify_binary(binary) diff --git a/lib/vagrant/provisioners/chef_server.rb b/lib/vagrant/provisioners/chef_server.rb index 9ac3578cc..1b886af09 100644 --- a/lib/vagrant/provisioners/chef_server.rb +++ b/lib/vagrant/provisioners/chef_server.rb @@ -6,9 +6,9 @@ module Vagrant # with a chef server. class ChefServer < Chef def prepare - raise ChefError.new(:server_validation_key_required) if env.config.chef.validation_key_path.nil? - raise ChefError.new(:server_validation_key_doesnt_exist) if !File.file?(validation_key_path) - raise ChefError.new(:server_url_required) if env.config.chef.chef_server_url.nil? + raise ChefError, :server_validation_key_required if env.config.chef.validation_key_path.nil? + raise ChefError, :server_validation_key_doesnt_exist if !File.file?(validation_key_path) + raise ChefError, :server_url_required if env.config.chef.chef_server_url.nil? end def provision! diff --git a/lib/vagrant/provisioners/puppet.rb b/lib/vagrant/provisioners/puppet.rb index 5dc5d0a92..a3fa9e2d1 100644 --- a/lib/vagrant/provisioners/puppet.rb +++ b/lib/vagrant/provisioners/puppet.rb @@ -22,7 +22,6 @@ module Vagrant end class Puppet < Base - def prepare check_manifest_dir share_manifests @@ -63,7 +62,7 @@ module Vagrant env.ui.info I18n.t("vagrant.provisioners.puppet.manifest_to_run", :manifest => @manifest) return @manifest else - raise PuppetError.new(:_key => :manifest_missing, :manifest => @manifest) + raise PuppetError, :_key => :manifest_missing, :manifest => @manifest end end @@ -81,7 +80,6 @@ module Vagrant end end end - end end end diff --git a/lib/vagrant/ssh.rb b/lib/vagrant/ssh.rb index 472dc5a8e..8b8ce2223 100644 --- a/lib/vagrant/ssh.rb +++ b/lib/vagrant/ssh.rb @@ -23,11 +23,11 @@ module Vagrant # of options which override the configuration values. def connect(opts={}) if Mario::Platform.windows? - raise Errors::SSHUnavailableWindows.new(:key_path => env.config.ssh.private_key_path, - :ssh_port => port(opts)) + raise Errors::SSHUnavailableWindows, :key_path => env.config.ssh.private_key_path, + :ssh_port => port(opts) end - raise Errors::SSHUnavailable.new if !Kernel.system("which ssh > /dev/null 2>&1") + raise Errors::SSHUnavailable if !Kernel.system("which ssh > /dev/null 2>&1") options = {} options[:port] = port(opts) @@ -74,7 +74,7 @@ module Vagrant end end rescue Errno::ECONNREFUSED - raise Errors::SSHConnectionRefused.new + raise Errors::SSHConnectionRefused end # Uploads a file from `from` to `to`. `from` is expected to be a filename @@ -105,7 +105,7 @@ module Vagrant true rescue Net::SSH::AuthenticationFailed - raise Errors::SSHAuthenticationFailed.new + raise Errors::SSHAuthenticationFailed rescue Timeout::Error, Errno::ECONNREFUSED, Net::SSH::Disconnect, Errors::SSHConnectionRefused, Net::SSH::AuthenticationFailed return false @@ -122,12 +122,12 @@ module Vagrant if stat.owned? && file_perms(key_path) != "600" File.chmod(0600, key_path) - raise Errors::SSHKeyBadPermissions.new(:key_path => key_path) if file_perms(key_path) != "600" + raise Errors::SSHKeyBadPermissions, :key_path => key_path if file_perms(key_path) != "600" end rescue Errno::EPERM # This shouldn't happen since we verify we own the file, but just # in case. - raise Errors::SSHKeyBadPermissions.new(:key_path => key_path) + raise Errors::SSHKeyBadPermissions, :key_path => key_path end # Returns the file permissions of a given file. This is fairly unix specific @@ -229,7 +229,7 @@ module Vagrant :command => command }.merge(options || {}) - raise options[:_error_class].new(options) + raise options[:_error_class], options end end end diff --git a/lib/vagrant/systems/linux.rb b/lib/vagrant/systems/linux.rb index c0aee84b7..67485d410 100644 --- a/lib/vagrant/systems/linux.rb +++ b/lib/vagrant/systems/linux.rb @@ -104,8 +104,8 @@ module Vagrant def mount_folder(ssh, name, guestpath, sleeptime=5) # Determine the permission string to attach to the mount command perms = [] - perms << "uid=#{vm.env.config.vm.shared_folder_uid}" - perms << "gid=#{vm.env.config.vm.shared_folder_gid}" + perms << "uid=`id -u #{vm.env.config.vm.shared_folder_uid}`" + perms << "gid=`id -g #{vm.env.config.vm.shared_folder_gid}`" perms = " -o #{perms.join(",")}" if !perms.empty? attempts = 0 @@ -118,7 +118,7 @@ module Vagrant break unless result attempts += 1 - raise LinuxError.new(:mount_fail) if attempts >= 10 + raise LinuxError, :mount_fail if attempts >= 10 sleep sleeptime end end diff --git a/lib/vagrant/version.rb b/lib/vagrant/version.rb index a6e78360b..6c8af3a62 100644 --- a/lib/vagrant/version.rb +++ b/lib/vagrant/version.rb @@ -2,5 +2,5 @@ module Vagrant # This will always be up to date with the current version of Vagrant, # since it is used to generate the gemspec and is also the source of # the version for `vagrant -v` - VERSION = "0.6.9.dev" + VERSION = "0.7.0.beta2.dev" end diff --git a/lib/vagrant/vm.rb b/lib/vagrant/vm.rb index d6a49fc55..99d857ad1 100644 --- a/lib/vagrant/vm.rb +++ b/lib/vagrant/vm.rb @@ -53,15 +53,15 @@ module Vagrant if system.is_a?(Class) @system = system.new(self) - raise Errors::VMSystemError.new(:_key => :invalid_class, :system => system.to_s) if !@system.is_a?(Systems::Base) + raise Errors::VMSystemError, :_key => :invalid_class, :system => system.to_s if !@system.is_a?(Systems::Base) elsif system.is_a?(Symbol) # Hard-coded internal systems mapping = { :linux => Systems::Linux, :solaris => Systems::Solaris } - raise Errors::VMSystemError.new(:_key => :unknown_type, :system => system.to_s) if !mapping.has_key?(system) + raise Errors::VMSystemError, :_key => :unknown_type, :system => system.to_s if !mapping.has_key?(system) @system = mapping[system].new(self) else - raise Errors::VMSystemError.new(:unspecified) + raise Errors::VMSystemError, :unspecified end end diff --git a/templates/locales/en.yml b/templates/locales/en.yml index e7a08560d..f0a944aca 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -96,8 +96,13 @@ en: to continue. virtualbox_invalid_version: |- Vagrant has detected that you have VirtualBox version %{version} installed! - Vagrant requires that you use at least VirtualBox version 3.2. Please install + Vagrant requires that you use at least VirtualBox version 4.0. Please install a more recent version of VirtualBox to continue. + + The Vagrant 0.6.x series supports VirtualBox 3.2, so if you're stuck with that + version, then please use the 0.6.x series of Vagrant. + + Any earlier versions of VirtualBox are completely unsupported. Please upgrade. virtualbox_not_detected: |- Vagrant could not detect VirtualBox! Make sure VirtualBox is properly installed. If VirtualBox is installed, it may be an incorrect version. Vagrant currently @@ -304,14 +309,19 @@ en: This will cause your specified IP to be inaccessible. Please change the IP or name of your host only network to not match that of a bridged or non-hostonly network. - creating: Creating new host only network for environment... - enabling: Enabling host only network... + creating: "Creating new host only network for environment..." + enabling: "Enabling host only network..." not_found: |- The specified host network could not be found: '%{name}.' If the name specification is removed, Vagrant will create a new host only network for you. Alternatively, please create the specified network manually. - preparing: Preparing host only network... + preparing: "Preparing host only network..." + windows_not_implemented: |- + Host only networking is currently broken on Windows due to a bug + in jruby-win32ole. When the bug is fixed, a patch release for Vagrant + will be released to remove this error. Until then, please just use + forwarded ports. nfs: host_required: |- A host class is required for NFS shared folders. By default, these @@ -351,6 +361,7 @@ en: creating: Creating shared folders metadata... mounting: Mounting shared folders... mounting_entry: "-- %{name}: %{guest_path}" + nomount_entry: "-- %{name}: Automounting disabled." suspend: suspending: Saving VM state and suspending execution... @@ -360,7 +371,6 @@ en: download: with: "Downloading with %{class}..." cleaning: "Cleaning up downloaded box..." - copying: "Copying box to temporary location..." unknown_type: "Unknown or unsupported URI type given for box download." unpackage: extracting: "Extracting box..." @@ -391,8 +401,10 @@ en: downloaders: file: + download: "Copying box to temporary location..." file_missing: "The specified path to a file doesn't exist." http: + download: "Downloading box: %{url}" socket_error: |- An error occurred while trying to download the specified box. This most often happens if there is no internet connection or the address is diff --git a/test/vagrant/action/vm/check_box_test.rb b/test/vagrant/action/vm/check_box_test.rb index 453e064b6..121554b38 100644 --- a/test/vagrant/action/vm/check_box_test.rb +++ b/test/vagrant/action/vm/check_box_test.rb @@ -45,6 +45,7 @@ class CheckBoxVMActionTest < Test::Unit::TestCase env.env.boxes.expects(:find).returns(nil) Vagrant::Box.expects(:add).with(env.env, env["config"].vm.box, env["config"].vm.box_url).in_sequence(seq) env.env.boxes.expects(:reload!).in_sequence(seq) + env.env.expects(:reload_config!).in_sequence(seq) app.expects(:call).with(env).once.in_sequence(seq) assert_nothing_raised { diff --git a/test/vagrant/action/vm/clean_machine_folder_test.rb b/test/vagrant/action/vm/clean_machine_folder_test.rb index 809714faa..f6ce54b2c 100644 --- a/test/vagrant/action/vm/clean_machine_folder_test.rb +++ b/test/vagrant/action/vm/clean_machine_folder_test.rb @@ -37,10 +37,10 @@ class CleanMachineFolderVMActionTest < Test::Unit::TestCase @instance.clean_machine_folder end - should "delete directories with only .xml-prev files" do + should "delete directories with only .vbox-prev files" do folders = { - "sfoo" => %W[foo bar baz.xml-prev], - "sbar" => %W[foo.xml-prev] + "sfoo" => %W[foo bar baz.vbox-prev], + "sbar" => %W[foo.vbox-prev] } Dir.expects(:[]).with(@folder).returns(folders.keys) @@ -57,7 +57,7 @@ class CleanMachineFolderVMActionTest < Test::Unit::TestCase should "delete directories with only subdirectories" do folders = { "sfoo" => %W[foo bar], - "sbar" => %W[foo.xml-prev] + "sbar" => %W[foo.vbox-prev] } File.stubs(:file?).returns(false) @@ -77,6 +77,8 @@ class CleanMachineFolderVMActionTest < Test::Unit::TestCase should "do nothing if folder is < 10 characters" do VirtualBox::Global.global.system_properties.stubs(:default_machine_folder).returns("foo") Dir.expects(:[]).never + + @instance.clean_machine_folder end end end diff --git a/test/vagrant/action/vm/destroy_test.rb b/test/vagrant/action/vm/destroy_test.rb index 9b4a382bf..da9efbc41 100644 --- a/test/vagrant/action/vm/destroy_test.rb +++ b/test/vagrant/action/vm/destroy_test.rb @@ -16,7 +16,7 @@ class DestroyVMActionTest < Test::Unit::TestCase context "destroying the VM" do should "destroy VM and attached images" do - @internal_vm.expects(:destroy).with(:destroy_medium => :delete).once + @internal_vm.expects(:destroy).once @env["vm"].expects(:vm=).with(nil).once @app.expects(:call).with(@env).once @instance.call(@env) diff --git a/test/vagrant/action/vm/destroy_unused_network_interfaces_test.rb b/test/vagrant/action/vm/destroy_unused_network_interfaces_test.rb index 95cc12f8d..7e4a9c7a0 100644 --- a/test/vagrant/action/vm/destroy_unused_network_interfaces_test.rb +++ b/test/vagrant/action/vm/destroy_unused_network_interfaces_test.rb @@ -16,24 +16,27 @@ class DestroyUnusedNetworkInterfacesVMActionTest < Test::Unit::TestCase context "calling" do setup do - @network_adapters = [] - @internal_vm.stubs(:network_adapters).returns(@network_adapters) + @interfaces = [] + global = mock("global") + host = mock("host") + VirtualBox::Global.stubs(:global).returns(global) + global.stubs(:host).returns(host) + host.stubs(:network_interfaces).returns(@interfaces) end - def stub_interface(length=5) + def stub_interface(length=5, type=:host_only) interface = mock("interface") - adapter = mock("adapter") - adapter.stubs(:host_interface_object).returns(interface) + interface.stubs(:interface_type).returns(type) interface.stubs(:attached_vms).returns(Array.new(length)) - @network_adapters << adapter + @interfaces << interface interface end should "destroy only the unused network interfaces" do stub_interface(5) stub_interface(7) - results = [stub_interface(1), stub_interface(1)] + results = [stub_interface(0), stub_interface(0)] results.each do |result| result.expects(:destroy).once diff --git a/test/vagrant/action/vm/disable_networks_test.rb b/test/vagrant/action/vm/disable_networks_test.rb deleted file mode 100644 index c8604fb1f..000000000 --- a/test/vagrant/action/vm/disable_networks_test.rb +++ /dev/null @@ -1,48 +0,0 @@ -require "test_helper" - -class DisableNetworksVMActionTest < Test::Unit::TestCase - setup do - @klass = Vagrant::Action::VM::DisableNetworks - @app, @env = action_env - - @vm = mock("vm") - @env.env.stubs(:vm).returns(@vm) - - @internal_vm = mock("internal") - @vm.stubs(:created?).returns(true) - @vm.stubs(:vm).returns(@internal_vm) - @internal_vm.stubs(:network_adapters).returns([]) - - @instance = @klass.new(@app, @env) - end - - def mock_adapter(type) - adapter = mock("adapter") - adapter.stubs(:attachment_type).returns(type) - - if type == :host_only - adapter.expects(:enabled=).with(false) - adapter.expects(:save) - end - - @internal_vm.network_adapters << adapter - end - - should "do nothing if VM is not created" do - @vm.stubs(:created?).returns(false) - @vm.expects(:vm).never - - @app.expects(:call).with(@env).once - @instance.call(@env) - end - - should "remove all network adapters and continue chain" do - mock_adapter(:bridged) - mock_adapter(:host_only) - mock_adapter(:host_only) - - @app.expects(:call).with(@env).once - - @instance.call(@env) - end -end diff --git a/test/vagrant/action/vm/network_test.rb b/test/vagrant/action/vm/network_test.rb index 924d50b02..33626d3ab 100644 --- a/test/vagrant/action/vm/network_test.rb +++ b/test/vagrant/action/vm/network_test.rb @@ -16,6 +16,24 @@ class NetworkVMActionTest < Test::Unit::TestCase end context "initializing" do + should "raise an error if on windows and networking is enabled" do + Vagrant::Util::Platform.stubs(:windows?).returns(true) + @env.env.config.vm.network("foo") + + assert_raises(Vagrant::Errors::NetworkNotImplemented) { + @klass.new(@app, @env) + } + end + + should "not raise an error if not on windows and networking is enabled" do + Vagrant::Util::Platform.stubs(:windows?).returns(false) + @env.env.config.vm.network("foo") + + assert_nothing_raised { + @klass.new(@app, @env) + } + end + should "verify no bridge collisions for each network enabled" do @env.env.config.vm.network("foo") @klass.any_instance.expects(:verify_no_bridge_collision).returns(true).once.with() do |options| diff --git a/test/vagrant/action/vm/nfs_test.rb b/test/vagrant/action/vm/nfs_test.rb index fb59d0dcd..b6f5efcee 100644 --- a/test/vagrant/action/vm/nfs_test.rb +++ b/test/vagrant/action/vm/nfs_test.rb @@ -160,13 +160,19 @@ class NFSVMActionTest < Test::Unit::TestCase context "mounting folders" do setup do @instance.stubs(:host_ip).returns("foo") - @instance.stubs(:folders).returns(["bar"]) + @instance.stubs(:folders).returns([{:guestpath => "foo"}]) end should "mount the folders on the system" do @vm.system.expects(:mount_nfs).with(@instance.host_ip, @instance.folders) @instance.mount_folders end + + should "not mount folders which have no guest path" do + @instance.stubs(:folders).returns([{}]) + @vm.system.expects(:mount_nfs).with(@instance.host_ip, []) + @instance.mount_folders + end end context "getting the host IP" do diff --git a/test/vagrant/action/vm/share_folders_test.rb b/test/vagrant/action/vm/share_folders_test.rb index d33b6f49d..9b9de8878 100644 --- a/test/vagrant/action/vm/share_folders_test.rb +++ b/test/vagrant/action/vm/share_folders_test.rb @@ -116,6 +116,7 @@ class ShareFoldersVMActionTest < Test::Unit::TestCase @folders = stub_shared_folders(<<-sf) config.vm.share_folder("foo", "fooguest", "foohost") config.vm.share_folder("bar", "barguest", "barhost") + config.vm.share_folder("foo_no_mount", nil, "foohost2") sf @ssh = mock("ssh") @vm.ssh.stubs(:execute).yields(@ssh) @@ -125,7 +126,11 @@ class ShareFoldersVMActionTest < Test::Unit::TestCase should "mount all shared folders to the VM" do mount_seq = sequence("mount_seq") @folders.each do |name, data| - @vm.system.expects(:mount_shared_folder).with(@ssh, name, data[:guestpath]).in_sequence(mount_seq) + if data[:guestpath] + @vm.system.expects(:mount_shared_folder).with(@ssh, name, data[:guestpath]).in_sequence(mount_seq) + else + @vm.system.expects(:mount_shared_folder).with(@ssh, name, anything).never + end end @instance.mount_shared_folders diff --git a/test/vagrant/downloaders/file_test.rb b/test/vagrant/downloaders/file_test.rb index 70180d28a..271e01e6b 100644 --- a/test/vagrant/downloaders/file_test.rb +++ b/test/vagrant/downloaders/file_test.rb @@ -17,11 +17,25 @@ class FileDownloaderTest < Test::Unit::TestCase end context "downloading" do + setup do + clean_paths + end + should "cp the file" do - path = '/path' - @tempfile.expects(:path).returns(path) - FileUtils.expects(:cp).with(@uri, path) - @downloader.download!(@uri, @tempfile) + uri = tmp_path.join("foo_source") + dest = tmp_path.join("foo_dest") + + # Create the source file, then "download" it + File.open(uri, "w+") { |f| f.write("FOO") } + File.open(dest, "w+") do |dest_file| + @downloader.download!(uri, dest_file) + end + + # Finally, verify the destination file was properly created + assert File.file?(dest) + File.open(dest) do |f| + assert_equal "FOO", f.read + end end end diff --git a/test/vagrant/environment_test.rb b/test/vagrant/environment_test.rb index c63257deb..7e1c3c6f8 100644 --- a/test/vagrant/environment_test.rb +++ b/test/vagrant/environment_test.rb @@ -8,11 +8,11 @@ class EnvironmentTest < Test::Unit::TestCase context "class method check virtualbox version" do setup do - VirtualBox.stubs(:version).returns("3.1.4") + VirtualBox.stubs(:version).returns("4.0.0") end should "not error and exit if everything is good" do - VirtualBox.expects(:version).returns("3.2.4") + VirtualBox.expects(:version).returns("4.0.0") assert_nothing_raised { @klass.check_virtualbox! } end @@ -21,14 +21,14 @@ class EnvironmentTest < Test::Unit::TestCase assert_raises(Vagrant::Errors::VirtualBoxNotDetected) { @klass.check_virtualbox! } end - should "error and exit if VirtualBox is lower than version 3.2" do - version = "3.1.12r1041" + should "error and exit if VirtualBox is lower than version 4.0" do + version = "3.2.12r1041" VirtualBox.expects(:version).returns(version) assert_raises(Vagrant::Errors::VirtualBoxInvalidVersion) { @klass.check_virtualbox! } end should "error and exit for OSE VirtualBox" do - version = "3.2.6_OSE" + version = "4.0.0_OSE" VirtualBox.expects(:version).returns(version) assert_raises(Vagrant::Errors::VirtualBoxInvalidOSE) { @klass.check_virtualbox! } end @@ -425,6 +425,21 @@ class EnvironmentTest < Test::Unit::TestCase @env.load_config! assert @env.instance_variable_get(:@logger).nil? end + + should "be able to reload config" do + vagrantfile(@env.root_path, "config.vm.box = 'box'") + + # First load the config normally + @env.load_config! + assert_equal "box", @env.config.vm.box + assert_not_equal "set", @env.config.vm.base_mac + + # Modify the Vagrantfile and reload it, then verify new results + # are available + vagrantfile(@env.root_path, "config.vm.base_mac = 'set'") + @env.reload_config! + assert_equal "set", @env.config.vm.base_mac + end end context "loading home directory" do diff --git a/test/vagrant/ssh_test.rb b/test/vagrant/ssh_test.rb index f63c38788..0acb81e62 100644 --- a/test/vagrant/ssh_test.rb +++ b/test/vagrant/ssh_test.rb @@ -12,7 +12,7 @@ class SshTest < Test::Unit::TestCase end setup do - VirtualBox.stubs(:version).returns("3.2.4") + VirtualBox.stubs(:version).returns("4.0.0") end context "connecting to external SSH" do diff --git a/test/vagrant/systems/linux_test.rb b/test/vagrant/systems/linux_test.rb index dfea92d70..16b44d390 100644 --- a/test/vagrant/systems/linux_test.rb +++ b/test/vagrant/systems/linux_test.rb @@ -61,7 +61,7 @@ class LinuxSystemTest < Test::Unit::TestCase end should "execute the proper mount command" do - @ssh.expects(:exec!).with("sudo mount -t vboxsf -o uid=#{@vm.env.config.ssh.username},gid=#{@vm.env.config.ssh.username} #{@name} #{@guestpath}").returns(@success_return) + @ssh.expects(:exec!).with("sudo mount -t vboxsf -o uid=`id -u #{@vm.env.config.ssh.username}`,gid=`id -g #{@vm.env.config.ssh.username}` #{@name} #{@guestpath}").returns(@success_return) mount_folder end @@ -107,7 +107,7 @@ class LinuxSystemTest < Test::Unit::TestCase @vm.stubs(:env).returns(env) - @ssh.expects(:exec!).with("sudo mount -t vboxsf -o uid=#{uid},gid=#{gid} #{@name} #{@guestpath}").returns(@success_return) + @ssh.expects(:exec!).with("sudo mount -t vboxsf -o uid=`id -u #{uid}`,gid=`id -g #{gid}` #{@name} #{@guestpath}").returns(@success_return) mount_folder end end diff --git a/vagrant.gemspec b/vagrant.gemspec index ac944e1cd..67397757b 100644 --- a/vagrant.gemspec +++ b/vagrant.gemspec @@ -21,7 +21,7 @@ Gem::Specification.new do |s| s.add_dependency "net-scp", "~> 1.0.3" s.add_dependency "i18n", "~> 0.4.1" s.add_dependency "thor", "~> 0.14.2" - s.add_dependency "virtualbox", "~> 0.7.6" + s.add_dependency "virtualbox", "~> 0.8.0" s.add_development_dependency "rake" s.add_development_dependency "contest", ">= 0.1.2"