Sha256: 43d65e7c891afa665260a362db64f7e9b069123fabee8a262696e81f2e0cee7c

Contents?: true

Size: 1.43 KB

Versions: 8

Compression:

Stored size: 1.43 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::LinuxNFSMountFailed, tries: 5, sleep: 2) do
                comm.execute(mount_command,
                             error_class: Vagrant::Errors::LinuxNFSMountFailed)
              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

8 entries across 5 versions & 2 rubygems

Version Path
vagrant-unbundled-1.8.4.2 plugins/guests/esxi/cap/mount_nfs_folder.rb
vagrant-unbundled-1.8.4.1 plugins/guests/esxi/cap/mount_nfs_folder.rb
vagrant-unbundled-1.8.1.2 plugins/guests/esxi/cap/mount_nfs_folder.rb
vagrant-unbundled-1.8.1.1 plugins/guests/esxi/cap/mount_nfs_folder.rb
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-1cf2a8db4ccb/plugins/guests/esxi/cap/mount_nfs_folder.rb
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-b421af58e8b3/plugins/guests/esxi/cap/mount_nfs_folder.rb
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-309e896975d1/plugins/guests/esxi/cap/mount_nfs_folder.rb
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-272fb27e0536/plugins/guests/esxi/cap/mount_nfs_folder.rb