Host NFS export
This commit is contained in:
parent
de38af8111
commit
9f4950375e
|
@ -2,10 +2,26 @@ module Vagrant
|
|||
module Hosts
|
||||
# Represents a BSD host, such as FreeBSD and Darwin (Mac OS X).
|
||||
class BSD < Base
|
||||
include Util
|
||||
|
||||
def nfs?
|
||||
# TODO: verify it exists
|
||||
true
|
||||
end
|
||||
|
||||
def nfs_export(ip, folders)
|
||||
output = TemplateRenderer.render('nfs/exports',
|
||||
:uuid => env.vm.uuid,
|
||||
:ip => ip,
|
||||
:folders => folders)
|
||||
|
||||
env.logger.info "Preparing to edit /etc/exports. Administrator priveleges will be required..."
|
||||
output.split("\n").each do |line|
|
||||
# This should only ask for administrative permission once, even
|
||||
# though its executed in multiple subshells.
|
||||
system(%Q[sudo su root -c "echo '#{line}' >> /etc/exports"])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
# VAGRANT-BEGIN: <%= uuid %>
|
||||
<%= folders.inspect %>
|
||||
# VAGRANT-END: <%= uuid %>
|
|
@ -0,0 +1,36 @@
|
|||
require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
|
||||
|
||||
class BSDHostTest < Test::Unit::TestCase
|
||||
setup do
|
||||
@klass = Vagrant::Hosts::BSD
|
||||
@env = mock_environment
|
||||
@env.stubs(:vm).returns(Vagrant::VM.new(:env => @env))
|
||||
@instance = @klass.new(@env)
|
||||
end
|
||||
|
||||
context "supporting nfs check" do
|
||||
should "support NFS" do
|
||||
assert @instance.nfs?
|
||||
end
|
||||
end
|
||||
|
||||
context "nfs export" do
|
||||
setup do
|
||||
@instance.stubs(:system)
|
||||
|
||||
@ip = "foo"
|
||||
@folders = "bar"
|
||||
end
|
||||
|
||||
should "output the lines of the rendered template" do
|
||||
output = %W[foo bar baz].join("\n")
|
||||
Vagrant::Util::TemplateRenderer.expects(:render).with("nfs/exports",
|
||||
:uuid => @env.vm.uuid,
|
||||
:ip => @ip,
|
||||
:folders => @folders).returns(output)
|
||||
|
||||
@instance.expects(:system).times(output.split("\n").length)
|
||||
@instance.nfs_export(@ip, @folders)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue