use a safer default name for virtualbox

if the same vagrantfile is up'd in the same second in the same basedir
this caused a conflict,

most notably, all jenkins jobs sit in a 'workspace' directory, which
breaks if more than one job launches from the same trigger.
This commit is contained in:
Andy Fowler 2013-11-09 15:54:46 -05:00
parent a92e03cf4c
commit d775756d18
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