Skip to content

Commit

Permalink
Merge pull request #62 from patricknelson/master
Browse files Browse the repository at this point in the history
Custom override of host IP addressed used in NFS shares
  • Loading branch information
GM-Alex committed Dec 7, 2015
2 parents c88a64d + 447faff commit 97a300e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions lib/vagrant-winnfsd/config/winnfsd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ class WinNFSd < Vagrant.plugin('2', :config)
attr_accessor :logging
attr_accessor :uid
attr_accessor :gid
attr_accessor :host_ip

def initialize
@logging = UNSET_VALUE
@uid = UNSET_VALUE
@gid = UNSET_VALUE
@host_ip = UNSET_VALUE
end

def validate(machine)
Expand All @@ -19,6 +21,7 @@ def validate(machine)
errors << 'winnfsd.logging cannot only be \'on\' or \'off\'.' unless (machine.config.winnfsd.logging == 'on' || machine.config.winnfsd.logging == 'off')
errors << 'winnfsd.uid cannot be nil.' if machine.config.winnfsd.uid.nil?
errors << 'winnfsd.gid cannot be nil.' if machine.config.winnfsd.gid.nil?
errors << 'winnfsd.host_ip cannot be nil.' if machine.config.winnfsd.host_ip.nil?

{ "WinNFSd" => errors }
end
Expand All @@ -27,6 +30,7 @@ def finalize!
@logging = 'off' if @logging == UNSET_VALUE
@uid = 0 if @uid == UNSET_VALUE
@gid = 0 if @gid == UNSET_VALUE
@host_ip = "" if @host_ip == UNSET_VALUE
end
end
end
Expand Down
11 changes: 9 additions & 2 deletions lib/vagrant-winnfsd/synced_folder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,17 @@ def enable(machine, folders, nfsopts)
end
mount_folders[id] = opts.dup if opts[:guestpath]
end


# Allow override of the host IP via config.
# TODO: This should be configurable somewhere deeper in Vagrant core.
host_ip = nfsopts[:nfs_host_ip]
if (machine.env.vagrantfile.config.winnfsd.host_ip)
host_ip = machine.env.vagrantfile.config.winnfsd.host_ip
end

# Mount them!
machine.guest.capability(
:mount_nfs_folder, nfsopts[:nfs_host_ip], mount_folders)
:mount_nfs_folder, host_ip, mount_folders)
end
end
end

0 comments on commit 97a300e

Please sign in to comment.