guests/omnios: Update NFS folder mounting in one command
This commit is contained in:
parent
95972c1527
commit
c441732c59
|
@ -3,11 +3,17 @@ module VagrantPlugins
|
||||||
module Cap
|
module Cap
|
||||||
class MountNFSFolder
|
class MountNFSFolder
|
||||||
def self.mount_nfs_folder(machine, ip, folders)
|
def self.mount_nfs_folder(machine, ip, folders)
|
||||||
su_cmd = machine.config.solaris.suexec_cmd
|
comm = machine.communicate
|
||||||
folders.each do |name, opts|
|
commands = []
|
||||||
machine.communicate.execute("#{su_cmd} mkdir -p #{opts[:guestpath]}")
|
|
||||||
machine.communicate.execute("#{su_cmd} /sbin/mount '#{ip}:#{opts[:hostpath]}' '#{opts[:guestpath]}'")
|
folders.each do |_, opts|
|
||||||
end
|
commands << <<-EOH.gsub(/^ {14}/, '')
|
||||||
|
mkdir -p '#{opts[:guestpath]}'
|
||||||
|
/sbin/mount '#{ip}:#{opts[:hostpath]}' '#{opts[:guestpath]}'
|
||||||
|
EOH
|
||||||
|
end
|
||||||
|
|
||||||
|
comm.sudo(commands.join("\n"))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
require_relative "../../../../base"
|
||||||
|
|
||||||
|
describe "VagrantPlugins::GuestOmniOS::Cap:RSync" do
|
||||||
|
let(:caps) do
|
||||||
|
VagrantPlugins::GuestOmniOS::Plugin
|
||||||
|
.components
|
||||||
|
.guest_capabilities[:omnios]
|
||||||
|
end
|
||||||
|
|
||||||
|
let(:machine) { double("machine") }
|
||||||
|
let(:comm) { VagrantTests::DummyCommunicator::Communicator.new(machine) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
allow(machine).to receive(:communicate).and_return(comm)
|
||||||
|
end
|
||||||
|
|
||||||
|
after do
|
||||||
|
comm.verify_expectations!
|
||||||
|
end
|
||||||
|
|
||||||
|
describe ".mount_nfs_folder" do
|
||||||
|
let(:cap) { caps.get(:mount_nfs_folder) }
|
||||||
|
|
||||||
|
let(:ip) { "1.2.3.4" }
|
||||||
|
|
||||||
|
let(:hostpath) { "/host" }
|
||||||
|
let(:guestpath) { "/guest" }
|
||||||
|
|
||||||
|
it "mounts the folder" do
|
||||||
|
folders = {
|
||||||
|
"/vagrant-nfs" => {
|
||||||
|
type: :nfs,
|
||||||
|
guestpath: "/guest",
|
||||||
|
hostpath: "/host",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cap.mount_nfs_folder(machine, ip, folders)
|
||||||
|
|
||||||
|
expect(comm.received_commands[0]).to match(/mkdir -p '#{guestpath}'/)
|
||||||
|
expect(comm.received_commands[0]).to match(/'1.2.3.4:#{hostpath}' '#{guestpath}'/)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "mounts with options" do
|
||||||
|
pending "not yet implemented"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue