2014-03-14 17:51:00 +00:00
|
|
|
require "vagrant/util/template_renderer"
|
|
|
|
|
|
|
|
module VagrantPlugins
|
|
|
|
module GuestWindows
|
|
|
|
module Cap
|
|
|
|
class MountSharedFolder
|
|
|
|
def self.mount_virtualbox_shared_folder(machine, name, guestpath, options)
|
|
|
|
mount_shared_folder(machine, name, guestpath, "\\\\vboxsrv\\")
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.mount_vmware_shared_folder(machine, name, guestpath, options)
|
|
|
|
mount_shared_folder(machine, name, guestpath, "\\\\vmware-host\\Shared Folders\\")
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.mount_parallels_shared_folder(machine, name, guestpath, options)
|
|
|
|
mount_shared_folder(machine, name, guestpath, "\\\\psf\\")
|
|
|
|
end
|
|
|
|
|
2014-07-17 10:13:50 +00:00
|
|
|
def self.mount_smb_shared_folder(machine, name, guestpath, options)
|
|
|
|
machine.communicate.execute("cmdkey /add:#{options[:smb_host]} /user:#{options[:smb_username]} /pass:#{options[:smb_password]}", {shell: :powershell, elevated: true})
|
|
|
|
mount_shared_folder(machine, name, guestpath, "\\\\#{options[:smb_host]}\\")
|
|
|
|
end
|
|
|
|
|
2014-03-14 17:51:00 +00:00
|
|
|
protected
|
|
|
|
|
|
|
|
def self.mount_shared_folder(machine, name, guestpath, vm_provider_unc_base)
|
|
|
|
name = name.gsub(/[\/\/]/,'_').sub(/^_/, '')
|
|
|
|
|
2014-03-14 18:05:00 +00:00
|
|
|
path = File.expand_path("../../scripts/mount_volume.ps1", __FILE__)
|
2014-03-14 17:51:00 +00:00
|
|
|
script = Vagrant::Util::TemplateRenderer.render(path, options: {
|
|
|
|
mount_point: guestpath,
|
|
|
|
share_name: name,
|
|
|
|
vm_provider_unc_path: vm_provider_unc_base + name,
|
|
|
|
})
|
|
|
|
|
|
|
|
machine.communicate.execute(script, shell: :powershell)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|