From 5cb2f3275a9d3d953b5c3f02163f3c36c9788f12 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 26 Dec 2012 20:02:03 -0800 Subject: [PATCH 1/7] Get rid of a silly constant for subdirs in Environment The data is only used once anyways so just use a local variable. --- lib/vagrant/environment.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/vagrant/environment.rb b/lib/vagrant/environment.rb index 1087744fd..ad9110db8 100644 --- a/lib/vagrant/environment.rb +++ b/lib/vagrant/environment.rb @@ -12,7 +12,6 @@ module Vagrant # defined as basically a folder with a "Vagrantfile." This class allows # access to the VMs, CLI, etc. all in the scope of this environment. class Environment - HOME_SUBDIRS = ["tmp", "boxes", "gems"] DEFAULT_HOME = "~/.vagrant.d" DEFAULT_RC = "~/.vagrantrc" @@ -415,9 +414,11 @@ module Vagrant DEFAULT_HOME)) @logger.info("Home path: #{@home_path}") - # Setup the array of necessary home directories - dirs = [@home_path] - dirs += HOME_SUBDIRS.collect { |subdir| @home_path.join(subdir) } + # Setup the list of child directories that need to be created if they + # don't already exist. + dirs = [@home_path] + subdirs = ["tmp", "boxes", "gems"] + dirs += subdirs.collect { |subdir| @home_path.join(subdir) } # Go through each required directory, creating it if it doesn't exist dirs.each do |dir| From cc18492c7afb244b122e83a299b1907cfeb38f8b Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 26 Dec 2012 20:36:46 -0800 Subject: [PATCH 2/7] Local data path introduced The local data path is set to the `ROOT_DIR/.vagrant` by default and is a directory where Vagrant can store environment-local state. This can be overriden on a per-Environment basis using the `local_data_path` option. --- lib/vagrant/environment.rb | 68 +++++++++++++++++++-------- lib/vagrant/errors.rb | 4 ++ templates/locales/en.yml | 7 +++ test/unit/vagrant/environment_test.rb | 29 ++++++++++-- 4 files changed, 84 insertions(+), 24 deletions(-) diff --git a/lib/vagrant/environment.rb b/lib/vagrant/environment.rb index ad9110db8..c6ecdee13 100644 --- a/lib/vagrant/environment.rb +++ b/lib/vagrant/environment.rb @@ -13,6 +13,7 @@ module Vagrant # access to the VMs, CLI, etc. all in the scope of this environment. class Environment DEFAULT_HOME = "~/.vagrant.d" + DEFAULT_LOCAL_DATA = ".vagrant" DEFAULT_RC = "~/.vagrantrc" # This is the global config, comprised of loading configuration from @@ -34,6 +35,10 @@ module Vagrant # global state. attr_reader :home_path + # The directory to the directory where local, environment-specific + # data is stored. + attr_reader :local_data_path + # The directory where temporary files for Vagrant go. attr_reader :tmp_path @@ -58,10 +63,11 @@ module Vagrant def initialize(opts=nil) opts = { :cwd => nil, - :vagrantfile_name => nil, + :home_path => nil, + :local_data_path => nil, :lock_path => nil, :ui_class => nil, - :home_path => nil + :vagrantfile_name => nil }.merge(opts || {}) # Set the default working directory to look for the vagrantfile @@ -70,6 +76,9 @@ module Vagrant opts[:cwd] = Pathname.new(opts[:cwd]) raise Errors::EnvironmentNonExistentCWD if !opts[:cwd].directory? + # Set the default ui class + opts[:ui_class] ||= UI::Silent + # Set the Vagrantfile name up. We append "Vagrantfile" and "vagrantfile" so that # those continue to work as well, but anything custom will take precedence. opts[:vagrantfile_name] ||= [] @@ -77,15 +86,12 @@ module Vagrant opts[:vagrantfile_name] += ["Vagrantfile", "vagrantfile"] # Set instance variables for all the configuration parameters. - @cwd = opts[:cwd] + @cwd = opts[:cwd] + @home_path = opts[:home_path] + @lock_path = opts[:lock_path] @vagrantfile_name = opts[:vagrantfile_name] - @lock_path = opts[:lock_path] - @home_path = opts[:home_path] + @ui = opts[:ui_class].new("vagrant") - ui_class = opts[:ui_class] || UI::Silent - @ui = ui_class.new("vagrant") - - @loaded = false @lock_acquired = false @logger = Log4r::Logger.new("vagrant::environment") @@ -94,10 +100,22 @@ module Vagrant # Setup the home directory setup_home_path - @tmp_path = @home_path.join("tmp") + @tmp_path = @home_path.join("tmp") @boxes_path = @home_path.join("boxes") @gems_path = @home_path.join("gems") + # Setup the local data directory. If a configuration path is given, + # then it is expanded relative to the working directory. Otherwise, + # we use the default which is expanded relative to the root path. + @local_data_path = nil + if opts[:local_data_path] + @local_data_path = Pathname.new(File.expand_path(opts[:local_data_path], @cwd)) + elsif !root_path.nil? + @local_data_path = root_path.join(DEFAULT_LOCAL_DATA) + end + + setup_local_data_path + # Setup the default private key @default_private_key_path = @home_path.join("insecure_private_key") copy_insecure_private_key @@ -131,15 +149,6 @@ module Vagrant :virtualbox end - # The path to the `dotfile`, which contains the persisted UUID of - # the VM if it exists. - # - # @return [Pathname] - def dotfile_path - return nil if !root_path - root_path.join(config_global.vagrant.dotfile_name) - end - # Returns the collection of boxes for the environment. # # @return [BoxCollection] @@ -315,7 +324,7 @@ module Vagrant # # @return [DataStore] def local_data - @local_data ||= DataStore.new(dotfile_path) + @local_data ||= DataStore.new(@local_data_path.join("environment_data")) end # The root path is the path where the top-most (loaded last) @@ -433,6 +442,25 @@ module Vagrant end end + # This creates the local data directory and show an error if it + # couldn't properly be created. + def setup_local_data_path + if @local_data_path.nil? + @logger.warn("No local data path is set. Local data cannot be stored.") + return + end + + @logger.info("Local data path: #{@local_data_path}") + + begin + @logger.debug("Creating: #{@local_data_path}") + FileUtils.mkdir_p(@local_data_path) + rescue Errno::EACCES + raise Errors::LocalDataDirectoryNotAccessible, + :local_data_path => @local_data_path.to_s + end + end + protected # This method copies the private key into the home directory if it diff --git a/lib/vagrant/errors.rb b/lib/vagrant/errors.rb index 690afa86d..f4961b45e 100644 --- a/lib/vagrant/errors.rb +++ b/lib/vagrant/errors.rb @@ -230,6 +230,10 @@ module Vagrant error_key(:port_collision_resume) end + class LocalDataDirectoryNotAccessible < VagrantError + error_key(:local_data_dir_not_accessible) + end + class MachineGuestNotReady < VagrantError error_key(:machine_guest_not_ready) end diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 8712e41fd..6adf62cf4 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -85,6 +85,13 @@ en: You specified: %{home_path} interrupted: |- Vagrant exited after cleanup due to external interrupt. + local_data_dir_not_accessible: |- + The directory Vagrant will use to store local environment-specific + state is not accessible. The directory specified as the local data + directory must be both readable and writable for the user that is + running Vagrant. + + Local data directory: %{local_data_path} machine_guest_not_ready: |- Guest-specific operations were attempted on a machine that is not ready for guest communication. This should not happen and a bug diff --git a/test/unit/vagrant/environment_test.rb b/test/unit/vagrant/environment_test.rb index 6ab1e29be..b4e1e4b8a 100644 --- a/test/unit/vagrant/environment_test.rb +++ b/test/unit/vagrant/environment_test.rb @@ -23,19 +23,22 @@ describe Vagrant::Environment do describe "current working directory" do it "is the cwd by default" do - with_temp_env("VAGRANT_CWD" => nil) do - described_class.new.cwd.should == Pathname.new(Dir.pwd) + temp_dir = Tempdir.new.path + Dir.chdir(temp_dir) do + with_temp_env("VAGRANT_CWD" => nil) do + described_class.new.cwd.should == Pathname.new(Dir.pwd) + end end end it "is set to the cwd given" do - directory = File.dirname(__FILE__) + directory = Tempdir.new.path instance = described_class.new(:cwd => directory) instance.cwd.should == Pathname.new(directory) end it "is set to the environmental variable VAGRANT_CWD" do - directory = File.dirname(__FILE__) + directory = Tempdir.new.path instance = with_temp_env("VAGRANT_CWD" => directory) do described_class.new end @@ -72,6 +75,24 @@ describe Vagrant::Environment do end end + describe "local data path" do + it "is set to the proper default" do + default = instance.root_path.join(described_class::DEFAULT_LOCAL_DATA) + instance.local_data_path.should == default + end + + it "is expanded relative to the cwd" do + instance = described_class.new(:local_data_path => "foo") + instance.local_data_path.should == instance.cwd.join("foo") + end + + it "is set to the given value" do + dir = Tempdir.new.path + instance = described_class.new(:local_data_path => dir) + instance.local_data_path.to_s.should == dir + end + end + describe "default provider" do it "should return virtualbox" do instance.default_provider.should == :virtualbox From d18edc3ce5048ba72b29a7507e82fa054e8561a6 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 26 Dec 2012 20:43:07 -0800 Subject: [PATCH 3/7] Detect a V1 environment and stub upgrade process --- lib/vagrant/environment.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/vagrant/environment.rb b/lib/vagrant/environment.rb index c6ecdee13..2a2ad854a 100644 --- a/lib/vagrant/environment.rb +++ b/lib/vagrant/environment.rb @@ -452,6 +452,13 @@ module Vagrant @logger.info("Local data path: #{@local_data_path}") + # If the local data path is a file, then we are probably seeing an + # old (V1) "dotfile." In this case, we upgrade it. The upgrade process + # will remove the old data file if it is successful. + if @local_data_path.file? + upgrade_v1_dotfile(@local_data_path) + end + begin @logger.debug("Creating: #{@local_data_path}") FileUtils.mkdir_p(@local_data_path) @@ -517,5 +524,16 @@ module Vagrant @logger.debug("RC file not found. Not loading: #{rc_path}") end end + + # This upgrades a Vagrant 1.0.x "dotfile" to the new V2 format. + # + # This is a destructive process. Once the upgrade is complete, the + # old dotfile is removed, and the environment becomes incompatible for + # Vagrant 1.0 environments. + # + # @param [Pathname] path The path to the dotfile + def upgrade_v1_dotfile(path) + raise "V1 environment detected. An auto-upgrade process will be made soon." + end end end From 3baa31460f6743693544aec872db18fde3533c6d Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 26 Dec 2012 21:31:23 -0800 Subject: [PATCH 4/7] Store machine ID in "id" file in data directory. Instead of storing an "active" hash in the local_data of an Environment, we now place the ID of a machine in the "id" file of the machine data directory. This file is read upon re-instantiation in order to load the proper state. --- lib/vagrant/environment.rb | 17 +++++-------- lib/vagrant/machine.rb | 41 ++++++++++++++++++++----------- test/unit/vagrant/machine_test.rb | 9 +++++-- 3 files changed, 39 insertions(+), 28 deletions(-) diff --git a/lib/vagrant/environment.rb b/lib/vagrant/environment.rb index 2a2ad854a..537ed708a 100644 --- a/lib/vagrant/environment.rb +++ b/lib/vagrant/environment.rb @@ -223,10 +223,15 @@ module Vagrant # Get the provider configuration from the final loaded configuration provider_config = config.vm.providers[provider].config + # Determine the machine data directory and pass it to the machine. + # XXX: Permissions error here. + machine_data_path = @local_data_path.join("machines/#{name}/#{provider}") + FileUtils.mkdir_p(machine_data_path) + # Create the machine and cache it for future calls. This will also # return the machine from this method. @machines[cache_key] = Machine.new(name, provider_cls, provider_config, - config, box, self) + config, machine_data_path, box, self) end # This returns a list of the configured machines for this environment. @@ -317,16 +322,6 @@ module Vagrant @global_data ||= DataStore.new(File.expand_path("global_data.json", home_path)) end - # Loads (on initial access) and reads data from the local data - # store. This file is always at the root path as the file "~/.vagrant" - # and contains a JSON dump of a hash. See {DataStore} for more - # information. - # - # @return [DataStore] - def local_data - @local_data ||= DataStore.new(@local_data_path.join("environment_data")) - end - # The root path is the path where the top-most (loaded last) # Vagrantfile resides. It can be considered the project root for # this environment. diff --git a/lib/vagrant/machine.rb b/lib/vagrant/machine.rb index e66e8e684..b9f028f57 100644 --- a/lib/vagrant/machine.rb +++ b/lib/vagrant/machine.rb @@ -15,6 +15,11 @@ module Vagrant # @return [Object] attr_reader :config + # Directory where machine-specific data can be stored. + # + # @return [Pathname] + attr_reader :data_dir + # The environment that this machine is a part of. # # @return [Environment] @@ -50,19 +55,22 @@ module Vagrant # @param [Object] provider_config The provider-specific configuration for # this machine. # @param [Object] config The configuration for this machine. + # @param [Pathname] data_dir The directory where machine-specific data + # can be stored. This directory is ensured to exist. # @param [Box] box The box that is backing this virtual machine. # @param [Environment] env The environment that this machine is a # part of. - def initialize(name, provider_cls, provider_config, config, box, env, base=false) + def initialize(name, provider_cls, provider_config, config, data_dir, box, env, base=false) @logger = Log4r::Logger.new("vagrant::machine") @logger.info("Initializing machine: #{name}") @logger.info(" - Provider: #{provider_cls}") @logger.info(" - Box: #{box}") - @box = box - @config = config - @env = env - @name = name + @box = box + @config = config + @data_dir = data_dir + @env = env + @name = name @provider_config = provider_config # Read the ID, which is usually in local storage @@ -72,7 +80,10 @@ module Vagrant if base @id = name else - @id = @env.local_data[:active][@name.to_s] if @env.local_data[:active] + # Read the id file from the data directory if it exists as the + # ID for the pre-existing physical representation of this machine. + id_file = @data_dir.join("id") + @id = id_file.read if id_file.file? end # Initializes the provider last so that it has access to all the @@ -176,20 +187,20 @@ module Vagrant # # @param [String] value The ID. def id=(value) - @env.local_data[:active] ||= {} + # The file that will store the id if we have one. This allows the + # ID to persist across Vagrant runs. + id_file = @data_dir.join("id") if value - # Set the value - @env.local_data[:active][@name] = value + # Write the "id" file with the id given. + id_file.open("w+") do |f| + f.write(value) + end else - # Delete it from the active hash - @env.local_data[:active].delete(@name) + # Delete the file, since the machine is now destroyed + id_file.delete end - # Commit the local data so that the next time Vagrant is initialized, - # it realizes the VM exists (or doesn't). - @env.local_data.commit - # Store the ID locally @id = value diff --git a/test/unit/vagrant/machine_test.rb b/test/unit/vagrant/machine_test.rb index 7c98acfc7..aa60ab8b4 100644 --- a/test/unit/vagrant/machine_test.rb +++ b/test/unit/vagrant/machine_test.rb @@ -1,3 +1,5 @@ +require "pathname" + require File.expand_path("../../base", __FILE__) describe Vagrant::Machine do @@ -13,6 +15,7 @@ describe Vagrant::Machine do let(:provider_config) { Object.new } let(:box) { Object.new } let(:config) { env.config_global } + let(:data_dir) { Pathname.new(Tempdir.new.path) } let(:env) do # We need to create a Vagrantfile so that this test environment # has a proper root path @@ -28,7 +31,8 @@ describe Vagrant::Machine do # Returns a new instance with the test data def new_instance - described_class.new(name, provider_cls, provider_config, config, box, env) + described_class.new(name, provider_cls, provider_config, + config, data_dir, box, env) end describe "initialization" do @@ -57,7 +61,8 @@ describe Vagrant::Machine do # Initialize a new machine and verify that we properly receive # the machine we expect. - instance = described_class.new(name, provider_cls, provider_config, config, box, env) + instance = described_class.new(name, provider_cls, provider_config, + config, data_dir, box, env) received_machine.should eql(instance) end From b15a6dee0e5d8cee004e867ca102332bdf7a005d Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 26 Dec 2012 21:33:20 -0800 Subject: [PATCH 5/7] Log more information about the machine --- lib/vagrant/machine.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/vagrant/machine.rb b/lib/vagrant/machine.rb index b9f028f57..605179a45 100644 --- a/lib/vagrant/machine.rb +++ b/lib/vagrant/machine.rb @@ -65,6 +65,7 @@ module Vagrant @logger.info("Initializing machine: #{name}") @logger.info(" - Provider: #{provider_cls}") @logger.info(" - Box: #{box}") + @logger.info(" - Data dir: #{data_dir}") @box = box @config = config From c0c3e7bf43049aae1bb3d0dd2ebe8591ee7be8ae Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 26 Dec 2012 21:36:44 -0800 Subject: [PATCH 6/7] Remove Vagrant::DataStore We just don't use it yet and the old implementation was sketchy. I was not happy with it. --- lib/vagrant.rb | 1 - lib/vagrant/data_store.rb | 92 ---------------------------- lib/vagrant/environment.rb | 11 ---- test/unit/vagrant/data_store_test.rb | 79 ------------------------ 4 files changed, 183 deletions(-) delete mode 100644 lib/vagrant/data_store.rb delete mode 100644 test/unit/vagrant/data_store_test.rb diff --git a/lib/vagrant.rb b/lib/vagrant.rb index 040ec3b93..af9ad2263 100644 --- a/lib/vagrant.rb +++ b/lib/vagrant.rb @@ -67,7 +67,6 @@ module Vagrant autoload :CLI, 'vagrant/cli' autoload :Command, 'vagrant/command' autoload :Config, 'vagrant/config' - autoload :DataStore, 'vagrant/data_store' autoload :Downloaders, 'vagrant/downloaders' autoload :Driver, 'vagrant/driver' autoload :Easy, 'vagrant/easy' diff --git a/lib/vagrant/data_store.rb b/lib/vagrant/data_store.rb deleted file mode 100644 index f59f004b5..000000000 --- a/lib/vagrant/data_store.rb +++ /dev/null @@ -1,92 +0,0 @@ -require 'pathname' - -require 'log4r' - -module Vagrant - # The Vagrant data store is a key-value store which is persisted - # as JSON in a local file which is specified in the initializer. - # The data store itself is accessed via typical hash accessors: `[]` - # and `[]=`. If a key is set to `nil`, then it is removed from the - # datastore. The data store is only updated on disk when {#commit} - # is called on the data store itself. - # - # The data store is a hash with indifferent access, meaning that - # while all keys are persisted as strings in the JSON, you can access - # them back as either symbols or strings. Note that this is only true - # for the top-level data store. As soon as you set a hash inside the - # data store, unless you explicitly use a {Util::HashWithIndifferentAccess}, - # it will be a regular hash. - class DataStore < Util::HashWithIndifferentAccess - attr_reader :file_path - - def initialize(file_path) - @logger = Log4r::Logger.new("vagrant::datastore") - - if file_path - @logger.info("Created: #{file_path}") - - @file_path = Pathname.new(file_path) - if @file_path.exist? - raise Errors::DotfileIsDirectory if @file_path.directory? - - begin - merge!(JSON.parse(@file_path.read)) - rescue JSON::ParserError - # Ignore if the data is invalid in the file. - @logger.error("Data store contained invalid JSON. Ignoring.") - end - end - else - @logger.info("No file path. In-memory data store.") - @file_path = nil - end - end - - # Commits any changes to the data to disk. Even if the data - # hasn't changed, it will be reserialized and written to disk. - def commit - if !@file_path - raise StandardError, "In-memory data stores can't be committed." - end - - clean_nil_and_empties - - if empty? - # Delete the file since an empty data store is not useful - @logger.info("Deleting data store since we're empty: #{@file_path}") - @file_path.delete if @file_path.exist? - else - @logger.info("Committing data to data store: #{@file_path}") - - @file_path.open("w") do |f| - f.write(to_json) - f.fsync - end - end - end - - protected - - # Removes the "nil" and "empty?" values from the hash (children - # included) so that the final output JSON is cleaner. - def clean_nil_and_empties(hash=self) - # Clean depth first - hash.each do |k, v| - clean_nil_and_empties(v) if v.is_a?(Hash) - end - - # Clean ourselves, knowing that any children have already been - # cleaned up - bad_keys = hash.inject([]) do |acc, data| - k,v = data - acc.push(k) if v.nil? - acc.push(k) if v.respond_to?(:empty?) && v.empty? - acc - end - - bad_keys.each do |key| - hash.delete(key) - end - end - end -end diff --git a/lib/vagrant/environment.rb b/lib/vagrant/environment.rb index 537ed708a..126667dc6 100644 --- a/lib/vagrant/environment.rb +++ b/lib/vagrant/environment.rb @@ -311,17 +311,6 @@ module Vagrant end end - # Loads on initial access and reads data from the global data store. - # The global data store is global to Vagrant everywhere (in every environment), - # so it can be used to store system-wide information. Note that "system-wide" - # typically means "for this user" since the location of the global data - # store is in the home directory. - # - # @return [DataStore] - def global_data - @global_data ||= DataStore.new(File.expand_path("global_data.json", home_path)) - end - # The root path is the path where the top-most (loaded last) # Vagrantfile resides. It can be considered the project root for # this environment. diff --git a/test/unit/vagrant/data_store_test.rb b/test/unit/vagrant/data_store_test.rb deleted file mode 100644 index 0cf2cc308..000000000 --- a/test/unit/vagrant/data_store_test.rb +++ /dev/null @@ -1,79 +0,0 @@ -require File.expand_path("../../base", __FILE__) - -require 'pathname' - -describe Vagrant::DataStore do - include_context "unit" - - let(:db_file) do - # We create a tempfile and force an explicit close/unlink - # but save the path so that we can re-use it multiple times - temp = Tempfile.new("vagrant") - result = Pathname.new(temp.path) - temp.close - temp.unlink - - result - end - - let(:instance) { described_class.new(db_file) } - - it "initializes a new DB file" do - instance[:data] = true - instance.commit - instance[:data].should == true - - test = described_class.new(db_file) - test[:data].should == true - end - - it "initializes empty if the file contains invalid data" do - db_file.open("w+") { |f| f.write("NOPE!") } - described_class.new(db_file).should be_empty - end - - it "initializes empty if the file doesn't exist" do - described_class.new("NOPENOPENOPENOPENPEPEPEPE").should be_empty - end - - it "raises an error if the path given is a directory" do - db_file.delete if db_file.exist? - db_file.mkdir - - expect { described_class.new(db_file) }. - to raise_error(Vagrant::Errors::DotfileIsDirectory) - end - - it "cleans nil and empties when committing" do - instance[:data] = { :bar => nil } - instance[:another] = {} - instance.commit - - # The instance is now empty because the data was nil - instance.should be_empty - end - - it "deletes the data file if the store is empty when saving" do - instance[:data] = true - instance.commit - - another = described_class.new(db_file) - another[:data] = nil - another.commit - - # The file should no longer exist - db_file.should_not be_exist - end - - it "works if the DB file is nil" do - store = described_class.new(nil) - store[:foo] = "bar" - store[:foo].should == "bar" - end - - it "throws an exception if attempting to commit a data store with no file" do - store = described_class.new(nil) - expect { store.commit }. - to raise_error(StandardError) - end -end From cd969e1e059dcb6612bd108f805c4b2ce4b2bfb4 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 26 Dec 2012 21:42:54 -0800 Subject: [PATCH 7/7] Remove the dotfile_name configuration option. The dotfile is gone now so the configuration option is obselete --- config/default.rb | 1 - plugins/kernel_v1/config/vagrant.rb | 3 ++- plugins/kernel_v2/config/vagrant.rb | 1 - test/unit/vagrant/environment_test.rb | 11 +++++------ 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/config/default.rb b/config/default.rb index f2108d8a1..180e0fc76 100644 --- a/config/default.rb +++ b/config/default.rb @@ -1,6 +1,5 @@ Vagrant.configure("2") do |config| # default config goes here - config.vagrant.dotfile_name = ".vagrant" config.vagrant.host = :detect config.ssh.username = "vagrant" diff --git a/plugins/kernel_v1/config/vagrant.rb b/plugins/kernel_v1/config/vagrant.rb index b9730a056..ed77bc668 100644 --- a/plugins/kernel_v1/config/vagrant.rb +++ b/plugins/kernel_v1/config/vagrant.rb @@ -12,8 +12,9 @@ module VagrantPlugins end def upgrade(new) - new.vagrant.dotfile_name = @dotfile_name if @dotfile_name != UNSET_VALUE new.vagrant.host = @host if @host != UNSET_VALUE + + # TODO: Warn that "dotfile_name" is gone in V2 end end end diff --git a/plugins/kernel_v2/config/vagrant.rb b/plugins/kernel_v2/config/vagrant.rb index 0b5860081..afe13213f 100644 --- a/plugins/kernel_v2/config/vagrant.rb +++ b/plugins/kernel_v2/config/vagrant.rb @@ -3,7 +3,6 @@ require "vagrant" module VagrantPlugins module Kernel_V2 class VagrantConfig < Vagrant.plugin("2", :config) - attr_accessor :dotfile_name attr_accessor :host end end diff --git a/test/unit/vagrant/environment_test.rb b/test/unit/vagrant/environment_test.rb index b4e1e4b8a..e44d6b8da 100644 --- a/test/unit/vagrant/environment_test.rb +++ b/test/unit/vagrant/environment_test.rb @@ -158,26 +158,26 @@ VF environment = isolated_environment do |env| env.vagrantfile(<<-VF) Vagrant.configure("2") do |config| - config.vagrant.dotfile_name = "foo" + config.ssh.port = 200 end VF end env = environment.create_vagrant_env - env.config_global.vagrant.dotfile_name.should == "foo" + env.config_global.ssh.port.should == 200 end it "should load from a custom Vagrantfile" do environment = isolated_environment do |env| env.file("non_standard_name", <<-VF) Vagrant.configure("2") do |config| - config.vagrant.dotfile_name = "custom" + config.ssh.port = 200 end VF end env = environment.create_vagrant_env(:vagrantfile_name => "non_standard_name") - env.config_global.vagrant.dotfile_name.should == "custom" + env.config_global.ssh.port.should == 200 end end @@ -323,7 +323,6 @@ VF env.vagrantfile(<<-VF) Vagrant.configure("2") do |config| config.ssh.port = 1 - config.vagrant.dotfile_name = "foo" config.vm.box = "base" config.vm.define "vm1" do |inner| @@ -338,7 +337,7 @@ VF env = environment.create_vagrant_env machine = env.machine(:vm1, :foo) machine.config.ssh.port.should == 100 - machine.config.vagrant.dotfile_name.should == "foo" + machine.config.vm.box.should == "base" end it "should load the box configuration for a V2 box" do