Class: VagrantPlugins::Parallels::Action::PrepareNFSSettings

Inherits:
Object
  • Object
show all
Includes:
Vagrant::Action::Builtin::MixinSyncedFolders, Vagrant::Util::Retryable
Defined in:
lib/vagrant-parallels/action/prepare_nfs_settings.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ PrepareNFSSettings

Returns a new instance of PrepareNFSSettings.



11
12
13
14
# File 'lib/vagrant-parallels/action/prepare_nfs_settings.rb', line 11

def initialize(app, env)
  @app = app
  @logger = Log4r::Logger.new('vagrant_parallels::action::nfs')
end

Instance Method Details

#add_ips_to_env!(env) ⇒ Object

Extracts the proper host and guest IPs for NFS mounts and stores them in the environment for the SyncedFolder action to use them in mounting.

The ! indicates that this method modifies its argument.

Raises:

  • (Vagrant::Errors::NFSNoHostIP)


38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/vagrant-parallels/action/prepare_nfs_settings.rb', line 38

def add_ips_to_env!(env)
  host_ip  = @machine.provider.driver.read_shared_interface[:ip]
  guest_ip = @machine.provider.driver.ssh_ip

  # If we couldn't determine either guest's or host's IP, then
  # it is probably a bug. Display an appropriate error message.
  raise Vagrant::Errors::NFSNoHostIP  if !host_ip
  raise Vagrant::Errors::NFSNoGuestIP if !guest_ip

  env[:nfs_host_ip]    = host_ip
  env[:nfs_machine_ip] = guest_ip
end

#call(env) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/vagrant-parallels/action/prepare_nfs_settings.rb', line 16

def call(env)
  @machine = env[:machine]
  @app.call(env)

  opts = {
    cached: !!env[:synced_folders_cached],
    config: env[:synced_folders_config],
    disable_usable_check: !!env[:test],
  }
  folders = synced_folders(env[:machine], **opts)

  if folders.has_key?(:nfs)
    @logger.info('Using NFS, preparing NFS settings by reading host IP and machine IP')
    add_ips_to_env!(env)
  end
end