diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-01-01 00:08:05 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-01-01 00:08:05 +0000 |
| commit | 54a838e68e52b2eac353d70cb9281ca75d741839 (patch) | |
| tree | 371e7fb59d2b7116b16984aa70187e646c1ecbc3 | |
| parent | b8f798f0ad88c990b5f9fe4c2d7b830aeb36a446 (diff) | |
Fixing #369. I was not flushing changes to disk when ensure was out of sync. This is going to become a common problem, and should probably be addressed by the framework rather than by individual types, but for now, it works.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2008 980ebf18-57e1-0310-9a29-db15c13687c0
| -rwxr-xr-x | lib/puppet/type/mount.rb | 17 | ||||
| -rwxr-xr-x | test/types/mount.rb | 28 |
2 files changed, 38 insertions, 7 deletions
diff --git a/lib/puppet/type/mount.rb b/lib/puppet/type/mount.rb index 884b86c00..d9e894b05 100755 --- a/lib/puppet/type/mount.rb +++ b/lib/puppet/type/mount.rb @@ -14,6 +14,7 @@ module Puppet newvalue(:present) do if provider.mounted? + syncothers() provider.unmount return :mount_unmounted else @@ -36,9 +37,8 @@ module Puppet if self.is == :absent or self.is.nil? provider.create end - # We have to flush any changes to disk. - @parent.flush + syncothers() provider.mount end @@ -56,7 +56,20 @@ module Puppet else @is = super() end + end + def syncothers + # We have to flush any changes to disk. + oos = @parent.send(:states).find_all do |st| + if st.name == :ensure + false + else + ! st.insync? + end + end.each { |st| st.sync }.length + if oos > 0 + @parent.flush + end end end diff --git a/test/types/mount.rb b/test/types/mount.rb index 1e576070c..949253b5e 100755 --- a/test/types/mount.rb +++ b/test/types/mount.rb @@ -29,7 +29,6 @@ class TestMounts < Test::Unit::TestCase def destroy @ensure = :absent - @mounted = false end def exists? @@ -41,15 +40,15 @@ class TestMounts < Test::Unit::TestCase end def mounted? - self.mounted + @ensure == :mounted end def mount - self.mounted = true + @ensure = :mounted end def unmount - self.mounted = false + @ensure = :present end end @@ -123,8 +122,27 @@ class TestMounts < Test::Unit::TestCase # Now modify a field mount[:dump] = 2 + mount[:options] = "defaults,ro" + + assert_events([:mount_changed,:mount_changed], mount) + assert_equal(2, mount.provider.dump, "Changes did not get flushed") + assert_equal("defaults,ro", mount.provider.options, "Changes did not get flushed") + + # Now modify a field in addition to change :ensure. + mount[:ensure] = :present + mount[:options] = "defaults" - assert_events([:mount_changed], mount) + assert_apply(mount) + assert(! mount.provider.mounted?, "mount was still mounted") + assert_equal("defaults", mount.provider.options) + + # Now remount it and make sure changes get flushed then, too. + mount[:ensure] = :mounted + mount[:options] = "aftermount" + + assert_apply(mount) + assert(mount.provider.mounted?, "mount was not mounted") + assert_equal("aftermount", mount.provider.options) end # Make sure fs mounting behaves appropriately. This is more a test of |
