diff options
author | Luke Kanies <luke@madstop.com> | 2008-02-18 22:07:12 -0600 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2008-02-18 22:07:12 -0600 |
commit | 0afea69c06742eff1e8d8bd7df13c9c0e4c397c0 (patch) | |
tree | 33ed3b2b964dad9ec6129cbc56c12a8f41890cd8 /lib | |
parent | a53106cf08c28e996502cba703f64944250a4b29 (diff) | |
parent | 39f9818276e49020c1a6db9667371f7617d5cc93 (diff) | |
download | puppet-0afea69c06742eff1e8d8bd7df13c9c0e4c397c0.tar.gz puppet-0afea69c06742eff1e8d8bd7df13c9c0e4c397c0.tar.xz puppet-0afea69c06742eff1e8d8bd7df13c9c0e4c397c0.zip |
Merge branch '0.24.x'
Conflicts:
CHANGELOG
Diffstat (limited to 'lib')
-rw-r--r-- | lib/puppet/node/catalog.rb | 9 | ||||
-rw-r--r-- | lib/puppet/type/file.rb | 12 | ||||
-rwxr-xr-x | lib/puppet/type/file/source.rb | 42 |
3 files changed, 24 insertions, 39 deletions
diff --git a/lib/puppet/node/catalog.rb b/lib/puppet/node/catalog.rb index b74947107..ee4cedd4b 100644 --- a/lib/puppet/node/catalog.rb +++ b/lib/puppet/node/catalog.rb @@ -68,7 +68,11 @@ class Puppet::Node::Catalog < Puppet::PGraph @resource_table[ref] = resource + # If the name and title differ, set up an alias + self.alias(resource, resource.name) if resource.respond_to?(:name) and resource.respond_to?(:title) and resource.name != resource.title + resource.catalog = self if resource.respond_to?(:catalog=) and ! is_relationship_graph + add_vertex(resource) end end @@ -78,7 +82,10 @@ class Puppet::Node::Catalog < Puppet::PGraph resource.ref =~ /^(.+)\[/ newref = "%s[%s]" % [$1 || resource.class.name, name] - raise(ArgumentError, "Cannot alias %s to %s; resource %s already exists" % [resource.ref, name, newref]) if @resource_table[newref] + if existing = @resource_table[newref] + return if existing == resource + raise(ArgumentError, "Cannot alias %s to %s; resource %s already exists" % [resource.ref, name, newref]) + end @resource_table[newref] = resource @aliases[resource.ref] << newref end diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb index 65ee7e72e..0ec54d907 100644 --- a/lib/puppet/type/file.rb +++ b/lib/puppet/type/file.rb @@ -642,7 +642,6 @@ module Puppet # :file. return nil unless child = catalog.create_implicit_resource(self.class.name, args) rescue => detail - puts detail.backtrace self.notice "Cannot manage: %s" % [detail] return nil end @@ -769,11 +768,8 @@ module Puppet begin File.unlink(newfile) rescue => detail - if Puppet[:trace] - puts detail.backtrace - end - self.err "Could not remove old backup: %s" % - detail + puts detail.backtrace if Puppet[:trace] + self.err "Could not remove old backup: %s" % detail return false end end @@ -979,7 +975,7 @@ module Puppet end def uri2obj(source) - sourceobj = FileSource.new + sourceobj = Puppet::Type::File::FileSource.new path = nil unless source devfail "Got a nil source" @@ -1152,7 +1148,7 @@ module Puppet # the filesource class can't include the path, because the path # changes for every file instance - class FileSource + class ::Puppet::Type::File::FileSource attr_accessor :mount, :root, :server, :local end diff --git a/lib/puppet/type/file/source.rb b/lib/puppet/type/file/source.rb index 3dfb5cccd..a3e533c31 100755 --- a/lib/puppet/type/file/source.rb +++ b/lib/puppet/type/file/source.rb @@ -101,8 +101,7 @@ module Puppet begin desc = server.describe(path, @resource[:links]) rescue Puppet::Network::XMLRPCClientError => detail - self.err "Could not describe %s: %s" % - [path, detail] + self.err "Could not describe %s: %s" % [path, detail] return nil end @@ -163,7 +162,7 @@ module Puppet # Diff the contents if they ask it. This is quite annoying -- we need to do this in # 'insync?' because they might be in noop mode, but we don't want to do the file - # retrieval twice, so we cache the value annoyingly. + # retrieval twice, so we cache the value. if ! result and Puppet[:show_diff] and File.exists?(@resource[:path]) and ! @stats[:_diffed] @stats[:_remote_content] = get_remote_content string_file_diff(@resource[:path], @stats[:_remote_content]) @@ -203,13 +202,10 @@ module Puppet case @stats[:type] when "directory", "file": - unless @resource.deleting? - @resource[:ensure] = @stats[:type] - end + @resource[:ensure] = @stats[:type] unless @resource.deleting? else self.info @stats.inspect - self.err "Cannot use files of type %s as sources" % - @stats[:type] + self.err "Cannot use files of type %s as sources" % @stats[:type] return :nocopy end @@ -221,11 +217,9 @@ module Puppet # was the stat already specified, or should the value # be inherited from the source? - unless @resource.argument?(stat) - @resource[stat] = value - end + @resource[stat] = value unless @resource.argument?(stat) } - + return @stats[:checksum] end @@ -261,34 +255,22 @@ module Puppet end private + def get_remote_content - unless @stats[:type] == "file" - #if @stats[:type] == "directory" - #[@resource.name, @should.inspect] - #end - raise Puppet::DevError, "Got told to copy non-file %s" % - @resource[:path] - end + raise Puppet::DevError, "Got told to copy non-file %s" % @resource[:path] unless @stats[:type] == "file" sourceobj, path = @resource.uri2obj(@source) begin contents = sourceobj.server.retrieve(path, @resource[:links]) - rescue Puppet::Network::XMLRPCClientError => detail - self.err "Could not retrieve %s: %s" % - [path, detail] - return nil + rescue => detail + self.fail "Could not retrieve %s: %s" % [path, detail] end - # FIXME It's stupid that this isn't taken care of in the - # protocol. - unless sourceobj.server.local - contents = CGI.unescape(contents) - end + contents = CGI.unescape(contents) unless sourceobj.server.local if contents == "" - self.notice "Could not retrieve contents for %s" % - @source + self.notice "Could not retrieve contents for %s" % @source end return contents |