summaryrefslogtreecommitdiffstats
path: root/lib/puppet/node
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-11-28 15:20:52 -0600
committerLuke Kanies <luke@madstop.com>2007-11-28 15:20:52 -0600
commit11ae473e3852adcc382a3efea2329586d2e4bcb3 (patch)
tree7a7ff70f7d9f7bc9af0635c56690fb9fc810b9f5 /lib/puppet/node
parent8127397e1efafc13975b79eabf7ce951c1e90114 (diff)
downloadpuppet-11ae473e3852adcc382a3efea2329586d2e4bcb3.tar.gz
puppet-11ae473e3852adcc382a3efea2329586d2e4bcb3.tar.xz
puppet-11ae473e3852adcc382a3efea2329586d2e4bcb3.zip
Theoretically, this patch is to fix #917 (which it does), but
there were enough problems fixing it that I decided something more drastic needed to be done. This uses the new Puppet::ResourceReference class to canonize what a resource reference looks like and how to retrieve resources via their references. Specifically, it guarantees that resource types are always capitalized, even when they include '::' in them. While many files are modified in this commit, the majority of changes are quite small, and most of the changes are fixing the tests to use capitalized types. As we look at consolidating some of our resource types, we could consolidate the ResourceReference stuff at the same time, but at least the Puppet::Parser::ResourceReference class subclasses the main Puppet::ResourceReference class.
Diffstat (limited to 'lib/puppet/node')
-rw-r--r--lib/puppet/node/configuration.rb27
1 files changed, 12 insertions, 15 deletions
diff --git a/lib/puppet/node/configuration.rb b/lib/puppet/node/configuration.rb
index 393f23913..5da539e5c 100644
--- a/lib/puppet/node/configuration.rb
+++ b/lib/puppet/node/configuration.rb
@@ -103,9 +103,7 @@ class Puppet::Node::Configuration < Puppet::PGraph
rescue Puppet::Error => detail
Puppet.err "Could not apply complete configuration: %s" % detail
rescue => detail
- if Puppet[:trace]
- puts detail.backtrace
- end
+ puts detail.backtrace if Puppet[:trace]
Puppet.err "Got an uncaught exception of type %s: %s" % [detail.class, detail]
ensure
# Don't try to store state unless we're a host config
@@ -113,21 +111,15 @@ class Puppet::Node::Configuration < Puppet::PGraph
Puppet::Util::Storage.store if host_config?
end
- if block_given?
- yield transaction
- end
+ yield transaction if block_given?
- if host_config and (Puppet[:report] or Puppet[:summarize])
- transaction.send_report
- end
+ transaction.send_report if host_config and (Puppet[:report] or Puppet[:summarize])
return transaction
ensure
@applying = false
cleanup()
- if defined? transaction and transaction
- transaction.cleanup
- end
+ transaction.cleanup if defined? transaction and transaction
end
# Are we in the middle of applying the configuration?
@@ -213,7 +205,7 @@ class Puppet::Node::Configuration < Puppet::PGraph
current = nil
buckets = {}
- unless main = vertices.find { |res| res.type == "class" and res.title == :main }
+ unless main = vertices.find { |res| res.type == "Class" and res.title == :main }
raise Puppet::DevError, "Could not find 'main' class; cannot generate configuration"
end
@@ -358,10 +350,15 @@ class Puppet::Node::Configuration < Puppet::PGraph
# Look a resource up by its reference (e.g., File[/etc/passwd]).
def resource(type, title = nil)
+ # Always create a resource reference, so that it always canonizes how we
+ # are referring to them.
if title
- ref = "%s[%s]" % [type.to_s.capitalize, title]
+ ref = Puppet::ResourceReference.new(type, title).to_s
else
- ref = type
+ # If they didn't provide a title, then we expect the first
+ # argument to be of the form 'Class[name]', which our
+ # Reference class canonizes for us.
+ ref = Puppet::ResourceReference.new(nil, type).to_s
end
if resource = @resource_table[ref]
return resource