diff --git a/lib/vagrant/action/vm/nfs.rb b/lib/vagrant/action/vm/nfs.rb index af80e3785..72694ff57 100644 --- a/lib/vagrant/action/vm/nfs.rb +++ b/lib/vagrant/action/vm/nfs.rb @@ -65,7 +65,7 @@ module Vagrant @env.logger.info "Exporting NFS shared folders..." catch_action_exception(@env) do - @env["host"].nfs_export(folders) + @env["host"].nfs_export(guest_ip, folders) end end @@ -90,6 +90,14 @@ module Vagrant interface.host_interface_object.ip_address end + # Returns the IP address of the guest by looking at the first + # enabled host only network. + # + # @return [String] + def guest_ip + @env["config"].vm.network_options[1][:ip] + end + # Verifies that the host is set and supports NFS. def verify_settings return @env.error!(:nfs_host_required) if @env["host"].nil? diff --git a/lib/vagrant/hosts/base.rb b/lib/vagrant/hosts/base.rb index b153b3c75..ba1d76ec5 100644 --- a/lib/vagrant/hosts/base.rb +++ b/lib/vagrant/hosts/base.rb @@ -63,8 +63,9 @@ module Vagrant # Exports the given hash of folders via NFS. This method will raise # an {Vagrant::Action::ActionException} if anything goes wrong. # + # @param [String] ip IP of the guest machine. # @param [Hash] folders Shared folders to sync. - def nfs_export(folders) + def nfs_export(ip, folders) end end end diff --git a/test/vagrant/action/vm/nfs_test.rb b/test/vagrant/action/vm/nfs_test.rb index 41a76901c..742f17cbc 100644 --- a/test/vagrant/action/vm/nfs_test.rb +++ b/test/vagrant/action/vm/nfs_test.rb @@ -96,10 +96,11 @@ class NFSVMActionTest < Test::Unit::TestCase context "exporting folders" do setup do @instance.stubs(:folders).returns({}) + @instance.stubs(:guest_ip).returns("192.168.33.10") end should "call nfs_export on the host" do - @env["host"].expects(:nfs_export).with(@instance.folders) + @env["host"].expects(:nfs_export).with(@instance.guest_ip, @instance.folders) @instance.export_folders end @@ -151,6 +152,15 @@ class NFSVMActionTest < Test::Unit::TestCase end end + context "getting the guest IP" do + should "return the first networked IP" do + ip = "192.168.33.10" + @env.env.config.vm.network(ip, :adapter => 1) + @env.env.config.vm.network("192.168.66.10", :adapter => 2) + assert_equal ip, @instance.guest_ip + end + end + context "verifying settings" do setup do @env.env.host.stubs(:nfs?).returns(true) diff --git a/vagrant.gemspec b/vagrant.gemspec index 509354404..fdcc28cea 100644 --- a/vagrant.gemspec +++ b/vagrant.gemspec @@ -9,7 +9,7 @@ Gem::Specification.new do |s| s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version= s.authors = ["Mitchell Hashimoto", "John Bender"] - s.date = %q{2010-07-11} + s.date = %q{2010-07-12} s.default_executable = %q{vagrant} s.description = %q{Vagrant is a tool for building and distributing virtualized development environments.} s.email = ["mitchell.hashimoto@gmail.com", "john.m.bender@gmail.com"]