Merge pull request #5880 from strzibny/fix-nfs

Fix: Rewrite Red Hat NFS handling based on systemd
This commit is contained in:
Mitchell Hashimoto 2015-07-09 14:27:30 -06:00
commit c65c62b2c1
4 changed files with 26 additions and 24 deletions

View File

@ -1,11 +0,0 @@
module VagrantPlugins
module GuestFedora
module Cap
class NFSClient
def self.nfs_client_install(machine)
machine.communicate.sudo("yum -y install nfs-utils nfs-utils-lib")
end
end
end
end
end

View File

@ -30,11 +30,6 @@ module VagrantPlugins
require_relative "cap/flavor" require_relative "cap/flavor"
Cap::Flavor Cap::Flavor
end end
guest_capability("fedora", "nfs_client_install") do
require_relative "cap/nfs_client"
Cap::NFSClient
end
end end
end end
end end

View File

@ -3,14 +3,27 @@ module VagrantPlugins
module Cap module Cap
class NFSClient class NFSClient
def self.nfs_client_install(machine) def self.nfs_client_install(machine)
machine.communicate.tap do |comm| machine.communicate.sudo("yum -y install nfs-utils nfs-utils-lib")
comm.sudo("yum -y install nfs-utils nfs-utils-lib") restart_nfs(machine)
case machine.guest.capability("flavor") end
when :rhel_7
comm.sudo("/bin/systemctl restart rpcbind nfs") def self.nfs_client_installed(machine)
else installed = machine.communicate.test("test -x /sbin/mount.nfs")
comm.sudo("/etc/init.d/rpcbind restart; /etc/init.d/nfs restart") restart_nfs(machine) if installed
end installed
end
protected
def self.systemd?
`ps -o comm= 1`.chomp == 'systemd'
end
def self.restart_nfs(machine)
if systemd?
machine.communicate.sudo("/bin/systemctl restart rpcbind nfs")
else
machine.communicate.sudo("/etc/init.d/rpcbind restart; /etc/init.d/nfs restart")
end end
end end
end end

View File

@ -36,6 +36,11 @@ module VagrantPlugins
Cap::NFSClient Cap::NFSClient
end end
guest_capability("redhat", "nfs_client_installed") do
require_relative "cap/nfs_client"
Cap::NFSClient
end
guest_capability("redhat", "rsync_install") do guest_capability("redhat", "rsync_install") do
require_relative "cap/rsync" require_relative "cap/rsync"
Cap::RSync Cap::RSync