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"
Cap::Flavor
end
guest_capability("fedora", "nfs_client_install") do
require_relative "cap/nfs_client"
Cap::NFSClient
end
end
end
end

View File

@ -3,14 +3,27 @@ module VagrantPlugins
module Cap
class NFSClient
def self.nfs_client_install(machine)
machine.communicate.tap do |comm|
comm.sudo("yum -y install nfs-utils nfs-utils-lib")
case machine.guest.capability("flavor")
when :rhel_7
comm.sudo("/bin/systemctl restart rpcbind nfs")
else
comm.sudo("/etc/init.d/rpcbind restart; /etc/init.d/nfs restart")
end
machine.communicate.sudo("yum -y install nfs-utils nfs-utils-lib")
restart_nfs(machine)
end
def self.nfs_client_installed(machine)
installed = machine.communicate.test("test -x /sbin/mount.nfs")
restart_nfs(machine) if installed
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

View File

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