Sha256: a41d887326fe8f854f17c37aa26c16d0e0a296912f036cd293e38b208cd4519e

Contents?: true

Size: 1.42 KB

Versions: 54

Compression:

Stored size: 1.42 KB

Contents

module VagrantPlugins
  module GuestEsxi
    module Cap
      class MountNFSFolder
        extend Vagrant::Util::Retryable

        def self.mount_nfs_folder(machine, ip, folders)
          folders.each do |name, opts|
            guestpath = opts[:guestpath]
            volume = guestpath.gsub("/", "_")
            machine.communicate.tap do |comm|
              if comm.test("localcli storage nfs list | grep '^#{volume}'")
                comm.execute("localcli storage nfs remove -v #{volume}")
              end
              mount_command = "localcli storage nfs add -H #{ip} -s '#{opts[:hostpath]}' -v '#{volume}'"
              retryable(on: Vagrant::Errors::NFSMountFailed, tries: 5, sleep: 2) do
                comm.execute(mount_command,
                             error_class: Vagrant::Errors::NFSMountFailed)
              end

              # symlink vmfs volume to :guestpath
              if comm.test("test -L '#{guestpath}'")
                comm.execute("rm -f '#{guestpath}'")
              end
              if comm.test("test -d '#{guestpath}'")
                comm.execute("rmdir '#{guestpath}'")
              end
              dir = File.dirname(guestpath)
              if !comm.test("test -d '#{dir}'")
                comm.execute("mkdir -p '#{dir}'")
              end

              comm.execute("ln -s '/vmfs/volumes/#{volume}' '#{guestpath}'")
            end
          end
        end
      end
    end
  end
end

Version data entries

54 entries across 50 versions & 6 rubygems

Version Path
vagrant-unbundled-2.3.6.0 plugins/guests/esxi/cap/mount_nfs_folder.rb
tamtam-vagrant-reload-1.2.1 vendor/cache/vagrant-2092df529ae7/plugins/guests/esxi/cap/mount_nfs_folder.rb
vagrant-unbundled-2.3.3.0 plugins/guests/esxi/cap/mount_nfs_folder.rb
vagrant-unbundled-2.3.2.0 plugins/guests/esxi/cap/mount_nfs_folder.rb
vagrant-unbundled-2.2.19.0 plugins/guests/esxi/cap/mount_nfs_folder.rb
vagrant-unbundled-2.2.18.0 plugins/guests/esxi/cap/mount_nfs_folder.rb
vagrant-unbundled-2.2.16.0 plugins/guests/esxi/cap/mount_nfs_folder.rb
vagrant-unbundled-2.2.14.0 plugins/guests/esxi/cap/mount_nfs_folder.rb
vagrant-aws-mkubenka-0.7.2.pre.24 vendor/bundle/ruby/2.7.0/bundler/gems/vagrant-22795b161bf6/plugins/guests/esxi/cap/mount_nfs_folder.rb
vagrant-unbundled-2.2.10.0 plugins/guests/esxi/cap/mount_nfs_folder.rb
vagrant-unbundled-2.2.9.0 plugins/guests/esxi/cap/mount_nfs_folder.rb
vagrant-unbundled-2.2.8.0 plugins/guests/esxi/cap/mount_nfs_folder.rb
vagrant-unbundled-2.2.7.0 plugins/guests/esxi/cap/mount_nfs_folder.rb
vagrant-unbundled-2.2.6.2 plugins/guests/esxi/cap/mount_nfs_folder.rb
vagrant-unbundled-2.2.6.1 plugins/guests/esxi/cap/mount_nfs_folder.rb
vagrant-unbundled-2.2.6.0 plugins/guests/esxi/cap/mount_nfs_folder.rb
vagrant-unbundled-2.2.5.0 plugins/guests/esxi/cap/mount_nfs_folder.rb
vagrant-unbundled-2.2.4.0 plugins/guests/esxi/cap/mount_nfs_folder.rb
vagrant-unbundled-2.2.3.0 plugins/guests/esxi/cap/mount_nfs_folder.rb
vagrant-unbundled-2.2.2.0 plugins/guests/esxi/cap/mount_nfs_folder.rb