Class: VagrantPlugins::Parallels::SyncedFolder
- Inherits:
-
Object
- Object
- VagrantPlugins::Parallels::SyncedFolder
- Defined in:
- lib/vagrant-parallels/synced_folder.rb
Instance Method Summary collapse
- #cleanup(machine, opts) ⇒ Object
- #disable(machine, folders, _opts) ⇒ Object
- #enable(machine, folders, _opts) ⇒ Object
- #prepare(machine, folders, _opts) ⇒ Object
- #usable?(machine, raise_errors = false) ⇒ Boolean
Instance Method Details
#cleanup(machine, opts) ⇒ Object
94 95 96 |
# File 'lib/vagrant-parallels/synced_folder.rb', line 94 def cleanup(machine, opts) driver(machine).clear_shared_folders if machine.id && machine.id != '' end |
#disable(machine, folders, _opts) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/vagrant-parallels/synced_folder.rb', line 80 def disable(machine, folders, _opts) if machine.guest.capability?(:unmount_parallels_shared_folder) folders.each do |id, data| machine.guest.capability( :unmount_parallels_shared_folder, data[:guestpath], data) end end # Remove the shared folders from the VM metadata names = folders.map { |id, data| data[:plugin].capability(:mount_name, id, data) } driver(machine).unshare_folders(names) end |
#enable(machine, folders, _opts) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/vagrant-parallels/synced_folder.rb', line 31 def enable(machine, folders, _opts) # short guestpaths first, so we don't step on ourselves folders = folders.sort_by do |id, data| if data[:guestpath] data[:guestpath].length else # A long enough path to just do this at the end. 10000 end end # Parallels Shared Folder services can override Vagrant synced folder # configuration. These services should be pre-configured. if machine.guest.capability?(:prepare_psf_services) machine.guest.capability(:prepare_psf_services) end # Go through each folder and mount machine.ui.output(I18n.t('vagrant.actions.vm.share_folders.mounting')) folders.each do |id , data| if data[:guestpath] # Guest path specified, so mount the folder to specified point machine.ui.detail(I18n.t('vagrant.actions.vm.share_folders.mounting_entry', guestpath: data[:guestpath], hostpath: data[:hostpath])) # Dup the data so we can pass it to the guest API data = data.dup # Calculate the owner and group ssh_info = machine.ssh_info data[:owner] ||= ssh_info[:username] data[:group] ||= ssh_info[:username] # Mount the actual folder machine.guest.capability( :mount_parallels_shared_folder, data[:plugin].capability(:mount_name, id, data), data[:guestpath], data ) else # If no guest path is specified, then automounting is disabled machine.ui.detail(I18n.t('vagrant.actions.vm.share_folders.nomount_entry', :hostpath => data[:hostpath])) end end end |
#prepare(machine, folders, _opts) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/vagrant-parallels/synced_folder.rb', line 13 def prepare(machine, folders, _opts) # Setup shared folder definitions in the VM config. defs = [] folders.each do |id, data| hostpath = data[:hostpath] if !data[:hostpath_exact] hostpath = Vagrant::Util::Platform.cygwin_windows_path(hostpath) end defs << { name: data[:plugin].capability(:mount_name, id, data), hostpath: hostpath.to_s, } end driver(machine).share_folders(defs) end |
#usable?(machine, raise_errors = false) ⇒ Boolean
6 7 8 9 10 11 |
# File 'lib/vagrant-parallels/synced_folder.rb', line 6 def usable?(machine, raise_errors=false) # These synced folders only work if the provider is Parallels and the guest is not *.macvm machine.provider_name == :parallels && machine.provider_config.functional_psf && !Util::Common::is_macvm(machine) end |