providers/virtualbox: synced folder supports the "disable" method
This commit is contained in:
parent
ef7a230c6b
commit
afb61b1466
|
@ -266,6 +266,10 @@ module VagrantPlugins
|
|||
def suspend
|
||||
end
|
||||
|
||||
# Unshare folders.
|
||||
def unshare_folders(names)
|
||||
end
|
||||
|
||||
# Verifies that the driver is ready to accept work.
|
||||
#
|
||||
# This should raise a VagrantError if things are not ready.
|
||||
|
|
|
@ -478,6 +478,27 @@ module VagrantPlugins
|
|||
execute("controlvm", @uuid, "savestate")
|
||||
end
|
||||
|
||||
def unshare_folders(names)
|
||||
names.each do |name|
|
||||
begin
|
||||
execute(
|
||||
"sharedfolder", "remove", @uuid,
|
||||
"--name", name,
|
||||
"--transient")
|
||||
|
||||
execute(
|
||||
"setextradata", @uuid,
|
||||
"VBoxInternal2/SharedFoldersEnableSymlinksCreate/#{name}")
|
||||
rescue Vagrant::Errors::VBoxManageError => e
|
||||
if e.extra_data[:stderr].include?("VBOX_E_FILE_ERROR")
|
||||
# The folder doesn't exist. ignore.
|
||||
else
|
||||
raise
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def verify!
|
||||
# This command sometimes fails if kernel drivers aren't properly loaded
|
||||
# so we just run the command and verify that it succeeded.
|
||||
|
|
|
@ -488,6 +488,27 @@ module VagrantPlugins
|
|||
execute("controlvm", @uuid, "savestate")
|
||||
end
|
||||
|
||||
def unshare_folders(names)
|
||||
names.each do |name|
|
||||
begin
|
||||
execute(
|
||||
"sharedfolder", "remove", @uuid,
|
||||
"--name", name,
|
||||
"--transient")
|
||||
|
||||
execute(
|
||||
"setextradata", @uuid,
|
||||
"VBoxInternal2/SharedFoldersEnableSymlinksCreate/#{name}")
|
||||
rescue Vagrant::Errors::VBoxManageError => e
|
||||
if e.extra_data[:stderr].include?("VBOX_E_FILE_ERROR")
|
||||
# The folder doesn't exist. ignore.
|
||||
else
|
||||
raise
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def verify!
|
||||
# This command sometimes fails if kernel drivers aren't properly loaded
|
||||
# so we just run the command and verify that it succeeded.
|
||||
|
|
|
@ -512,6 +512,27 @@ module VagrantPlugins
|
|||
execute("controlvm", @uuid, "savestate")
|
||||
end
|
||||
|
||||
def unshare_folders(names)
|
||||
names.each do |name|
|
||||
begin
|
||||
execute(
|
||||
"sharedfolder", "remove", @uuid,
|
||||
"--name", name,
|
||||
"--transient")
|
||||
|
||||
execute(
|
||||
"setextradata", @uuid,
|
||||
"VBoxInternal2/SharedFoldersEnableSymlinksCreate/#{name}")
|
||||
rescue Vagrant::Errors::VBoxManageError => e
|
||||
if e.extra_data[:stderr].include?("VBOX_E_FILE_ERROR")
|
||||
# The folder doesn't exist. ignore.
|
||||
else
|
||||
raise
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def verify!
|
||||
# This command sometimes fails if kernel drivers aren't properly loaded
|
||||
# so we just run the command and verify that it succeeded.
|
||||
|
|
|
@ -520,6 +520,27 @@ module VagrantPlugins
|
|||
execute("controlvm", @uuid, "savestate")
|
||||
end
|
||||
|
||||
def unshare_folders(names)
|
||||
names.each do |name|
|
||||
begin
|
||||
execute(
|
||||
"sharedfolder", "remove", @uuid,
|
||||
"--name", name,
|
||||
"--transient")
|
||||
|
||||
execute(
|
||||
"setextradata", @uuid,
|
||||
"VBoxInternal2/SharedFoldersEnableSymlinksCreate/#{name}")
|
||||
rescue Vagrant::Errors::VBoxManageError => e
|
||||
if e.extra_data[:stderr].include?("VBOX_E_FILE_ERROR")
|
||||
# The folder doesn't exist. ignore.
|
||||
else
|
||||
raise
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def verify!
|
||||
# This command sometimes fails if kernel drivers aren't properly loaded
|
||||
# so we just run the command and verify that it succeeded.
|
||||
|
|
|
@ -63,6 +63,14 @@ module VagrantPlugins
|
|||
end
|
||||
end
|
||||
|
||||
def disable(machine, folders, _opts)
|
||||
# TODO: unmount.
|
||||
|
||||
# Remove the shared folders from the VM metadata
|
||||
names = folders.map { |id, _data| os_friendly_id(id) }
|
||||
driver(machine).unshare_folders(names)
|
||||
end
|
||||
|
||||
def cleanup(machine, opts)
|
||||
driver(machine).clear_shared_folders if machine.id && machine.id != ""
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue