diff options
Diffstat (limited to 'lib/puppet')
-rw-r--r-- | lib/puppet/metatype/container.rb | 5 | ||||
-rw-r--r-- | lib/puppet/pgraph.rb | 3 | ||||
-rwxr-xr-x | lib/puppet/server/authstore.rb | 3 | ||||
-rwxr-xr-x | lib/puppet/server/fileserver.rb | 17 | ||||
-rw-r--r-- | lib/puppet/transaction.rb | 224 | ||||
-rw-r--r-- | lib/puppet/type/pfile.rb | 204 | ||||
-rwxr-xr-x | lib/puppet/type/pfile/ensure.rb | 1 | ||||
-rwxr-xr-x | lib/puppet/type/pfile/source.rb | 201 | ||||
-rw-r--r-- | lib/puppet/type/pfile/target.rb | 2 | ||||
-rw-r--r-- | lib/puppet/type/state.rb | 2 |
10 files changed, 350 insertions, 312 deletions
diff --git a/lib/puppet/metatype/container.rb b/lib/puppet/metatype/container.rb index 9ed587a4c..d7c509699 100644 --- a/lib/puppet/metatype/container.rb +++ b/lib/puppet/metatype/container.rb @@ -80,10 +80,7 @@ class Puppet::Type end self.class.delete(self) - if defined? @parent and @parent - @parent.delete(self) - @parent = nil - end + @parent = nil # Remove the reference to the provider. if self.provider diff --git a/lib/puppet/pgraph.rb b/lib/puppet/pgraph.rb index 292e25073..58bee8605 100644 --- a/lib/puppet/pgraph.rb +++ b/lib/puppet/pgraph.rb @@ -11,6 +11,9 @@ require 'puppet/relationship' # This class subclasses a graph class in order to handle relationships # among resources. class Puppet::PGraph < GRATR::Digraph + # This is the type used for splicing. + attr_accessor :container_type + # The dependencies for a given resource. def dependencies(resource) tree_from_vertex(resource, :dfs).keys diff --git a/lib/puppet/server/authstore.rb b/lib/puppet/server/authstore.rb index 3e7881162..b0f63b68a 100755 --- a/lib/puppet/server/authstore.rb +++ b/lib/puppet/server/authstore.rb @@ -28,6 +28,9 @@ class Server def allowed?(name, ip) if name or ip + # This is probably unnecessary, and can cause some weirdnesses in + # cases where we're operating over localhost but don't have a real + # IP defined. unless name and ip raise Puppet::DevError, "Name and IP must be passed to 'allowed?'" end diff --git a/lib/puppet/server/fileserver.rb b/lib/puppet/server/fileserver.rb index 8033fac5b..53c60cdbe 100755 --- a/lib/puppet/server/fileserver.rb +++ b/lib/puppet/server/fileserver.rb @@ -126,6 +126,10 @@ class Server sub.join("\t") }.join("\n") end + + def local? + self.local + end # Mount a new directory with a name. def mount(path, name) @@ -188,6 +192,11 @@ class Server private def authcheck(file, mount, client, clientip) + # If we're local, don't bother passing in information. + if local? + client = nil + clientip = nil + end unless mount.allowed?(client, clientip) mount.warning "%s cannot access %s" % [client, file] @@ -482,12 +491,6 @@ class Server @path = nil end - @comp = Puppet.type(:component).create( - :name => "mount[#{name}]" - ) - #@comp.type = "mount" - #@comp.name = name - super() end @@ -504,8 +507,6 @@ class Server :name => path, :check => CHECKPARAMS ) - - @comp.push(obj) end if links == :manage diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb index 6835b1b19..5bd5afd2f 100644 --- a/lib/puppet/transaction.rb +++ b/lib/puppet/transaction.rb @@ -6,8 +6,10 @@ require 'puppet/statechange' module Puppet class Transaction - attr_accessor :component, :resources, :tags, :ignoreschedules, :ignoretags - attr_accessor :relgraph + attr_accessor :component, :resources, :ignoreschedules, :ignoretags + attr_accessor :relgraph, :sorted_resources + + attr_writer :tags include Puppet::Util @@ -24,41 +26,42 @@ class Transaction end end - # Apply all changes for a child, returning a list of the events + # Apply all changes for a resource, returning a list of the events # generated. - def apply(child) - child.info "applying" + def apply(resource) # First make sure there are no failed dependencies. To do this, # we check for failures in any of the vertexes above us. It's not # enough to check the immediate dependencies, which is why we use # a tree from the reversed graph. - p @relgraph.vertices.collect { |v| v.ref } - @relgraph.reversal.tree_from_vertex(child, :dfs).keys.each do |dep| + @relgraph.reversal.tree_from_vertex(resource, :dfs).keys.each do |dep| skip = false if fails = failed?(dep) - child.notice "Dependency %s[%s] has %s failures" % + resource.notice "Dependency %s[%s] has %s failures" % [dep.class.name, dep.name, @failures[dep]] skip = true end if skip - child.warning "Skipping because of failed dependencies" + resource.warning "Skipping because of failed dependencies" @resourcemetrics[:skipped] += 1 return [] end end + + # If the resource needs to generate new objects at eval time, do it now. + eval_generate(resource) begin - changes = child.evaluate + changes = resource.evaluate rescue => detail if Puppet[:trace] puts detail.backtrace end - child.err "Failed to retrieve current state: %s" % detail + resource.err "Failed to retrieve current state: %s" % detail # Mark that it failed - @failures[child] += 1 + @failures[resource] += 1 # And then return return [] @@ -72,7 +75,7 @@ class Transaction @resourcemetrics[:out_of_sync] += 1 end - childevents = changes.collect { |change| + resourceevents = changes.collect { |change| @changes << change @count += 1 change.transaction = self @@ -87,7 +90,7 @@ class Transaction end change.state.err "change from %s to %s failed: %s" % [change.state.is_to_s, change.state.should_to_s, detail] - @failures[child] += 1 + @failures[resource] += 1 next # FIXME this should support using onerror to determine # behaviour; or more likely, the client calling us @@ -106,15 +109,15 @@ class Transaction unless changes.empty? # Record when we last synced - child.cache(:synced, Time.now) + resource.cache(:synced, Time.now) # Flush, if appropriate - if child.respond_to?(:flush) - child.flush + if resource.respond_to?(:flush) + resource.flush end end - childevents + resourceevents end # Find all of the changed resources. @@ -123,75 +126,96 @@ class Transaction change.state.parent }.uniq end + + # Do any necessary cleanup. Basically just removes any generated + # resources. + def cleanup + @generated.each do |resource| + resource.remove + end + end + + # See if the resource generates new resources at evaluation time. + def eval_generate(resource) + if resource.respond_to?(:eval_generate) + if children = resource.eval_generate + dependents = @relgraph.adjacent(resource, :direction => :out, :type => :edges) + targets = @relgraph.adjacent(resource, :direction => :in, :type => :edges) + children.each do |gen_child| + gen_child.info "generated" + @relgraph.add_edge!(resource, gen_child) + dependents.each do |edge| + @relgraph.add_edge!(gen_child, edge.target, edge.label) + end + targets.each do |edge| + @relgraph.add_edge!(edge.source, gen_child, edge.label) + end + @sorted_resources.insert(@sorted_resources.index(resource) + 1, gen_child) + @generated << gen_child + end + end + end + end + + # Evaluate a single resource. + def eval_resource(resource) + events = [] + + unless tagged?(resource) + resource.debug "Not tagged with %s" % tags.join(", ") + return events + end + + unless scheduled?(resource) + resource.debug "Not scheduled" + return events + end + + @resourcemetrics[:scheduled] += 1 + + # Perform the actual changes + seconds = thinmark do + events = apply(resource) + end + + # Keep track of how long we spend in each type of resource + @timemetrics[resource.class.name] += seconds + + # Check to see if there are any events for this resource + if triggedevents = trigger(resource) + events += triggedevents + end + + # Collect the targets of any subscriptions to those events + @relgraph.matching_edges(events).each do |edge| + @targets[edge.target] << edge + end + + # And return the events for collection + events + end # This method does all the actual work of running a transaction. It # collects all of the changes, executes them, and responds to any # necessary events. def evaluate @count = 0 - - # Allow the tags to be overriden - tags = self.tags || Puppet[:tags] - if tags.nil? or tags == "" - tags = nil - else - tags = [tags] unless tags.is_a? Array - tags = tags.collect do |tag| - tag.split(/\s*,\s*/) - end.flatten - end - + # Start logging. Puppet::Log.newdestination(@report) - - prefetch() - - # Now add any dynamically generated resources - generate() - - # Create a relationship graph from our resource graph - @relgraph = relationship_graph - @relgraph.to_jpg("relations") + prepare() begin - allevents = @relgraph.topsort.collect { |child| - events = [] - if (self.ignoretags or tags.nil? or child.tagged?(tags)) - if self.ignoreschedules or child.scheduled? - @resourcemetrics[:scheduled] += 1 - # Perform the actual changes - - seconds = thinmark do - events = apply(child) - end - - # Keep track of how long we spend in each type of resource - @timemetrics[child.class.name] += seconds - else - child.debug "Not scheduled" - end - else - child.debug "Not tagged with %s" % tags.join(", ") - end - - # Check to see if there are any events for this child - if triggedevents = trigger(child) - events += triggedevents - end - - # Collect the targets of any subscriptions to those events - @relgraph.matching_edges(events).each do |edge| - @targets[edge.target] << edge - end - - # And return the events for collection - events + allevents = @sorted_resources.collect { |resource| + eval_resource(resource) }.flatten.reject { |e| e.nil? } ensure # And then close the transaction log. Puppet::Log.close(@report) end + + cleanup() Puppet.debug "Finishing transaction %s with %s changes" % [self.object_id, @count] @@ -211,17 +235,25 @@ class Transaction # Collect any dynamically generated resources. def generate list = @resources.vertices + + # Store a list of all generated resources, so that we can clean them up + # after the transaction closes. + @generated = [] + newlist = [] while ! list.empty? list.each do |resource| if resource.respond_to?(:generate) made = resource.generate + next unless made unless made.is_a?(Array) made = [made] end + made.uniq! made.each do |res| @resources.add_vertex!(res) newlist << res + @generated << res end end end @@ -288,6 +320,19 @@ class Transaction end end + # Prepare to evaluate the elements in a transaction. + def prepare + prefetch() + + # Now add any dynamically generated resources + generate() + + # Create a relationship graph from our resource graph + @relgraph = relationship_graph + + @sorted_resources = @relgraph.topsort + end + # Create a graph of all of the relationships in our resource graph. def relationship_graph graph = Puppet::PGraph.new @@ -392,6 +437,43 @@ class Transaction events }.flatten.reject { |e| e.nil? } end + + # Is the resource currently scheduled? + def scheduled?(resource) + self.ignoreschedules or resource.scheduled? + end + + # The tags we should be checking. + def tags + # Allow the tags to be overridden + unless defined? @tags + @tags = Puppet[:tags] + end + + unless defined? @processed_tags + if @tags.nil? or @tags == "" + @tags = [] + else + @tags = [@tags] unless @tags.is_a? Array + @tags = @tags.collect do |tag| + tag.split(/\s*,\s*/) + end.flatten + end + @processed_tags = true + end + + @tags + end + + # Is this resource tagged appropriately? + def tagged?(resource) + self.ignoretags or tags.empty? or resource.tagged?(tags) + end + + # Are there any edges that target this resource? + def targeted?(resource) + @targets[resource] + end # Trigger any subscriptions to a child. This does an upwardly recursive # search -- it triggers the passed resource, but also the resource's parent diff --git a/lib/puppet/type/pfile.rb b/lib/puppet/type/pfile.rb index 15367a0c2..b3bbba3b9 100644 --- a/lib/puppet/type/pfile.rb +++ b/lib/puppet/type/pfile.rb @@ -174,18 +174,7 @@ module Puppet # Autorequire any parent directories. autorequire(:file) do - cur = [] - pary = self[:path].split(File::SEPARATOR) - pary.shift # remove the initial nil - pary.pop # remove us - - pary.inject([""]) do |ary, dir| - ary << dir - cur << ary.join(File::SEPARATOR) - ary - end - - cur + File.dirname(self[:path]) end # Autorequire the owner and group of the file. @@ -285,6 +274,11 @@ module Puppet end super end + + # Create any children via recursion or whatever. + def eval_generate + recurse() + end # Deal with backups. def handlebackup(file = nil) @@ -413,12 +407,14 @@ module Puppet @arghash = tmphash @arghash.delete(self.class.namevar) - if @arghash.include?(:source) - @arghash.delete(:source) + [:source, :parent].each do |param| + if @arghash.include?(param) + @arghash.delete(param) + end end - if @arghash.include?(:parent) - @arghash.delete(:parent) + if @arghash[:target] + warning "%s vs %s" % [@arghash[:ensure], @arghash[:target]] end @stat = nil @@ -435,15 +431,11 @@ module Puppet targetstat = nil unless FileTest.exist?(target) - #self.info "%s does not exist; not recursing" % - # target return end # Now stat our target targetstat = File.send(method, target) unless targetstat.ftype == "directory" - #self.info "%s is not a directory; not recursing" % - # target return end @@ -458,10 +450,10 @@ module Puppet children = Dir.entries(target).reject { |d| d =~ /^\.+$/ } - #Get rid of ignored children + # Get rid of ignored children if @parameters.include?(:ignore) children = handleignore(children) - end + end added = [] children.each do |file| @@ -476,13 +468,12 @@ module Puppet } if child = self.newchild(file, true, args) - unless @children.include?(child) - self.push child - added.push file - end + added << child end end end + + added end # Build up a recursive map of what's around right now @@ -503,7 +494,7 @@ module Puppet #Get rid of ignored children if @parameters.include?(:ignore) children = handleignore(children) - end + end added = [] children.each { |file| @@ -514,16 +505,17 @@ module Puppet if child = self.newchild(file, true, options) # Mark any unmanaged files for removal if purge is set. # Use the array rather than [] because tidy uses this method, too. - if @parameters.include?(:purge) and self[:purge] == :true and child.implicit? + if @parameters.include?(:purge) and self.purge? + info "purging %s" % child.ref child[:ensure] = :absent + else + child[:require] = self end - - unless @children.include?(child) - self.push child - added.push file - end + added << child end } + + added end # Create a new file or directory object as a child to the current @@ -574,13 +566,13 @@ module Puppet else klass = self.class end - + # The child might already exist because 'localrecurse' runs # before 'sourcerecurse'. I could push the override stuff into # a separate method or something, but the work is the same other # than this last bit, so it doesn't really make sense. if child = klass[path] - unless @children.include?(child) + unless child.parent.object_id == self.object_id self.debug "Not managing more explicit file %s" % path return nil @@ -599,6 +591,7 @@ module Puppet end } end + return nil else # create it anew #notice "Creating new file with args %s" % args.inspect args[:parent] = self @@ -609,7 +602,6 @@ module Puppet if child.nil? return nil end - @children << child rescue Puppet::Error => detail self.notice( "Cannot manage: %s" % @@ -629,6 +621,9 @@ module Puppet return child end + # Files handle paths specially, because they just lengthen their + # path names, rather than including the full parent's title each + # time. def pathbuilder if defined? @parent # We only need to behave specially when our parent is also @@ -658,40 +653,53 @@ module Puppet end end end + + # Should we be purging? + def purge? + @parameters.include?(:purge) and (self[:purge] == :true or self[:purge] == "true") + end # Recurse into the directory. This basically just calls 'localrecurse' - # and maybe 'sourcerecurse'. + # and maybe 'sourcerecurse', returning the collection of generated + # files. def recurse + # are we at the end of the recursion? + unless self.recurse? + return + end + recurse = self[:recurse] # we might have a string, rather than a number if recurse.is_a?(String) if recurse =~ /^[0-9]+$/ recurse = Integer(recurse) - #elsif recurse =~ /^inf/ # infinite recursion else # anything else is infinite recursion recurse = true end end - # are we at the end of the recursion? - #if recurse == 0 - unless self.recurse? - return - end - if recurse.is_a?(Integer) recurse -= 1 end - - self.localrecurse(recurse) - if @states.include? :target - self.linkrecurse(recurse) + + children = [] + + # We want to do link-recursing before normal recursion so that all + # of the target stuff gets copied over correctly. + if @states.include? :target and ret = self.linkrecurse(recurse) + children += ret end - if @states.include?(:source) - self.sourcerecurse(recurse) + if ret = self.localrecurse(recurse) + children += ret end + if @states.include?(:source) and ret = self.sourcerecurse(recurse) + children += ret + end + + children end + # A simple method for determining whether we should be recursing. def recurse? return false unless @parameters.include?(:recurse) @@ -767,96 +775,78 @@ module Puppet # a wrapper method to make sure the file exists before doing anything def retrieve - if @states.include?(:source) - # This probably isn't the best place for it, but we need - # to make sure that we have a corresponding checksum state. - unless @states.include?(:checksum) - self[:checksum] = "md5" - end - - # We have to retrieve the source info before the recursion happens, - # although I'm not exactly clear on why. - @states[:source].retrieve - end - - if @parameters.include?(:recurse) - self.recurse - end - unless stat = self.stat(true) self.debug "File does not exist" @states.each { |name,state| # We've already retrieved the source, and we don't # want to overwrite whatever it did. This is a bit # of a hack, but oh well, source is definitely special. - next if name == :source + # next if name == :source state.is = :absent } + + # If the file doesn't exist but we have a source, then call + # retrieve on that state + if @states.include?(:source) + @states[:source].retrieve + end return end states().each { |state| - # We don't want to call 'describe()' twice, so only do a local - # retrieve on the source. - if state.name == :source - state.retrieve(false) - else - state.retrieve - end + state.retrieve } end # This recurses against the remote source and makes sure the local - # and remote structures match. It's run after 'localrecurse'. + # and remote structures match. It's run after 'localrecurse'. This + # method only does anything when its corresponding remote entry is + # a directory; in that case, this method creates file objects that + # correspond to any contained remote files. def sourcerecurse(recurse) - # FIXME sourcerecurse should support purging non-remote files - source = @states[:source].source - - unless ! source.nil? and source !~ /^\s*$/ - self.notice "source %s does not exist" % @states[:source].should - return nil - end - - sourceobj, path = uri2obj(source) - # we'll set this manually as necessary if @arghash.include?(:ensure) @arghash.delete(:ensure) end - - # okay, we've got our source object; now we need to - # build up a local file structure to match the remote - # one - - server = sourceobj.server - sum = "md5" - if state = self.state(:checksum) - sum = state.should - end + r = false if recurse unless recurse == 0 r = 1 end end - + ignore = self[:ignore] - desc = server.list(path, self[:links], r, ignore) + @states[:source].should.each do |source| + sourceobj, path = uri2obj(source) + + # okay, we've got our source object; now we need to + # build up a local file structure to match the remote + # one - # Now create a new child for every file returned in the list. - desc.split("\n").each { |line| - file, type = line.split("\t") - next if file == "/" # skip the listing object - name = file.sub(/^\//, '') - args = {:source => source + file} - if type == file - args[:recurse] = nil + server = sourceobj.server + + desc = server.list(path, self[:links], r, ignore) + if desc == "" + next end + + # Now create a new child for every file returned in the list. + return desc.split("\n").collect { |line| + file, type = line.split("\t") + next if file == "/" # skip the listing object + name = file.sub(/^\//, '') + args = {:source => source + file} + if type == file + args[:recurse] = nil + end - self.newchild(name, false, args) - } + self.newchild(name, false, args) + }.reject {|c| c.nil? }.each do |f| f.info "sourced" end + end + return [] end # Set the checksum, from another state. There are multiple states that diff --git a/lib/puppet/type/pfile/ensure.rb b/lib/puppet/type/pfile/ensure.rb index 6f7b15d49..c998e0f7f 100755 --- a/lib/puppet/type/pfile/ensure.rb +++ b/lib/puppet/type/pfile/ensure.rb @@ -60,6 +60,7 @@ module Puppet end newvalue(:directory) do + p @is mode = @parent.should(:mode) parent = File.dirname(@parent[:path]) unless FileTest.exists? parent diff --git a/lib/puppet/type/pfile/source.rb b/lib/puppet/type/pfile/source.rb index 62d3dbbc4..8ac60422c 100755 --- a/lib/puppet/type/pfile/source.rb +++ b/lib/puppet/type/pfile/source.rb @@ -1,7 +1,11 @@ require 'puppet/server/fileserver' module Puppet - # Copy files from a local or remote source. + # Copy files from a local or remote source. This state *only* does any work + # when the remote file is an actual file; in that case, this state copies + # the file down. If the remote file is a dir or a link or whatever, then + # this state, during retrieval, modifies the appropriate other states + # so that things get taken care of appropriately. Puppet.type(:file).newstate(:source) do PINPARAMS = Puppet::Server::FileServer::CHECKPARAMS @@ -38,12 +42,38 @@ module Puppet } This will use the first found file as the source. + + You cannot currently copy links using this mechanism; set ``links`` + to ``follow`` if any remote sources are links. [fileserver docs]: ../installing/fsconfigref.html " uncheckable + + validate do |source| + unless @parent.uri2obj(source) + raise Puppet::Error, "Invalid source %s" % source + end + end + + munge do |source| + # if source.is_a? Symbol + # return source + # end + + # Remove any trailing slashes + source.sub(/\/$/, '') + end + + def checksum + if defined?(@stats) + @stats[:checksum] + else + nil + end + end # Ask the file server to describe our file. def describe(source) @@ -75,34 +105,52 @@ module Puppet args.delete(:owner) end - if args.empty? + if args.empty? or (args[:type] == "link" and @parent[:links] == :ignore) return nil else return args end end - + + # Have we successfully described the remote source? + def described? + ! @stats.nil? and ! @stats[:type].nil? and @is != :notdescribed + end + + # Use the info we get from describe() to check if we're in sync. + def insync? + unless described? + info "No specified sources exist" + return true + end + + if @is == :nocopy + return true + end + + # the only thing this actual state can do is copy files around. Therefore, + # only pay attention if the remote is a file. + unless @stats[:type] == "file" + return true + end + # Now, we just check to see if the checksums are the same + return @parent.is(:checksum) == @stats[:checksum] + end + # This basically calls describe() on our file, and then sets all # of the local states appropriately. If the remote file is a normal # file then we set it to copy; if it's a directory, then we just mark # that the local directory should be created. def retrieve(remote = true) sum = nil - - unless defined? @shouldorig - raise Puppet::DevError, "No sources defined for %s" % - @parent.title - end - - @source = nil unless defined? @source + @source = nil # This is set to false by the File#retrieve function on the second # retrieve, so that we do not do two describes. if remote - @source = nil # Find the first source that exists. @shouldorig contains # the sources as specified by the user. - @shouldorig.each { |source| + @should.each { |source| if @stats = self.describe(source) @source = source break @@ -112,70 +160,18 @@ module Puppet if @stats.nil? or @stats[:type].nil? @is = :notdescribed - @source = nil return nil end - - # If we're a normal file, then set things up to copy the file down. + case @stats[:type] - when "file": - if sum = @parent.state(:checksum) - if sum.is - if sum.is == :absent - sum.retrieve(true) - end - @is = sum.is - else - @is = :absent - end - else - self.info "File does not have checksum" - @is = :absent - end - # if replace => false then fake the checksum so that the file - # is not overwritten. - unless @is == :absent - if @parent[:replace] == :false - info "Not replacing existing file" - @is = @stats[:checksum] - end - end - @should = [@stats[:checksum]] - # If we're a directory, then do not copy anything, and instead just - # create the directory using the 'create' state. - when "directory": - if state = @parent.state(:ensure) - unless state.should == "directory" - state.should = "directory" - end - else - @parent[:ensure] = "directory" - @parent.state(:ensure).retrieve - end - # we'll let the :ensure state do our work - @should.clear - @is = true - when "link": - case @parent[:links] - when :ignore - @is = :nocopy - @should = [:nocopy] - self.info "Ignoring link %s" % @source - return - when :follow - @stats = self.describe(source, :follow) - if @stats.empty? - raise Puppet::Error, "Could not follow link %s" % @source - end - when :copy - raise Puppet::Error, "Cannot copy links yet" - end + when "directory", "file": + @parent[:ensure] = @stats[:type] else self.info @stats.inspect self.err "Cannot use files of type %s as sources" % @stats[:type] - @should = [:nocopy] @is = :nocopy + return end # Take each of the stats and set them as states on the local file @@ -187,61 +183,32 @@ module Puppet # was the stat already specified, or should the value # be inherited from the source? unless @parent.argument?(stat) - if state = @parent.state(stat) - state.should = value - else - @parent[stat] = value - end - #else - # @parent.info "Already specified %s" % stat + @parent[stat] = value end } + + @is = @stats[:checksum] end - - # The special thing here is that we need to make sure that 'should' - # is only set for files, not directories. The processing we're doing - # here doesn't really matter, because the @should values will be - # overridden when we 'retrieve'. - munge do |source| - if source.is_a? Symbol - return source - end - - # Remove any trailing slashes - source.sub!(/\/$/, '') - unless @parent.uri2obj(source) - raise Puppet::Error, "Invalid source %s" % source + + def should + @should + end + + # Make sure we're also checking the checksum + def should=(value) + super + + # @parent[:check] = [:checksum, :ensure] + unless @parent.state(:checksum) + @parent[:checksum] = :md5 end - - if ! defined? @stats or @stats.nil? - # stupid hack for now; it'll get overriden - return source - else - if @stats[:type] == "directory" - @is = true - return nil - else - return source - end + + unless @parent.state(:ensure) + @parent[:check] = :ensure end end def sync - if @is == :notdescribed - self.retrieve # try again - if @is == :notdescribed - @parent.log "Could not retrieve information on %s" % - @parent.title - return nil - end - if @is == @should - return nil - end - end - - case @stats[:type] - when "link": - end unless @stats[:type] == "file" #if @stats[:type] == "directory" #[@parent.name, @is.inspect, @should.inspect] @@ -250,10 +217,6 @@ module Puppet @parent[:path] end - unless defined? @source - raise Puppet::DevError, "Somehow source is still undefined" - end - sourceobj, path = @parent.uri2obj(@source) begin diff --git a/lib/puppet/type/pfile/target.rb b/lib/puppet/type/pfile/target.rb index 8c22b10b9..17d9bebbc 100644 --- a/lib/puppet/type/pfile/target.rb +++ b/lib/puppet/type/pfile/target.rb @@ -59,8 +59,6 @@ module Puppet (tstat = File.lstat(should)) and (tstat.ftype == "directory") and @parent.recurse? - warning "Changing ensure to directory; recurse is %s but %s" % - [@parent[:recurse].inspect, @parent.recurse?] @parent[:ensure] = :directory @is = should @linkmaker = true diff --git a/lib/puppet/type/state.rb b/lib/puppet/type/state.rb index 9b96b909f..6dd5f1567 100644 --- a/lib/puppet/type/state.rb +++ b/lib/puppet/type/state.rb @@ -491,7 +491,7 @@ class State < Puppet::Parameter def change_to_s begin - if @is == :absent + if @is == :absent or @is.nil? return "created" elsif self.should == :absent return "removed" |