Class: HashiCorp::VagrantVMwareDesktop::Action::PrepareNFSSettings

Inherits:
Object
  • Object
show all
Includes:
Common
Defined in:
lib/vagrant-vmware-desktop/action/prepare_nfs_settings.rb

Instance Method Summary collapse

Methods included from Common

#to_s

Constructor Details

#initialize(app, env) ⇒ PrepareNFSSettings

Returns a new instance of PrepareNFSSettings.



10
11
12
13
# File 'lib/vagrant-vmware-desktop/action/prepare_nfs_settings.rb', line 10

def initialize(app,env)
  @app = app
  @logger = Log4r::Logger.new("vagrant::action::vm::nfs")
end

Instance Method Details

#call(env) ⇒ Object



15
16
17
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-vmware-desktop/action/prepare_nfs_settings.rb', line 15

def call(env)
  @app.call(env)

  env[:nfs_machine_ip] = env[:machine].provider.driver.read_ip(
    env[:machine].provider_config.enable_vmrun_ip_lookup
  )

  # We just assume the machine IP is the first 3 octets
  # with "1" for the last octet. Poor assumption but can
  # be fixed later.
  if env[:nfs_machine_ip]
    host_ip = env[:nfs_machine_ip].split(".").map(&:to_i)
    host_ip[3] = 1
    env[:nfs_host_ip] = host_ip.join(".")
  end

  using_nfs = false
  env[:machine].config.vm.synced_folders.each do |id, opts|
    if opts[:nfs]
      using_nfs = true
      break
    end
  end

  if using_nfs
    raise Errors::NFSNoNetwork if !env[:nfs_machine_ip]
  end
end