diff options
author | Luke Kanies <luke@madstop.com> | 2005-07-20 20:50:11 +0000 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2005-07-20 20:50:11 +0000 |
commit | a33d5d44d92894c12c485f7de49d324cd1a2eb23 (patch) | |
tree | fcf9afcce5f176bbdb35741d0927c7496daa9e07 | |
parent | 2d34f8e9ddcfc03d57a71819810eef15fb7f965f (diff) | |
download | puppet-a33d5d44d92894c12c485f7de49d324cd1a2eb23.tar.gz puppet-a33d5d44d92894c12c485f7de49d324cd1a2eb23.tar.xz puppet-a33d5d44d92894c12c485f7de49d324cd1a2eb23.zip |
everything seems to actually be working now, including getting the correct file list back
git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@432 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r-- | lib/puppet/type.rb | 6 | ||||
-rw-r--r-- | lib/puppet/type/pfile.rb | 125 | ||||
-rw-r--r-- | test/types/tc_file.rb | 8 |
3 files changed, 79 insertions, 60 deletions
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb index 3c714eff2..4f937334d 100644 --- a/lib/puppet/type.rb +++ b/lib/puppet/type.rb @@ -819,8 +819,10 @@ class Type < Puppet::Element # now record how many changes we've resulted in Puppet::Metric.add(self.class,self,:changes,changes.length) - Puppet.info "%s resulted in %s changes" % - [self.name, changes.length] + if changes.length > 0 + Puppet.info "%s resulted in %s changes" % + [self.name, changes.length] + end return changes.flatten end #--------------------------------------------------------------- diff --git a/lib/puppet/type/pfile.rb b/lib/puppet/type/pfile.rb index aab107119..6ddcaa94a 100644 --- a/lib/puppet/type/pfile.rb +++ b/lib/puppet/type/pfile.rb @@ -85,15 +85,15 @@ module Puppet if hash = state[self.parent[:path]] if hash.include?(@checktype) @should = hash[@checktype] - Puppet.debug "Found checksum %s for %s" % - [@should,self.parent[:path]] + #Puppet.debug "Found checksum %s for %s" % + # [@should,self.parent[:path]] else - Puppet.debug "Found checksum for %s but not of type %s" % - [self.parent[:path],@checktype] + #Puppet.debug "Found checksum for %s but not of type %s" % + # [self.parent[:path],@checktype] @should = nil end - else - Puppet.debug "No checksum for %s" % self.parent[:path] + #else + #Puppet.debug "No checksum for %s" % self.parent[:path] end end @@ -707,11 +707,11 @@ module Puppet args[:path] = path unless hash.include?(:source) # it's being manually overridden if args.include?(:source) - Puppet.notice "Rewriting source for %s" % path + #Puppet.notice "Rewriting source for %s" % path name = File.basename(path) dirname = args[:source] - Puppet.notice "Old: %s" % args[:source] - Puppet.notice "New: %s" % File.join(dirname,name) + #Puppet.notice "Old: %s" % args[:source] + #Puppet.notice "New: %s" % File.join(dirname,name) if FileTest.exists?(dirname) and ! FileTest.directory?(dirname) Puppet.err "Cannot make a child of %s" % dirname exit @@ -735,6 +735,10 @@ module Puppet args[key] = value } + #if @states.include?(:checksum) + # args[:checksum] = @states[:checksum].checktype + #end + child = nil if child = self.class[path] args.each { |var,value| @@ -835,9 +839,6 @@ module Puppet # the pinned file's tree, instead of our own # if recursion is turned off, then this whole thing is pretty easy def paramsource=(source) - if File.basename(File.dirname(self.name)) =~ /^[a-z]/ - raise Puppet::Error.new("Somehow got lower-case directory") - end @parameters[:source] = source @source = source @@ -885,6 +886,60 @@ module Puppet end } + # now, checksum and copy kind of work in tandem + # first, make sure we're using the same mechanisms for retrieving + # checksums + + # we'll come out of this with a value set or through an error + checktype = nil + + if @states.include?(:checksum) and @sourceobj.state(:checksum) + sourcesum = @sourceobj.state(:checksum) + destsum = @states[:checksum] + + begin + unless destsum.checktype == sourcesum.checktype + Puppet.warning(("Source file '%s' checksum type %s is " + + "incompatible with destination file '%s' checksum " + + "type '%s'; defaulting to md5 for both") % + [ + @sourceobj.name, + sourcesum.checktype.inspect, + self.name, + destsum.checktype.inspect + ] + ) + + # and then, um, default to md5 for everyone? + unless sourcesum.checktype == "md5" + Puppet.warning "Changing checktype on %s to md5" % + @source + sourcesum.should = "md5" + end + + unless destsum.checktype == "md5" + Puppet.warning "Changing checktype on %s to md5" % + self.name + destsum.should = "md5" + end + checktype = "md5" + end + rescue => detail + Puppet.err detail + exit + end + elsif @sourceobj.state(:checksum) + checktype = @sourceobj.state(:checksum).checktype + self[:checksum] = checktype + elsif @states.include?(:checksum) + @sourceobj[:checksum] = @states[:checksum].checktype + checktype = @states[:checksum].checktype + else + checktype = "md5" + end + + @arghash[:checksum] = checktype + if FileTest.directory?(@source) self[:create] = "directory" @@ -927,52 +982,6 @@ module Puppet } else - # checksums are, like, special - if @states.include?(:checksum) and @sourceobj.state(:checksum) - sourcesum = @sourceobj.state(:checksum) - destsum = @states[:checksum] - - # this is weird, because normally setting a 'should' state - # on checksums just manipulates the contents of the state - # database - begin - if destsum.checktype == sourcesum.checktype - destsum.should = sourcesum.is - else - Puppet.warning(("Source file '%s' checksum type %s is " + - "incompatible with destination file '%s' checksum " + - "type '%s'; defaulting to md5 for both") % - [ - @sourceobj.name, - sourcesum.checktype.inspect, - self.name, - destsum.checktype.inspect - ] - ) - - # and then, um, default to md5 for everyone? - unless sourcesum.checktype == "md5" - Puppet.warning "Changing checktype on %s to md5" % - file.name - sourcesum.should = "md5" - end - - unless destsum.checktype == "md5" - Puppet.warning "Changing checktype on %s to md5" % - self.name - destsum.should = "md5" - end - end - rescue => detail - Puppet.err detail - exit - end - else - self[:check] = [:checksum] - #self[:checksum] = @sourceobj.state(:checksum).checktype - #@states[:checksum].should = @sourceobj[:checksum] - end - self[:copy] = @sourceobj.name end end diff --git a/test/types/tc_file.rb b/test/types/tc_file.rb index e0ae7274d..21ccc8a69 100644 --- a/test/types/tc_file.rb +++ b/test/types/tc_file.rb @@ -555,6 +555,14 @@ class TestFile < Test::Unit::TestCase assert_nothing_raised { trans.evaluate } + + # until we have characterized how backups work, just get + # rid of them + FileUtils.cd(todir) { + %x{find . -name '*puppet-bak'}.chomp.split(/\n/).each { |file| + File.unlink(file) + } + } assert_trees_equal(fromdir,todir) clearstorage Puppet::Type.allclear |