summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-03-18 16:35:06 -0500
committerLuke Kanies <luke@madstop.com>2008-03-18 16:35:06 -0500
commite81fc583f1f25241d91e2402b89a06026138a20c (patch)
tree4b41df56a26864e9e6963c31e8ae291fedfbc692 /lib
parentfca467da6013dfeb1015a82e178d0db241eaa54e (diff)
downloadpuppet-e81fc583f1f25241d91e2402b89a06026138a20c.tar.gz
puppet-e81fc583f1f25241d91e2402b89a06026138a20c.tar.xz
puppet-e81fc583f1f25241d91e2402b89a06026138a20c.zip
Settings now (again?) do not use a section more than
once, which should make the system a bit more efficient.
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/util/settings.rb21
1 files changed, 13 insertions, 8 deletions
diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb
index 366688944..383e31b69 100644
--- a/lib/puppet/util/settings.rb
+++ b/lib/puppet/util/settings.rb
@@ -225,6 +225,9 @@ class Puppet::Util::Settings
# A central concept of a name.
@name = nil
+
+ # The list of sections we've used.
+ @used = []
end
# Return a given object's file metadata.
@@ -663,26 +666,28 @@ Generated on #{Time.now}.
# you can 'use' a section as many times as you want.
def use(*sections)
@@sync.synchronize do # yay, thread-safe
- unless defined? @used
- @used = []
- end
+ sections = sections.reject { |s| @used.include?(s.to_sym) }
+
+ return if sections.empty?
bucket = to_transportable(*sections)
begin
- config = bucket.to_catalog
- config.host_config = false
- config.apply do |transaction|
+ catalog = bucket.to_catalog
+ raise "wtf?(%s)" % sections.inspect unless catalog
+ catalog.host_config = false
+ catalog.apply do |transaction|
if failures = transaction.any_failed?
raise "Could not configure for running; got %s failure(s)" % failures
end
end
ensure
- config.clear
+ # The catalog won't exist if there was an error creating it.
+ catalog.clear if catalog
end
sections.each { |s| @used << s }
- @used.uniq
+ @used.uniq!
end
end