Class: Vagrant::Solaris10::Cap::MountNFSFolder

Inherits:
Object
  • Object
show all
Extended by:
Util::Retryable
Defined in:
lib/vagrant-solaris10/cap/mount_nfs_folder.rb

Class Method Summary collapse

Class Method Details

.mount_nfs_folder(machine, ip, folders) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/vagrant-solaris10/cap/mount_nfs_folder.rb', line 18

def self.mount_nfs_folder(machine, ip, folders)
  folders.each do |name, opts|
    # Expand the guest path so we can handle things like "~/vagrant"
    expanded_guest_path = machine.guest.capability(
      :shell_expand_guest_path, opts[:guestpath])
  
    # Create the folder
    machine.communicate.sudo("mkdir -p #{expanded_guest_path}")
  
    # Figure out any options
    mount_opts = ["vers=#{opts[:nfs_version]}"]
    if opts[:mount_options]
      mount_opts = opts[:mount_options].dup
    end
  
    mount_command = "mount -F nfs " +
      "-o '#{mount_opts.join(",")}' " +
      "'#{ip}:#{opts[:hostpath]}' '#{expanded_guest_path}'"
    retryable(on: Vagrant::Errors::SolarisNFSMountFailed, tries: 10, sleep: 5) do
      machine.communicate.sudo(
        mount_command,
        error_class: Vagrant::Errors::SolarisNFSMountFailed)
    end
  end
end