Class: VagrantPlugins::Parallels::SyncedFolderMacVM

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-parallels/synced_folder_macvm.rb

Instance Method Summary collapse

Instance Method Details

#cleanup(machine, opts) ⇒ Object



40
41
42
# File 'lib/vagrant-parallels/synced_folder_macvm.rb', line 40

def cleanup(machine, opts)
  driver(machine).clear_shared_folders if machine.id && machine.id != ''
end

#disable(machine, folders, _opts) ⇒ Object



34
35
36
37
38
# File 'lib/vagrant-parallels/synced_folder_macvm.rb', line 34

def disable(machine, folders, _opts)
  # 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

#driver(machine) ⇒ Object

This is here so that we can stub it for tests



45
46
47
# File 'lib/vagrant-parallels/synced_folder_macvm.rb', line 45

def driver(machine)
  machine.provider.driver
end

#enable(machine, folders, _opts) ⇒ Object



29
30
31
32
# File 'lib/vagrant-parallels/synced_folder_macvm.rb', line 29

def enable(machine, folders, _opts)
  # TBD: Synced folders for *.macvm are not implemented yet
  return
end

#prepare(machine, folders, _opts) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/vagrant-parallels/synced_folder_macvm.rb', line 11

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

Returns:

  • (Boolean)


6
7
8
9
# File 'lib/vagrant-parallels/synced_folder_macvm.rb', line 6

def usable?(machine, raise_errors=false)
  # These synced folders only work if the provider is Parallels and the guest is *.macvm
  machine.provider_name == :parallels && Util::Common::is_macvm(machine)
end