Merge pull request #2482 from andyfowler/safer-vbox-names

core: safer default VM names for Virtualbox
This commit is contained in:
Mitchell Hashimoto 2013-11-21 15:01:31 -08:00
commit 504707f96a
1 changed files with 2 additions and 1 deletions

View File

@ -23,7 +23,8 @@ module VagrantPlugins
if !name
prefix = "#{env[:root_path].basename.to_s}_#{env[:machine].name}"
prefix.gsub!(/[^-a-z0-9_]/i, "")
name = prefix + "_#{Time.now.to_i}"
# milliseconds + random number suffix to allow for simultaneous `vagrant up` of the same box in different dirs
name = prefix + "_#{(Time.now.to_f * 1000.0).to_i}_#{rand(100000)}"
end
# Verify the name is not taken