summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/defaults.rb9
-rw-r--r--lib/puppet/indirector/indirection.rb67
2 files changed, 34 insertions, 42 deletions
diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb
index 1b0b402ec..6ea4eef4c 100644
--- a/lib/puppet/defaults.rb
+++ b/lib/puppet/defaults.rb
@@ -500,15 +500,6 @@ module Puppet
"The server through which to send email reports."]
)
- # This needs to be in main because it's used too early in the system, such that
- # we get an infinite loop otherwise.
- self.setdefaults(:main,
- :facts_terminus => ["yaml",
- "The backend store to use for client facts."],
- :checksum_terminus => ["file",
- "The backend store to use for storing files by checksum (i.e., filebuckets)."]
- )
-
self.setdefaults(:rails,
:dblocation => { :default => "$statedir/clientconfigs.sqlite3",
:mode => 0660,
diff --git a/lib/puppet/indirector/indirection.rb b/lib/puppet/indirector/indirection.rb
index 9cc116e40..3a6284877 100644
--- a/lib/puppet/indirector/indirection.rb
+++ b/lib/puppet/indirector/indirection.rb
@@ -17,34 +17,26 @@ class Puppet::Indirector::Indirection
# Create and return our cache terminus.
def cache
- terminus(cache_name)
+ raise(Puppet::DevError, "Tried to cache when no cache class was set") unless cache_class
+ terminus(cache_class)
end
# Should we use a cache?
def cache?
- cache_name ? true : false
- end
-
- # Figure out the cache name, if there is one. If there's no name, then
- # caching is disabled.
- def cache_name
- unless @cache_name
- setting_name = "%s_cache" % self.name
- if ! Puppet.settings.valid?(setting_name) or (value = Puppet.settings[setting_name] and value == "none")
- @cache_name = nil
- else
- @cache_name = value
- @cache_name = @cache_name.intern if @cache_name.is_a?(String)
- end
- end
- @cache_name
+ cache_class ? true : false
+ end
+
+ attr_reader :cache_class
+ # Define a terminus class to be used for caching.
+ def cache_class=(class_name)
+ validate_terminus_class(class_name)
+ @cache_class = class_name
end
# Clear our cached list of termini, and reset the cache name
# so it's looked up again.
# This is only used for testing.
def clear_cache
- @cache_name = nil
@termini.clear
end
@@ -65,7 +57,7 @@ class Puppet::Indirector::Indirection
end
@termini = {}
@terminus_types = {}
- @cache_name = nil
+ @cache_class = nil
raise(ArgumentError, "Indirection %s is already defined" % @name) if @@indirections.find { |i| i.name == @name }
@@indirections << self
end
@@ -73,22 +65,31 @@ class Puppet::Indirector::Indirection
# Return the singleton terminus for this indirection.
def terminus(terminus_name = nil)
# Get the name of the terminus.
- unless terminus_name
- param_name = "%s_terminus" % self.name
- if Puppet.settings.valid?(param_name)
- terminus_name = Puppet.settings[param_name]
- else
- terminus_name = Puppet[:default_terminus]
- end
- unless terminus_name and terminus_name.to_s != ""
- raise ArgumentError, "Invalid terminus name %s" % terminus_name.inspect
- end
- terminus_name = terminus_name.intern if terminus_name.is_a?(String)
+ unless terminus_name ||= terminus_class
+ raise Puppet::DevError, "No terminus specified for %s; cannot redirect" % self.name
end
return @termini[terminus_name] ||= make_terminus(terminus_name)
end
+ attr_reader :terminus_class
+
+ # Specify the terminus class to use.
+ def terminus_class=(terminus_class)
+ validate_terminus_class(terminus_class)
+ @terminus_class = terminus_class
+ end
+
+ # This is used by terminus_class= and cache=.
+ def validate_terminus_class(terminus_class)
+ unless terminus_class and terminus_class.to_s != ""
+ raise ArgumentError, "Invalid terminus name %s" % terminus_class.inspect
+ end
+ unless Puppet::Indirector::Terminus.terminus_class(terminus_class, self.name)
+ raise ArgumentError, "Could not find terminus %s for indirection %s" % [terminus_class, self.name]
+ end
+ end
+
def find(*args)
terminus.find(*args)
end
@@ -111,10 +112,10 @@ class Puppet::Indirector::Indirection
private
# Create a new terminus instance.
- def make_terminus(name)
+ def make_terminus(terminus_class)
# Load our terminus class.
- unless klass = Puppet::Indirector::Terminus.terminus_class(name, self.name)
- raise ArgumentError, "Could not find terminus %s for indirection %s" % [name, self.name]
+ unless klass = Puppet::Indirector::Terminus.terminus_class(terminus_class, self.name)
+ raise ArgumentError, "Could not find terminus %s for indirection %s" % [terminus_class, self.name]
end
return klass.new
end