providers/virtualbox: don't do transient by default

This commit is contained in:
Mitchell Hashimoto 2014-05-05 15:44:45 -07:00
parent 958684fd7e
commit f475df0987
3 changed files with 39 additions and 20 deletions

View File

@ -2,9 +2,6 @@
BACKWARDS INCOMPATIBILITIES: BACKWARDS INCOMPATIBILITIES:
- providers/virtualbox: Shared folders backed by VirtualBox are now
"transient". They will be removed if you reboot outside of Vagrant.
Always use `vagrant reload`.
- Deprecated: `halt_timeout` and `halt_check_interval` settings for - Deprecated: `halt_timeout` and `halt_check_interval` settings for
SmartOS, Solaris, and Solaris11 guests. These will be fully SmartOS, Solaris, and Solaris11 guests. These will be fully
removed in 1.7. A warning will be shown if they're in use in removed in 1.7. A warning will be shown if they're in use in

View File

@ -117,6 +117,11 @@ module VagrantPlugins
# Add this synced folder onto the new config if we haven't # Add this synced folder onto the new config if we haven't
# already shared it before. # already shared it before.
if !existing_ids.has_key?(id) if !existing_ids.has_key?(id)
# A bit of a hack for VirtualBox to mount our
# folder as transient. This can be removed once
# the VirtualBox synced folder mechanism is smarter.
data[:virtualbox__transient] = true
new_config.synced_folder( new_config.synced_folder(
data[:hostpath], data[:hostpath],
data[:guestpath], data[:guestpath],

View File

@ -9,23 +9,12 @@ module VagrantPlugins
machine.provider_config.functional_vboxsf machine.provider_config.functional_vboxsf
end end
def prepare(machine, folders, _opts)
share_folders(machine, folders, false)
end
def enable(machine, folders, _opts) def enable(machine, folders, _opts)
# Export the shared folders to the VM share_folders(machine, folders, true)
defs = []
folders.each do |id, data|
hostpath = data[:hostpath]
if !data[:hostpath_exact]
hostpath = Vagrant::Util::Platform.cygwin_windows_path(hostpath)
end
defs << {
name: os_friendly_id(id),
hostpath: hostpath.to_s,
transient: true,
}
end
driver(machine).share_folders(defs)
# short guestpaths first, so we don't step on ourselves # short guestpaths first, so we don't step on ourselves
folders = folders.sort_by do |id, data| folders = folders.sort_by do |id, data|
@ -94,6 +83,34 @@ module VagrantPlugins
def os_friendly_id(id) def os_friendly_id(id)
id.gsub(/[\/]/,'_').sub(/^_/, '') id.gsub(/[\/]/,'_').sub(/^_/, '')
end end
# share_folders sets up the shared folder definitions on the
# VirtualBox VM.
#
# The transient parameter determines if we're FORCING transient
# or not. If this is false, then any shared folders will be
# shared as non-transient unless they've specifically asked for
# transient.
def share_folders(machine, folders, transient)
defs = []
folders.each do |id, data|
hostpath = data[:hostpath]
if !data[:hostpath_exact]
hostpath = Vagrant::Util::Platform.cygwin_windows_path(hostpath)
end
# Only setup the shared folders that match our transient level
if (!!data[:transient]) == transient
defs << {
name: os_friendly_id(id),
hostpath: hostpath.to_s,
transient: transient,
}
end
end
driver(machine).share_folders(defs)
end
end end
end end
end end