summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Schulte <stefan.schulte@taunusstein.net>2011-01-23 13:10:17 +0100
committerStefan Schulte <stefan.schulte@taunusstein.net>2011-01-25 21:23:35 +0100
commitfd111f26f17b3dbdd0de310d0a4b43877eef7e14 (patch)
treebe8280e50486fcd6c302d61fa7672540c0ebf4a6
parent2884660768fbea22a91e3c5bab9595ce075e67a5 (diff)
downloadpuppet-fd111f26f17b3dbdd0de310d0a4b43877eef7e14.tar.gz
puppet-fd111f26f17b3dbdd0de310d0a4b43877eef7e14.tar.xz
puppet-fd111f26f17b3dbdd0de310d0a4b43877eef7e14.zip
(#4914) Query property_hash for mountstate
Change mounted? to query the property_hash so we don't have to run the mountcommand for every specified mount but rely on the prefetched state Also update the prefetched property_hash[:ensure] after mount or umount. This is important if we query mounted? later (most obvious when refresh is called. We dont want to remount a resource that was umounted before)
-rw-r--r--lib/puppet/provider/mount.rb26
1 files changed, 12 insertions, 14 deletions
diff --git a/lib/puppet/provider/mount.rb b/lib/puppet/provider/mount.rb
index 8c7b24bd4..65296eed2 100644
--- a/lib/puppet/provider/mount.rb
+++ b/lib/puppet/provider/mount.rb
@@ -14,8 +14,11 @@ module Puppet::Provider::Mount
args << "-o" << self.options if self.options and self.options != :absent
args << resource[:name]
- flush if respond_to?(:flush)
mountcmd(*args)
+ case get(:ensure)
+ when :absent; set(:ensure => :ghost)
+ when :unmounted; set(:ensure => :mounted)
+ end
end
def remount
@@ -30,22 +33,17 @@ module Puppet::Provider::Mount
# This only works when the mount point is synced to the fstab.
def unmount
- umount resource[:name]
+ umount(resource[:name])
+
+ # Update property hash for future queries (e.g. refresh is called)
+ case get(:ensure)
+ when :mounted; set(:ensure => :unmounted)
+ when :ghost; set(:ensure => :absent)
+ end
end
# Is the mount currently mounted?
def mounted?
- platform = Facter.value("operatingsystem")
- name = resource[:name]
- mounts = mountcmd.split("\n").find do |line|
- case platform
- when "Darwin"
- line =~ / on #{name} / or line =~ %r{ on /private/var/automount#{name}}
- when "Solaris", "HP-UX"
- line =~ /^#{name} on /
- else
- line =~ / on #{name} /
- end
- end
+ [:mounted, :ghost].include?(get(:ensure))
end
end