diff options
| -rw-r--r-- | lib/puppet/log.rb | 4 | ||||
| -rw-r--r-- | lib/puppet/parameter.rb | 9 | ||||
| -rw-r--r-- | lib/puppet/provider/mount.rb | 7 | ||||
| -rw-r--r-- | lib/puppet/transaction.rb | 10 | ||||
| -rwxr-xr-x | lib/puppet/type/mount.rb | 12 | ||||
| -rwxr-xr-x | test/providers/mount/parsed.rb | 6 | ||||
| -rwxr-xr-x | test/types/mount.rb | 19 |
7 files changed, 43 insertions, 24 deletions
diff --git a/lib/puppet/log.rb b/lib/puppet/log.rb index 53535e90c..44b4352ce 100644 --- a/lib/puppet/log.rb +++ b/lib/puppet/log.rb @@ -517,7 +517,9 @@ module Puppet # we retrieve any tags we can. def source=(source) # We can't store the actual source, we just store the path. - if source.respond_to?(:path) + # We can't just check for whether it responds to :path, because + # plenty of providers respond to that in their normal function. + if source.is_a?(Puppet::Element) and source.respond_to?(:path) @objectsource = true @source = source.path else diff --git a/lib/puppet/parameter.rb b/lib/puppet/parameter.rb index 78ee4ddf1..e480a06bd 100644 --- a/lib/puppet/parameter.rb +++ b/lib/puppet/parameter.rb @@ -287,15 +287,6 @@ module Puppet # return the full path to us, for logging and rollback; not currently # used - def path - unless defined? @path - @path = pathbuilder - end - return @path.join("/") - end - - # return the full path to us, for logging and rollback; not currently - # used def pathbuilder if defined? @parent and @parent return [@parent.pathbuilder, self.name] diff --git a/lib/puppet/provider/mount.rb b/lib/puppet/provider/mount.rb index bd8693e7d..103d1da0e 100644 --- a/lib/puppet/provider/mount.rb +++ b/lib/puppet/provider/mount.rb @@ -14,7 +14,12 @@ module Puppet::Provider::Mount def remount info "Remounting" if @model[:remounts] == :true - mountcmd "-o", "remount", @model[:name] + if Facter.value(:operatingsystem) == "FreeBSD" + # Thanks FreeBSD + mountcmd @model[:name] + else + mountcmd "-o", "remount", @model[:name] + end else unmount() mount() diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb index f3662ccfe..2240ca19f 100644 --- a/lib/puppet/transaction.rb +++ b/lib/puppet/transaction.rb @@ -84,10 +84,12 @@ class Transaction resource.flush end - # And set a trigger for refreshing this resource if it's a self-refresher - if resource.self_refresh? - # Create an edge with this resource as both the source and target. The triggering - # method treats these specially for logging. + # And set a trigger for refreshing this resource if it's a + # self-refresher + if resource.self_refresh? and ! resource.deleting? + # Create an edge with this resource as both the source and + # target. The triggering method treats these specially for + # logging. set_trigger(Puppet::Relationship.new(resource, resource, :callback => :refresh, :event => :ALL_EVENTS)) end end diff --git a/lib/puppet/type/mount.rb b/lib/puppet/type/mount.rb index 4961e689a..df0beca6f 100755 --- a/lib/puppet/type/mount.rb +++ b/lib/puppet/type/mount.rb @@ -155,13 +155,14 @@ module Puppet end newparam(:remounts) do - desc "Whether the mount can be remounted ``mount -o remount``. If this is false, - then the filesystem will be unmounted and remounted manually, which is prone to failure." + desc "Whether the mount can be remounted ``mount -o remount``. If + this is false, then the filesystem will be unmounted and remounted + manually, which is prone to failure." newvalues(:true, :false) defaultto do case Facter.value(:operatingsystem) - when "Darwin": false + when "Darwin", "FreeBSD": false else true end @@ -173,7 +174,10 @@ module Puppet on the value of the 'ensure' parameter." def refresh - provider.remount + # Only remount if we're supposed to be mounted. + if ens = @states[:ensure] and ens.should == :mounted + provider.remount + end end def value(name) diff --git a/test/providers/mount/parsed.rb b/test/providers/mount/parsed.rb index 8c60c9626..c062960f3 100755 --- a/test/providers/mount/parsed.rb +++ b/test/providers/mount/parsed.rb @@ -147,7 +147,7 @@ class TestParsedMounts < Test::Unit::TestCase end end - if Puppet::SUIDManager.uid == 0 + if Puppet::SUIDManager.uid == 0 and Facter.value(:operatingsystem) != "Darwin" def test_mountfs fs = nil case Facter.value(:hostname) @@ -197,6 +197,10 @@ class TestParsedMounts < Test::Unit::TestCase assert(obj.mounted?, "FS not mounted") assert(obj.df().include?(fs), "%s is not listed in df" % fs) + # Now try remounting + assert_nothing_raised("Could not remount filesystem") do + obj.remount + end end end diff --git a/test/types/mount.rb b/test/types/mount.rb index df1a71d71..9bdf599cd 100755 --- a/test/types/mount.rb +++ b/test/types/mount.rb @@ -47,6 +47,9 @@ class TestMounts < Test::Unit::TestCase @ensure = :mounted end + def remount + end + def unmount @ensure = :present end @@ -121,7 +124,7 @@ class TestMounts < Test::Unit::TestCase mount[:dump] = 2 mount[:options] = "defaults,ro" - assert_events([:mount_changed,:mount_changed], mount) + assert_events([:mount_changed,:mount_changed, :triggered], mount) assert_equal(2, mount.provider.dump, "Changes did not get flushed") assert_equal("defaults,ro", mount.provider.options, "Changes did not get flushed") @@ -164,7 +167,7 @@ class TestMounts < Test::Unit::TestCase obj[:ensure] = :present } - assert_events([:mount_created], obj) + assert_events([:mount_created, :triggered], obj) assert_events([], obj) assert(! obj.provider.mounted?, "Object is mounted incorrectly") @@ -173,7 +176,7 @@ class TestMounts < Test::Unit::TestCase obj[:ensure] = :mounted } - assert_events([:mount_mounted], obj) + assert_events([:mount_mounted, :triggered], obj) assert_events([], obj) obj.retrieve @@ -235,7 +238,7 @@ class TestMounts < Test::Unit::TestCase mount[:ensure] = :present - assert_events([:mount_created], mount) + assert_events([:mount_created, :triggered], mount) assert_events([], mount) mount[:ensure] = :absent @@ -285,6 +288,14 @@ class TestMounts < Test::Unit::TestCase assert_apply(mount) assert(remounted, "did not remount when mount changed") + + # Now make sure it doesn't remount if the mount is just 'present' + mount[:ensure] = :present + mount[:device] = "/dev/funtest" + remounted = false + assert_apply(mount) + + assert(! remounted, "remounted even though not supposed to be mounted") end end |
