providers/virtualbox: only set default name on first up [GH-1817]

This commit is contained in:
Mitchell Hashimoto 2013-08-31 22:43:33 -07:00
parent 9e38601f18
commit a96efcdec9
2 changed files with 14 additions and 0 deletions

View File

@ -73,6 +73,8 @@ BUG FIXES:
with Puppet. [GH-2015]
- providers/virtualbox: Use `getent` to get the group ID instead of
`id` in case the name doesn't have a user. [GH-1801]
- providers/virtualbox: Will only set the default name of the VM on
initial `up`. [GH-1817]
## 1.2.7 (July 28, 2013)

View File

@ -12,6 +12,13 @@ module VagrantPlugins
def call(env)
name = env[:machine].provider_config.name
# If we already set the name before, then don't do anything
sentinel = env[:machine].data_dir.join("action_set_name")
if !name && sentinel.file?
@logger.info("Default name was already set before, not doing it again.")
return @app.call(env)
end
# If no name was manually set, then use a default
if !name
prefix = "#{env[:root_path].basename.to_s}_#{env[:machine].name}"
@ -32,6 +39,11 @@ module VagrantPlugins
env[:machine].provider.driver.set_name(name)
end
# Create the sentinel
sentinel.open("w") do |f|
f.write(Time.now.to_i.to_s)
end
@app.call(env)
end
end