Please review pull request #243: maint/2.7.x - the little indirector cleanup that didn't opened by (daniel-pittman)
Description:
A little over a year ago the first step in a series, planned to clean up the indirector, was committed to the tree. It extracted some of the mixin behaviour of indirection and replaced it with access through an explicit accessor for the indirection class.
The plan itself was good, but delivery never came, and for the last year we have carried the burden of this partially completed work - a burden of incompatibility between the 2.6 and 2.7 series, and a burden of extra ceremony every time an indirected model was touched.
This series undoes that change, and performs some minor cleanup to get this back into a pleasant and easy to use - and 2.6 compatible - form.
In the event we do decide to again go down the path of the cleanup, this is not too onerous to extract again. In reality, the odds are that the form of the cleanup would, today, be different to the form a year ago as more of the code has moved, and the overall architecture is no longer envisioned the way it once was.
There are no substantial functional changes in this, but there are some minor cleanups to unify interactions with terminus configuration in the model classes, and to ensure that we have less ways to do the same thing overall.
Diff follows:
diff --git a/ext/upload_facts.rb b/ext/upload_facts.rb
index 3a99033..70531de 100755
--- a/ext/upload_facts.rb
+++ b/ext/upload_facts.rb
@@ -98,7 +98,7 @@ def main
failed = false
- terminus = Puppet::Node::Facts.indirection.terminus
+ terminus = Puppet::Node::Facts.terminus
files.each do |file|
facts = YAML.load_file(file)
diff --git a/lib/puppet/application/agent.rb b/lib/puppet/application/agent.rb
index a3854a8..ad89d5c 100644
--- a/lib/puppet/application/agent.rb
+++ b/lib/puppet/application/agent.rb
@@ -447,9 +447,9 @@ def setup
# access to the local files and we don't need a ca.
Puppet::SSL::Host.ca_location = options[:fingerprint] ? :none : :remote
- Puppet::Transaction::Report.indirection.terminus_class = :rest
+ Puppet::Transaction::Report.terminus_class = :rest
# we want the last report to be persisted locally
- Puppet::Transaction::Report.indirection.cache_class = :yaml
+ Puppet::Transaction::Report.cache_class = :yaml
# Override the default; puppetd needs this, usually.
# You can still override this on the command-line with, e.g., :compiler.
@@ -458,7 +458,7 @@ def setup
# Override the default.
Puppet[:facts_terminus] = :facter
- Puppet::Resource::Catalog.indirection.cache_class = :yaml
+ Puppet::Resource::Catalog.cache_class = :yaml
# We need tomake the client either way, we just don't start it
# if --no-client is set.
diff --git a/lib/puppet/application/apply.rb b/lib/puppet/application/apply.rb
index 5df00d7..991ab4b 100644
--- a/lib/puppet/application/apply.rb
+++ b/lib/puppet/application/apply.rb
@@ -169,7 +169,7 @@ def main
end
# Collect our facts.
- unless facts = Puppet::Node::Facts.indirection.find(Puppet[:node_name_value])
+ unless facts = Puppet::Node::Facts.find(Puppet[:node_name_value])
raise "Could not find facts for #{Puppet[:node_name_value]}"
end
@@ -179,7 +179,7 @@ def main
end
# Find our Node
- unless node = Puppet::Node.indirection.find(Puppet[:node_name_value])
+ unless node = Puppet::Node.find(Puppet[:node_name_value])
raise "Could not find node #{Puppet[:node_name_value]}"
end
@@ -201,7 +201,7 @@ def main
begin
# Compile our catalog
starttime = Time.now
- catalog = Puppet::Resource::Catalog.indirection.find(node.name, :use_node => node)
+ catalog = Puppet::Resource::Catalog.find(node.name, :use_node => node)
# Translate it to a RAL catalog
catalog = catalog.to_ral
@@ -241,7 +241,7 @@ def setup
end
# we want the last report to be persisted locally
- Puppet::Transaction::Report.indirection.cache_class = :yaml
+ Puppet::Transaction::Report.cache_class = :yaml
if options[:debug]
Puppet::Util::Log.level = :debug
diff --git a/lib/puppet/application/device.rb b/lib/puppet/application/device.rb
index d0b9387..d06ea5b 100644
--- a/lib/puppet/application/device.rb
+++ b/lib/puppet/application/device.rb
@@ -243,7 +243,7 @@ def setup
# access to the local files and we don't need a ca.
Puppet::SSL::Host.ca_location = :remote
- Puppet::Transaction::Report.indirection.terminus_class = :rest
+ Puppet::Transaction::Report.terminus_class = :rest
# Override the default; puppetd needs this, usually.
# You can still override this on the command-line with, e.g., :compiler.
@@ -251,6 +251,6 @@ def setup
Puppet[:facts_terminus] = :network_device
- Puppet::Resource::Catalog.indirection.cache_class = :yaml
+ Puppet::Resource::Catalog.cache_class = :yaml
end
end
diff --git a/lib/puppet/application/inspect.rb b/lib/puppet/application/inspect.rb
index 6737128..81cfb78 100644
--- a/lib/puppet/application/inspect.rb
+++ b/lib/puppet/application/inspect.rb
@@ -100,8 +100,8 @@ def setup
Puppet::Util::Log.level = :info
end
- Puppet::Transaction::Report.indirection.terminus_class = :rest
- Puppet::Resource::Catalog.indirection.terminus_class = :yaml
+ Puppet::Transaction::Report.terminus_class = :rest
+ Puppet::Resource::Catalog.terminus_class = :yaml
end
def preinit
@@ -113,7 +113,7 @@ def run_command
benchmark(:notice, "Finished inspection") do
retrieval_starttime = Time.now
- unless catalog = Puppet::Resource::Catalog.indirection.find(Puppet[:certname])
+ unless catalog = Puppet::Resource::Catalog.find(Puppet[:certname])
raise "Could not find catalog for #{Puppet[:certname]}"
end
@@ -180,7 +180,7 @@ def run_command
@report.finalize_report
begin
- Puppet::Transaction::Report.indirection.save(@report)
+ @report.save
rescue => detail
puts detail.backtrace if Puppet[:trace]
Puppet.err "Could not send report: #{detail}"
diff --git a/lib/puppet/application/kick.rb b/lib/puppet/application/kick.rb
index 72f0608..a305b45 100644
--- a/lib/puppet/application/kick.rb
+++ b/lib/puppet/application/kick.rb
@@ -232,7 +232,7 @@ def run_for_host(host)
end
require 'puppet/run'
- Puppet::Run.indirection.terminus_class = :rest
+ Puppet::Run.terminus_class = :rest
port = Puppet[:puppetport]
url = ["https://#{host}:#{port}", "production", "run", host].join('/')
@@ -243,7 +243,7 @@ def run_for_host(host)
:background => ! options[:foreground],
:ignoreschedules => options[:ignoreschedules]
}
- run = Puppet::Run.indirection.save(Puppet::Run.new( run_options ), url)
+ run = Puppet::Run.new(run_options).save(url)
puts "Getting status"
result = run.status
puts "status is #{result}"
@@ -298,12 +298,12 @@ def setup
if Puppet[:node_terminus] == "ldap" and (options[:all] or @classes)
if options[:all]
- @hosts = Puppet::Node.indirection.search("whatever", :fqdn => options[:fqdn]).collect { |node| node.name }
+ @hosts = Puppet::Node.search("whatever", :fqdn => options[:fqdn]).collect { |node| node.name }
puts "all: #{@hosts.join(", ")}"
else
@hosts = []
@classes.each do |klass|
- list = Puppet::Node.indirection.search("whatever", :fqdn => options[:fqdn], :class => klass).collect { |node| node.name }
+ list = Puppet::Node.search("whatever", :fqdn => options[:fqdn], :class => klass).collect { |node| node.name }
puts "#{klass}: #{list.join(", ")}"
@hosts += list
diff --git a/lib/puppet/application/master.rb b/lib/puppet/application/master.rb
index b4da770..42c63a4 100644
--- a/lib/puppet/application/master.rb
+++ b/lib/puppet/application/master.rb
@@ -149,7 +149,7 @@ def compile
Puppet::Util::Log.newdestination :console
raise ArgumentError, "Cannot render compiled catalogs without pson support" unless Puppet.features.pson?
begin
- unless catalog = Puppet::Resource::Catalog.indirection.find(options[:node])
+ unless catalog = Puppet::Resource::Catalog.find(options[:node])
raise "Could not compile catalog for #{options[:node]}"
end
@@ -229,7 +229,7 @@ def setup
Puppet.settings.use :main, :master, :ssl, :metrics
# Cache our nodes in yaml. Currently not configurable.
- Puppet::Node.indirection.cache_class = :yaml
+ Puppet::Node.cache_class = :yaml
# Configure all of the SSL stuff.
if Puppet::SSL::CertificateAuthority.ca?
diff --git a/lib/puppet/application/queue.rb b/lib/puppet/application/queue.rb
index 2a9d3e7..d5d44c5 100644
--- a/lib/puppet/application/queue.rb
+++ b/lib/puppet/application/queue.rb
@@ -137,7 +137,7 @@ def main
# by the terminus_class = :active_record setting above)
Puppet::Util.benchmark(:notice, "Processing queued catalog for #{catalog.name}") do
begin
- Puppet::Resource::Catalog.indirection.save(catalog)
+ Puppet::Resource::Catalog.save(catalog)
rescue => detail
puts detail.backtrace if Puppet[:trace]
Puppet.err "Could not save queued catalog for #{catalog.name}: #{detail}"
@@ -171,7 +171,7 @@ def setup
exit(Puppet.settings.print_configs ? 0 : 1) if Puppet.settings.print_configs?
require 'puppet/resource/catalog'
- Puppet::Resource::Catalog.indirection.terminus_class = :store_configs
+ Puppet::Resource::Catalog.terminus_class = :store_configs
daemon.daemonize if Puppet[:daemonize]
@@ -179,6 +179,6 @@ def setup
# class set up, because if storeconfigs is enabled,
# we'll get a loop of continually caching the catalog
# for storage again.
- Puppet::Resource::Catalog.indirection.cache_class = nil
+ Puppet::Resource::Catalog.cache_class = nil
end
end
diff --git a/lib/puppet/application/resource.rb b/lib/puppet/application/resource.rb
index c9a84f3..6b0e164 100644
--- a/lib/puppet/application/resource.rb
+++ b/lib/puppet/application/resource.rb
@@ -166,7 +166,7 @@ def setup
private
def remote_key(type, name)
- Puppet::Resource.indirection.terminus_class = :rest
+ Puppet::Resource.terminus_class = :rest
port = Puppet[:puppetport]
["https://#{@host}:#{port}", "production", "resources", type, name].join('/')
end
@@ -219,19 +219,19 @@ def find_or_save_resources(type, name, params)
if name
if params.empty?
- [ Puppet::Resource.indirection.find( key ) ]
+ [Puppet::Resource.find(key)]
else
resource = Puppet::Resource.new( type, name, :parameters => params )
# save returns [resource that was saved, transaction log from applying the resource]
- save_result = Puppet::Resource.indirection.save(resource, key)
+ save_result = resource.save(key)
[ save_result.first ]
end
else
if type == "file"
raise "Listing all file instances is not supported. Please specify a file or directory, e.g. puppet resource file /etc"
end
- Puppet::Resource.indirection.search( key, {} )
+ Puppet::Resource.search( key, {} )
end
end
end
diff --git a/lib/puppet/configurer.rb b/lib/puppet/configurer.rb
index 83b5a9a..0016a02 100644
--- a/lib/puppet/configurer.rb
+++ b/lib/puppet/configurer.rb
@@ -136,7 +136,7 @@ def run(options = {})
begin
prepare(options)
- if Puppet::Resource::Catalog.indirection.terminus_class == :rest
+ if Puppet::Resource::Catalog.terminus_class == :rest
# This is a bit complicated. We need the serialized and escaped facts,
# and we need to know which format they're encoded in. Thus, we
# get a hash with both of these pieces of information.
@@ -171,7 +171,7 @@ def run(options = {})
def send_report(report)
puts report.summary if Puppet[:summarize]
save_last_run_summary(report)
- Puppet::Transaction::Report.indirection.save(report) if Puppet[:report]
+ Puppet::Transaction::Report.save(report) if Puppet[:report]
rescue => detail
puts detail.backtrace if Puppet[:trace]
Puppet.err "Could not send report: #{detail}"
@@ -221,7 +221,7 @@ def execute_from_setting(setting)
def retrieve_catalog_from_cache(fact_options)
result = nil
@duration = thinmark do
- result = Puppet::Resource::Catalog.indirection.find(Puppet[:node_name_value], fact_options.merge(:ignore_terminus => true))
+ result = Puppet::Resource::Catalog.find(Puppet[:node_name_value], fact_options.merge(:ignore_terminus => true))
end
Puppet.notice "Using cached catalog"
result
@@ -234,7 +234,7 @@ def retrieve_catalog_from_cache(fact_options)
def retrieve_new_catalog(fact_options)
result = nil
@duration = thinmark do
- result = Puppet::Resource::Catalog.indirection.find(Puppet[:node_name_value], fact_options.merge(:ignore_cache => true))
+ result = Puppet::Resource::Catalog.find(Puppet[:node_name_value], fact_options.merge(:ignore_cache => true))
end
result
rescue SystemExit,NoMemoryError
diff --git a/lib/puppet/configurer/fact_handler.rb b/lib/puppet/configurer/fact_handler.rb
index 8034957..77bd1e5 100644
--- a/lib/puppet/configurer/fact_handler.rb
+++ b/lib/puppet/configurer/fact_handler.rb
@@ -16,7 +16,7 @@ def find_facts
# compile them and then "cache" them on the server.
begin
reload_facter
- facts = Puppet::Node::Facts.indirection.find(Puppet[:node_name_value])
+ facts = Puppet::Node::Facts.find(Puppet[:node_name_value])
unless Puppet[:node_name_fact].empty?
Puppet[:node_name_value] = facts.values[Puppet[:node_name_fact]]
facts.name = Puppet[:node_name_value]
diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb
index f1b1ac7..be8dfda 100644
--- a/lib/puppet/defaults.rb
+++ b/lib/puppet/defaults.rb
@@ -137,7 +137,7 @@ module Puppet
require 'puppet/node/facts'
# Cache to YAML if we're uploading facts away
if %w[rest inventory_service].include? value.to_s
- Puppet::Node::Facts.indirection.cache_class = :yaml
+ Puppet::Node::Facts.cache_class = :yaml
end
end
},
@@ -168,7 +168,7 @@ module Puppet
Puppet.settings[:storeconfigs] = true
# But then we modify the configuration
- Puppet::Resource::Catalog.indirection.cache_class = :queue
+ Puppet::Resource::Catalog.cache_class = :queue
else
raise "Cannot disable asynchronous storeconfigs in a running process"
end
@@ -908,11 +908,11 @@ module Puppet
require 'puppet/node/facts'
if value
Puppet.settings[:async_storeconfigs] or
- Puppet::Resource::Catalog.indirection.cache_class = :store_configs
- Puppet::Node::Facts.indirection.cache_class = :store_configs
- Puppet::Node.indirection.cache_class = :store_configs
+ Puppet::Resource::Catalog.cache_class = :store_configs
+ Puppet::Node::Facts.cache_class = :store_configs
+ Puppet::Node.cache_class = :store_configs
- Puppet::Resource.indirection.terminus_class = :store_configs
+ Puppet::Resource.terminus_class = :store_configs
end
end
},
diff --git a/lib/puppet/face/catalog.rb b/lib/puppet/face/catalog.rb
index 10b15d2..21580da 100644
--- a/lib/puppet/face/catalog.rb
+++ b/lib/puppet/face/catalog.rb
@@ -96,7 +96,7 @@
returns "Nothing."
notes <<-'EOT'
When used from the Ruby API, this action has a side effect of leaving
- Puppet::Resource::Catalog.indirection.terminus_class set to yaml. The
+ Puppet::Resource::Catalog.terminus_class set to yaml. The
terminus must be explicitly re-set for subsequent catalog actions.
EOT
examples <<-'EOT'
@@ -112,8 +112,8 @@
# ...
EOT
when_invoked do |options|
- Puppet::Resource::Catalog.indirection.terminus_class = :rest
- Puppet::Resource::Catalog.indirection.cache_class = nil
+ Puppet::Resource::Catalog.terminus_class = :rest
+ Puppet::Resource::Catalog.cache_class = nil
catalog = nil
retrieval_duration = thinmark do
catalog = Puppet::Face[:catalog, '0.0.1'].find(Puppet[:certname])
@@ -121,7 +121,7 @@
catalog.retrieval_duration = retrieval_duration
catalog.write_class_file
- Puppet::Resource::Catalog.indirection.terminus_class = :yaml
+ Puppet::Resource::Catalog.terminus_class = :yaml
Puppet::Face[:catalog, "0.0.1"].save(catalog)
Puppet.notice "Saved catalog for #{Puppet[:certname]} to yaml"
nil
diff --git a/lib/puppet/face/catalog/select.rb b/lib/puppet/face/catalog/select.rb
index de2ca80..c24ca73 100644
--- a/lib/puppet/face/catalog/select.rb
+++ b/lib/puppet/face/catalog/select.rb
@@ -28,7 +28,7 @@
# REVISIT: Eventually, type should have a default value that triggers
# the non-specific behaviour. For now, though, this will do.
# --daniel 2011-05-03
- catalog = Puppet::Resource::Catalog.indirection.find(host)
+ catalog = Puppet::Resource::Catalog.find(host)
if type == '*'
catalog.resources
diff --git a/lib/puppet/face/certificate.rb b/lib/puppet/face/certificate.rb
index d116796..87d2116 100644
--- a/lib/puppet/face/certificate.rb
+++ b/lib/puppet/face/certificate.rb
@@ -79,9 +79,7 @@
EOT
when_invoked do |options|
- Puppet::SSL::Host.indirection.search("*", {
- :for => :certificate_request,
- }).map { |h| h.inspect }
+ Puppet::SSL::Host.search("*", {:for => :certificate_request}).map { |h| h.inspect }
end
end
@@ -109,7 +107,7 @@
end
host.desired_state = 'signed'
- Puppet::SSL::Host.indirection.save(host)
+ host.save
else
# We have to do this case manually because we need to specify
# allow_dns_alt_names.
diff --git a/lib/puppet/face/facts.rb b/lib/puppet/face/facts.rb
index 9d83e3d..4c04f25 100644
--- a/lib/puppet/face/facts.rb
+++ b/lib/puppet/face/facts.rb
@@ -70,10 +70,10 @@
render_as :yaml
when_invoked do |options|
- Puppet::Node::Facts.indirection.terminus_class = :facter
- facts = Puppet::Node::Facts.indirection.find(Puppet[:certname])
- Puppet::Node::Facts.indirection.terminus_class = :rest
- Puppet::Node::Facts.indirection.save(facts)
+ Puppet::Node::Facts.terminus_class = :facter
+ facts = Puppet::Node::Facts.find(Puppet[:certname])
+ Puppet::Node::Facts.terminus_class = :rest
+ facts.save
Puppet.notice "Uploaded facts for '#{Puppet[:certname]}'"
nil
end
diff --git a/lib/puppet/face/file/download.rb b/lib/puppet/face/file/download.rb
index 3e67e45..da5a67a 100644
--- a/lib/puppet/face/file/download.rb
+++ b/lib/puppet/face/file/download.rb
@@ -23,7 +23,7 @@
if sum =~ /^puppet:\/\// # it's a puppet url
require 'puppet/file_serving'
require 'puppet/file_serving/content'
- raise "Could not find metadata for #{sum}" unless content = Puppet::FileServing::Content.indirection.find(sum)
+ raise "Could not find metadata for #{sum}" unless content = Puppet::FileServing::Content.find(sum)
file = Puppet::FileBucket::File.new(content.content)
else
tester = Object.new
@@ -34,20 +34,20 @@
key = "#{type}/#{sumdata}"
- Puppet::FileBucket::File.indirection.terminus_class = :file
- if Puppet::FileBucket::File.indirection.find(key)
+ Puppet::FileBucket::File.terminus_class = :file
+ if Puppet::FileBucket::File.find(key)
Puppet.info "Content for '#{sum}' already exists"
return
end
- Puppet::FileBucket::File.indirection.terminus_class = :rest
- raise "Could not download content for '#{sum}'" unless file = Puppet::FileBucket::File.indirection.find(key)
+ Puppet::FileBucket::File.terminus_class = :rest
+ raise "Could not download content for '#{sum}'" unless file = Puppet::FileBucket::File.find(key)
end
- Puppet::FileBucket::File.indirection.terminus_class = :file
+ Puppet::FileBucket::File.terminus_class = :file
Puppet.notice "Saved #{sum} to filebucket"
- Puppet::FileBucket::File.indirection.save file
+ file.save
return nil
end
end
diff --git a/lib/puppet/face/file/store.rb b/lib/puppet/face/file/store.rb
index 139181b..4837e9b 100644
--- a/lib/puppet/face/file/store.rb
+++ b/lib/puppet/face/file/store.rb
@@ -13,8 +13,8 @@
when_invoked do |path, options|
file = Puppet::FileBucket::File.new(Puppet::Util.binread(path))
- Puppet::FileBucket::File.indirection.terminus_class = :file
- Puppet::FileBucket::File.indirection.save file
+ Puppet::FileBucket::File.terminus_class = :file
+ file.save
file.checksum
end
end
diff --git a/lib/puppet/face/node/clean.rb b/lib/puppet/face/node/clean.rb
index d2852de..b3b7267 100644
--- a/lib/puppet/face/node/clean.rb
+++ b/lib/puppet/face/node/clean.rb
@@ -40,10 +40,10 @@
Puppet::SSL::Host.ca_location = :none
end
- Puppet::Node::Facts.indirection.terminus_class = :yaml
- Puppet::Node::Facts.indirection.cache_class = :yaml
- Puppet::Node.indirection.terminus_class = :yaml
- Puppet::Node.indirection.cache_class = :yaml
+ Puppet::Node::Facts.terminus_class = :yaml
+ Puppet::Node::Facts.cache_class = :yaml
+ Puppet::Node.terminus_class = :yaml
+ Puppet::Node.cache_class = :yaml
nodes.each { |node| cleanup(node.downcase, options[:unexport]) }
end
@@ -73,19 +73,19 @@ def clean_cert(node)
# clean facts for +host+
def clean_cached_facts(node)
- Puppet::Node::Facts.indirection.destroy(node)
+ Puppet::Node::Facts.destroy(node)
Puppet.info "#{node}'s facts removed"
end
# clean cached node +host+
def clean_cached_node(node)
- Puppet::Node.indirection.destroy(node)
+ Puppet::Node.destroy(node)
Puppet.info "#{node}'s cached node removed"
end
# clean node reports for +host+
def clean_reports(node)
- Puppet::Transaction::Report.indirection.destroy(node)
+ Puppet::Transaction::Report.destroy(node)
Puppet.info "#{node}'s reports removed"
end
diff --git a/lib/puppet/face/report.rb b/lib/puppet/face/report.rb
index 2273710..60000b1 100644
--- a/lib/puppet/face/report.rb
+++ b/lib/puppet/face/report.rb
@@ -17,7 +17,7 @@
From the implementation of `puppet report submit` (API example):
begin
- Puppet::Transaction::Report.indirection.terminus_class = :rest
+ Puppet::Transaction::Report.terminus_class = :rest
Puppet::Face[:report, "0.0.1"].save(report)
Puppet.notice "Uploaded report for #{report.name}"
rescue => detail
@@ -44,7 +44,7 @@
EOT
when_invoked do |report, options|
begin
- Puppet::Transaction::Report.indirection.terminus_class = :rest
+ Puppet::Transaction::Report.terminus_class = :rest
Puppet::Face[:report, "0.0.1"].save(report)
Puppet.notice "Uploaded report for #{report.name}"
rescue => detail
diff --git a/lib/puppet/file_bucket/dipper.rb b/lib/puppet/file_bucket/dipper.rb
index 27a86f8..34f42fe 100644
--- a/lib/puppet/file_bucket/dipper.rb
+++ b/lib/puppet/file_bucket/dipper.rb
@@ -40,8 +40,8 @@ def backup(file)
# Make a HEAD request for the file so that we don't waste time
# uploading it if it already exists in the bucket.
- unless Puppet::FileBucket::File.indirection.head(file_bucket_path)
- Puppet::FileBucket::File.indirection.save(file_bucket_file, dest_path)
+ unless Puppet::FileBucket::File.head(file_bucket_path)
+ file_bucket_file.save(dest_path)
end
return file_bucket_file.checksum_data
@@ -54,7 +54,7 @@ def backup(file)
# Retrieve a file by sum.
def getfile(sum)
source_path = "#{@rest_path}md5/#{sum}"
- file_bucket_file = Puppet::FileBucket::File.indirection.find(source_path, :bucket_path => @local_path)
+ file_bucket_file = Puppet::FileBucket::File.find(source_path, :bucket_path => @local_path)
raise Puppet::Error, "File not found" unless file_bucket_file
file_bucket_file.to_s
diff --git a/lib/puppet/file_bucket/file/indirection_hooks.rb b/lib/puppet/file_bucket/file/indirection_hooks.rb
index 58c2927..016b4ba 100644
--- a/lib/puppet/file_bucket/file/indirection_hooks.rb
+++ b/lib/puppet/file_bucket/file/indirection_hooks.rb
@@ -4,6 +4,6 @@
# in filebucket indirections.
module Puppet::FileBucket::File::IndirectionHooks
def select_terminus(request)
- return(request.protocol == 'https' ? :rest : Puppet::FileBucket::File.indirection.terminus_class)
+ return(request.protocol == 'https' ? :rest : Puppet::FileBucket::File.terminus_class)
end
end
diff --git a/lib/puppet/indirector.rb b/lib/puppet/indirector.rb
index 6de3d72..e4531c3 100644
--- a/lib/puppet/indirector.rb
+++ b/lib/puppet/indirector.rb
@@ -15,8 +15,8 @@ module Puppet::Indirector
def self.configure_routes(application_routes)
application_routes.each do |indirection_name, termini|
indirection_name = indirection_name.to_sym
- terminus_name = termini["terminus"]
- cache_name = termini["cache"]
+ terminus_name = termini["terminus"]
+ cache_name = termini["cache"]
Puppet::Indirector::Terminus.terminus_class(indirection_name, terminus_name || cache_name)
@@ -24,7 +24,7 @@ def self.configure_routes(application_routes)
raise "Indirection #{indirection_name} does not exist" unless indirection
indirection.terminus_class = terminus_name if terminus_name
- indirection.cache_class = cache_name if cache_name
+ indirection.cache_class = cache_name if cache_name
end
end
@@ -36,17 +36,34 @@ def self.configure_routes(application_routes)
def indirects(indirection, options = {})
raise(ArgumentError, "Already handling indirection for #{@indirection.name}; cannot also handle #{indirection}") if @indirection
# populate this class with the various new methods
- extend ClassMethods
+ include InstanceMethods
+ extend ClassMethods
+
include Puppet::Indirector::Envelope
- extend Puppet::Network::FormatHandler
+ extend Puppet::Network::FormatHandler
# instantiate the actual Terminus for that type and this name (:ldap, w/ args :node)
# & hook the instantiated Terminus into this class (Node: @indirection = terminus)
- @indirection = Puppet::Indirector::Indirection.new(self, indirection, options)
+ @indirection = Puppet::Indirector::Indirection.new(self, indirection, options)
+ end
+
+ module InstanceMethods
+ # Only save really applies sensibly on an instance, and is shorthand for
+ # saving self. Other methods are all sensibly class based.
+ def save(key = nil)
+ self.class.save(self, key)
+ end
end
module ClassMethods
attr_reader :indirection
+
+ [:expire, :find, :head, :destroy, :search, :save, :terminus,
+ :terminus_class, :terminus_class=,
+ :cache_class, :cache_class=
+ ].each do |forward|
+ define_method(forward) {|*args| indirection.__send__(forward, *args) }
+ end
end
# Helper definition for indirections that handle filenames.
diff --git a/lib/puppet/indirector/catalog/active_record.rb b/lib/puppet/indirector/catalog/active_record.rb
index 365cdfe..f814f4a 100644
--- a/lib/puppet/indirector/catalog/active_record.rb
+++ b/lib/puppet/indirector/catalog/active_record.rb
@@ -30,7 +30,7 @@ def save(request)
host.merge_resources(catalog.vertices)
host.last_compile = Time.now
- if node = Puppet::Node.indirection.find(catalog.name)
+ if node = Puppet::Node.find(catalog.name)
host.ip = node.parameters["ipaddress"]
host.environment = node.environment.to_s
end
diff --git a/lib/puppet/indirector/catalog/compiler.rb b/lib/puppet/indirector/catalog/compiler.rb
index 19f8386..27d1c6a 100644
--- a/lib/puppet/indirector/catalog/compiler.rb
+++ b/lib/puppet/indirector/catalog/compiler.rb
@@ -23,7 +23,7 @@ def extract_facts_from_request(request)
facts = Puppet::Node::Facts.convert_from(format, text_facts)
end
facts.add_timestamp
- Puppet::Node::Facts.indirection.save(facts)
+ facts.save
end
# Compile a node's catalog.
@@ -87,7 +87,7 @@ def compile(node)
# Turn our host name into a node object.
def find_node(name)
begin
- return nil unless node = Puppet::Node.indirection.find(name)
+ return nil unless node = Puppet::Node.find(name)
rescue => detail
puts detail.backtrace if Puppet[:trace]
raise Puppet::Error, "Failed when searching for node #{name}: #{detail}"
diff --git a/lib/puppet/indirector/catalog/static_compiler.rb b/lib/puppet/indirector/catalog/static_compiler.rb
index 1d92121..b01e3ab 100644
--- a/lib/puppet/indirector/catalog/static_compiler.rb
+++ b/lib/puppet/indirector/catalog/static_compiler.rb
@@ -126,7 +126,7 @@ def store_content(resource)
type = @summer.sumtype(resource[:content])
sum = @summer.sumdata(resource[:content])
- if Puppet::FileBucket::File.indirection.find("#{type}/#{sum}")
+ if Puppet::FileBucket::File.find("#{type}/#{sum}")
Puppet.info "Content for '#{resource[:source]}' already exists"
else
Puppet.info "Storing content for source '#{resource[:source]}'"
diff --git a/lib/puppet/indirector/certificate_request/ca.rb b/lib/puppet/indirector/certificate_request/ca.rb
index 5d76ee5..ec36883 100644
--- a/lib/puppet/indirector/certificate_request/ca.rb
+++ b/lib/puppet/indirector/certificate_request/ca.rb
@@ -7,7 +7,7 @@ class Puppet::SSL::CertificateRequest::Ca < Puppet::Indirector::SslFile
store_in :csrdir
def save(request)
- if host = Puppet::SSL::Host.indirection.find(request.key)
+ if host = Puppet::SSL::Host.find(request.key)
if Puppet[:allow_duplicate_certs]
Puppet.notice "#{request.key} already has a #{host.state} certificate; new certificate will overwrite it"
else
diff --git a/lib/puppet/indirector/certificate_status/file.rb b/lib/puppet/indirector/certificate_status/file.rb
index 9061d94..0432c74 100644
--- a/lib/puppet/indirector/certificate_status/file.rb
+++ b/lib/puppet/indirector/certificate_status/file.rb
@@ -18,9 +18,9 @@ def destroy(request)
Puppet::SSL::Certificate,
Puppet::SSL::CertificateRequest,
Puppet::SSL::Key,
- ].collect do |part|
- if part.indirection.destroy(request.key)
- deleted << "#{part}"
+ ].collect do |part_of_ssl_stuff|
+ if part_of_ssl_stuff.destroy(request.key)
+ deleted << "#{part_of_ssl_stuff}"
end
end
@@ -30,11 +30,11 @@ def destroy(request)
def save(request)
if request.instance.desired_state == "signed"
- certificate_request = Puppet::SSL::CertificateRequest.indirection.find(request.key)
+ certificate_request = Puppet::SSL::CertificateRequest.find(request.key)
raise Puppet::Error, "Cannot sign for host #{request.key} without a certificate request" unless certificate_request
ca.sign(request.key)
elsif request.instance.desired_state == "revoked"
- certificate = Puppet::SSL::Certificate.indirection.find(request.key)
+ certificate = Puppet::SSL::Certificate.find(request.key)
raise Puppet::Error, "Cannot revoke host #{request.key} because has it doesn't have a signed certificate" unless certificate
ca.revoke(request.key)
else
@@ -63,7 +63,7 @@ def search(request)
end
klasses.collect do |klass|
- klass.indirection.search(request.key, request.options)
+ klass.search(request.key, request.options)
end.flatten.collect do |result|
result.name
end.uniq.collect &Puppet::SSL::Host.method(:new)
@@ -71,7 +71,7 @@ def search(request)
def find(request)
ssl_host = Puppet::SSL::Host.new(request.key)
- public_key = Puppet::SSL::Certificate.indirection.find(request.key)
+ public_key = Puppet::SSL::Certificate.find(request.key)
if ssl_host.certificate_request || public_key
ssl_host
diff --git a/lib/puppet/indirector/face.rb b/lib/puppet/indirector/face.rb
index adb6b68..a5983fd 100644
--- a/lib/puppet/indirector/face.rb
+++ b/lib/puppet/indirector/face.rb
@@ -25,7 +25,11 @@ class Puppet::Indirector::Face < Puppet::Face
end
after_action do |action, args, options|
- indirection.reset_terminus_class
+ # Reset the indirection to the default terminus class. Technically, we
+ # could destroy some other hand configuration here, but there is no
+ # *robust* way for someone to make that not break - so, hopefully, no
+ # one is doing that. I found no evidence to date. --daniel 2011-12-04
+ indirection.terminus_class = nil
end
end
diff --git a/lib/puppet/indirector/indirection.rb b/lib/puppet/indirector/indirection.rb
index 20b260b..f9afecb 100644
--- a/lib/puppet/indirector/indirection.rb
+++ b/lib/puppet/indirector/indirection.rb
@@ -139,13 +139,17 @@ def terminus_class
@terminus_class
end
+ # Deprecated unofficially in 2.7, officially in 2.8; just set the terminus
+ # class to `nil` instead. Keep in mind, though, that won't work reliably if
+ # you need to support older 2.7 earlier Puppet versions.
def reset_terminus_class
- @terminus_class = nil
+ terminus_class = nil
end
- # Specify the terminus class to use.
+ # Specify the terminus class to use. `nil` will reset the class, just like
+ # the deprecated `reset_terminus_class` method would have.
def terminus_class=(klass)
- validate_terminus_class(klass)
+ klass.nil? or validate_terminus_class(klass)
@terminus_class = klass
end
diff --git a/lib/puppet/network/handler/ca.rb b/lib/puppet/network/handler/ca.rb
index a61f62f..1dabeee 100644
--- a/lib/puppet/network/handler/ca.rb
+++ b/lib/puppet/network/handler/ca.rb
@@ -36,8 +36,8 @@ def getcert(csrtext, client = nil, clientip = nil)
# and it mucks with the permissions requirements.
# first check to see if we already have a signed cert for the host
- cert = Puppet::SSL::Certificate.indirection.find(hostname)
- cacert = Puppet::SSL::Certificate.indirection.find(@ca.host.name)
+ cert = Puppet::SSL::Certificate.find(hostname)
+ cacert = Puppet::SSL::Certificate.find(@ca.host.name)
if cert
Puppet.info "Retrieving existing certificate for #{hostname}"
@@ -46,10 +46,10 @@ def getcert(csrtext, client = nil, clientip = nil)
end
[cert.to_s, cacert.to_s]
else
- Puppet::SSL::CertificateRequest.indirection.save(csr)
+ csr.save
# We determine whether we signed the csr by checking if there's a certificate for it
- if cert = Puppet::SSL::Certificate.indirection.find(hostname)
+ if cert = Puppet::SSL::Certificate.find(hostname)
[cert.to_s, cacert.to_s]
else
nil
diff --git a/lib/puppet/network/handler/filebucket.rb b/lib/puppet/network/handler/filebucket.rb
index 0ca467f..a1b99fd 100755
--- a/lib/puppet/network/handler/filebucket.rb
+++ b/lib/puppet/network/handler/filebucket.rb
@@ -30,12 +30,12 @@ def initialize(hash)
def addfile(contents, path, client = nil, clientip = nil)
contents = Base64.decode64(contents) if client
bucket = Puppet::FileBucket::File.new(contents)
- Puppet::FileBucket::File.indirection.save(bucket)
+ bucket.save
end
# Return the contents associated with a given md5 sum.
def getfile(md5, client = nil, clientip = nil)
- bucket = Puppet::FileBucket::File.indirection.find("md5:#{md5}")
+ bucket = Puppet::FileBucket::File.find("md5:#{md5}")
contents = bucket.contents
if client
diff --git a/lib/puppet/network/handler/fileserver.rb b/lib/puppet/network/handler/fileserver.rb
index 8fe3da2..5851e79 100755
--- a/lib/puppet/network/handler/fileserver.rb
+++ b/lib/puppet/network/handler/fileserver.rb
@@ -236,7 +236,7 @@ def modules_mount(module_name, client)
unless hostname = (client || Facter.value("hostname"))
raise ArgumentError, "Could not find hostname"
end
- env = (node = Puppet::Node.indirection.find(hostname)) ? node.environment : nil
+ env = (node = Puppet::Node.find(hostname)) ? node.environment : nil
# And use the environment to look up the module.
(mod = Puppet::Node::Environment.new(env).module(module_name) and mod.files?) ? @mounts[MODULES].copy(mod.name, mod.file_directory) : nil
diff --git a/lib/puppet/network/handler/master.rb b/lib/puppet/network/handler/master.rb
index fd2bb95..9ea24f2 100644
--- a/lib/puppet/network/handler/master.rb
+++ b/lib/puppet/network/handler/master.rb
@@ -45,9 +45,9 @@ def getconfig(facts, format = "marshal", client = nil, clientip = nil)
client ||= facts["hostname"]
# Pass the facts to the fact handler
- Puppet::Node::Facts.indirection.save(Puppet::Node::Facts.new(client, facts)) unless local?
+ Puppet::Node::Facts.new(client, facts).save unless local?
- catalog = Puppet::Resource::Catalog.indirection.find(client)
+ catalog = Puppet::Resource::Catalog.find(client)
case format
when "yaml"
diff --git a/lib/puppet/network/http/handler.rb b/lib/puppet/network/http/handler.rb
index 2c78a02..3744ace 100644
--- a/lib/puppet/network/http/handler.rb
+++ b/lib/puppet/network/http/handler.rb
@@ -103,7 +103,7 @@ def model(indirection_name)
# Execute our find.
def do_find(indirection_name, key, params, request, response)
- unless result = model(indirection_name).indirection.find(key, params)
+ unless result = model(indirection_name).find(key, params)
Puppet.info("Could not find #{indirection_name} for '#{key}'")
return do_exception(response, "Could not find #{indirection_name} #{key}", 404)
end
@@ -123,7 +123,7 @@ def do_find(indirection_name, key, params, request, response)
# Execute our head.
def do_head(indirection_name, key, params, request, response)
- unless self.model(indirection_name).indirection.head(key, params)
+ unless self.model(indirection_name).head(key, params)
Puppet.info("Could not find #{indirection_name} for '#{key}'")
return do_exception(response, "Could not find #{indirection_name} #{key}", 404)
end
@@ -135,7 +135,7 @@ def do_head(indirection_name, key, params, request, response)
# Execute our search.
def do_search(indirection_name, key, params, request, response)
model = self.model(indirection_name)
- result = model.indirection.search(key, params)
+ result = model.search(key, params)
if result.nil?
return do_exception(response, "Could not find instances in #{indirection_name} with '#{key}'", 404)
@@ -149,7 +149,7 @@ def do_search(indirection_name, key, params, request, response)
# Execute our destroy.
def do_destroy(indirection_name, key, params, request, response)
- result = model(indirection_name).indirection.destroy(key, params)
+ result = model(indirection_name).destroy(key, params)
return_yaml_response(response, result)
end
@@ -160,8 +160,7 @@ def do_save(indirection_name, key, params, request, response)
raise ArgumentError, "No data to save" if !data or data.empty?
format = request_format(request)
- obj = model(indirection_name).convert_from(format, data)
- result = model(indirection_name).indirection.save(obj, key)
+ result = model(indirection_name).convert_from(format, data).save(key)
return_yaml_response(response, result)
end
diff --git a/lib/puppet/network/http/webrick.rb b/lib/puppet/network/http/webrick.rb
index 52aec1b..d30351d 100644
--- a/lib/puppet/network/http/webrick.rb
+++ b/lib/puppet/network/http/webrick.rb
@@ -105,7 +105,7 @@ def setup_ssl
results[:SSLStartImmediately] = true
results[:SSLEnable] = true
- raise Puppet::Error, "Could not find CA certificate" unless Puppet::SSL::Certificate.indirection.find(Puppet::SSL::CA_NAME)
+ raise Puppet::Error, "Could not find CA certificate" unless Puppet::SSL::Certificate.find(Puppet::SSL::CA_NAME)
results[:SSLCACertificateFile] = Puppet[:localcacert]
results[:SSLVerifyClient] = OpenSSL::SSL::VERIFY_PEER
diff --git a/lib/puppet/node.rb b/lib/puppet/node.rb
index 5b0a986..e8d58e6 100644
--- a/lib/puppet/node.rb
+++ b/lib/puppet/node.rb
@@ -57,7 +57,7 @@ def initialize(name, options = {})
# Merge the node facts with parameters from the node source.
def fact_merge
- if facts = Puppet::Node::Facts.indirection.find(name)
+ if facts = Puppet::Node::Facts.find(name)
merge(facts.values)
end
rescue => detail
diff --git a/lib/puppet/node/facts.rb b/lib/puppet/node/facts.rb
index 577b62b..f7a8be4 100755
--- a/lib/puppet/node/facts.rb
+++ b/lib/puppet/node/facts.rb
@@ -16,7 +16,7 @@ class Puppet::Node::Facts
# We want to expire any cached nodes if the facts are saved.
module NodeExpirer
def save(instance, key = nil)
- Puppet::Node.indirection.expire(instance.name)
+ Puppet::Node.expire(instance.name)
super
end
end
diff --git a/lib/puppet/parser/collector.rb b/lib/puppet/parser/collector.rb
index c9ab34a..a38b7da 100644
--- a/lib/puppet/parser/collector.rb
+++ b/lib/puppet/parser/collector.rb
@@ -101,8 +101,7 @@ def collect_exported
resources = collect_virtual(true).reject { |r| ! r.virtual? }
# key is '#{type}/#{name}', and host and filter.
- found = Puppet::Resource.indirection.
- search(@type, :host => @scope.host, :filter => @equery)
+ found = Puppet::Resource.search(@type, :host => @scope.host, :filter => @equery)
found.map {|x| x.to_resource(@scope) }.each do |item|
if existing = @scope.findresource(item.type, item.title)
diff --git a/lib/puppet/ssl/certificate_authority.rb b/lib/puppet/ssl/certificate_authority.rb
index 179acd9..231bf73 100644
--- a/lib/puppet/ssl/certificate_authority.rb
+++ b/lib/puppet/ssl/certificate_authority.rb
@@ -81,7 +81,7 @@ def autosign
store = nil
store = autosign_store(auto) if auto != true
- Puppet::SSL::CertificateRequest.indirection.search("*").each do |csr|
+ Puppet::SSL::CertificateRequest.search("*").each do |csr|
sign(csr.name) if auto == true or store.allowed?(csr.name, "127.1.1.1")
end
end
@@ -111,10 +111,10 @@ def autosign_store(file)
# Retrieve (or create, if necessary) the certificate revocation list.
def crl
unless defined?(@crl)
- unless @crl = Puppet::SSL::CertificateRevocationList.indirection.find(Puppet::SSL::CA_NAME)
+ unless @crl = Puppet::SSL::CertificateRevocationList.find(Puppet::SSL::CA_NAME)
@crl = Puppet::SSL::CertificateRevocationList.new(Puppet::SSL::CA_NAME)
@crl.generate(host.certificate.content, host.key.content)
- Puppet::SSL::CertificateRevocationList.indirection.save(@crl)
+ @crl.save
end
end
@crl
@@ -127,7 +127,7 @@ def destroy(name)
# Generate a new certificate.
def generate(name, options = {})
- raise ArgumentError, "A Certificate already exists for #{name}" if Puppet::SSL::Certificate.indirection.find(name)
+ raise ArgumentError, "A Certificate already exists for #{name}" if Puppet::SSL::Certificate.find(name)
host = Puppet::SSL::Host.new(name)
# Pass on any requested subjectAltName field.
@@ -192,7 +192,7 @@ def generate_password
# List all signed certificates.
def list
- Puppet::SSL::Certificate.indirection.search("*").collect { |c| c.name }
+ Puppet::SSL::Certificate.search("*").collect { |c| c.name }
end
# Read the next serial from the serial file, and increment the
@@ -222,14 +222,14 @@ def password?
# Print a given host's certificate as text.
def print(name)
- (cert = Puppet::SSL::Certificate.indirection.find(name)) ? cert.to_text : nil
+ (cert = Puppet::SSL::Certificate.find(name)) ? cert.to_text : nil
end
# Revoke a given certificate.
def revoke(name)
raise ArgumentError, "Cannot revoke certificates when the CRL is disabled" unless crl
- if cert = Puppet::SSL::Certificate.indirection.find(name)
+ if cert = Puppet::SSL::Certificate.find(name)
serial = cert.content.serial
elsif ! serial = inventory.serial(name)
raise ArgumentError, "Could not find a serial number for #{name}"
@@ -258,7 +258,7 @@ def sign(hostname, allow_dns_alt_names = false, self_signing_csr = nil)
issuer = csr.content
else
allow_dns_alt_names = true if hostname == Puppet[:certname].downcase
- unless csr = Puppet::SSL::CertificateRequest.indirection.find(hostname)
+ unless csr = Puppet::SSL::CertificateRequest.find(hostname)
raise ArgumentError, "Could not find certificate request for #{hostname}"
end
@@ -285,10 +285,10 @@ def sign(hostname, allow_dns_alt_names = false, self_signing_csr = nil)
# Save the now-signed cert. This should get routed correctly depending
# on the certificate type.
- Puppet::SSL::Certificate.indirection.save(cert)
+ Puppet::SSL::Certificate.save(cert)
# And remove the CSR if this wasn't self signed.
- Puppet::SSL::CertificateRequest.indirection.destroy(csr.name) unless self_signing_csr
+ Puppet::SSL::CertificateRequest.destroy(csr.name) unless self_signing_csr
cert
end
@@ -336,7 +336,7 @@ def check_internal_signing_policies(hostname, csr, allow_dns_alt_names)
# Verify a given host's certificate.
def verify(name)
- unless cert = Puppet::SSL::Certificate.indirection.find(name)
+ unless cert = Puppet::SSL::Certificate.find(name)
raise ArgumentError, "Could not find a certificate for #{name}"
end
store = OpenSSL::X509::Store.new
@@ -349,7 +349,7 @@ def verify(name)
end
def fingerprint(name, md = :MD5)
- unless cert = Puppet::SSL::Certificate.indirection.find(name) || Puppet::SSL::CertificateRequest.indirection.find(name)
+ unless cert = Puppet::SSL::Certificate.find(name) || Puppet::SSL::CertificateRequest.find(name)
raise ArgumentError, "Could not find a certificate or csr for #{name}"
end
cert.fingerprint(md)
@@ -357,6 +357,6 @@ def fingerprint(name, md = :MD5)
# List the waiting certificate requests.
def waiting?
- Puppet::SSL::CertificateRequest.indirection.search("*").collect { |r| r.name }
+ Puppet::SSL::CertificateRequest.search("*").collect { |r| r.name }
end
end
diff --git a/lib/puppet/ssl/certificate_authority/interface.rb b/lib/puppet/ssl/certificate_authority/interface.rb
index 1e4e06e..34751a8 100644
--- a/lib/puppet/ssl/certificate_authority/interface.rb
+++ b/lib/puppet/ssl/certificate_authority/interface.rb
@@ -74,13 +74,13 @@ def list(ca)
end
if verify_error
- cert = Puppet::SSL::Certificate.indirection.find(host)
+ cert = Puppet::SSL::Certificate.find(host)
certs[:invalid][host] = [cert, verify_error]
elsif signed.include?(host)
- cert = Puppet::SSL::Certificate.indirection.find(host)
+ cert = Puppet::SSL::Certificate.find(host)
certs[:signed][host] = cert
else
- req = Puppet::SSL::CertificateRequest.indirection.find(host)
+ req = Puppet::SSL::CertificateRequest.find(host)
certs[:request][host] = req
end
end
diff --git a/lib/puppet/ssl/certificate_revocation_list.rb b/lib/puppet/ssl/certificate_revocation_list.rb
index 293f4b8..04c075e 100644
--- a/lib/puppet/ssl/certificate_revocation_list.rb
+++ b/lib/puppet/ssl/certificate_revocation_list.rb
@@ -79,6 +79,6 @@ def revoke(serial, cakey, reason = OpenSSL::OCSP::REVOKED_STATUS_KEYCOMPROMISE)
@content.sign(cakey, OpenSSL::Digest::SHA1.new)
- Puppet::SSL::CertificateRevocationList.indirection.save(self)
+ self.save
end
end
diff --git a/lib/puppet/ssl/host.rb b/lib/puppet/ssl/host.rb
index d70fe32..225fe83 100644
--- a/lib/puppet/ssl/host.rb
+++ b/lib/puppet/ssl/host.rb
@@ -50,38 +50,31 @@ class << self
# Configure how our various classes interact with their various terminuses.
def self.configure_indirection(terminus, cache = nil)
- Certificate.indirection.terminus_class = terminus
- CertificateRequest.indirection.terminus_class = terminus
- CertificateRevocationList.indirection.terminus_class = terminus
+ Certificate.terminus_class = terminus
+ CertificateRequest.terminus_class = terminus
+ CertificateRevocationList.terminus_class = terminus
+ # Set, or reset, the terminus class.
host_map = {:ca => :file, :file => nil, :rest => :rest}
- if term = host_map[terminus]
- self.indirection.terminus_class = term
- else
- self.indirection.reset_terminus_class
- end
+ self.terminus_class = host_map[terminus]
if cache
- # This is weird; we don't actually cache our keys, we
- # use what would otherwise be the cache as our normal
- # terminus.
- Key.indirection.terminus_class = cache
- else
- Key.indirection.terminus_class = terminus
- end
+ # This is weird; we don't actually cache our keys, we use what would
+ # otherwise be the cache as our normal terminus.
+ Key.terminus_class = cache
- if cache
- Certificate.indirection.cache_class = cache
- CertificateRequest.indirection.cache_class = cache
- CertificateRevocationList.indirection.cache_class = cache
+ Certificate.cache_class = cache
+ CertificateRequest.cache_class = cache
+ CertificateRevocationList.cache_class = cache
else
- # Make sure we have no cache configured. puppet master
- # switches the configurations around a bit, so it's important
- # that we specify the configs for absolutely everything, every
- # time.
- Certificate.indirection.cache_class = nil
- CertificateRequest.indirection.cache_class = nil
- CertificateRevocationList.indirection.cache_class = nil
+ Key.terminus_class = terminus
+
+ # Make sure we have no cache configured. puppet master switches the
+ # configurations around a bit, so it's important that we specify the
+ # configs for absolutely everything, every time.
+ Certificate.cache_class = nil
+ CertificateRequest.cache_class = nil
+ CertificateRevocationList.cache_class = nil
end
end
@@ -135,7 +128,7 @@ def ca?
end
def key
- @key ||= Key.indirection.find(name)
+ @key ||= Key.find(name)
end
# This is the private key; we can create it from scratch
@@ -144,7 +137,7 @@ def generate_key
@key = Key.new(name)
@key.generate
begin
- Key.indirection.save(@key)
+ @key.save
rescue
@key = nil
raise
@@ -153,7 +146,7 @@ def generate_key
end
def certificate_request
- @certificate_request ||= CertificateRequest.indirection.find(name)
+ @certificate_request ||= CertificateRequest.find(name)
end
def this_csr_is_for_the_current_host
@@ -181,7 +174,7 @@ def generate_certificate_request(options = {})
@certificate_request = CertificateRequest.new(name)
@certificate_request.generate(key.content, options)
begin
- CertificateRequest.indirection.save(@certificate_request)
+ @certificate_request.save
rescue
@certificate_request = nil
raise
@@ -196,8 +189,8 @@ def certificate
# get the CA cert first, since it's required for the normal cert
# to be of any use.
- return nil unless Certificate.indirection.find("ca") unless ca?
- return nil unless @certificate = Certificate.indirection.find(name)
+ return nil unless Certificate.find("ca") unless ca?
+ return nil unless @certificate = Certificate.find(name)
unless certificate_matches_key?
raise Puppet::Error, "Retrieved certificate does not match private key; please remove certificate from server and regenerate it with the current key"
@@ -249,7 +242,7 @@ def ssl_store(purpose = OpenSSL::X509::PURPOSE_ANY)
@ssl_store.add_file(Puppet[:localcacert])
# If there's a CRL, add it to our store.
- if crl = Puppet::SSL::CertificateRevocationList.indirection.find(CA_NAME)
+ if crl = Puppet::SSL::CertificateRevocationList.find(CA_NAME)
@ssl_store.flags = OpenSSL::X509::V_FLAG_CRL_CHECK_ALL|OpenSSL::X509::V_FLAG_CRL_CHECK if Puppet.settings[:certificate_revocation]
@ssl_store.add_crl(crl.content)
end
@@ -259,7 +252,7 @@ def ssl_store(purpose = OpenSSL::X509::PURPOSE_ANY)
end
def to_pson(*args)
- my_cert = Puppet::SSL::Certificate.indirection.find(name)
+ my_cert = Puppet::SSL::Certificate.find(name)
pson_hash = { :name => name }
my_state = state
@@ -314,7 +307,7 @@ def wait_for_cert(time)
end
def state
- my_cert = Puppet::SSL::Certificate.indirection.find(name)
+ my_cert = Puppet::SSL::Certificate.find(name)
if certificate_request
return 'requested'
end
diff --git a/lib/puppet/ssl/inventory.rb b/lib/puppet/ssl/inventory.rb
index c210fdc..b34cdc1 100644
--- a/lib/puppet/ssl/inventory.rb
+++ b/lib/puppet/ssl/inventory.rb
@@ -36,7 +36,7 @@ def rebuild
f.print "# Inventory of signed certificates\n# SERIAL NOT_BEFORE NOT_AFTER SUBJECT\n"
end
- Puppet::SSL::Certificate.indirection.search("*").each { |cert| add(cert) }
+ Puppet::SSL::Certificate.search("*").each { |cert| add(cert) }
end
# Find the serial number for a given certificate.
diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb
index 20c774a..ae0cc86 100644
--- a/lib/puppet/type/file.rb
+++ b/lib/puppet/type/file.rb
@@ -593,7 +593,7 @@ def recurse_remote(children)
end
def perform_recursion(path)
- Puppet::FileServing::Metadata.indirection.search(
+ Puppet::FileServing::Metadata.search(
path,
:links => self[:links],
:recurse => (self[:recurse] == :remote ? true : self[:recurse]),
diff --git a/lib/puppet/type/file/source.rb b/lib/puppet/type/file/source.rb
index 9375550..2ff8a68 100755
--- a/lib/puppet/type/file/source.rb
+++ b/lib/puppet/type/file/source.rb
@@ -114,7 +114,7 @@ def content
return @content if @content
raise Puppet::DevError, "No source for content was stored with the metadata" unless metadata.source
- unless tmp = Puppet::FileServing::Content.indirection.find(metadata.source)
+ unless tmp = Puppet::FileServing::Content.find(metadata.source)
fail "Could not find any content at %s" % metadata.source
end
@content = tmp.content
@@ -163,7 +163,7 @@ def metadata
return nil unless value
value.each do |source|
begin
- if data = Puppet::FileServing::Metadata.indirection.find(source)
+ if data = Puppet::FileServing::Metadata.find(source)
@metadata = data
@metadata.source = source
break
diff --git a/spec/integration/configurer_spec.rb b/spec/integration/configurer_spec.rb
index f5d8bce..dc35c26 100755
--- a/spec/integration/configurer_spec.rb
+++ b/spec/integration/configurer_spec.rb
@@ -33,7 +33,7 @@
it "should send a transaction report with valid data" do
@configurer.stubs(:save_last_run_summary)
- Puppet::Transaction::Report.indirection.expects(:save).with do |report, x|
+ Puppet::Transaction::Report.expects(:save).with do |report, x|
report.time.class == Time and report.logs.length > 0
end
@@ -44,7 +44,7 @@
it "should save a correct last run summary" do
report = Puppet::Transaction::Report.new("apply")
- Puppet::Transaction::Report.indirection.stubs(:save)
+ Puppet::Transaction::Report.stubs(:save)
Puppet[:lastrunfile] = tmpfile("lastrunfile")
Puppet[:report] = true
diff --git a/spec/integration/defaults_spec.rb b/spec/integration/defaults_spec.rb
index 02dbf96..f4589fc 100755
--- a/spec/integration/defaults_spec.rb
+++ b/spec/integration/defaults_spec.rb
@@ -148,40 +148,40 @@
describe "when enabling storeconfigs" do
before do
- Puppet::Resource::Catalog.indirection.stubs(:cache_class=)
- Puppet::Node::Facts.indirection.stubs(:cache_class=)
- Puppet::Node.indirection.stubs(:cache_class=)
+ Puppet::Resource::Catalog.stubs(:cache_class=)
+ Puppet::Node::Facts.stubs(:cache_class=)
+ Puppet::Node.stubs(:cache_class=)
Puppet.features.stubs(:rails?).returns true
end
it "should set the Catalog cache class to :store_configs" do
- Puppet::Resource::Catalog.indirection.expects(:cache_class=).with(:store_configs)
+ Puppet::Resource::Catalog.expects(:cache_class=).with(:store_configs)
Puppet.settings[:storeconfigs] = true
end
it "should not set the Catalog cache class to :store_configs if asynchronous storeconfigs is enabled" do
- Puppet::Resource::Catalog.indirection.expects(:cache_class=).with(:store_configs).never
+ Puppet::Resource::Catalog.expects(:cache_class=).with(:store_configs).never
Puppet.settings.expects(:value).with(:async_storeconfigs).returns true
Puppet.settings[:storeconfigs] = true
end
it "should set the Facts cache class to :store_configs" do
- Puppet::Node::Facts.indirection.expects(:cache_class=).with(:store_configs)
+ Puppet::Node::Facts.expects(:cache_class=).with(:store_configs)
Puppet.settings[:storeconfigs] = true
end
it "should set the Node cache class to :store_configs" do
- Puppet::Node.indirection.expects(:cache_class=).with(:store_configs)
+ Puppet::Node.expects(:cache_class=).with(:store_configs)
Puppet.settings[:storeconfigs] = true
end
end
describe "when enabling asynchronous storeconfigs" do
before do
- Puppet::Resource::Catalog.indirection.stubs(:cache_class=)
- Puppet::Node::Facts.indirection.stubs(:cache_class=)
- Puppet::Node.indirection.stubs(:cache_class=)
+ Puppet::Resource::Catalog.stubs(:cache_class=)
+ Puppet::Node::Facts.stubs(:cache_class=)
+ Puppet::Node.stubs(:cache_class=)
Puppet.features.stubs(:rails?).returns true
end
@@ -191,26 +191,26 @@
end
it "should set the Catalog cache class to :queue" do
- Puppet::Resource::Catalog.indirection.expects(:cache_class=).with(:queue)
+ Puppet::Resource::Catalog.expects(:cache_class=).with(:queue)
Puppet.settings[:async_storeconfigs] = true
end
it "should set the Facts cache class to :store_configs" do
- Puppet::Node::Facts.indirection.expects(:cache_class=).with(:store_configs)
+ Puppet::Node::Facts.expects(:cache_class=).with(:store_configs)
Puppet.settings[:storeconfigs] = true
end
it "should set the Node cache class to :store_configs" do
- Puppet::Node.indirection.expects(:cache_class=).with(:store_configs)
+ Puppet::Node.expects(:cache_class=).with(:store_configs)
Puppet.settings[:storeconfigs] = true
end
end
describe "when enabling thin storeconfigs" do
before do
- Puppet::Resource::Catalog.indirection.stubs(:cache_class=)
- Puppet::Node::Facts.indirection.stubs(:cache_class=)
- Puppet::Node.indirection.stubs(:cache_class=)
+ Puppet::Resource::Catalog.stubs(:cache_class=)
+ Puppet::Node::Facts.stubs(:cache_class=)
+ Puppet::Node.stubs(:cache_class=)
Puppet.features.stubs(:rails?).returns true
end
diff --git a/spec/integration/indirector/catalog/compiler_spec.rb b/spec/integration/indirector/catalog/compiler_spec.rb
index f51a3f2..9d29d48 100755
--- a/spec/integration/indirector/catalog/compiler_spec.rb
+++ b/spec/integration/indirector/catalog/compiler_spec.rb
@@ -3,7 +3,7 @@
require 'puppet/resource/catalog'
-Puppet::Resource::Catalog.indirection.terminus(:compiler)
+Puppet::Resource::Catalog.terminus(:compiler)
describe Puppet::Resource::Catalog::Compiler do
before do
@@ -17,48 +17,48 @@
it "should remove virtual resources when filtering" do
@one.virtual = true
- Puppet::Resource::Catalog.indirection.terminus.filter(@catalog).resource_refs.should == [ @two.ref ]
+ Puppet::Resource::Catalog.terminus.filter(@catalog).resource_refs.should == [ @two.ref ]
end
it "should not remove exported resources when filtering" do
@one.exported = true
- Puppet::Resource::Catalog.indirection.terminus.filter(@catalog).resource_refs.sort.should == [ @one.ref, @two.ref ]
+ Puppet::Resource::Catalog.terminus.filter(@catalog).resource_refs.sort.should == [ @one.ref, @two.ref ]
end
it "should remove virtual exported resources when filtering" do
@one.exported = true
@one.virtual = true
- Puppet::Resource::Catalog.indirection.terminus.filter(@catalog).resource_refs.should == [ @two.ref ]
+ Puppet::Resource::Catalog.terminus.filter(@catalog).resource_refs.should == [ @two.ref ]
end
it "should filter out virtual resources when finding a catalog" do
@one.virtual = true
request = stub 'request', :name => "mynode"
- Puppet::Resource::Catalog.indirection.terminus.stubs(:extract_facts_from_request)
- Puppet::Resource::Catalog.indirection.terminus.stubs(:node_from_request)
- Puppet::Resource::Catalog.indirection.terminus.stubs(:compile).returns(@catalog)
+ Puppet::Resource::Catalog.terminus.stubs(:extract_facts_from_request)
+ Puppet::Resource::Catalog.terminus.stubs(:node_from_request)
+ Puppet::Resource::Catalog.terminus.stubs(:compile).returns(@catalog)
- Puppet::Resource::Catalog.indirection.find(request).resource_refs.should == [ @two.ref ]
+ Puppet::Resource::Catalog.find(request).resource_refs.should == [ @two.ref ]
end
it "should not filter out exported resources when finding a catalog" do
@one.exported = true
request = stub 'request', :name => "mynode"
- Puppet::Resource::Catalog.indirection.terminus.stubs(:extract_facts_from_request)
- Puppet::Resource::Catalog.indirection.terminus.stubs(:node_from_request)
- Puppet::Resource::Catalog.indirection.terminus.stubs(:compile).returns(@catalog)
+ Puppet::Resource::Catalog.terminus.stubs(:extract_facts_from_request)
+ Puppet::Resource::Catalog.terminus.stubs(:node_from_request)
+ Puppet::Resource::Catalog.terminus.stubs(:compile).returns(@catalog)
- Puppet::Resource::Catalog.indirection.find(request).resource_refs.sort.should == [ @one.ref, @two.ref ]
+ Puppet::Resource::Catalog.find(request).resource_refs.sort.should == [ @one.ref, @two.ref ]
end
it "should filter out virtual exported resources when finding a catalog" do
@one.exported = true
@one.virtual = true
request = stub 'request', :name => "mynode"
- Puppet::Resource::Catalog.indirection.terminus.stubs(:extract_facts_from_request)
- Puppet::Resource::Catalog.indirection.terminus.stubs(:node_from_request)
- Puppet::Resource::Catalog.indirection.terminus.stubs(:compile).returns(@catalog)
+ Puppet::Resource::Catalog.terminus.stubs(:extract_facts_from_request)
+ Puppet::Resource::Catalog.terminus.stubs(:node_from_request)
+ Puppet::Resource::Catalog.terminus.stubs(:compile).returns(@catalog)
- Puppet::Resource::Catalog.indirection.find(request).resource_refs.should == [ @two.ref ]
+ Puppet::Resource::Catalog.find(request).resource_refs.should == [ @two.ref ]
end
end
diff --git a/spec/integration/indirector/catalog/queue_spec.rb b/spec/integration/indirector/catalog/queue_spec.rb
index 940c8ba..3725177 100755
--- a/spec/integration/indirector/catalog/queue_spec.rb
+++ b/spec/integration/indirector/catalog/queue_spec.rb
@@ -5,7 +5,7 @@
describe "Puppet::Resource::Catalog::Queue", :if => Puppet.features.pson? do
before do
- Puppet::Resource::Catalog.indirection.terminus(:queue)
+ Puppet::Resource::Catalog.terminus(:queue)
@catalog = Puppet::Resource::Catalog.new
@one = Puppet::Resource.new(:file, "/one")
@@ -20,7 +20,7 @@
after { Puppet.settings.clear }
it "should render catalogs to pson and publish them via the queue client when catalogs are saved" do
- terminus = Puppet::Resource::Catalog.indirection.terminus(:queue)
+ terminus = Puppet::Resource::Catalog.terminus(:queue)
client = mock 'client'
terminus.stubs(:client).returns client
diff --git a/spec/integration/indirector/file_content/file_server_spec.rb b/spec/integration/indirector/file_content/file_server_spec.rb
index e210cec..407c165 100755
--- a/spec/integration/indirector/file_content/file_server_spec.rb
+++ b/spec/integration/indirector/file_content/file_server_spec.rb
@@ -31,7 +31,7 @@
env = Puppet::Node::Environment.new("foo")
env.stubs(:modulepath).returns [path]
- result = Puppet::FileServing::Content.indirection.search("plugins", :environment => "foo", :recurse => true)
+ result = Puppet::FileServing::Content.search("plugins", :environment => "foo", :recurse => true)
result.should_not be_nil
result.length.should == 2
@@ -51,7 +51,7 @@
Puppet.settings[:modulepath] = path
- result = Puppet::FileServing::Content.indirection.find("modules/mymod/myfile")
+ result = Puppet::FileServing::Content.find("modules/mymod/myfile")
result.should_not be_nil
result.should be_instance_of(Puppet::FileServing::Content)
@@ -81,7 +81,7 @@
path = File.join(@path, "myfile")
- result = Puppet::FileServing::Content.indirection.find("one/myfile", :environment => "foo", :node => "mynode")
+ result = Puppet::FileServing::Content.find("one/myfile", :environment => "foo", :node => "mynode")
result.should_not be_nil
result.should be_instance_of(Puppet::FileServing::Content)
diff --git a/spec/integration/indirector/node/ldap_spec.rb b/spec/integration/indirector/node/ldap_spec.rb
index 7e53141..f43f493 100755
--- a/spec/integration/indirector/node/ldap_spec.rb
+++ b/spec/integration/indirector/node/ldap_spec.rb
@@ -5,10 +5,10 @@
describe Puppet::Node::Ldap do
it "should use a restrictive filter when searching for nodes in a class" do
- ldap = Puppet::Node.indirection.terminus(:ldap)
+ ldap = Puppet::Node.terminus(:ldap)
Puppet::Node.indirection.stubs(:terminus).returns ldap
ldap.expects(:ldapsearch).with("(&(objectclass=puppetClient)(puppetclass=foo))")
- Puppet::Node.indirection.search "eh", :class => "foo"
+ Puppet::Node.search "eh", :class => "foo"
end
end
diff --git a/spec/integration/network/server/webrick_spec.rb b/spec/integration/network/server/webrick_spec.rb
index 7365462..b8dfc02 100755
--- a/spec/integration/network/server/webrick_spec.rb
+++ b/spec/integration/network/server/webrick_spec.rb
@@ -23,7 +23,7 @@
Puppet::SSL::Host.ca_location = :local
ca = Puppet::SSL::CertificateAuthority.new
- ca.generate(Puppet[:certname]) unless Puppet::SSL::Certificate.indirection.find(Puppet[:certname])
+ ca.generate(Puppet[:certname]) unless Puppet::SSL::Certificate.find(Puppet[:certname])
end
after do
diff --git a/spec/integration/node/facts_spec.rb b/spec/integration/node/facts_spec.rb
index 78bdabc..129dd14 100755
--- a/spec/integration/node/facts_spec.rb
+++ b/spec/integration/node/facts_spec.rb
@@ -6,26 +6,25 @@
it "should expire any cached node instances when it is saved" do
Puppet::Node::Facts.indirection.stubs(:terminus_class).returns :yaml
- Puppet::Node::Facts.indirection.terminus(:yaml).should equal(Puppet::Node::Facts.indirection.terminus(:yaml))
- terminus = Puppet::Node::Facts.indirection.terminus(:yaml)
+ Puppet::Node::Facts.terminus(:yaml).should equal(Puppet::Node::Facts.terminus(:yaml))
+ terminus = Puppet::Node::Facts.terminus(:yaml)
terminus.stubs :save
- Puppet::Node.indirection.expects(:expire).with("me")
+ Puppet::Node.expects(:expire).with("me")
- facts = Puppet::Node::Facts.new("me")
- Puppet::Node::Facts.indirection.save(facts)
+ Puppet::Node::Facts.new("me").save
end
it "should be able to delegate to the :yaml terminus" do
Puppet::Node::Facts.indirection.stubs(:terminus_class).returns :yaml
# Load now, before we stub the exists? method.
- terminus = Puppet::Node::Facts.indirection.terminus(:yaml)
+ terminus = Puppet::Node::Facts.terminus(:yaml)
terminus.expects(:path).with("me").returns "/my/yaml/file"
FileTest.expects(:exist?).with("/my/yaml/file").returns false
- Puppet::Node::Facts.indirection.find("me").should be_nil
+ Puppet::Node::Facts.find("me").should be_nil
end
it "should be able to delegate to the :facter terminus" do
@@ -35,7 +34,7 @@
facts = Puppet::Node::Facts.new("me")
Puppet::Node::Facts.expects(:new).with("me", "facter_hash").returns facts
- Puppet::Node::Facts.indirection.find("me").should equal(facts)
+ Puppet::Node::Facts.find("me").should equal(facts)
end
end
end
diff --git a/spec/integration/node_spec.rb b/spec/integration/node_spec.rb
index 5abb880..884c58e 100755
--- a/spec/integration/node_spec.rb
+++ b/spec/integration/node_spec.rb
@@ -6,8 +6,8 @@
describe Puppet::Node do
describe "when delegating indirection calls" do
before do
- Puppet::Node.indirection.reset_terminus_class
- Puppet::Node.indirection.cache_class = nil
+ Puppet::Node.terminus_class = nil
+ Puppet::Node.cache_class = nil
@name = "me"
@node = Puppet::Node.new(@name)
@@ -17,75 +17,75 @@
Puppet::Node.indirection.stubs(:terminus_class).returns :exec
# Load now so we can stub
- terminus = Puppet::Node.indirection.terminus(:exec)
+ terminus = Puppet::Node.terminus(:exec)
terminus.expects(:query).with(@name).returns "myresults"
terminus.expects(:translate).with(@name, "myresults").returns "translated_results"
terminus.expects(:create_node).with(@name, "translated_results").returns @node
- Puppet::Node.indirection.find(@name).should equal(@node)
+ Puppet::Node.find(@name).should equal(@node)
end
it "should be able to use the yaml terminus" do
Puppet::Node.indirection.stubs(:terminus_class).returns :yaml
# Load now, before we stub the exists? method.
- terminus = Puppet::Node.indirection.terminus(:yaml)
+ terminus = Puppet::Node.terminus(:yaml)
terminus.expects(:path).with(@name).returns "/my/yaml/file"
FileTest.expects(:exist?).with("/my/yaml/file").returns false
- Puppet::Node.indirection.find(@name).should be_nil
+ Puppet::Node.find(@name).should be_nil
end
it "should have an ldap terminus" do
- Puppet::Node.indirection.terminus(:ldap).should_not be_nil
+ Puppet::Node.terminus(:ldap).should_not be_nil
end
it "should be able to use the plain terminus", :'fails_on_ruby_1.9.2' => true do
Puppet::Node.indirection.stubs(:terminus_class).returns :plain
# Load now, before we stub the exists? method.
- Puppet::Node.indirection.terminus(:plain)
+ Puppet::Node.terminus(:plain)
Puppet::Node.expects(:new).with(@name).returns @node
- Puppet::Node.indirection.find(@name).should equal(@node)
+ Puppet::Node.find(@name).should equal(@node)
end
describe "and using the memory terminus" do
before do
@name = "me"
- @old_terminus = Puppet::Node.indirection.terminus_class
- @terminus = Puppet::Node.indirection.terminus(:memory)
+ @old_terminus = Puppet::Node.terminus_class
+ @terminus = Puppet::Node.terminus(:memory)
Puppet::Node.indirection.stubs(:terminus).returns @terminus
@node = Puppet::Node.new(@name)
end
it "should find no nodes by default" do
- Puppet::Node.indirection.find(@name).should be_nil
+ Puppet::Node.find(@name).should be_nil
end
it "should be able to find nodes that were previously saved" do
- Puppet::Node.indirection.save(@node)
- Puppet::Node.indirection.find(@name).should equal(@node)
+ @node.save
+ Puppet::Node.find(@name).should equal(@node)
end
it "should replace existing saved nodes when a new node with the same name is saved" do
- Puppet::Node.indirection.save(@node)
+ @node.save
two = Puppet::Node.new(@name)
- Puppet::Node.indirection.save(two)
- Puppet::Node.indirection.find(@name).should equal(two)
+ two.save
+ Puppet::Node.find(@name).should equal(two)
end
it "should be able to remove previously saved nodes" do
- Puppet::Node.indirection.save(@node)
- Puppet::Node.indirection.destroy(@node.name)
- Puppet::Node.indirection.find(@name).should be_nil
+ @node.save
+ Puppet::Node.destroy(@node.name)
+ Puppet::Node.find(@name).should be_nil
end
it "should fail when asked to destroy a node that does not exist" do
- proc { Puppet::Node.indirection.destroy(@node) }.should raise_error(ArgumentError)
+ proc { Puppet::Node.destroy(@node) }.should raise_error(ArgumentError)
end
end
end
diff --git a/spec/integration/resource/catalog_spec.rb b/spec/integration/resource/catalog_spec.rb
index df310b1..841344e 100755
--- a/spec/integration/resource/catalog_spec.rb
+++ b/spec/integration/resource/catalog_spec.rb
@@ -20,26 +20,26 @@
Puppet::Resource::Catalog.indirection.stubs(:terminus_class).returns :yaml
# Load now, before we stub the exists? method.
- terminus = Puppet::Resource::Catalog.indirection.terminus(:yaml)
+ terminus = Puppet::Resource::Catalog.terminus(:yaml)
terminus.expects(:path).with("me").returns "/my/yaml/file"
FileTest.expects(:exist?).with("/my/yaml/file").returns false
- Puppet::Resource::Catalog.indirection.find("me").should be_nil
+ Puppet::Resource::Catalog.find("me").should be_nil
end
it "should be able to delegate to the :compiler terminus" do
Puppet::Resource::Catalog.indirection.stubs(:terminus_class).returns :compiler
# Load now, before we stub the exists? method.
- compiler = Puppet::Resource::Catalog.indirection.terminus(:compiler)
+ compiler = Puppet::Resource::Catalog.terminus(:compiler)
node = mock 'node'
node.stub_everything
- Puppet::Node.indirection.expects(:find).returns(node)
+ Puppet::Node.expects(:find).returns(node)
compiler.expects(:compile).with(node).returns nil
- Puppet::Resource::Catalog.indirection.find("me").should be_nil
+ Puppet::Resource::Catalog.find("me").should be_nil
end
it "should pass provided node information directly to the terminus" do
@@ -49,7 +49,7 @@
node = mock 'node'
terminus.expects(:find).with { |request| request.options[:use_node] == node }
- Puppet::Resource::Catalog.indirection.find("me", :use_node => node)
+ Puppet::Resource::Catalog.find("me", :use_node => node)
end
end
end
diff --git a/spec/integration/ssl/certificate_authority_spec.rb b/spec/integration/ssl/certificate_authority_spec.rb
index a479244..aecc7f3 100755
--- a/spec/integration/ssl/certificate_authority_spec.rb
+++ b/spec/integration/ssl/certificate_authority_spec.rb
@@ -39,7 +39,7 @@
it "should be able to generate a new host certificate" do
@ca.generate("newhost")
- Puppet::SSL::Certificate.indirection.find("newhost").should be_instance_of(Puppet::SSL::Certificate)
+ Puppet::SSL::Certificate.find("newhost").should be_instance_of(Puppet::SSL::Certificate)
end
it "should be able to revoke a host certificate" do
@@ -86,7 +86,7 @@
it "should save the signed certificate" do
@ca.sign("luke.madstop.com")
- Puppet::SSL::Certificate.indirection.find("luke.madstop.com").should be_instance_of(Puppet::SSL::Certificate)
+ Puppet::SSL::Certificate.find("luke.madstop.com").should be_instance_of(Puppet::SSL::Certificate)
end
it "should be able to sign multiple certificates" do
@@ -99,15 +99,15 @@
@ca.sign("luke.madstop.com")
@ca.sign("other.madstop.com")
- Puppet::SSL::Certificate.indirection.find("other.madstop.com").should be_instance_of(Puppet::SSL::Certificate)
- Puppet::SSL::Certificate.indirection.find("luke.madstop.com").should be_instance_of(Puppet::SSL::Certificate)
+ Puppet::SSL::Certificate.find("other.madstop.com").should be_instance_of(Puppet::SSL::Certificate)
+ Puppet::SSL::Certificate.find("luke.madstop.com").should be_instance_of(Puppet::SSL::Certificate)
end
it "should save the signed certificate to the :signeddir" do
@ca.sign("luke.madstop.com")
client_cert = File.join(Puppet[:signeddir], "luke.madstop.com.pem")
- File.read(client_cert).should == Puppet::SSL::Certificate.indirection.find("luke.madstop.com").content.to_s
+ File.read(client_cert).should == Puppet::SSL::Certificate.find("luke.madstop.com").content.to_s
end
it "should save valid certificates" do
diff --git a/spec/integration/ssl/certificate_request_spec.rb b/spec/integration/ssl/certificate_request_spec.rb
index f634636..1936c95 100755
--- a/spec/integration/ssl/certificate_request_spec.rb
+++ b/spec/integration/ssl/certificate_request_spec.rb
@@ -35,20 +35,21 @@
end
it "should be able to save CSRs" do
- Puppet::SSL::CertificateRequest.indirection.save(@csr)
+ @csr.save
end
it "should be able to find saved certificate requests via the Indirector" do
@csr.generate(@key)
- Puppet::SSL::CertificateRequest.indirection.save(@csr)
+ @csr.save
- Puppet::SSL::CertificateRequest.indirection.find("luke.madstop.com").should be_instance_of(Puppet::SSL::CertificateRequest)
+ Puppet::SSL::CertificateRequest.find("luke.madstop.com").
+ should be_instance_of(Puppet::SSL::CertificateRequest)
end
it "should save the completely CSR when saving" do
@csr.generate(@key)
- Puppet::SSL::CertificateRequest.indirection.save(@csr)
+ @csr.save
- Puppet::SSL::CertificateRequest.indirection.find("luke.madstop.com").content.to_s.should == @csr.content.to_s
+ Puppet::SSL::CertificateRequest.find("luke.madstop.com").content.to_s.should == @csr.content.to_s
end
end
diff --git a/spec/integration/ssl/host_spec.rb b/spec/integration/ssl/host_spec.rb
index 18e80be..462fcc9 100755
--- a/spec/integration/ssl/host_spec.rb
+++ b/spec/integration/ssl/host_spec.rb
@@ -38,7 +38,7 @@
it "should save the key such that the Indirector can find it" do
@host.generate_key
- Puppet::SSL::Key.indirection.find(@host.name).content.to_s.should == @host.key.to_s
+ Puppet::SSL::Key.find(@host.name).content.to_s.should == @host.key.to_s
end
it "should save the private key into the :privatekeydir" do
@@ -55,7 +55,7 @@
it "should save the certificate request such that the Indirector can find it" do
@host.generate_certificate_request
- Puppet::SSL::CertificateRequest.indirection.find(@host.name).content.to_s.should == @host.certificate_request.to_s
+ Puppet::SSL::CertificateRequest.find(@host.name).content.to_s.should == @host.certificate_request.to_s
end
it "should save the private certificate request into the :privatekeydir" do
diff --git a/spec/integration/transaction/report_spec.rb b/spec/integration/transaction/report_spec.rb
index 8c581cc..5081bec 100755
--- a/spec/integration/transaction/report_spec.rb
+++ b/spec/integration/transaction/report_spec.rb
@@ -8,9 +8,9 @@
end
it "should be able to delegate to the :processor terminus" do
- Puppet::Transaction::Report.indirection.stubs(:terminus_class).returns :processor
+ Puppet::Transaction::Report.stubs(:terminus_class).returns :processor
- terminus = Puppet::Transaction::Report.indirection.terminus(:processor)
+ terminus = Puppet::Transaction::Report.terminus(:processor)
Facter.stubs(:value).returns "host.domain.com"
@@ -18,7 +18,7 @@
terminus.expects(:process).with(report)
- Puppet::Transaction::Report.indirection.save(report)
+ report.save
end
end
end
diff --git a/spec/unit/application/agent_spec.rb b/spec/unit/application/agent_spec.rb
index 6d31ec3..64a09b8 100755
--- a/spec/unit/application/agent_spec.rb
+++ b/spec/unit/application/agent_spec.rb
@@ -19,9 +19,9 @@
@puppetd.preinit
Puppet::Util::Log.stubs(:newdestination)
- Puppet::Node.indirection.stubs(:terminus_class=)
- Puppet::Node.indirection.stubs(:cache_class=)
- Puppet::Node::Facts.indirection.stubs(:terminus_class=)
+ Puppet::Node.stubs(:terminus_class=)
+ Puppet::Node.stubs(:cache_class=)
+ Puppet::Node::Facts.stubs(:terminus_class=)
end
it "should operate in agent run_mode" do
@@ -173,11 +173,11 @@
FileTest.stubs(:exists?).returns(true)
Puppet[:libdir] = "/dev/null/lib"
Puppet::SSL::Host.stubs(:ca_location=)
- Puppet::Transaction::Report.indirection.stubs(:terminus_class=)
- Puppet::Transaction::Report.indirection.stubs(:cache_class=)
- Puppet::Resource::Catalog.indirection.stubs(:terminus_class=)
- Puppet::Resource::Catalog.indirection.stubs(:cache_class=)
- Puppet::Node::Facts.indirection.stubs(:terminus_class=)
+ Puppet::Transaction::Report.stubs(:terminus_class=)
+ Puppet::Transaction::Report.stubs(:cache_class=)
+ Puppet::Resource::Catalog.stubs(:terminus_class=)
+ Puppet::Resource::Catalog.stubs(:cache_class=)
+ Puppet::Node::Facts.stubs(:terminus_class=)
@host = stub_everything 'host'
Puppet::SSL::Host.stubs(:new).returns(@host)
Puppet.stubs(:settraps)
@@ -295,13 +295,13 @@
end
it "should tell the report handler to use REST" do
- Puppet::Transaction::Report.indirection.expects(:terminus_class=).with(:rest)
+ Puppet::Transaction::Report.expects(:terminus_class=).with(:rest)
@puppetd.setup
end
it "should tell the report handler to cache locally as yaml" do
- Puppet::Transaction::Report.indirection.expects(:cache_class=).with(:yaml)
+ Puppet::Transaction::Report.expects(:cache_class=).with(:yaml)
@puppetd.setup
end
@@ -313,7 +313,7 @@
end
it "should tell the catalog handler to use cache" do
- Puppet::Resource::Catalog.indirection.expects(:cache_class=).with(:yaml)
+ Puppet::Resource::Catalog.expects(:cache_class=).with(:yaml)
@puppetd.setup
end
diff --git a/spec/unit/application/apply_spec.rb b/spec/unit/application/apply_spec.rb
index b12c4fa..245cbe3 100755
--- a/spec/unit/application/apply_spec.rb
+++ b/spec/unit/application/apply_spec.rb
@@ -13,11 +13,11 @@
end
after :each do
- Puppet::Node::Facts.indirection.reset_terminus_class
- Puppet::Node::Facts.indirection.cache_class = nil
+ Puppet::Node::Facts.terminus_class = nil
+ Puppet::Node::Facts.cache_class = nil
- Puppet::Node.indirection.reset_terminus_class
- Puppet::Node.indirection.cache_class = nil
+ Puppet::Node.terminus_class = nil
+ Puppet::Node.cache_class = nil
end
[:debug,:loadclasses,:verbose,:use_nodes,:detailed_exitcodes].each do |option|
@@ -61,7 +61,7 @@
Puppet.stubs(:parse_config)
Puppet::FileBucket::Dipper.stubs(:new)
STDIN.stubs(:read)
- Puppet::Transaction::Report.indirection.stubs(:cache_class=)
+ Puppet::Transaction::Report.stubs(:cache_class=)
@apply.options.stubs(:[]).with(any_parameters)
end
@@ -102,7 +102,7 @@
end
it "should tell the report handler to cache locally as yaml" do
- Puppet::Transaction::Report.indirection.expects(:cache_class=).with(:yaml)
+ Puppet::Transaction::Report.expects(:cache_class=).with(:yaml)
@apply.setup
end
@@ -130,21 +130,21 @@
Puppet[:prerun_command] = ''
Puppet[:postrun_command] = ''
- Puppet::Node::Facts.indirection.terminus_class = :memory
- Puppet::Node::Facts.indirection.cache_class = :memory
- Puppet::Node.indirection.terminus_class = :memory
- Puppet::Node.indirection.cache_class = :memory
+ Puppet::Node::Facts.terminus_class = :memory
+ Puppet::Node::Facts.cache_class = :memory
+ Puppet::Node.terminus_class = :memory
+ Puppet::Node.cache_class = :memory
@facts = Puppet::Node::Facts.new(Puppet[:node_name_value])
- Puppet::Node::Facts.indirection.save(@facts)
+ @facts.save
@node = Puppet::Node.new(Puppet[:node_name_value])
- Puppet::Node.indirection.save(@node)
+ @node.save
@catalog = Puppet::Resource::Catalog.new
@catalog.stubs(:to_ral).returns(@catalog)
- Puppet::Resource::Catalog.indirection.stubs(:find).returns(@catalog)
+ Puppet::Resource::Catalog.stubs(:find).returns(@catalog)
STDIN.stubs(:read)
@@ -201,10 +201,10 @@
it "should set the facts name based on the node_name_fact" do
@facts = Puppet::Node::Facts.new(Puppet[:node_name_value], 'my_name_fact' => 'other_node_name')
- Puppet::Node::Facts.indirection.save(@facts)
+ @facts.save
node = Puppet::Node.new('other_node_name')
- Puppet::Node.indirection.save(node)
+ node.save
Puppet[:node_name_fact] = 'my_name_fact'
@@ -215,9 +215,9 @@
it "should set the node_name_value based on the node_name_fact" do
facts = Puppet::Node::Facts.new(Puppet[:node_name_value], 'my_name_fact' => 'other_node_name')
- Puppet::Node::Facts.indirection.save(facts)
+ facts.save
node = Puppet::Node.new('other_node_name')
- Puppet::Node.indirection.save(node)
+ node.save
Puppet[:node_name_fact] = 'my_name_fact'
expect { @apply.main }.to exit_with 0
@@ -226,13 +226,13 @@
end
it "should raise an error if we can't find the facts" do
- Puppet::Node::Facts.indirection.expects(:find).returns(nil)
+ Puppet::Node::Facts.expects(:find).returns(nil)
lambda { @apply.main }.should raise_error
end
it "should raise an error if we can't find the node" do
- Puppet::Node.indirection.expects(:find).returns(nil)
+ Puppet::Node.expects(:find).returns(nil)
lambda { @apply.main }.should raise_error
end
@@ -257,7 +257,7 @@
end
it "should compile the catalog" do
- Puppet::Resource::Catalog.indirection.expects(:find).returns(@catalog)
+ Puppet::Resource::Catalog.expects(:find).returns(@catalog)
expect { @apply.main }.to exit_with 0
end
diff --git a/spec/unit/application/device_spec.rb b/spec/unit/application/device_spec.rb
index 43048fb..464c31a 100755
--- a/spec/unit/application/device_spec.rb
+++ b/spec/unit/application/device_spec.rb
@@ -14,9 +14,9 @@
@device.preinit
Puppet::Util::Log.stubs(:newdestination)
- Puppet::Node.indirection.stubs(:terminus_class=)
- Puppet::Node.indirection.stubs(:cache_class=)
- Puppet::Node::Facts.indirection.stubs(:terminus_class=)
+ Puppet::Node.stubs(:terminus_class=)
+ Puppet::Node.stubs(:cache_class=)
+ Puppet::Node::Facts.stubs(:terminus_class=)
end
it "should operate in agent run_mode" do
@@ -122,10 +122,10 @@
FileTest.stubs(:exists?).returns(true)
Puppet[:libdir] = "/dev/null/lib"
Puppet::SSL::Host.stubs(:ca_location=)
- Puppet::Transaction::Report.indirection.stubs(:terminus_class=)
- Puppet::Resource::Catalog.indirection.stubs(:terminus_class=)
- Puppet::Resource::Catalog.indirection.stubs(:cache_class=)
- Puppet::Node::Facts.indirection.stubs(:terminus_class=)
+ Puppet::Transaction::Report.stubs(:terminus_class=)
+ Puppet::Resource::Catalog.stubs(:terminus_class=)
+ Puppet::Resource::Catalog.stubs(:cache_class=)
+ Puppet::Node::Facts.stubs(:terminus_class=)
@host = stub_everything 'host'
Puppet::SSL::Host.stubs(:new).returns(@host)
Puppet.stubs(:settraps)
@@ -196,7 +196,7 @@
end
it "should tell the report handler to use REST" do
- Puppet::Transaction::Report.indirection.expects(:terminus_class=).with(:rest)
+ Puppet::Transaction::Report.expects(:terminus_class=).with(:rest)
@device.setup
end
@@ -208,7 +208,7 @@
end
it "should tell the catalog handler to use cache" do
- Puppet::Resource::Catalog.indirection.expects(:cache_class=).with(:yaml)
+ Puppet::Resource::Catalog.expects(:cache_class=).with(:yaml)
@device.setup
end
diff --git a/spec/unit/application/facts_spec.rb b/spec/unit/application/facts_spec.rb
index 7a7c365..cabcffd 100755
--- a/spec/unit/application/facts_spec.rb
+++ b/spec/unit/application/facts_spec.rb
@@ -16,7 +16,7 @@
end
it "should return facts if a key is given to find", :'fails_on_ruby_1.9.2' => true do
- Puppet::Node::Facts.indirection.reset_terminus_class
+ Puppet::Node::Facts.terminus_class = nil
subject.command_line.stubs(:args).returns %w{find whatever --render-as yaml}
expect {
diff --git a/spec/unit/application/inspect_spec.rb b/spec/unit/application/inspect_spec.rb
index 58eff02..97f6f2e 100755
--- a/spec/unit/application/inspect_spec.rb
+++ b/spec/unit/application/inspect_spec.rb
@@ -278,7 +278,7 @@ def retrieve
end
after :all do
- Puppet::Resource::Catalog.indirection.reset_terminus_class
- Puppet::Transaction::Report.indirection.terminus_class = :processor
+ Puppet::Resource::Catalog.terminus_class = nil
+ Puppet::Transaction::Report.terminus_class = :processor
end
end
diff --git a/spec/unit/application/kick_spec.rb b/spec/unit/application/kick_spec.rb
index b24e784..9cca704 100755
--- a/spec/unit/application/kick_spec.rb
+++ b/spec/unit/application/kick_spec.rb
@@ -154,7 +154,7 @@
@kick.options.stubs(:[]).with(:all).returns(true)
@kick.stubs(:puts)
- Puppet::Node.indirection.expects(:search).with("whatever",:fqdn => :something).returns([])
+ Puppet::Node.expects(:search).with("whatever",:fqdn => :something).returns([])
@kick.setup
end
@@ -163,7 +163,7 @@
@kick.options.stubs(:[]).with(:all).returns(true)
@kick.stubs(:puts)
- Puppet::Node.indirection.expects(:search).with("whatever",:fqdn => nil).returns([])
+ Puppet::Node.expects(:search).with("whatever",:fqdn => nil).returns([])
@kick.setup
end
@@ -173,7 +173,7 @@
@kick.stubs(:puts)
@kick.classes = ['class']
- Puppet::Node.indirection.expects(:search).with("whatever", :class => "class", :fqdn => nil).returns([])
+ Puppet::Node.expects(:search).with("whatever", :class => "class", :fqdn => nil).returns([])
@kick.setup
end
@@ -258,12 +258,12 @@
@agent_run = Puppet::Run.new( options.dup )
@agent_run.stubs(:status).returns("success")
- Puppet::Run.indirection.expects(:terminus_class=).with( :rest )
+ Puppet::Run.expects(:terminus_class=).with( :rest )
Puppet::Run.expects(:new).with( options ).returns(@agent_run)
end
it "should call run on a Puppet::Run for the given host" do
- Puppet::Run.indirection.expects(:save).with(@agent_run, 'https://host:8139/production/run/host').returns(@agent_run)
+ Puppet::Run.expects(:save).with(@agent_run, 'https://host:8139/production/run/host').returns(@agent_run)
expect { @kick.run_for_host('host') }.to exit_with 0
end
diff --git a/spec/unit/application/master_spec.rb b/spec/unit/application/master_spec.rb
index c6df48f..50107e2 100755
--- a/spec/unit/application/master_spec.rb
+++ b/spec/unit/application/master_spec.rb
@@ -12,12 +12,12 @@
Puppet::Daemon.stubs(:new).returns(@daemon)
Puppet::Util::Log.stubs(:newdestination)
- Puppet::Node.indirection.stubs(:terminus_class=)
- Puppet::Node.indirection.stubs(:cache_class=)
- Puppet::Node::Facts.indirection.stubs(:terminus_class=)
- Puppet::Node::Facts.indirection.stubs(:cache_class=)
- Puppet::Transaction::Report.indirection.stubs(:terminus_class=)
- Puppet::Resource::Catalog.indirection.stubs(:terminus_class=)
+ Puppet::Node.stubs(:terminus_class=)
+ Puppet::Node.stubs(:cache_class=)
+ Puppet::Node::Facts.stubs(:terminus_class=)
+ Puppet::Node::Facts.stubs(:cache_class=)
+ Puppet::Transaction::Report.stubs(:terminus_class=)
+ Puppet::Resource::Catalog.stubs(:terminus_class=)
Puppet::SSL::Host.stubs(:ca_location=)
end
@@ -174,7 +174,7 @@
end
it "should cache class in yaml" do
- Puppet::Node.indirection.expects(:cache_class=).with(:yaml)
+ Puppet::Node.expects(:cache_class=).with(:yaml)
@master.setup
end
@@ -252,7 +252,7 @@
it "should compile a catalog for the specified node" do
@master.options[:node] = "foo"
- Puppet::Resource::Catalog.indirection.expects(:find).with("foo").returns Puppet::Resource::Catalog.new
+ Puppet::Resource::Catalog.expects(:find).with("foo").returns Puppet::Resource::Catalog.new
$stdout.stubs(:puts)
expect { @master.compile }.to exit_with 0
@@ -260,7 +260,7 @@
it "should convert the catalog to a pure-resource catalog and use 'jj' to pretty-print the catalog" do
catalog = Puppet::Resource::Catalog.new
- Puppet::Resource::Catalog.indirection.expects(:find).returns catalog
+ Puppet::Resource::Catalog.expects(:find).returns catalog
catalog.expects(:to_resource).returns("rescat")
@@ -272,14 +272,14 @@
it "should exit with error code 30 if no catalog can be found" do
@master.options[:node] = "foo"
- Puppet::Resource::Catalog.indirection.expects(:find).returns nil
+ Puppet::Resource::Catalog.expects(:find).returns nil
$stderr.expects(:puts)
expect { @master.compile }.to exit_with 30
end
it "should exit with error code 30 if there's a failure" do
@master.options[:node] = "foo"
- Puppet::Resource::Catalog.indirection.expects(:find).raises ArgumentError
+ Puppet::Resource::Catalog.expects(:find).raises ArgumentError
$stderr.expects(:puts)
expect { @master.compile }.to exit_with 30
end
diff --git a/spec/unit/application/queue_spec.rb b/spec/unit/application/queue_spec.rb
index 28378d8..0744b89 100755
--- a/spec/unit/application/queue_spec.rb
+++ b/spec/unit/application/queue_spec.rb
@@ -11,7 +11,7 @@
@daemon = stub_everything 'daemon', :daemonize => nil
Puppet::Util::Log.stubs(:newdestination)
- Puppet::Resource::Catalog.indirection.stubs(:terminus_class=)
+ Puppet::Resource::Catalog.stubs(:terminus_class=)
end
it "should ask Puppet::Application to parse Puppet configuration file" do
@@ -74,7 +74,7 @@
@queue.daemon.stubs(:daemonize)
Puppet.stubs(:info)
Puppet.features.stubs(:stomp?).returns true
- Puppet::Resource::Catalog.indirection.stubs(:terminus_class=)
+ Puppet::Resource::Catalog.stubs(:terminus_class=)
Puppet.stubs(:settraps)
Puppet.settings.stubs(:print_config?)
Puppet.settings.stubs(:print_config)
@@ -130,7 +130,7 @@
end
it "should configure the Catalog class to use StoreConfigs" do
- Puppet::Resource::Catalog.indirection.expects(:terminus_class=).with(:store_configs)
+ Puppet::Resource::Catalog.expects(:terminus_class=).with(:store_configs)
@queue.setup
end
@@ -157,7 +157,7 @@
it "should log and save each catalog passed by the queue" do
catalog = Puppet::Resource::Catalog.new('eh')
- Puppet::Resource::Catalog.indirection.expects(:save).with(catalog)
+ Puppet::Resource::Catalog.expects(:save).with(catalog, nil)
Puppet::Resource::Catalog::Queue.expects(:subscribe).yields(catalog)
Puppet.expects(:notice).times(2)
diff --git a/spec/unit/application/resource_spec.rb b/spec/unit/application/resource_spec.rb
index 79935cc..9d8fcb6 100755
--- a/spec/unit/application/resource_spec.rb
+++ b/spec/unit/application/resource_spec.rb
@@ -7,7 +7,7 @@
before :each do
@resource_app = Puppet::Application[:resource]
Puppet::Util::Log.stubs(:newdestination)
- Puppet::Resource.indirection.stubs(:terminus_class=)
+ Puppet::Resource.stubs(:terminus_class=)
end
it "should ask Puppet::Application to not parse Puppet configuration file" do
@@ -122,30 +122,33 @@
@resource_app.stubs(:puts)
@resource_app.host = 'host'
- Puppet::Resource.indirection.stubs(:find ).never
- Puppet::Resource.indirection.stubs(:search).never
- Puppet::Resource.indirection.stubs(:save ).never
+ Puppet::Resource.stubs(:find ).never
+ Puppet::Resource.stubs(:search).never
+ Puppet::Resource.stubs(:save ).never
end
it "should search for resources" do
@resource_app.command_line.stubs(:args).returns(['type'])
- Puppet::Resource.indirection.expects(:search).with('https://host:8139/production/resources/type/', {}).returns([])
+ Puppet::Resource.expects(:search).with('https://host:8139/production/resources/type/', {}).returns([])
@resource_app.main
end
it "should describe the given resource" do
@resource_app.command_line.stubs(:args).returns(['type', 'name'])
- Puppet::Resource.indirection.expects(:find).with('https://host:8139/production/resources/type/name').returns(@res)
+ Puppet::Resource.expects(:find).with('https://host:8139/production/resources/type/name').returns(@res)
@resource_app.main
end
it "should add given parameters to the object" do
@resource_app.command_line.stubs(:args).returns(['type','name','param=temp'])
- Puppet::Resource.indirection.expects(:save).
- with(@res, 'https://host:8139/production/resources/type/name').
+ @res.expects(:save).
+ with('https://host:8139/production/resources/type/name').
returns([@res, @report])
- Puppet::Resource.expects(:new).with('type', 'name', :parameters => {'param' => 'temp'}).returns(@res)
+
+ Puppet::Resource.expects(:new).
+ with('type', 'name', :parameters => {'param' => 'temp'}).
+ returns(@res)
@resource_app.main
end
@@ -156,27 +159,29 @@
@resource_app.stubs(:puts)
@resource_app.host = nil
- Puppet::Resource.indirection.stubs(:find ).never
- Puppet::Resource.indirection.stubs(:search).never
- Puppet::Resource.indirection.stubs(:save ).never
+ Puppet::Resource.stubs(:find ).never
+ Puppet::Resource.stubs(:search).never
+ Puppet::Resource.stubs(:save ).never
end
it "should search for resources" do
- Puppet::Resource.indirection.expects(:search).with('mytype/', {}).returns([])
+ Puppet::Resource.expects(:search).with('mytype/', {}).returns([])
@resource_app.main
end
it "should describe the given resource" do
@resource_app.command_line.stubs(:args).returns(['type','name'])
- Puppet::Resource.indirection.expects(:find).with('type/name').returns(@res)
+ Puppet::Resource.expects(:find).with('type/name').returns(@res)
@resource_app.main
end
it "should add given parameters to the object" do
@resource_app.command_line.stubs(:args).returns(['type','name','param=temp'])
- Puppet::Resource.indirection.expects(:save).with(@res, 'type/name').returns([@res, @report])
- Puppet::Resource.expects(:new).with('type', 'name', :parameters => {'param' => 'temp'}).returns(@res)
+ @res.expects(:save).with('type/name').returns([@res, @report])
+ Puppet::Resource.expects(:new).
+ with('type', 'name', :parameters => {'param' => 'temp'}).
+ returns(@res)
@resource_app.main
end
@@ -198,7 +203,7 @@
it "should output a file resource when given a file path" do
path = File.expand_path('/etc')
res = Puppet::Type.type(:file).new(:path => path).to_resource
- Puppet::Resource.indirection.expects(:find).returns(res)
+ Puppet::Resource.expects(:find).returns(res)
@resource_app.command_line.stubs(:args).returns(['file', path])
@resource_app.expects(:puts).with do |args|
diff --git a/spec/unit/application_spec.rb b/spec/unit/application_spec.rb
index fd93ceb..5e1554d 100755
--- a/spec/unit/application_spec.rb
+++ b/spec/unit/application_spec.rb
@@ -389,11 +389,11 @@ def run_command
include PuppetSpec::Files
before :each do
- Puppet::Node.indirection.reset_terminus_class
+ Puppet::Node.terminus_class = nil
end
after :each do
- Puppet::Node.indirection.reset_terminus_class
+ Puppet::Node.terminus_class = nil
end
it "should use the routes specified for only the active application" do
@@ -413,7 +413,7 @@ def run_command
@app.configure_indirector_routes
- Puppet::Node.indirection.terminus_class.should == 'exec'
+ Puppet::Node.terminus_class.should == 'exec'
end
it "should not fail if the route file doesn't exist" do
diff --git a/spec/unit/configurer/fact_handler_spec.rb b/spec/unit/configurer/fact_handler_spec.rb
index 4a3fe8b..cc9a895 100755
--- a/spec/unit/configurer/fact_handler_spec.rb
+++ b/spec/unit/configurer/fact_handler_spec.rb
@@ -46,14 +46,12 @@ class FactHandlerTester
describe "when finding facts" do
before :each do
@facthandler.stubs(:reload_facter)
- Puppet::Node::Facts.indirection.terminus_class = :memory
+ Puppet::Node::Facts.terminus_class = :memory
end
it "should use the node name value to retrieve the facts" do
- foo_facts = Puppet::Node::Facts.new('foo')
- bar_facts = Puppet::Node::Facts.new('bar')
- Puppet::Node::Facts.indirection.save(foo_facts)
- Puppet::Node::Facts.indirection.save(bar_facts)
+ foo_facts = Puppet::Node::Facts.new('foo').save
+ bar_facts = Puppet::Node::Facts.new('bar').save
Puppet[:certname] = 'foo'
Puppet[:node_name_value] = 'bar'
@@ -61,16 +59,13 @@ class FactHandlerTester
end
it "should set the facts name based on the node_name_fact" do
- facts = Puppet::Node::Facts.new(Puppet[:node_name_value], 'my_name_fact' => 'other_node_name')
- Puppet::Node::Facts.indirection.save(facts)
+ Puppet::Node::Facts.new(Puppet[:node_name_value], 'my_name_fact' => 'other_node_name').save
Puppet[:node_name_fact] = 'my_name_fact'
-
@facthandler.find_facts.name.should == 'other_node_name'
end
it "should set the node_name_value based on the node_name_fact" do
- facts = Puppet::Node::Facts.new(Puppet[:node_name_value], 'my_name_fact' => 'other_node_name')
- Puppet::Node::Facts.indirection.save(facts)
+ Puppet::Node::Facts.new(Puppet[:node_name_value], 'my_name_fact' => 'other_node_name').save
Puppet[:node_name_fact] = 'my_name_fact'
@facthandler.find_facts
@@ -87,7 +82,7 @@ class FactHandlerTester
it "should fail if finding facts fails" do
Puppet[:trace] = false
Puppet[:certname] = "myhost"
- Puppet::Node::Facts.indirection.expects(:find).raises RuntimeError
+ Puppet::Node::Facts.expects(:find).raises RuntimeError
lambda { @facthandler.find_facts }.should raise_error(Puppet::Error)
end
diff --git a/spec/unit/configurer_spec.rb b/spec/unit/configurer_spec.rb
index 5c660cc..24168e9 100755
--- a/spec/unit/configurer_spec.rb
+++ b/spec/unit/configurer_spec.rb
@@ -75,14 +75,14 @@
before do
Puppet.settings.stubs(:use).returns(true)
@agent.stubs(:prepare)
- Puppet::Node::Facts.indirection.terminus_class = :memory
+ Puppet::Node::Facts.terminus_class = :memory
@facts = Puppet::Node::Facts.new(Puppet[:node_name_value])
- Puppet::Node::Facts.indirection.save(@facts)
+ @facts.save
@catalog = Puppet::Resource::Catalog.new
@catalog.stubs(:to_ral).returns(@catalog)
- Puppet::Resource::Catalog.indirection.terminus_class = :rest
- Puppet::Resource::Catalog.indirection.stubs(:find).returns(@catalog)
+ Puppet::Resource::Catalog.terminus_class = :rest
+ Puppet::Resource::Catalog.stubs(:find).returns(@catalog)
@agent.stubs(:send_report)
@agent.stubs(:save_last_run_summary)
@@ -90,8 +90,8 @@
end
after :all do
- Puppet::Node::Facts.indirection.reset_terminus_class
- Puppet::Resource::Catalog.indirection.reset_terminus_class
+ Puppet::Node::Facts.terminus_class = nil
+ Puppet::Resource::Catalog.terminus_class = nil
end
it "should prepare for the run" do
@@ -318,9 +318,9 @@
describe "when not using a REST terminus for catalogs" do
it "should not pass any facts when retrieving the catalog" do
- Puppet::Resource::Catalog.indirection.terminus_class = :compiler
+ Puppet::Resource::Catalog.terminus_class = :compiler
@agent.expects(:facts_for_uploading).never
- Puppet::Resource::Catalog.indirection.expects(:find).with { |name, options|
+ Puppet::Resource::Catalog.expects(:find).with { |name, options|
options[:facts].nil?
}.returns @catalog
@@ -330,9 +330,9 @@
describe "when using a REST terminus for catalogs" do
it "should pass the prepared facts and the facts format as arguments when retrieving the catalog" do
- Puppet::Resource::Catalog.indirection.terminus_class = :rest
+ Puppet::Resource::Catalog.terminus_class = :rest
@agent.expects(:facts_for_uploading).returns(:facts => "myfacts", :facts_format => :foo)
- Puppet::Resource::Catalog.indirection.expects(:find).with { |name, options|
+ Puppet::Resource::Catalog.expects(:find).with { |name, options|
options[:facts] == "myfacts" and options[:facts_format] == :foo
}.returns @catalog
@@ -371,35 +371,35 @@
it "should save the report if reporting is enabled" do
Puppet.settings[:report] = true
- Puppet::Transaction::Report.indirection.expects(:save).with(@report)
+ Puppet::Transaction::Report.expects(:save).with(@report, nil)
@configurer.send_report(@report)
end
it "should not save the report if reporting is disabled" do
Puppet.settings[:report] = false
- Puppet::Transaction::Report.indirection.expects(:save).with(@report).never
+ Puppet::Transaction::Report.expects(:save).with(@report, nil).never
@configurer.send_report(@report)
end
it "should save the last run summary if reporting is enabled" do
Puppet.settings[:report] = true
- @configurer.expects(:save_last_run_summary).with(@report)
+ @configurer.expects(:save_last_run_summary).with(@report, nil)
@configurer.send_report(@report)
end
it "should save the last run summary if reporting is disabled" do
Puppet.settings[:report] = false
- @configurer.expects(:save_last_run_summary).with(@report)
+ @configurer.expects(:save_last_run_summary).with(@report, nil)
@configurer.send_report(@report)
end
it "should log but not fail if saving the report fails" do
Puppet.settings[:report] = true
- Puppet::Transaction::Report.indirection.expects(:save).raises("whatever")
+ Puppet::Transaction::Report.expects(:save).raises("whatever")
Puppet.expects(:err)
lambda { @configurer.send_report(@report) }.should_not raise_error
@@ -444,7 +444,7 @@
@catalog = Puppet::Resource::Catalog.new
# this is the default when using a Configurer instance
- Puppet::Resource::Catalog.indirection.stubs(:terminus_class).returns :rest
+ Puppet::Resource::Catalog.stubs(:terminus_class).returns :rest
@agent.stubs(:convert_catalog).returns @catalog
end
@@ -455,22 +455,22 @@
end
it "should first look in the cache for a catalog" do
- Puppet::Resource::Catalog.indirection.expects(:find).with { |name, options| options[:ignore_terminus] == true }.returns @catalog
- Puppet::Resource::Catalog.indirection.expects(:find).with { |name, options| options[:ignore_cache] == true }.never
+ Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:ignore_terminus] == true }.returns @catalog
+ Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:ignore_cache] == true }.never
@agent.retrieve_catalog({}).should == @catalog
end
it "should compile a new catalog if none is found in the cache" do
- Puppet::Resource::Catalog.indirection.expects(:find).with { |name, options| options[:ignore_terminus] == true }.returns nil
- Puppet::Resource::Catalog.indirection.expects(:find).with { |name, options| options[:ignore_cache] == true }.returns @catalog
+ Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:ignore_terminus] == true }.returns nil
+ Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:ignore_cache] == true }.returns @catalog
@agent.retrieve_catalog({}).should == @catalog
end
end
it "should use the Catalog class to get its catalog" do
- Puppet::Resource::Catalog.indirection.expects(:find).returns @catalog
+ Puppet::Resource::Catalog.expects(:find).returns @catalog
@agent.retrieve_catalog({})
end
@@ -478,20 +478,20 @@
it "should use its node_name_value to retrieve the catalog" do
Facter.stubs(:value).returns "eh"
Puppet.settings[:node_name_value] = "myhost.domain.com"
- Puppet::Resource::Catalog.indirection.expects(:find).with { |name, options| name == "myhost.domain.com" }.returns @catalog
+ Puppet::Resource::Catalog.expects(:find).with { |name, options| name == "myhost.domain.com" }.returns @catalog
@agent.retrieve_catalog({})
end
it "should default to returning a catalog retrieved directly from the server, skipping the cache" do
- Puppet::Resource::Catalog.indirection.expects(:find).with { |name, options| options[:ignore_cache] == true }.returns @catalog
+ Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:ignore_cache] == true }.returns @catalog
@agent.retrieve_catalog({}).should == @catalog
end
it "should log and return the cached catalog when no catalog can be retrieved from the server" do
- Puppet::Resource::Catalog.indirection.expects(:find).with { |name, options| options[:ignore_cache] == true }.returns nil
- Puppet::Resource::Catalog.indirection.expects(:find).with { |name, options| options[:ignore_terminus] == true }.returns @catalog
+ Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:ignore_cache] == true }.returns nil
+ Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:ignore_terminus] == true }.returns @catalog
Puppet.expects(:notice)
@@ -499,15 +499,15 @@
end
it "should not look in the cache for a catalog if one is returned from the server" do
- Puppet::Resource::Catalog.indirection.expects(:find).with { |name, options| options[:ignore_cache] == true }.returns @catalog
- Puppet::Resource::Catalog.indirection.expects(:find).with { |name, options| options[:ignore_terminus] == true }.never
+ Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:ignore_cache] == true }.returns @catalog
+ Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:ignore_terminus] == true }.never
@agent.retrieve_catalog({}).should == @catalog
end
it "should return the cached catalog when retrieving the remote catalog throws an exception" do
- Puppet::Resource::Catalog.indirection.expects(:find).with { |name, options| options[:ignore_cache] == true }.raises "eh"
- Puppet::Resource::Catalog.indirection.expects(:find).with { |name, options| options[:ignore_terminus] == true }.returns @catalog
+ Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:ignore_cache] == true }.raises "eh"
+ Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:ignore_terminus] == true }.returns @catalog
@agent.retrieve_catalog({}).should == @catalog
end
@@ -515,7 +515,7 @@
it "should log and return nil if no catalog can be retrieved from the server and :usecacheonfailure is disabled" do
Puppet.stubs(:[])
Puppet.expects(:[]).with(:usecacheonfailure).returns false
- Puppet::Resource::Catalog.indirection.expects(:find).with { |name, options| options[:ignore_cache] == true }.returns nil
+ Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:ignore_cache] == true }.returns nil
Puppet.expects(:warning)
@@ -523,21 +523,21 @@
end
it "should return nil if no cached catalog is available and no catalog can be retrieved from the server" do
- Puppet::Resource::Catalog.indirection.expects(:find).with { |name, options| options[:ignore_cache] == true }.returns nil
- Puppet::Resource::Catalog.indirection.expects(:find).with { |name, options| options[:ignore_terminus] == true }.returns nil
+ Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:ignore_cache] == true }.returns nil
+ Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:ignore_terminus] == true }.returns nil
@agent.retrieve_catalog({}).should be_nil
end
it "should convert the catalog before returning" do
- Puppet::Resource::Catalog.indirection.stubs(:find).returns @catalog
+ Puppet::Resource::Catalog.stubs(:find).returns @catalog
@agent.expects(:convert_catalog).with { |cat, dur| cat == @catalog }.returns "converted catalog"
@agent.retrieve_catalog({}).should == "converted catalog"
end
it "should return nil if there is an error while retrieving the catalog" do
- Puppet::Resource::Catalog.indirection.expects(:find).at_least_once.raises "eh"
+ Puppet::Resource::Catalog.expects(:find).at_least_once.raises "eh"
@agent.retrieve_catalog({}).should be_nil
end
diff --git a/spec/unit/face/node_spec.rb b/spec/unit/face/node_spec.rb
index cb36e58..4ea1d47 100755
--- a/spec/unit/face/node_spec.rb
+++ b/spec/unit/face/node_spec.rb
@@ -24,8 +24,8 @@
describe 'when running #clean' do
before :each do
- Puppet::Node::Facts.indirection.stubs(:terminus_class=)
- Puppet::Node::Facts.indirection.stubs(:cache_class=)
+ Puppet::Node::Facts.stubs(:terminus_class=)
+ Puppet::Node::Facts.stubs(:cache_class=)
Puppet::Node.stubs(:terminus_class=)
Puppet::Node.stubs(:cache_class=)
end
@@ -38,8 +38,8 @@
describe "clean action" do
before :each do
- Puppet::Node::Facts.indirection.stubs(:terminus_class=)
- Puppet::Node::Facts.indirection.stubs(:cache_class=)
+ Puppet::Node::Facts.stubs(:terminus_class=)
+ Puppet::Node::Facts.stubs(:cache_class=)
Puppet::Node.stubs(:terminus_class=)
Puppet::Node.stubs(:cache_class=)
subject.stubs(:cleanup)
@@ -81,8 +81,8 @@
describe "during setup" do
it "should set facts terminus and cache class to yaml" do
- Puppet::Node::Facts.indirection.expects(:terminus_class=).with(:yaml)
- Puppet::Node::Facts.indirection.expects(:cache_class=).with(:yaml)
+ Puppet::Node::Facts.expects(:terminus_class=).with(:yaml)
+ Puppet::Node::Facts.expects(:cache_class=).with(:yaml)
subject.clean('hostname')
end
@@ -93,8 +93,8 @@
end
it "should set node cache as yaml" do
- Puppet::Node.indirection.expects(:terminus_class=).with(:yaml)
- Puppet::Node.indirection.expects(:cache_class=).with(:yaml)
+ Puppet::Node.expects(:terminus_class=).with(:yaml)
+ Puppet::Node.expects(:cache_class=).with(:yaml)
subject.clean('hostname')
end
@@ -137,7 +137,7 @@
describe "when cleaning cached facts" do
it "should destroy facts" do
@host = 'node'
- Puppet::Node::Facts.indirection.expects(:destroy).with(@host)
+ Puppet::Node::Facts.expects(:destroy).with(@host)
subject.clean_cached_facts(@host)
end
@@ -145,14 +145,14 @@
describe "when cleaning cached node" do
it "should destroy the cached node" do
- Puppet::Node.indirection.expects(:destroy).with(@host)
+ Puppet::Node.expects(:destroy).with(@host)
subject.clean_cached_node(@host)
end
end
describe "when cleaning archived reports" do
it "should tell the reports to remove themselves" do
- Puppet::Transaction::Report.indirection.stubs(:destroy).with(@host)
+ Puppet::Transaction::Report.stubs(:destroy).with(@host)
subject.clean_reports(@host)
end
diff --git a/spec/unit/file_bucket/dipper_spec.rb b/spec/unit/file_bucket/dipper_spec.rb
index 1e92b2b..8a49531 100755
--- a/spec/unit/file_bucket/dipper_spec.rb
+++ b/spec/unit/file_bucket/dipper_spec.rb
@@ -19,7 +19,7 @@ def make_tmp_file(contents)
@dipper = Puppet::FileBucket::Dipper.new(:Path => make_absolute("/my/bucket"))
file = make_tmp_file('contents')
- Puppet::FileBucket::File.indirection.expects(:head).raises ArgumentError
+ Puppet::FileBucket::File.expects(:head).raises ArgumentError
lambda { @dipper.backup(file) }.should raise_error(Puppet::Error)
end
@@ -28,8 +28,8 @@ def make_tmp_file(contents)
@dipper = Puppet::FileBucket::Dipper.new(:Path => make_absolute("/my/bucket"))
file = make_tmp_file('contents')
- Puppet::FileBucket::File.indirection.expects(:head).returns false
- Puppet::FileBucket::File.indirection.expects(:save).raises ArgumentError
+ Puppet::FileBucket::File.expects(:head).returns false
+ Puppet::FileBucket::File.expects(:save).raises ArgumentError
lambda { @dipper.backup(file) }.should raise_error(Puppet::Error)
end
@@ -54,8 +54,8 @@ def make_tmp_file(contents)
file = make_tmp_file("my\r\ncontents")
checksum = Digest::MD5.hexdigest("my\r\ncontents")
- Puppet::FileBucket::File.indirection.expects(:head).returns true
- Puppet::FileBucket::File.indirection.expects(:save).never
+ Puppet::FileBucket::File.expects(:head).returns true
+ Puppet::FileBucket::File.expects(:save).never
@dipper.backup(file).should == checksum
end
diff --git a/spec/unit/file_bucket/file_spec.rb b/spec/unit/file_bucket/file_spec.rb
index 2757964..81658e2 100755
--- a/spec/unit/file_bucket/file_spec.rb
+++ b/spec/unit/file_bucket/file_spec.rb
@@ -52,7 +52,7 @@
end
it "should have a :save instance method" do
- Puppet::FileBucket::File.indirection.should respond_to(:save)
+ Puppet::FileBucket::File.should respond_to(:save)
end
end
@@ -80,25 +80,25 @@ def make_bucketed_file
describe "using the indirector's find method" do
it "should return nil if a file doesn't exist" do
- bucketfile = Puppet::FileBucket::File.indirection.find("md5/#{digest}")
+ bucketfile = Puppet::FileBucket::File.find("md5/#{digest}")
bucketfile.should == nil
end
it "should find a filebucket if the file exists" do
make_bucketed_file
- bucketfile = Puppet::FileBucket::File.indirection.find("md5/#{digest}")
+ bucketfile = Puppet::FileBucket::File.find("md5/#{digest}")
bucketfile.checksum.should == checksum
end
describe "using RESTish digest notation" do
it "should return nil if a file doesn't exist" do
- bucketfile = Puppet::FileBucket::File.indirection.find("md5/#{digest}")
+ bucketfile = Puppet::FileBucket::File.find("md5/#{digest}")
bucketfile.should == nil
end
it "should find a filebucket if the file exists" do
make_bucketed_file
- bucketfile = Puppet::FileBucket::File.indirection.find("md5/#{digest}")
+ bucketfile = Puppet::FileBucket::File.find("md5/#{digest}")
bucketfile.checksum.should == checksum
end
end
diff --git a/spec/unit/indirector/catalog/active_record_spec.rb b/spec/unit/indirector/catalog/active_record_spec.rb
index 35d0117..960c8a5 100755
--- a/spec/unit/indirector/catalog/active_record_spec.rb
+++ b/spec/unit/indirector/catalog/active_record_spec.rb
@@ -99,7 +99,7 @@ class Host < Tableless
@host.stubs(:railsmark).yields
@node = Puppet::Node.new("foo", :environment => "environment")
- Puppet::Node.indirection.stubs(:find).with("foo").returns(@node)
+ Puppet::Node.stubs(:find).with("foo").returns(@node)
Puppet::Rails::Host.stubs(:find_by_name).returns @host
@catalog = Puppet::Resource::Catalog.new("foo")
diff --git a/spec/unit/indirector/catalog/compiler_spec.rb b/spec/unit/indirector/catalog/compiler_spec.rb
index 3c559e3..6f1c03e 100755
--- a/spec/unit/indirector/catalog/compiler_spec.rb
+++ b/spec/unit/indirector/catalog/compiler_spec.rb
@@ -28,8 +28,8 @@
node1 = stub 'node1', :merge => nil
node2 = stub 'node2', :merge => nil
compiler.stubs(:compile)
- Puppet::Node.indirection.stubs(:find).with('node1').returns(node1)
- Puppet::Node.indirection.stubs(:find).with('node2').returns(node2)
+ Puppet::Node.stubs(:find).with('node1').returns(node1)
+ Puppet::Node.stubs(:find).with('node2').returns(node2)
compiler.find(stub('request', :key => 'node1', :node => 'node1', :options => {}))
compiler.find(stub('node2request', :key => 'node2', :node => 'node2', :options => {}))
@@ -49,12 +49,12 @@
@name = "me"
@node = Puppet::Node.new @name
@node.stubs(:merge)
- Puppet::Node.indirection.stubs(:find).returns @node
+ Puppet::Node.stubs(:find).returns @node
@request = stub 'request', :key => @name, :node => @name, :options => {}
end
it "should directly use provided nodes" do
- Puppet::Node.indirection.expects(:find).never
+ Puppet::Node.expects(:find).never
@compiler.expects(:compile).with(@node)
@request.stubs(:options).returns(:use_node => @node)
@compiler.find(@request)
@@ -62,7 +62,7 @@
it "should use the authenticated node name if no request key is provided" do
@request.stubs(:key).returns(nil)
- Puppet::Node.indirection.expects(:find).with(@name).returns(@node)
+ Puppet::Node.expects(:find).with(@name).returns(@node)
@compiler.expects(:compile).with(@node)
@compiler.find(@request)
end
@@ -70,37 +70,37 @@
it "should use the provided node name by default" do
@request.expects(:key).returns "my_node"
- Puppet::Node.indirection.expects(:find).with("my_node").returns @node
+ Puppet::Node.expects(:find).with("my_node").returns @node
@compiler.expects(:compile).with(@node)
@compiler.find(@request)
end
it "should fail if no node is passed and none can be found" do
- Puppet::Node.indirection.stubs(:find).with(@name).returns(nil)
+ Puppet::Node.stubs(:find).with(@name).returns(nil)
proc { @compiler.find(@request) }.should raise_error(ArgumentError)
end
it "should fail intelligently when searching for a node raises an exception" do
- Puppet::Node.indirection.stubs(:find).with(@name).raises "eh"
+ Puppet::Node.stubs(:find).with(@name).raises "eh"
proc { @compiler.find(@request) }.should raise_error(Puppet::Error)
end
it "should pass the found node to the compiler for compiling" do
- Puppet::Node.indirection.expects(:find).with(@name).returns(@node)
+ Puppet::Node.expects(:find).with(@name).returns(@node)
config = mock 'config'
Puppet::Parser::Compiler.expects(:compile).with(@node)
@compiler.find(@request)
end
it "should extract and save any facts from the request" do
- Puppet::Node.indirection.expects(:find).with(@name).returns @node
+ Puppet::Node.expects(:find).with(@name).returns @node
@compiler.expects(:extract_facts_from_request).with(@request)
Puppet::Parser::Compiler.stubs(:compile)
@compiler.find(@request)
end
it "should return the results of compiling as the catalog" do
- Puppet::Node.indirection.stubs(:find).returns(@node)
+ Puppet::Node.stubs(:find).returns(@node)
config = mock 'config'
result = mock 'result'
@@ -109,7 +109,7 @@
end
it "should benchmark the compile process" do
- Puppet::Node.indirection.stubs(:find).returns(@node)
+ Puppet::Node.stubs(:find).returns(@node)
@compiler.stubs(:networked?).returns(true)
@compiler.expects(:benchmark).with do |level, message|
level == :notice and message =~ /^Compiled catalog/
@@ -119,7 +119,7 @@
end
it "should log the benchmark result" do
- Puppet::Node.indirection.stubs(:find).returns(@node)
+ Puppet::Node.stubs(:find).returns(@node)
@compiler.stubs(:networked?).returns(true)
Puppet::Parser::Compiler.stubs(:compile)
@@ -136,7 +136,7 @@
@request = stub 'request', :options => {}
@facts = Puppet::Node::Facts.new('hostname', "fact" => "value", "architecture" => "i386")
- Puppet::Node::Facts.indirection.stubs(:save).returns(nil)
+ Puppet::Node::Facts.stubs(:save).returns(nil)
end
it "should do nothing if no facts are provided" do
@@ -172,7 +172,7 @@
@request.options[:facts] = "bar"
Puppet::Node::Facts.expects(:convert_from).returns @facts
- Puppet::Node::Facts.indirection.expects(:save).with(@facts)
+ Puppet::Node::Facts.expects(:save).with(@facts, nil)
@compiler.extract_facts_from_request(@request)
end
@@ -190,7 +190,7 @@
it "should look node information up via the Node class with the provided key" do
@node.stubs :merge
- Puppet::Node.indirection.expects(:find).with(@name).returns(@node)
+ Puppet::Node.expects(:find).with(@name).returns(@node)
@compiler.find(@request)
end
end
@@ -205,7 +205,7 @@
@node = mock 'node'
@request = stub 'request', :key => @name, :options => {}
@compiler.stubs(:compile)
- Puppet::Node.indirection.stubs(:find).with(@name).returns(@node)
+ Puppet::Node.stubs(:find).with(@name).returns(@node)
end
it "should add the server's Puppet version to the node's parameters as 'serverversion'" do
diff --git a/spec/unit/indirector/catalog/store_configs_spec.rb b/spec/unit/indirector/catalog/store_configs_spec.rb
index 623ae24..dfad3da 100755
--- a/spec/unit/indirector/catalog/store_configs_spec.rb
+++ b/spec/unit/indirector/catalog/store_configs_spec.rb
@@ -9,8 +9,8 @@ class Puppet::Resource::Catalog::StoreConfigsTesting < Puppet::Indirector::Memor
describe Puppet::Resource::Catalog::StoreConfigs do
after :each do
- Puppet::Resource::Catalog.indirection.reset_terminus_class
- Puppet::Resource::Catalog.indirection.cache_class = nil
+ Puppet::Resource::Catalog.terminus_class = nil
+ Puppet::Resource::Catalog.cache_class = nil
end
it_should_behave_like "a StoreConfigs terminus"
diff --git a/spec/unit/indirector/certificate_request/ca_spec.rb b/spec/unit/indirector/certificate_request/ca_spec.rb
index e5443a2..c78f0c4 100755
--- a/spec/unit/indirector/certificate_request/ca_spec.rb
+++ b/spec/unit/indirector/certificate_request/ca_spec.rb
@@ -35,11 +35,11 @@
host.generate_certificate_request
@ca.sign(host.name)
- Puppet::SSL::Host.indirection.find("foo").generate_certificate_request
+ Puppet::SSL::Host.find("foo").generate_certificate_request
- Puppet::SSL::Certificate.indirection.find("foo").name.should == "foo"
- Puppet::SSL::CertificateRequest.indirection.find("foo").name.should == "foo"
- Puppet::SSL::Host.indirection.find("foo").state.should == "requested"
+ Puppet::SSL::Certificate.find("foo").name.should == "foo"
+ Puppet::SSL::CertificateRequest.find("foo").name.should == "foo"
+ Puppet::SSL::Host.find("foo").state.should == "requested"
end
it "should reject a new certificate request if allow_duplicate_certs is false" do
@@ -48,10 +48,10 @@
host.generate_certificate_request
@ca.sign(host.name)
- expect { Puppet::SSL::Host.indirection.find("bar").generate_certificate_request }.should raise_error(/ignoring certificate request/)
+ expect { Puppet::SSL::Host.find("bar").generate_certificate_request }.should raise_error(/ignoring certificate request/)
- Puppet::SSL::Certificate.indirection.find("bar").name.should == "bar"
- Puppet::SSL::CertificateRequest.indirection.find("bar").should be_nil
- Puppet::SSL::Host.indirection.find("bar").state.should == "signed"
+ Puppet::SSL::Certificate.find("bar").name.should == "bar"
+ Puppet::SSL::CertificateRequest.find("bar").should be_nil
+ Puppet::SSL::Host.find("bar").state.should == "signed"
end
end
diff --git a/spec/unit/indirector/certificate_status/file_spec.rb b/spec/unit/indirector/certificate_status/file_spec.rb
index c5d4e28..7785df0 100755
--- a/spec/unit/indirector/certificate_status/file_spec.rb
+++ b/spec/unit/indirector/certificate_status/file_spec.rb
@@ -13,7 +13,7 @@
before do
Puppet::SSL::CertificateAuthority.stubs(:ca?).returns true
- @terminus = Puppet::SSL::Host.indirection.terminus(:file)
+ @terminus = Puppet::SSL::Host.terminus(:file)
@tmpdir = tmpdir("certificate_status_ca_testing")
Puppet[:confdir] = @tmpdir
@@ -29,7 +29,7 @@ def generate_csr(host)
host.generate_key
csr = Puppet::SSL::CertificateRequest.new(host.name)
csr.generate(host.key.content)
- Puppet::SSL::CertificateRequest.indirection.save(csr)
+ csr.save
end
def sign_csr(host)
@@ -123,7 +123,7 @@ def generate_revoked_cert(host)
signed_host = generate_signed_cert(@host)
signed_host.state.should == "signed"
- Puppet::SSL::Certificate.indirection.find("foobar").should be_instance_of(Puppet::SSL::Certificate)
+ Puppet::SSL::Certificate.find("foobar").should be_instance_of(Puppet::SSL::Certificate)
end
end
diff --git a/spec/unit/indirector/certificate_status/rest_spec.rb b/spec/unit/indirector/certificate_status/rest_spec.rb
index 39fbb70..665163f 100755
--- a/spec/unit/indirector/certificate_status/rest_spec.rb
+++ b/spec/unit/indirector/certificate_status/rest_spec.rb
@@ -5,7 +5,7 @@
describe "Puppet::CertificateStatus::Rest" do
before do
- @terminus = Puppet::SSL::Host.indirection.terminus(:rest)
+ @terminus = Puppet::SSL::Host.terminus(:rest)
end
it "should be a terminus on Puppet::SSL::Host" do
diff --git a/spec/unit/indirector/facts/inventory_active_record_spec.rb b/spec/unit/indirector/facts/inventory_active_record_spec.rb
index 88e5e53..74223cf 100755
--- a/spec/unit/indirector/facts/inventory_active_record_spec.rb
+++ b/spec/unit/indirector/facts/inventory_active_record_spec.rb
@@ -17,15 +17,15 @@
end
after :all do
- Puppet::Node::Facts.indirection.reset_terminus_class
+ Puppet::Node::Facts.terminus_class = nil
@dbfile.unlink
end
before :each do
- Puppet::Node.indirection.reset_terminus_class
- Puppet::Node.indirection.cache_class = nil
+ Puppet::Node.terminus_class = nil
+ Puppet::Node.cache_class = nil
- Puppet::Node::Facts.indirection.terminus_class = :inventory_active_record
+ Puppet::Node::Facts.terminus_class = :inventory_active_record
Puppet[:dbadapter] = 'sqlite3'
Puppet[:dblocation] = @dbfile.path
Puppet[:railslog] = "/dev/null"
@@ -41,8 +41,7 @@
it "should use an existing node if possible" do
node = Puppet::Rails::InventoryNode.new(:name => "foo", :timestamp => Time.now)
node.save
- facts = Puppet::Node::Facts.new("foo", "uptime_days" => "60", "kernel" => "Darwin")
- Puppet::Node::Facts.indirection.save(facts)
+ Puppet::Node::Facts.new("foo", "uptime_days" => "60", "kernel" => "Darwin").save
Puppet::Rails::InventoryNode.count.should == 1
Puppet::Rails::InventoryNode.first.should == node
@@ -52,30 +51,28 @@
# This test isn't valid if there are nodes to begin with
Puppet::Rails::InventoryNode.count.should == 0
- facts = Puppet::Node::Facts.new("foo", "uptime_days" => "60", "kernel" => "Darwin")
- Puppet::Node::Facts.indirection.save(facts)
+ Puppet::Node::Facts.new("foo", "uptime_days" => "60", "kernel" => "Darwin").save
Puppet::Rails::InventoryNode.count.should == 1
Puppet::Rails::InventoryNode.first.name.should == "foo"
end
it "should save the facts" do
- facts = Puppet::Node::Facts.new("foo", "uptime_days" => "60", "kernel" => "Darwin")
- Puppet::Node::Facts.indirection.save(facts)
+ Puppet::Node::Facts.new("foo", "uptime_days" => "60", "kernel" => "Darwin").save
Puppet::Rails::InventoryFact.all.map{|f| [f.name,f.value]}.should =~ [["uptime_days","60"],["kernel","Darwin"]]
end
it "should remove the previous facts for an existing node" do
facts = Puppet::Node::Facts.new("foo", "uptime_days" => "30", "kernel" => "Darwin")
- Puppet::Node::Facts.indirection.save(facts)
bar_facts = Puppet::Node::Facts.new("bar", "uptime_days" => "35", "kernel" => "Linux")
foo_facts = Puppet::Node::Facts.new("foo", "uptime_days" => "60", "is_virtual" => "false")
- Puppet::Node::Facts.indirection.save(bar_facts)
- Puppet::Node::Facts.indirection.save(foo_facts)
- Puppet::Node::Facts.indirection.find("bar").should == bar_facts
- Puppet::Node::Facts.indirection.find("foo").should == foo_facts
+ bar_facts.save
+ foo_facts.save
+
+ Puppet::Node::Facts.find("bar").should == bar_facts
+ Puppet::Node::Facts.find("foo").should == foo_facts
Puppet::Rails::InventoryFact.all.map{|f| [f.name,f.value]}.should_not include(["uptime_days", "30"], ["kernel", "Darwin"])
end
end
@@ -84,16 +81,17 @@
before do
@foo_facts = Puppet::Node::Facts.new("foo", "uptime_days" => "60", "kernel" => "Darwin")
@bar_facts = Puppet::Node::Facts.new("bar", "uptime_days" => "30", "kernel" => "Linux")
- Puppet::Node::Facts.indirection.save(@foo_facts)
- Puppet::Node::Facts.indirection.save(@bar_facts)
+
+ @foo_facts.save
+ @bar_facts.save
end
it "should identify facts by node name" do
- Puppet::Node::Facts.indirection.find("foo").should == @foo_facts
+ Puppet::Node::Facts.find("foo").should == @foo_facts
end
it "should return nil if no node instance can be found" do
- Puppet::Node::Facts.indirection.find("non-existent node").should == nil
+ Puppet::Node::Facts.find("non-existent node").should == nil
end
end
@@ -112,7 +110,7 @@ def search_request(conditions)
@bar.timestamp = @now - 3600*3
@baz.timestamp = @now - 3600*5
@bat.timestamp = @now - 3600*7
- [@foo, @bar, @baz, @bat].each {|facts| Puppet::Node::Facts.indirection.save(facts)}
+ [@foo, @bar, @baz, @bat].each {|facts| facts.save }
end
it "should return node names that match 'equal' constraints" do
diff --git a/spec/unit/indirector/facts/store_configs_spec.rb b/spec/unit/indirector/facts/store_configs_spec.rb
index d302d17..4e08274 100755
--- a/spec/unit/indirector/facts/store_configs_spec.rb
+++ b/spec/unit/indirector/facts/store_configs_spec.rb
@@ -9,8 +9,8 @@ class Puppet::Node::Facts::StoreConfigsTesting < Puppet::Indirector::Memory
describe Puppet::Node::Facts::StoreConfigs do
after :all do
- Puppet::Node::Facts.indirection.reset_terminus_class
- Puppet::Node::Facts.indirection.cache_class = nil
+ Puppet::Node::Facts.terminus_class = nil
+ Puppet::Node::Facts.cache_class = nil
end
it_should_behave_like "a StoreConfigs terminus"
diff --git a/spec/unit/indirector/file_bucket_file/file_spec.rb b/spec/unit/indirector/file_bucket_file/file_spec.rb
index 9141221..4df55d0 100755
--- a/spec/unit/indirector/file_bucket_file/file_spec.rb
+++ b/spec/unit/indirector/file_bucket_file/file_spec.rb
@@ -23,7 +23,7 @@
def save_bucket_file(contents, path = "/who_cares")
bucket_file = Puppet::FileBucket::File.new(contents)
- Puppet::FileBucket::File.indirection.save(bucket_file, "md5/#{Digest::MD5.hexdigest(contents)}#{path}")
+ bucket_file.save("md5/#{Digest::MD5.hexdigest(contents)}#{path}")
bucket_file.checksum_data
end
@@ -66,21 +66,21 @@ def save_bucket_file(contents, path = "/who_cares")
describe "when servicing a head/find request" do
describe "when supplying a path" do
it "should return false/nil if the file isn't bucketed" do
- Puppet::FileBucket::File.indirection.head("md5/0ae2ec1980410229885fe72f7b44fe55/foo/bar").should == false
- Puppet::FileBucket::File.indirection.find("md5/0ae2ec1980410229885fe72f7b44fe55/foo/bar").should == nil
+ Puppet::FileBucket::File.head("md5/0ae2ec1980410229885fe72f7b44fe55/foo/bar").should == false
+ Puppet::FileBucket::File.find("md5/0ae2ec1980410229885fe72f7b44fe55/foo/bar").should == nil
end
it "should return false/nil if the file is bucketed but with a different path" do
checksum = save_bucket_file("I'm the contents of a file", '/foo/bar')
- Puppet::FileBucket::File.indirection.head("md5/#{checksum}/foo/baz").should == false
- Puppet::FileBucket::File.indirection.find("md5/#{checksum}/foo/baz").should == nil
+ Puppet::FileBucket::File.head("md5/#{checksum}/foo/baz").should == false
+ Puppet::FileBucket::File.find("md5/#{checksum}/foo/baz").should == nil
end
it "should return true/file if the file is already bucketed with the given path" do
contents = "I'm the contents of a file"
checksum = save_bucket_file(contents, '/foo/bar')
- Puppet::FileBucket::File.indirection.head("md5/#{checksum}/foo/bar").should == true
- find_result = Puppet::FileBucket::File.indirection.find("md5/#{checksum}/foo/bar")
+ Puppet::FileBucket::File.head("md5/#{checksum}/foo/bar").should == true
+ find_result = Puppet::FileBucket::File.find("md5/#{checksum}/foo/bar")
find_result.should be_a(Puppet::FileBucket::File)
find_result.checksum.should == "{md5}#{checksum}"
find_result.to_s.should == contents
@@ -93,15 +93,15 @@ def save_bucket_file(contents, path = "/who_cares")
trailing_string = trailing_slash ? '/' : ''
it "should return false/nil if the file isn't bucketed" do
- Puppet::FileBucket::File.indirection.head("md5/0ae2ec1980410229885fe72f7b44fe55#{trailing_string}").should == false
- Puppet::FileBucket::File.indirection.find("md5/0ae2ec1980410229885fe72f7b44fe55#{trailing_string}").should == nil
+ Puppet::FileBucket::File.head("md5/0ae2ec1980410229885fe72f7b44fe55#{trailing_string}").should == false
+ Puppet::FileBucket::File.find("md5/0ae2ec1980410229885fe72f7b44fe55#{trailing_string}").should == nil
end
it "should return true/file if the file is already bucketed" do
contents = "I'm the contents of a file"
checksum = save_bucket_file(contents, '/foo/bar')
- Puppet::FileBucket::File.indirection.head("md5/#{checksum}#{trailing_string}").should == true
- find_result = Puppet::FileBucket::File.indirection.find("md5/#{checksum}#{trailing_string}")
+ Puppet::FileBucket::File.head("md5/#{checksum}#{trailing_string}").should == true
+ find_result = Puppet::FileBucket::File.find("md5/#{checksum}#{trailing_string}")
find_result.should be_a(Puppet::FileBucket::File)
find_result.checksum.should == "{md5}#{checksum}"
find_result.to_s.should == contents
@@ -114,13 +114,13 @@ def save_bucket_file(contents, path = "/who_cares")
describe "when diffing files", :unless => Puppet.features.microsoft_windows? do
it "should generate an empty string if there is no diff" do
checksum = save_bucket_file("I'm the contents of a file")
- Puppet::FileBucket::File.indirection.find("md5/#{checksum}", :diff_with => checksum).should == ''
+ Puppet::FileBucket::File.find("md5/#{checksum}", :diff_with => checksum).should == ''
end
it "should generate a proper diff if there is a diff" do
checksum1 = save_bucket_file("foo\nbar\nbaz")
checksum2 = save_bucket_file("foo\nbiz\nbaz")
- diff = Puppet::FileBucket::File.indirection.find("md5/#{checksum1}", :diff_with => checksum2)
+ diff = Puppet::FileBucket::File.find("md5/#{checksum1}", :diff_with => checksum2)
diff.should == <<HERE
2c2
< bar
@@ -132,13 +132,13 @@ def save_bucket_file(contents, path = "/who_cares")
it "should raise an exception if the hash to diff against isn't found" do
checksum = save_bucket_file("whatever")
bogus_checksum = "d1bf072d0e2c6e20e3fbd23f022089a1"
- lambda { Puppet::FileBucket::File.indirection.find("md5/#{checksum}", :diff_with => bogus_checksum) }.should raise_error "could not find diff_with #{bogus_checksum}"
+ lambda { Puppet::FileBucket::File.find("md5/#{checksum}", :diff_with => bogus_checksum) }.should raise_error "could not find diff_with #{bogus_checksum}"
end
it "should return nil if the hash to diff from isn't found" do
checksum = save_bucket_file("whatever")
bogus_checksum = "d1bf072d0e2c6e20e3fbd23f022089a1"
- Puppet::FileBucket::File.indirection.find("md5/#{bogus_checksum}", :diff_with => checksum).should == nil
+ Puppet::FileBucket::File.find("md5/#{bogus_checksum}", :diff_with => checksum).should == nil
end
end
end
diff --git a/spec/unit/indirector/indirection_spec.rb b/spec/unit/indirector/indirection_spec.rb
index c33fdf1..f49c31d 100755
--- a/spec/unit/indirector/indirection_spec.rb
+++ b/spec/unit/indirector/indirection_spec.rb
@@ -722,10 +722,6 @@ def authorized?
proc { @indirection.terminus_class = "" }.should raise_error(ArgumentError)
end
- it "should fail when the terminus class name is nil" do
- proc { @indirection.terminus_class = nil }.should raise_error(ArgumentError)
- end
-
it "should fail when the specified terminus class cannot be found" do
Puppet::Indirector::Terminus.expects(:terminus_class).with(:test, :foo).returns(nil)
proc { @indirection.terminus_class = :foo }.should raise_error(ArgumentError)
diff --git a/spec/unit/indirector/node/ldap_spec.rb b/spec/unit/indirector/node/ldap_spec.rb
index 5e57db3..f7727ef 100755
--- a/spec/unit/indirector/node/ldap_spec.rb
+++ b/spec/unit/indirector/node/ldap_spec.rb
@@ -310,7 +310,7 @@
@options = {}
@request = stub 'request', :key => "foo", :options => @options
- Puppet::Node::Facts.indirection.stubs(:terminus_class).returns :yaml
+ Puppet::Node::Facts.stubs(:terminus_class).returns :yaml
end
it "should find all nodes if no arguments are provided" do
diff --git a/spec/unit/indirector/node/store_configs_spec.rb b/spec/unit/indirector/node/store_configs_spec.rb
index 6d5f886..c8717ec 100755
--- a/spec/unit/indirector/node/store_configs_spec.rb
+++ b/spec/unit/indirector/node/store_configs_spec.rb
@@ -9,8 +9,8 @@ class Puppet::Node::StoreConfigsTesting < Puppet::Indirector::Memory
describe Puppet::Node::StoreConfigs do
after :each do
- Puppet::Node.indirection.reset_terminus_class
- Puppet::Node.indirection.cache_class = nil
+ Puppet::Node.terminus_class = nil
+ Puppet::Node.cache_class = nil
end
it_should_behave_like "a StoreConfigs terminus"
diff --git a/spec/unit/indirector/resource/active_record_spec.rb b/spec/unit/indirector/resource/active_record_spec.rb
index c923f79..5bd1d85 100755
--- a/spec/unit/indirector/resource/active_record_spec.rb
+++ b/spec/unit/indirector/resource/active_record_spec.rb
@@ -26,7 +26,7 @@
subject {
require 'puppet/indirector/resource/active_record'
- Puppet::Resource.indirection.terminus(:active_record)
+ Puppet::Resource.terminus(:active_record)
}
it "should automatically initialize Rails" do
diff --git a/spec/unit/indirector_spec.rb b/spec/unit/indirector_spec.rb
index 0c09831..2b9a27d 100755
--- a/spec/unit/indirector_spec.rb
+++ b/spec/unit/indirector_spec.rb
@@ -6,13 +6,13 @@
describe Puppet::Indirector, "when configuring routes" do
before :each do
- Puppet::Node.indirection.reset_terminus_class
- Puppet::Node.indirection.cache_class = nil
+ Puppet::Node.terminus_class = nil
+ Puppet::Node.cache_class = nil
end
after :each do
- Puppet::Node.indirection.reset_terminus_class
- Puppet::Node.indirection.cache_class = nil
+ Puppet::Node.terminus_class = nil
+ Puppet::Node.cache_class = nil
end
it "should configure routes as requested" do
@@ -25,8 +25,8 @@
Puppet::Indirector.configure_routes(routes)
- Puppet::Node.indirection.terminus_class.should == "exec"
- Puppet::Node.indirection.cache_class.should == "plain"
+ Puppet::Node.terminus_class.should == "exec"
+ Puppet::Node.cache_class.should == "plain"
end
it "should fail when given an invalid indirection" do
diff --git a/spec/unit/network/handler/ca_spec.rb b/spec/unit/network/handler/ca_spec.rb
index 43aa5a7..acbb7a6 100644
--- a/spec/unit/network/handler/ca_spec.rb
+++ b/spec/unit/network/handler/ca_spec.rb
@@ -74,8 +74,8 @@
it "should save the CSR without signing it" do
subject.getcert(csr.to_pem)
- Puppet::SSL::Certificate.indirection.find(host).should be_nil
- Puppet::SSL::CertificateRequest.indirection.find(host).should be_a(Puppet::SSL::CertificateRequest)
+ Puppet::SSL::Certificate.find(host).should be_nil
+ Puppet::SSL::CertificateRequest.find(host).should be_a(Puppet::SSL::CertificateRequest)
end
it "should not return a cert" do
diff --git a/spec/unit/network/http/handler_spec.rb b/spec/unit/network/http/handler_spec.rb
index c709d82..32e5fd4 100755
--- a/spec/unit/network/http/handler_spec.rb
+++ b/spec/unit/network/http/handler_spec.rb
@@ -127,7 +127,7 @@ def stub_server_interface
describe "when finding a model instance" do
before do
- @indirection.stubs(:find).returns @result
+ @model_class.stubs(:find).returns @result
Puppet::Indirector::Indirection.expects(:instance).with(:my_handler).returns( stub "indirection", :model => @model_class )
@format = stub 'format', :suitable? => true, :mime => "text/format", :name => "format"
@@ -142,14 +142,14 @@ def stub_server_interface
end
it "should use the escaped request key" do
- @indirection.expects(:find).with do |key, args|
+ @model_class.expects(:find).with do |key, args|
key == "my_result"
end.returns @result
@handler.do_find("my_handler", "my_result", {}, @request, @response)
end
it "should use a common method for determining the request parameters" do
- @indirection.expects(:find).with do |key, args|
+ @model_class.expects(:find).with do |key, args|
args[:foo] == :baz and args[:bar] == :xyzzy
end.returns @result
@handler.do_find("my_handler", "my_result", {:foo => :baz, :bar => :xyzzy}, @request, @response)
@@ -192,7 +192,7 @@ def stub_server_interface
end
it "should pass the result through without rendering it if the result is a string" do
- @indirection.stubs(:find).returns "foo"
+ @model_class.stubs(:find).returns "foo"
@handler.expects(:set_response).with(@response, "foo")
@handler.do_find("my_handler", "my_result", {}, @request, @response)
end
@@ -207,20 +207,20 @@ def stub_server_interface
@model_instance.expects(:render).returns "my_rendered_object"
@handler.expects(:set_response).with { |response, body, status| body == "my_rendered_object" }
- @indirection.stubs(:find).returns(@model_instance)
+ @model_class.stubs(:find).returns(@model_instance)
@handler.do_find("my_handler", "my_result", {}, @request, @response)
end
it "should return a 404 when no model instance can be found" do
@model_class.stubs(:name).returns "my name"
@handler.expects(:set_response).with { |response, body, status| status == 404 }
- @indirection.stubs(:find).returns(nil)
+ @model_class.stubs(:find).returns(nil)
@handler.do_find("my_handler", "my_result", {}, @request, @response)
end
it "should write a log message when no model instance can be found" do
@model_class.stubs(:name).returns "my name"
- @indirection.stubs(:find).returns(nil)
+ @model_class.stubs(:find).returns(nil)
Puppet.expects(:info).with("Could not find my_handler for 'my_result'")
@@ -233,14 +233,14 @@ def stub_server_interface
@handler.expects(:format_to_use).returns(@oneformat)
@model_instance.expects(:render).with(@oneformat).returns "my_rendered_object"
- @indirection.stubs(:find).returns(@model_instance)
+ @model_class.stubs(:find).returns(@model_instance)
@handler.do_find("my_handler", "my_result", {}, @request, @response)
end
end
describe "when performing head operation" do
before do
- @handler.stubs(:model).with("my_handler").returns(stub 'model', :indirection => @model_class)
+ @handler.stubs(:model).with("my_handler").returns(@model_class)
@handler.stubs(:http_method).with(@request).returns("HEAD")
@handler.stubs(:path).with(@request).returns("/production/my_handler/my_result")
@handler.stubs(:params).with(@request).returns({})
@@ -276,7 +276,7 @@ def stub_server_interface
@result = [@result1, @result2]
@model_class.stubs(:render_multiple).returns "my rendered instances"
- @indirection.stubs(:search).returns(@result)
+ @model_class.stubs(:search).returns(@result)
@format = stub 'format', :suitable? => true, :mime => "text/format", :name => "format"
Puppet::Network::FormatHandler.stubs(:format).returns @format
@@ -290,14 +290,14 @@ def stub_server_interface
end
it "should use a common method for determining the request parameters" do
- @indirection.expects(:search).with do |key, args|
+ @model_class.expects(:search).with do |key, args|
args[:foo] == :baz and args[:bar] == :xyzzy
end.returns @result
@handler.do_search("my_handler", "my_result", {:foo => :baz, :bar => :xyzzy}, @request, @response)
end
it "should use the default status when a model search call succeeds" do
- @indirection.stubs(:search).returns(@result)
+ @model_class.stubs(:search).returns(@result)
@handler.do_search("my_handler", "my_result", {}, @request, @response)
end
@@ -311,7 +311,7 @@ def stub_server_interface
it "should return a list of serialized objects when a model search call succeeds" do
@handler.expects(:accept_header).with(@request).returns "one,two"
- @indirection.stubs(:search).returns(@result)
+ @model_class.stubs(:search).returns(@result)
@model_class.expects(:render_multiple).with(@oneformat, @result).returns "my rendered instances"
@@ -321,7 +321,7 @@ def stub_server_interface
it "should return [] when searching returns an empty array" do
@handler.expects(:accept_header).with(@request).returns "one,two"
- @indirection.stubs(:search).returns([])
+ @model_class.stubs(:search).returns([])
@model_class.expects(:render_multiple).with(@oneformat, []).returns "[]"
@@ -332,7 +332,7 @@ def stub_server_interface
it "should return a 404 when searching returns nil" do
@model_class.stubs(:name).returns "my name"
@handler.expects(:set_response).with { |response, body, status| status == 404 }
- @indirection.stubs(:search).returns(nil)
+ @model_class.stubs(:search).returns(nil)
@handler.do_search("my_handler", "my_result", {}, @request, @response)
end
end
@@ -342,7 +342,7 @@ def stub_server_interface
Puppet::Indirector::Indirection.expects(:instance).with(:my_handler).returns( stub "indirection", :model => @model_class )
@result = stub 'result', :render => "the result"
- @indirection.stubs(:destroy).returns @result
+ @model_class.stubs(:destroy).returns @result
end
it "should use the indirection request to find the model" do
@@ -350,14 +350,14 @@ def stub_server_interface
end
it "should use the escaped request key to destroy the instance in the model" do
- @indirection.expects(:destroy).with do |key, args|
+ @model_class.expects(:destroy).with do |key, args|
key == "foo bar"
end
@handler.do_destroy("my_handler", "foo bar", {}, @request, @response)
end
it "should use a common method for determining the request parameters" do
- @indirection.expects(:destroy).with do |key, args|
+ @model_class.expects(:destroy).with do |key, args|
args[:foo] == :baz and args[:bar] == :xyzzy
end
@handler.do_destroy("my_handler", "my_result", {:foo => :baz, :bar => :xyzzy}, @request, @response)
@@ -370,7 +370,7 @@ def stub_server_interface
it "should return a yaml-encoded result when a model destroy call succeeds" do
@result = stub 'result', :to_yaml => "the result"
- @indirection.expects(:destroy).returns(@result)
+ @model_class.expects(:destroy).returns(@result)
@handler.expects(:set_response).with { |response, body, status| body == "the result" }
@@ -388,7 +388,6 @@ def stub_server_interface
@model_instance = stub('indirected model instance')
@model_class.stubs(:convert_from).returns(@model_instance)
- @indirection.stubs(:save)
@format = stub 'format', :suitable? => true, :name => "format", :mime => "text/format"
Puppet::Network::FormatHandler.stubs(:format).returns @format
@@ -397,12 +396,14 @@ def stub_server_interface
end
it "should use the indirection request to find the model" do
+ @model_instance.expects(:save)
@handler.do_save("my_handler", "my_result", {}, @request, @response)
end
it "should use the 'body' hook to retrieve the body of the request" do
@handler.expects(:body).returns "my body"
@model_class.expects(:convert_from).with { |format, body| body == "my body" }.returns @model_instance
+ @model_instance.expects(:save)
@handler.do_save("my_handler", "my_result", {}, @request, @response)
end
@@ -414,27 +415,30 @@ def stub_server_interface
end
it "should use a common method for determining the request parameters" do
- @indirection.expects(:save).with(@model_instance, 'key').once
+ @model_instance.expects(:save).with('key').once
@handler.do_save("my_handler", "key", {}, @request, @response)
end
it "should use the default status when a model save call succeeds" do
+ @model_instance.expects(:save).with('my_result').once
@handler.expects(:set_response).with { |response, body, status| status.nil? }
@handler.do_save("my_handler", "my_result", {}, @request, @response)
end
it "should return the yaml-serialized result when a model save call succeeds" do
- @indirection.stubs(:save).returns(@model_instance)
+ @model_instance.expects(:save).with('my_result').once.returns(@model_instance)
@model_instance.expects(:to_yaml).returns('foo')
@handler.do_save("my_handler", "my_result", {}, @request, @response)
end
it "should set the content to yaml" do
+ @model_instance.expects(:save).with('my_result').once.returns(@model_instance)
@handler.expects(:set_content_type).with(@response, @yamlformat)
@handler.do_save("my_handler", "my_result", {}, @request, @response)
end
it "should use the content-type header to know the body format" do
+ @model_instance.expects(:save).with('my_result').once.returns(@model_instance)
@handler.expects(:content_type_header).returns("text/format")
Puppet::Network::FormatHandler.stubs(:mime).with("text/format").returns @format
diff --git a/spec/unit/network/http/webrick_spec.rb b/spec/unit/network/http/webrick_spec.rb
index f84e78e..43f015e 100755
--- a/spec/unit/network/http/webrick_spec.rb
+++ b/spec/unit/network/http/webrick_spec.rb
@@ -278,7 +278,7 @@
@cert = stub 'cert', :content => "mycert"
@host = stub 'host', :key => @key, :certificate => @cert, :name => "yay", :ssl_store => "mystore"
- Puppet::SSL::Certificate.indirection.stubs(:find).with('ca').returns @cert
+ Puppet::SSL::Certificate.stubs(:find).with('ca').returns @cert
Puppet::SSL::Host.stubs(:localhost).returns @host
end
@@ -295,7 +295,7 @@
end
it "should fail if no CA certificate can be found" do
- Puppet::SSL::Certificate.indirection.stubs(:find).with('ca').returns nil
+ Puppet::SSL::Certificate.stubs(:find).with('ca').returns nil
lambda { @server.setup_ssl }.should raise_error(Puppet::Error)
end
diff --git a/spec/unit/node/facts_spec.rb b/spec/unit/node/facts_spec.rb
index 4514607..f8bd465 100755
--- a/spec/unit/node/facts_spec.rb
+++ b/spec/unit/node/facts_spec.rb
@@ -74,20 +74,20 @@
it "should redirect to the specified fact store for storage" do
Puppet::Node::Facts.stubs(:indirection).returns(@indirection)
@indirection.expects(:save)
- Puppet::Node::Facts.indirection.save(@facts)
+ @facts.save
end
describe "when the Puppet application is 'master'" do
it "should default to the 'yaml' terminus" do
pending "Cannot test the behavior of defaults in defaults.rb"
- # Puppet::Node::Facts.indirection.terminus_class.should == :yaml
+ # Puppet::Node::Facts.terminus_class.should == :yaml
end
end
describe "when the Puppet application is not 'master'" do
it "should default to the 'facter' terminus" do
pending "Cannot test the behavior of defaults in defaults.rb"
- # Puppet::Node::Facts.indirection.terminus_class.should == :facter
+ # Puppet::Node::Facts.terminus_class.should == :facter
end
end
diff --git a/spec/unit/node_spec.rb b/spec/unit/node_spec.rb
index 33bb4d1..7a2e76c 100755
--- a/spec/unit/node_spec.rb
+++ b/spec/unit/node_spec.rb
@@ -84,11 +84,11 @@
describe Puppet::Node, "when merging facts" do
before do
@node = Puppet::Node.new("testnode")
- Puppet::Node::Facts.indirection.stubs(:find).with(@node.name).returns(Puppet::Node::Facts.new(@node.name, "one" => "c", "two" => "b"))
+ Puppet::Node::Facts.stubs(:find).with(@node.name).returns(Puppet::Node::Facts.new(@node.name, "one" => "c", "two" => "b"))
end
it "should fail intelligently if it cannot find facts" do
- Puppet::Node::Facts.indirection.expects(:find).with(@node.name).raises "foo"
+ Puppet::Node::Facts.expects(:find).with(@node.name).raises "foo"
lambda { @node.fact_merge }.should raise_error(Puppet::Error)
end
@@ -129,9 +129,8 @@
describe Puppet::Node, "when indirecting" do
it "should default to the 'plain' node terminus" do
- Puppet::Node.indirection.reset_terminus_class
-
- Puppet::Node.indirection.terminus_class.should == :plain
+ Puppet::Node.terminus_class = nil
+ Puppet::Node.terminus_class.should == :plain
end
end
diff --git a/spec/unit/resource/catalog_spec.rb b/spec/unit/resource/catalog_spec.rb
index 7406e29..3a0b8a5 100755
--- a/spec/unit/resource/catalog_spec.rb
+++ b/spec/unit/resource/catalog_spec.rb
@@ -886,19 +886,19 @@ def self.title_patterns
# Puppet only checks the terminus setting the first time you ask
# so this returns the object to the clean state
# at the expense of making this test less pure
- Puppet::Resource::Catalog.indirection.reset_terminus_class
+ Puppet::Resource::Catalog.terminus_class = nil
Puppet.settings[:catalog_terminus] = "rest"
- Puppet::Resource::Catalog.indirection.terminus_class.should == :rest
+ Puppet::Resource::Catalog.terminus_class.should == :rest
end
it "should allow the terminus class to be set manually" do
- Puppet::Resource::Catalog.indirection.terminus_class = :rest
- Puppet::Resource::Catalog.indirection.terminus_class.should == :rest
+ Puppet::Resource::Catalog.terminus_class = :rest
+ Puppet::Resource::Catalog.terminus_class.should == :rest
end
after do
- @real_indirection.reset_terminus_class
+ @real_indirection.terminus_class = nil
end
end
diff --git a/spec/unit/resource/type_spec.rb b/spec/unit/resource/type_spec.rb
index 352f767..027ebe7 100755
--- a/spec/unit/resource/type_spec.rb
+++ b/spec/unit/resource/type_spec.rb
@@ -27,7 +27,7 @@
end
it "should default to 'parser' for its terminus class" do
- Puppet::Resource::Type.indirection.terminus_class.should == :parser
+ Puppet::Resource::Type.terminus_class.should == :parser
end
describe "when converting to json" do
diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb
index 7c2c6ac..52a3735 100755
--- a/spec/unit/resource_spec.rb
+++ b/spec/unit/resource_spec.rb
@@ -770,7 +770,7 @@ def pson_result_should
end
it "should have a default terminus" do
- Puppet::Resource.indirection.terminus_class.should be
+ Puppet::Resource.terminus_class.should be
end
it "should have a name" do
diff --git a/spec/unit/ssl/certificate_authority/interface_spec.rb b/spec/unit/ssl/certificate_authority/interface_spec.rb
index 41a57b8..6e82b9c 100755
--- a/spec/unit/ssl/certificate_authority/interface_spec.rb
+++ b/spec/unit/ssl/certificate_authority/interface_spec.rb
@@ -202,8 +202,8 @@
@cert.stubs(:subject_alt_names).returns []
@csr.stubs(:subject_alt_names).returns []
- Puppet::SSL::Certificate.indirection.stubs(:find).returns @cert
- Puppet::SSL::CertificateRequest.indirection.stubs(:find).returns @csr
+ Puppet::SSL::Certificate.stubs(:find).returns @cert
+ Puppet::SSL::CertificateRequest.stubs(:find).returns @csr
@ca.expects(:waiting?).returns %w{host1 host2 host3}
@ca.expects(:list).returns %w{host4 host5 host6}
diff --git a/spec/unit/ssl/certificate_authority_spec.rb b/spec/unit/ssl/certificate_authority_spec.rb
index 222b72e..feaf2ce 100755
--- a/spec/unit/ssl/certificate_authority_spec.rb
+++ b/spec/unit/ssl/certificate_authority_spec.rb
@@ -137,18 +137,18 @@ def stub_ca_host
it "should return any found CRL instance" do
crl = mock 'crl'
- Puppet::SSL::CertificateRevocationList.indirection.expects(:find).returns crl
+ Puppet::SSL::CertificateRevocationList.expects(:find).returns crl
@ca.crl.should equal(crl)
end
it "should create, generate, and save a new CRL instance of no CRL can be found" do
crl = Puppet::SSL::CertificateRevocationList.new("fakename")
- Puppet::SSL::CertificateRevocationList.indirection.expects(:find).returns nil
+ Puppet::SSL::CertificateRevocationList.expects(:find).returns nil
Puppet::SSL::CertificateRevocationList.expects(:new).returns crl
crl.expects(:generate).with(@ca.host.certificate.content, @ca.host.key.content)
- Puppet::SSL::CertificateRevocationList.indirection.expects(:save).with(crl)
+ Puppet::SSL::CertificateRevocationList.expects(:save).with(crl, nil)
@ca.crl.should equal(crl)
end
@@ -241,7 +241,7 @@ def stub_ca_host
Puppet::SSL::Certificate.stubs(:new).returns @cert
@cert.stubs(:content=)
- Puppet::SSL::Certificate.indirection.stubs(:save)
+ Puppet::SSL::Certificate.stubs(:save)
# Stub out the factory
Puppet::SSL::CertificateFactory.stubs(:build).returns "my real cert"
@@ -253,7 +253,7 @@ def stub_ca_host
@inventory = stub 'inventory', :add => nil
@ca.stubs(:inventory).returns @inventory
- Puppet::SSL::CertificateRequest.indirection.stubs(:destroy)
+ Puppet::SSL::CertificateRequest.stubs(:destroy)
end
describe "and calculating the next certificate serial number" do
@@ -296,7 +296,7 @@ def stub_ca_host
end
it "should not look up a certificate request for the host" do
- Puppet::SSL::CertificateRequest.indirection.expects(:find).never
+ Puppet::SSL::CertificateRequest.expects(:find).never
@ca.sign(@name, true, @request)
end
@@ -338,7 +338,7 @@ def stub_ca_host
end
it "should save the resulting certificate" do
- Puppet::SSL::Certificate.indirection.expects(:save).with(@cert)
+ Puppet::SSL::Certificate.expects(:save).with(@cert, nil)
@ca.sign(@name, :ca, @request)
end
@@ -349,8 +349,8 @@ def stub_ca_host
@serial = 10
@ca.stubs(:next_serial).returns @serial
- Puppet::SSL::CertificateRequest.indirection.stubs(:find).with(@name).returns @request
- Puppet::SSL::CertificateRequest.indirection.stubs :save
+ Puppet::SSL::CertificateRequest.stubs(:find).with(@name).returns @request
+ Puppet::SSL::CertificateRequest.stubs :save
end
it "should use a certificate type of :server" do
@@ -362,13 +362,13 @@ def stub_ca_host
end
it "should use look up a CSR for the host in the :ca_file terminus" do
- Puppet::SSL::CertificateRequest.indirection.expects(:find).with(@name).returns @request
+ Puppet::SSL::CertificateRequest.expects(:find).with(@name).returns @request
@ca.sign(@name)
end
it "should fail if no CSR can be found for the host" do
- Puppet::SSL::CertificateRequest.indirection.expects(:find).with(@name).returns nil
+ Puppet::SSL::CertificateRequest.expects(:find).with(@name).returns nil
lambda { @ca.sign(@name) }.should raise_error(ArgumentError)
end
@@ -427,12 +427,12 @@ def stub_ca_host
end
it "should save the resulting certificate" do
- Puppet::SSL::Certificate.indirection.stubs(:save).with(@cert)
+ Puppet::SSL::Certificate.stubs(:save).with(@cert)
@ca.sign(@name)
end
it "should remove the host's certificate request" do
- Puppet::SSL::CertificateRequest.indirection.expects(:destroy).with(@name)
+ Puppet::SSL::CertificateRequest.expects(:destroy).with(@name)
@ca.sign(@name)
end
@@ -448,7 +448,7 @@ def stub_ca_host
@serial = 10
@ca.stubs(:next_serial).returns @serial
- Puppet::SSL::CertificateRequest.indirection.stubs(:find).with(@name).returns @request
+ Puppet::SSL::CertificateRequest.stubs(:find).with(@name).returns @request
@cert.stubs :save
end
@@ -516,8 +516,8 @@ def stub_ca_host
@serial = 10
@ca.stubs(:next_serial).returns @serial
- Puppet::SSL::CertificateRequest.indirection.stubs(:find).with(@name).returns @request
- Puppet::SSL::Certificate.indirection.stubs :save
+ Puppet::SSL::CertificateRequest.stubs(:find).with(@name).returns @request
+ Puppet::SSL::Certificate.stubs :save
Puppet::SSL::Certificate.expects(:new).with(@name).returns @cert
@ca.sign(@name)
@@ -525,8 +525,8 @@ def stub_ca_host
it "should return the certificate instance" do
@ca.stubs(:next_serial).returns @serial
- Puppet::SSL::CertificateRequest.indirection.stubs(:find).with(@name).returns @request
- Puppet::SSL::Certificate.indirection.stubs :save
+ Puppet::SSL::CertificateRequest.stubs(:find).with(@name).returns @request
+ Puppet::SSL::Certificate.stubs :save
@ca.sign(@name).should equal(@cert)
end
@@ -534,8 +534,8 @@ def stub_ca_host
@ca.stubs(:next_serial).returns @serial
@inventory.expects(:add).with(@cert)
- Puppet::SSL::CertificateRequest.indirection.stubs(:find).with(@name).returns @request
- Puppet::SSL::Certificate.indirection.stubs :save
+ Puppet::SSL::CertificateRequest.stubs(:find).with(@name).returns @request
+ Puppet::SSL::Certificate.stubs :save
@ca.sign(@name)
end
@@ -547,7 +547,7 @@ def stub_ca_host
it "should do nothing if autosign is disabled" do
Puppet.settings.expects(:value).with(:autosign).returns 'false'
- Puppet::SSL::CertificateRequest.indirection.expects(:search).never
+ Puppet::SSL::CertificateRequest.expects(:search).never
@ca.autosign
end
@@ -555,7 +555,7 @@ def stub_ca_host
Puppet.settings.expects(:value).with(:autosign).returns '/auto/sign'
FileTest.expects(:exist?).with("/auto/sign").returns false
- Puppet::SSL::CertificateRequest.indirection.expects(:search).never
+ Puppet::SSL::CertificateRequest.expects(:search).never
@ca.autosign
end
@@ -565,7 +565,7 @@ def stub_ca_host
FileTest.stubs(:exist?).with("/auto/sign").returns true
File.stubs(:readlines).with("/auto/sign").returns ["one\n", "two\n"]
- Puppet::SSL::CertificateRequest.indirection.stubs(:search).returns []
+ Puppet::SSL::CertificateRequest.stubs(:search).returns []
@store = stub 'store', :allow => nil
Puppet::Network::AuthStore.stubs(:new).returns @store
@@ -606,13 +606,13 @@ def stub_ca_host
it "should sign all CSRs whose hostname matches the autosign configuration" do
csr1 = mock 'csr1'
csr2 = mock 'csr2'
- Puppet::SSL::CertificateRequest.indirection.stubs(:search).returns [csr1, csr2]
+ Puppet::SSL::CertificateRequest.stubs(:search).returns [csr1, csr2]
end
it "should not sign CSRs whose hostname does not match the autosign configuration" do
csr1 = mock 'csr1'
csr2 = mock 'csr2'
- Puppet::SSL::CertificateRequest.indirection.stubs(:search).returns [csr1, csr2]
+ Puppet::SSL::CertificateRequest.stubs(:search).returns [csr1, csr2]
end
end
end
@@ -659,7 +659,7 @@ def stub_ca_host
it "should be able to list waiting certificate requests" do
req1 = stub 'req1', :name => "one"
req2 = stub 'req2', :name => "two"
- Puppet::SSL::CertificateRequest.indirection.expects(:search).with("*").returns [req1, req2]
+ Puppet::SSL::CertificateRequest.expects(:search).with("*").returns [req1, req2]
@ca.waiting?.should == %w{one two}
end
@@ -677,19 +677,19 @@ def stub_ca_host
it "should list certificates as the sorted list of all existing signed certificates" do
cert1 = stub 'cert1', :name => "cert1"
cert2 = stub 'cert2', :name => "cert2"
- Puppet::SSL::Certificate.indirection.expects(:search).with("*").returns [cert1, cert2]
+ Puppet::SSL::Certificate.expects(:search).with("*").returns [cert1, cert2]
@ca.list.should == %w{cert1 cert2}
end
describe "and printing certificates" do
it "should return nil if the certificate cannot be found" do
- Puppet::SSL::Certificate.indirection.expects(:find).with("myhost").returns nil
+ Puppet::SSL::Certificate.expects(:find).with("myhost").returns nil
@ca.print("myhost").should be_nil
end
it "should print certificates by calling :to_text on the host's certificate" do
cert1 = stub 'cert1', :name => "cert1", :to_text => "mytext"
- Puppet::SSL::Certificate.indirection.expects(:find).with("myhost").returns cert1
+ Puppet::SSL::Certificate.expects(:find).with("myhost").returns cert1
@ca.print("myhost").should == "mytext"
end
end
@@ -697,19 +697,19 @@ def stub_ca_host
describe "and fingerprinting certificates" do
before :each do
@cert = stub 'cert', :name => "cert", :fingerprint => "DIGEST"
- Puppet::SSL::Certificate.indirection.stubs(:find).with("myhost").returns @cert
- Puppet::SSL::CertificateRequest.indirection.stubs(:find).with("myhost")
+ Puppet::SSL::Certificate.stubs(:find).with("myhost").returns @cert
+ Puppet::SSL::CertificateRequest.stubs(:find).with("myhost")
end
it "should raise an error if the certificate or CSR cannot be found" do
- Puppet::SSL::Certificate.indirection.expects(:find).with("myhost").returns nil
- Puppet::SSL::CertificateRequest.indirection.expects(:find).with("myhost").returns nil
+ Puppet::SSL::Certificate.expects(:find).with("myhost").returns nil
+ Puppet::SSL::CertificateRequest.expects(:find).with("myhost").returns nil
lambda { @ca.fingerprint("myhost") }.should raise_error
end
it "should try to find a CSR if no certificate can be found" do
- Puppet::SSL::Certificate.indirection.expects(:find).with("myhost").returns nil
- Puppet::SSL::CertificateRequest.indirection.expects(:find).with("myhost").returns @cert
+ Puppet::SSL::Certificate.expects(:find).with("myhost").returns nil
+ Puppet::SSL::CertificateRequest.expects(:find).with("myhost").returns @cert
@cert.expects(:fingerprint)
@ca.fingerprint("myhost")
end
@@ -734,7 +734,7 @@ def stub_ca_host
Puppet.settings.stubs(:value).returns "crtstuff"
@cert = stub 'cert', :content => "mycert"
- Puppet::SSL::Certificate.indirection.stubs(:find).returns @cert
+ Puppet::SSL::Certificate.stubs(:find).returns @cert
@crl = stub('crl', :content => "mycrl")
@@ -742,7 +742,7 @@ def stub_ca_host
end
it "should fail if the host's certificate cannot be found" do
- Puppet::SSL::Certificate.indirection.expects(:find).with("me").returns(nil)
+ Puppet::SSL::Certificate.expects(:find).with("me").returns(nil)
lambda { @ca.verify("me") }.should raise_error(ArgumentError)
end
@@ -805,7 +805,7 @@ def stub_ca_host
@real_cert = stub 'real_cert', :serial => 15
@cert = stub 'cert', :content => @real_cert
- Puppet::SSL::Certificate.indirection.stubs(:find).returns @cert
+ Puppet::SSL::Certificate.stubs(:find).returns @cert
end
@@ -825,7 +825,7 @@ def stub_ca_host
it "should get the serial number from the local certificate if it exists" do
@ca.crl.expects(:revoke).with { |serial, key| serial == 15 }
- Puppet::SSL::Certificate.indirection.expects(:find).with("host").returns @cert
+ Puppet::SSL::Certificate.expects(:find).with("host").returns @cert
@ca.revoke('host')
end
@@ -833,7 +833,7 @@ def stub_ca_host
it "should get the serial number from inventory if no local certificate exists" do
real_cert = stub 'real_cert', :serial => 15
cert = stub 'cert', :content => real_cert
- Puppet::SSL::Certificate.indirection.expects(:find).with("host").returns nil
+ Puppet::SSL::Certificate.expects(:find).with("host").returns nil
@ca.inventory.expects(:serial).with("host").returns 16
@@ -850,13 +850,13 @@ def stub_ca_host
before do
@host = stub 'host', :generate_certificate_request => nil
Puppet::SSL::Host.stubs(:new).returns @host
- Puppet::SSL::Certificate.indirection.stubs(:find).returns nil
+ Puppet::SSL::Certificate.stubs(:find).returns nil
@ca.stubs(:sign)
end
it "should fail if a certificate already exists for the host" do
- Puppet::SSL::Certificate.indirection.expects(:find).with("him").returns "something"
+ Puppet::SSL::Certificate.expects(:find).with("him").returns "something"
lambda { @ca.generate("him") }.should raise_error(ArgumentError)
end
diff --git a/spec/unit/ssl/certificate_request_spec.rb b/spec/unit/ssl/certificate_request_spec.rb
index 9a27397..ddbfb70 100755
--- a/spec/unit/ssl/certificate_request_spec.rb
+++ b/spec/unit/ssl/certificate_request_spec.rb
@@ -257,7 +257,7 @@
Puppet::SSL::CertificateRequest.indirection.expects(:prepare).returns(terminus)
terminus.expects(:save).with { |request| request.instance == csr && request.key == "me" }
- Puppet::SSL::CertificateRequest.indirection.save(csr)
+ csr.save
end
end
@@ -270,7 +270,7 @@
Puppet::SSL::CertificateRequest.indirection.expects(:prepare).returns(terminus)
terminus.expects(:save).with { |request| request.instance == csr && request.key == "me" }
- Puppet::SSL::CertificateRequest.indirection.save(csr)
+ csr.save
end
end
end
diff --git a/spec/unit/ssl/certificate_revocation_list_spec.rb b/spec/unit/ssl/certificate_revocation_list_spec.rb
index 99058b3..d2f195c 100755
--- a/spec/unit/ssl/certificate_revocation_list_spec.rb
+++ b/spec/unit/ssl/certificate_revocation_list_spec.rb
@@ -118,7 +118,7 @@
@crl.generate(@cert, @key)
@crl.content.stubs(:sign)
- Puppet::SSL::CertificateRevocationList.indirection.stubs :save
+ Puppet::SSL::CertificateRevocationList.stubs :save
@key = mock 'key'
end
@@ -160,7 +160,7 @@
end
it "should save the CRL" do
- Puppet::SSL::CertificateRevocationList.indirection.expects(:save).with(@crl, nil)
+ Puppet::SSL::CertificateRevocationList.expects(:save).with(@crl, nil)
@crl.revoke(1, @key)
end
end
diff --git a/spec/unit/ssl/host_spec.rb b/spec/unit/ssl/host_spec.rb
index dd64343..1f2134e 100755
--- a/spec/unit/ssl/host_spec.rb
+++ b/spec/unit/ssl/host_spec.rb
@@ -7,7 +7,7 @@
include PuppetSpec::Files
before do
- Puppet::SSL::Host.indirection.terminus_class = :file
+ Puppet::SSL::Host.terminus_class = :file
# Get a safe temporary file
dir = tmpdir("ssl_host_testing")
@@ -31,7 +31,7 @@
it "should retrieve its public key from its private key" do
realkey = mock 'realkey'
key = stub 'key', :content => realkey
- Puppet::SSL::Key.indirection.stubs(:find).returns(key)
+ Puppet::SSL::Key.stubs(:find).returns(key)
pubkey = mock 'public_key'
realkey.expects(:public_key).returns pubkey
@@ -97,12 +97,13 @@
before :each do
@key = stub('key content')
key = stub('key', :generate => true, :content => @key)
+ key.stubs(:save).returns(key)
Puppet::SSL::Key.stubs(:new).returns key
- Puppet::SSL::Key.indirection.stubs(:save).with(key)
+ Puppet::SSL::Key.stubs(:save).with(key)
@cr = stub('certificate request')
+ @cr.stubs(:save).returns(@cr)
Puppet::SSL::CertificateRequest.stubs(:new).returns @cr
- Puppet::SSL::CertificateRequest.indirection.stubs(:save).with(@cr)
end
describe "explicitly specified" do
@@ -112,7 +113,6 @@
it "should not include subjectAltName if not the local node" do
@cr.expects(:generate).with(@key, {})
-
Puppet::SSL::Host.new('not-the-' + Puppet[:certname]).generate
end
@@ -262,20 +262,20 @@
end
it "should set the cache class for Certificate, CertificateRevocationList, and CertificateRequest as :file" do
- Puppet::SSL::Certificate.indirection.cache_class.should == :file
- Puppet::SSL::CertificateRequest.indirection.cache_class.should == :file
- Puppet::SSL::CertificateRevocationList.indirection.cache_class.should == :file
+ Puppet::SSL::Certificate.cache_class.should == :file
+ Puppet::SSL::CertificateRequest.cache_class.should == :file
+ Puppet::SSL::CertificateRevocationList.cache_class.should == :file
end
it "should set the terminus class for Key and Host as :file" do
- Puppet::SSL::Key.indirection.terminus_class.should == :file
- Puppet::SSL::Host.indirection.terminus_class.should == :file
+ Puppet::SSL::Key.terminus_class.should == :file
+ Puppet::SSL::Host.terminus_class.should == :file
end
it "should set the terminus class for Certificate, CertificateRevocationList, and CertificateRequest as :ca" do
- Puppet::SSL::Certificate.indirection.terminus_class.should == :ca
- Puppet::SSL::CertificateRequest.indirection.terminus_class.should == :ca
- Puppet::SSL::CertificateRevocationList.indirection.terminus_class.should == :ca
+ Puppet::SSL::Certificate.terminus_class.should == :ca
+ Puppet::SSL::CertificateRequest.terminus_class.should == :ca
+ Puppet::SSL::CertificateRevocationList.terminus_class.should == :ca
end
end
@@ -285,20 +285,20 @@
end
it "should set the cache class for Certificate, CertificateRevocationList, and CertificateRequest as :file" do
- Puppet::SSL::Certificate.indirection.cache_class.should == :file
- Puppet::SSL::CertificateRequest.indirection.cache_class.should == :file
- Puppet::SSL::CertificateRevocationList.indirection.cache_class.should == :file
+ Puppet::SSL::Certificate.cache_class.should == :file
+ Puppet::SSL::CertificateRequest.cache_class.should == :file
+ Puppet::SSL::CertificateRevocationList.cache_class.should == :file
end
it "should set the terminus class for Key as :file" do
- Puppet::SSL::Key.indirection.terminus_class.should == :file
+ Puppet::SSL::Key.terminus_class.should == :file
end
it "should set the terminus class for Host, Certificate, CertificateRevocationList, and CertificateRequest as :rest" do
- Puppet::SSL::Host.indirection.terminus_class.should == :rest
- Puppet::SSL::Certificate.indirection.terminus_class.should == :rest
- Puppet::SSL::CertificateRequest.indirection.terminus_class.should == :rest
- Puppet::SSL::CertificateRevocationList.indirection.terminus_class.should == :rest
+ Puppet::SSL::Host.terminus_class.should == :rest
+ Puppet::SSL::Certificate.terminus_class.should == :rest
+ Puppet::SSL::CertificateRequest.terminus_class.should == :rest
+ Puppet::SSL::CertificateRevocationList.terminus_class.should == :rest
end
end
@@ -308,20 +308,20 @@
end
it "should set the terminus class for Key, Certificate, CertificateRevocationList, and CertificateRequest as :ca" do
- Puppet::SSL::Key.indirection.terminus_class.should == :ca
- Puppet::SSL::Certificate.indirection.terminus_class.should == :ca
- Puppet::SSL::CertificateRequest.indirection.terminus_class.should == :ca
- Puppet::SSL::CertificateRevocationList.indirection.terminus_class.should == :ca
+ Puppet::SSL::Key.terminus_class.should == :ca
+ Puppet::SSL::Certificate.terminus_class.should == :ca
+ Puppet::SSL::CertificateRequest.terminus_class.should == :ca
+ Puppet::SSL::CertificateRevocationList.terminus_class.should == :ca
end
it "should set the cache class for Certificate, CertificateRevocationList, and CertificateRequest to nil" do
- Puppet::SSL::Certificate.indirection.cache_class.should be_nil
- Puppet::SSL::CertificateRequest.indirection.cache_class.should be_nil
- Puppet::SSL::CertificateRevocationList.indirection.cache_class.should be_nil
+ Puppet::SSL::Certificate.cache_class.should be_nil
+ Puppet::SSL::CertificateRequest.cache_class.should be_nil
+ Puppet::SSL::CertificateRevocationList.cache_class.should be_nil
end
it "should set the terminus class for Host to :file" do
- Puppet::SSL::Host.indirection.terminus_class.should == :file
+ Puppet::SSL::Host.terminus_class.should == :file
end
end
@@ -331,14 +331,14 @@
end
it "should set the terminus class for Key, Certificate, CertificateRevocationList, and CertificateRequest as :file" do
- Puppet::SSL::Key.indirection.terminus_class.should == :file
- Puppet::SSL::Certificate.indirection.terminus_class.should == :file
- Puppet::SSL::CertificateRequest.indirection.terminus_class.should == :file
- Puppet::SSL::CertificateRevocationList.indirection.terminus_class.should == :file
+ Puppet::SSL::Key.terminus_class.should == :file
+ Puppet::SSL::Certificate.terminus_class.should == :file
+ Puppet::SSL::CertificateRequest.terminus_class.should == :file
+ Puppet::SSL::CertificateRevocationList.terminus_class.should == :file
end
it "should set the terminus class for Host to 'none'" do
- lambda { Puppet::SSL::Host.indirection.terminus_class }.should raise_error(Puppet::DevError)
+ lambda { Puppet::SSL::Host.terminus_class }.should raise_error(Puppet::DevError)
end
end
end
@@ -349,21 +349,21 @@
describe "when destroying a host's SSL files" do
before do
- Puppet::SSL::Key.indirection.stubs(:destroy).returns false
- Puppet::SSL::Certificate.indirection.stubs(:destroy).returns false
- Puppet::SSL::CertificateRequest.indirection.stubs(:destroy).returns false
+ Puppet::SSL::Key.stubs(:destroy).returns false
+ Puppet::SSL::Certificate.stubs(:destroy).returns false
+ Puppet::SSL::CertificateRequest.stubs(:destroy).returns false
end
it "should destroy its certificate, certificate request, and key" do
- Puppet::SSL::Key.indirection.expects(:destroy).with("myhost")
- Puppet::SSL::Certificate.indirection.expects(:destroy).with("myhost")
- Puppet::SSL::CertificateRequest.indirection.expects(:destroy).with("myhost")
+ Puppet::SSL::Key.expects(:destroy).with("myhost")
+ Puppet::SSL::Certificate.expects(:destroy).with("myhost")
+ Puppet::SSL::CertificateRequest.expects(:destroy).with("myhost")
Puppet::SSL::Host.destroy("myhost")
end
it "should return true if any of the classes returned true" do
- Puppet::SSL::Certificate.indirection.expects(:destroy).with("myhost").returns true
+ Puppet::SSL::Certificate.expects(:destroy).with("myhost").returns true
Puppet::SSL::Host.destroy("myhost").should be_true
end
@@ -403,12 +403,12 @@
end
it "should return nil if the key is not set and cannot be found" do
- Puppet::SSL::Key.indirection.expects(:find).with("myname").returns(nil)
+ Puppet::SSL::Key.expects(:find).with("myname").returns(nil)
@host.key.should be_nil
end
it "should find the key in the Key class and return the Puppet instance" do
- Puppet::SSL::Key.indirection.expects(:find).with("myname").returns(@key)
+ Puppet::SSL::Key.expects(:find).with("myname").returns(@key)
@host.key.should equal(@key)
end
@@ -416,7 +416,7 @@
Puppet::SSL::Key.expects(:new).with("myname").returns(@key)
@key.expects(:generate)
- Puppet::SSL::Key.indirection.expects(:save)
+ Puppet::SSL::Key.expects(:save)
@host.generate_key.should be_true
@host.key.should equal(@key)
@@ -426,14 +426,14 @@
Puppet::SSL::Key.expects(:new).with("myname").returns(@key)
@key.stubs(:generate)
- Puppet::SSL::Key.indirection.expects(:save).raises "eh"
+ Puppet::SSL::Key.expects(:save).raises "eh"
lambda { @host.generate_key }.should raise_error
@host.key.should be_nil
end
it "should return any previously found key without requerying" do
- Puppet::SSL::Key.indirection.expects(:find).with("myname").returns(@key).once
+ Puppet::SSL::Key.expects(:find).with("myname").returns(@key).once
@host.key.should equal(@key)
@host.key.should equal(@key)
end
@@ -447,12 +447,12 @@
end
it "should return nil if the key is not set and cannot be found" do
- Puppet::SSL::CertificateRequest.indirection.expects(:find).with("myname").returns(nil)
+ Puppet::SSL::CertificateRequest.expects(:find).with("myname").returns(nil)
@host.certificate_request.should be_nil
end
it "should find the request in the Key class and return it and return the Puppet SSL request" do
- Puppet::SSL::CertificateRequest.indirection.expects(:find).with("myname").returns @request
+ Puppet::SSL::CertificateRequest.expects(:find).with("myname").returns @request
@host.certificate_request.should equal(@request)
end
@@ -466,7 +466,7 @@
@host.expects(:generate_key).returns(key)
@request.stubs(:generate)
- Puppet::SSL::CertificateRequest.indirection.stubs(:save)
+ Puppet::SSL::CertificateRequest.stubs(:save)
@host.generate_certificate_request
end
@@ -477,14 +477,14 @@
key = stub 'key', :public_key => mock("public_key"), :content => "mycontent"
@host.stubs(:key).returns(key)
@request.expects(:generate).with("mycontent", {})
- Puppet::SSL::CertificateRequest.indirection.expects(:save).with(@request)
+ Puppet::SSL::CertificateRequest.expects(:save).with(@request, nil)
@host.generate_certificate_request.should be_true
@host.certificate_request.should equal(@request)
end
it "should return any previously found request without requerying" do
- Puppet::SSL::CertificateRequest.indirection.expects(:find).with("myname").returns(@request).once
+ Puppet::SSL::CertificateRequest.expects(:find).with("myname").returns(@request).once
@host.certificate_request.should equal(@request)
@host.certificate_request.should equal(@request)
@@ -517,36 +517,36 @@
end
it "should find the CA certificate if it does not have a certificate" do
- Puppet::SSL::Certificate.indirection.expects(:find).with(Puppet::SSL::CA_NAME).returns mock("cacert")
- Puppet::SSL::Certificate.indirection.stubs(:find).with("myname").returns @cert
+ Puppet::SSL::Certificate.expects(:find).with(Puppet::SSL::CA_NAME).returns mock("cacert")
+ Puppet::SSL::Certificate.stubs(:find).with("myname").returns @cert
@host.certificate
end
it "should not find the CA certificate if it is the CA host" do
@host.expects(:ca?).returns true
- Puppet::SSL::Certificate.indirection.stubs(:find)
- Puppet::SSL::Certificate.indirection.expects(:find).with(Puppet::SSL::CA_NAME).never
+ Puppet::SSL::Certificate.stubs(:find)
+ Puppet::SSL::Certificate.expects(:find).with(Puppet::SSL::CA_NAME).never
@host.certificate
end
it "should return nil if it cannot find a CA certificate" do
- Puppet::SSL::Certificate.indirection.expects(:find).with(Puppet::SSL::CA_NAME).returns nil
- Puppet::SSL::Certificate.indirection.expects(:find).with("myname").never
+ Puppet::SSL::Certificate.expects(:find).with(Puppet::SSL::CA_NAME).returns nil
+ Puppet::SSL::Certificate.expects(:find).with("myname").never
@host.certificate.should be_nil
end
it "should find the key if it does not have one" do
- Puppet::SSL::Certificate.indirection.stubs(:find)
+ Puppet::SSL::Certificate.stubs(:find)
@host.expects(:key).returns mock("key")
@host.certificate
end
it "should generate the key if one cannot be found" do
- Puppet::SSL::Certificate.indirection.stubs(:find)
+ Puppet::SSL::Certificate.stubs(:find)
@host.expects(:key).returns nil
@host.expects(:generate_key)
@@ -555,8 +555,8 @@
end
it "should find the certificate in the Certificate class and return the Puppet certificate instance" do
- Puppet::SSL::Certificate.indirection.expects(:find).with(Puppet::SSL::CA_NAME).returns mock("cacert")
- Puppet::SSL::Certificate.indirection.expects(:find).with("myname").returns @cert
+ Puppet::SSL::Certificate.expects(:find).with(Puppet::SSL::CA_NAME).returns mock("cacert")
+ Puppet::SSL::Certificate.expects(:find).with("myname").returns @cert
@host.certificate.should equal(@cert)
end
@@ -564,14 +564,14 @@
it "should fail if the found certificate does not match the private key" do
@host.expects(:certificate_matches_key?).returns false
- Puppet::SSL::Certificate.indirection.stubs(:find).returns @cert
+ Puppet::SSL::Certificate.stubs(:find).returns @cert
lambda { @host.certificate }.should raise_error(Puppet::Error)
end
it "should return any previously found certificate" do
- Puppet::SSL::Certificate.indirection.expects(:find).with(Puppet::SSL::CA_NAME).returns mock("cacert")
- Puppet::SSL::Certificate.indirection.expects(:find).with("myname").returns(@cert).once
+ Puppet::SSL::Certificate.expects(:find).with(Puppet::SSL::CA_NAME).returns mock("cacert")
+ Puppet::SSL::Certificate.expects(:find).with("myname").returns(@cert).once
@host.certificate.should equal(@cert)
@host.certificate.should equal(@cert)
@@ -584,30 +584,30 @@
describe "when listing certificate hosts" do
it "should default to listing all clients with any file types" do
- Puppet::SSL::Key.indirection.expects(:search).returns []
- Puppet::SSL::Certificate.indirection.expects(:search).returns []
- Puppet::SSL::CertificateRequest.indirection.expects(:search).returns []
+ Puppet::SSL::Key.expects(:search).returns []
+ Puppet::SSL::Certificate.expects(:search).returns []
+ Puppet::SSL::CertificateRequest.expects(:search).returns []
Puppet::SSL::Host.search
end
it "should be able to list only clients with a key" do
- Puppet::SSL::Key.indirection.expects(:search).returns []
- Puppet::SSL::Certificate.indirection.expects(:search).never
- Puppet::SSL::CertificateRequest.indirection.expects(:search).never
+ Puppet::SSL::Key.expects(:search).returns []
+ Puppet::SSL::Certificate.expects(:search).never
+ Puppet::SSL::CertificateRequest.expects(:search).never
Puppet::SSL::Host.search :for => Puppet::SSL::Key
end
it "should be able to list only clients with a certificate" do
- Puppet::SSL::Key.indirection.expects(:search).never
- Puppet::SSL::Certificate.indirection.expects(:search).returns []
- Puppet::SSL::CertificateRequest.indirection.expects(:search).never
+ Puppet::SSL::Key.expects(:search).never
+ Puppet::SSL::Certificate.expects(:search).returns []
+ Puppet::SSL::CertificateRequest.expects(:search).never
Puppet::SSL::Host.search :for => Puppet::SSL::Certificate
end
it "should be able to list only clients with a certificate request" do
- Puppet::SSL::Key.indirection.expects(:search).never
- Puppet::SSL::Certificate.indirection.expects(:search).never
- Puppet::SSL::CertificateRequest.indirection.expects(:search).returns []
+ Puppet::SSL::Key.expects(:search).never
+ Puppet::SSL::Certificate.expects(:search).never
+ Puppet::SSL::CertificateRequest.expects(:search).returns []
Puppet::SSL::Host.search :for => Puppet::SSL::CertificateRequest
end
@@ -616,9 +616,9 @@
cert = stub 'cert', :name => "cert"
csr = stub 'csr', :name => "csr"
- Puppet::SSL::Key.indirection.expects(:search).returns [key]
- Puppet::SSL::Certificate.indirection.expects(:search).returns [cert]
- Puppet::SSL::CertificateRequest.indirection.expects(:search).returns [csr]
+ Puppet::SSL::Key.expects(:search).returns [key]
+ Puppet::SSL::Certificate.expects(:search).returns [cert]
+ Puppet::SSL::CertificateRequest.expects(:search).returns [csr]
returned = []
%w{key cert csr}.each do |name|
@@ -708,7 +708,7 @@
Puppet.settings.stubs(:value).with(:localcacert).returns "ssl_host_testing"
- Puppet::SSL::CertificateRevocationList.indirection.stubs(:find).returns(nil)
+ Puppet::SSL::CertificateRevocationList.stubs(:find).returns(nil)
end
it "should accept a purpose" do
@@ -730,7 +730,7 @@
describe "and a CRL is available" do
before do
@crl = stub 'crl', :content => "real_crl"
- Puppet::SSL::CertificateRevocationList.indirection.stubs(:find).returns @crl
+ Puppet::SSL::CertificateRevocationList.stubs(:find).returns @crl
Puppet.settings.stubs(:value).with(:certificate_revocation).returns true
end
@@ -840,7 +840,7 @@
host.generate_certificate_request
@ca.sign(host.name)
pson_hash = {
- "fingerprint" => Puppet::SSL::Certificate.indirection.find(host.name).fingerprint,
+ "fingerprint" => Puppet::SSL::Certificate.find(host.name).fingerprint,
"desired_state" => 'signed',
"name" => host.name,
}
@@ -857,7 +857,7 @@
@ca.sign(host.name)
@ca.revoke(host.name)
pson_hash = {
- "fingerprint" => Puppet::SSL::Certificate.indirection.find(host.name).fingerprint,
+ "fingerprint" => Puppet::SSL::Certificate.find(host.name).fingerprint,
"desired_state" => 'revoked',
"name" => host.name,
}
diff --git a/spec/unit/ssl/inventory_spec.rb b/spec/unit/ssl/inventory_spec.rb
index 000f0a2..e7323e8 100755
--- a/spec/unit/ssl/inventory_spec.rb
+++ b/spec/unit/ssl/inventory_spec.rb
@@ -39,7 +39,7 @@
Puppet.settings.stubs(:write)
FileTest.stubs(:exist?).with("/inven/tory").returns false
- Puppet::SSL::Certificate.indirection.stubs(:search).returns []
+ Puppet::SSL::Certificate.stubs(:search).returns []
end
it "should log that it is building a new inventory file" do
@@ -66,7 +66,7 @@
cert1 = mock 'cert1'
cert2 = mock 'cert2'
- Puppet::SSL::Certificate.indirection.expects(:search).with("*").returns [cert1, cert2]
+ Puppet::SSL::Certificate.expects(:search).with("*").returns [cert1, cert2]
@class.any_instance.expects(:add).with(cert1)
@class.any_instance.expects(:add).with(cert2)
diff --git a/spec/unit/ssl/key_spec.rb b/spec/unit/ssl/key_spec.rb
index cddf9f8..13647f0 100755
--- a/spec/unit/ssl/key_spec.rb
+++ b/spec/unit/ssl/key_spec.rb
@@ -17,7 +17,7 @@
end
it "should default to the :file terminus" do
- @class.indirection.terminus_class.should == :file
+ @class.terminus_class.should == :file
end
it "should only support the text format" do
diff --git a/spec/unit/status_spec.rb b/spec/unit/status_spec.rb
index 0c572fd..1d258f9 100755
--- a/spec/unit/status_spec.rb
+++ b/spec/unit/status_spec.rb
@@ -3,8 +3,8 @@
describe Puppet::Status do
it "should implement find" do
- Puppet::Status.indirection.find( :default ).should be_is_a(Puppet::Status)
- Puppet::Status.indirection.find( :default ).status["is_alive"].should == true
+ Puppet::Status.find( :default ).should be_is_a(Puppet::Status)
+ Puppet::Status.find( :default ).status["is_alive"].should == true
end
it "should default to is_alive is true" do
diff --git a/spec/unit/transaction/report_spec.rb b/spec/unit/transaction/report_spec.rb
index fe5c2e2..c5086cb 100755
--- a/spec/unit/transaction/report_spec.rb
+++ b/spec/unit/transaction/report_spec.rb
@@ -39,7 +39,7 @@
end
it "should not include whits" do
- Puppet::FileBucket::File.indirection.stubs(:save)
+ Puppet::FileBucket::File.stubs(:save)
filename = tmpfile('whit_test')
file = Puppet::Type.type(:file).new(:path => filename)
@@ -91,11 +91,11 @@
Puppet::Transaction::Report.stubs(:indirection).returns(@indirection)
report = Puppet::Transaction::Report.new("apply")
@indirection.expects(:save)
- Puppet::Transaction::Report.indirection.save(report)
+ report.save
end
it "should default to the 'processor' terminus" do
- Puppet::Transaction::Report.indirection.terminus_class.should == :processor
+ Puppet::Transaction::Report.terminus_class.should == :processor
end
it "should delegate its name attribute to its host method" do
diff --git a/spec/unit/type/file/source_spec.rb b/spec/unit/type/file/source_spec.rb
index f776457..c61ef2c 100755
--- a/spec/unit/type/file/source_spec.rb
+++ b/spec/unit/type/file/source_spec.rb
@@ -107,22 +107,22 @@
it "should collect its metadata using the Metadata class if it is not already set" do
@source = source.new(:resource => @resource, :value => @foobar)
- Puppet::FileServing::Metadata.indirection.expects(:find).with(@foobar_uri).returns @metadata
+ Puppet::FileServing::Metadata.expects(:find).with(@foobar_uri).returns @metadata
@source.metadata
end
it "should use the metadata from the first found source" do
metadata = stub 'metadata', :source= => nil
@source = source.new(:resource => @resource, :value => [@foobar, @feebooz])
- Puppet::FileServing::Metadata.indirection.expects(:find).with(@foobar_uri).returns nil
- Puppet::FileServing::Metadata.indirection.expects(:find).with(@feebooz_uri).returns metadata
+ Puppet::FileServing::Metadata.expects(:find).with(@foobar_uri).returns nil
+ Puppet::FileServing::Metadata.expects(:find).with(@feebooz_uri).returns metadata
@source.metadata.should equal(metadata)
end
it "should store the found source as the metadata's source" do
metadata = mock 'metadata'
@source = source.new(:resource => @resource, :value => @foobar)
- Puppet::FileServing::Metadata.indirection.expects(:find).with(@foobar_uri).returns metadata
+ Puppet::FileServing::Metadata.expects(:find).with(@foobar_uri).returns metadata
metadata.expects(:source=).with(@foobar_uri)
@source.metadata
@@ -130,7 +130,7 @@
it "should fail intelligently if an exception is encountered while querying for metadata" do
@source = source.new(:resource => @resource, :value => @foobar)
- Puppet::FileServing::Metadata.indirection.expects(:find).with(@foobar_uri).raises RuntimeError
+ Puppet::FileServing::Metadata.expects(:find).with(@foobar_uri).raises RuntimeError
@source.expects(:fail).raises ArgumentError
lambda { @source.metadata }.should raise_error(ArgumentError)
@@ -138,7 +138,7 @@
it "should fail if no specified sources can be found" do
@source = source.new(:resource => @resource, :value => @foobar)
- Puppet::FileServing::Metadata.indirection.expects(:find).with(@foobar_uri).returns nil
+ Puppet::FileServing::Metadata.expects(:find).with(@foobar_uri).returns nil
@source.expects(:fail).raises RuntimeError
@@ -294,7 +294,7 @@
before(:each) do
metadata = Puppet::FileServing::Metadata.new(path, :source => uri, 'type' => 'file')
#metadata = stub('remote', :ftype => "file", :source => uri)
- Puppet::FileServing::Metadata.indirection.stubs(:find).with(uri).returns metadata
+ Puppet::FileServing::Metadata.stubs(:find).with(uri).returns metadata
resource[:source] = uri
end
diff --git a/spec/unit/type/file_spec.rb b/spec/unit/type/file_spec.rb
index cf278b4..e3f9887 100755
--- a/spec/unit/type/file_spec.rb
+++ b/spec/unit/type/file_spec.rb
@@ -741,7 +741,7 @@
it "should set checksum_type to none if this file checksum is none" do
file[:checksum] = :none
- Puppet::FileServing::Metadata.indirection.expects(:search).with { |path,params| params[:checksum_type] == :none }.returns [@metadata]
+ Puppet::FileServing::Metadata.expects(:search).with { |path,params| params[:checksum_type] == :none }.returns [@metadata]
file.expects(:newchild).with("my/file").returns "fiebar"
file.recurse_local
end
@@ -892,47 +892,47 @@
describe "#perform_recursion" do
it "should use Metadata to do its recursion" do
- Puppet::FileServing::Metadata.indirection.expects(:search)
+ Puppet::FileServing::Metadata.expects(:search)
file.perform_recursion(file[:path])
end
it "should use the provided path as the key to the search" do
- Puppet::FileServing::Metadata.indirection.expects(:search).with { |key, options| key == "/foo" }
+ Puppet::FileServing::Metadata.expects(:search).with { |key, options| key == "/foo" }
file.perform_recursion("/foo")
end
it "should return the results of the metadata search" do
- Puppet::FileServing::Metadata.indirection.expects(:search).returns "foobar"
+ Puppet::FileServing::Metadata.expects(:search).returns "foobar"
file.perform_recursion(file[:path]).should == "foobar"
end
it "should pass its recursion value to the search" do
file[:recurse] = true
- Puppet::FileServing::Metadata.indirection.expects(:search).with { |key, options| options[:recurse] == true }
+ Puppet::FileServing::Metadata.expects(:search).with { |key, options| options[:recurse] == true }
file.perform_recursion(file[:path])
end
it "should pass true if recursion is remote" do
file[:recurse] = :remote
- Puppet::FileServing::Metadata.indirection.expects(:search).with { |key, options| options[:recurse] == true }
+ Puppet::FileServing::Metadata.expects(:search).with { |key, options| options[:recurse] == true }
file.perform_recursion(file[:path])
end
it "should pass its recursion limit value to the search" do
file[:recurselimit] = 10
- Puppet::FileServing::Metadata.indirection.expects(:search).with { |key, options| options[:recurselimit] == 10 }
+ Puppet::FileServing::Metadata.expects(:search).with { |key, options| options[:recurselimit] == 10 }
file.perform_recursion(file[:path])
end
it "should configure the search to ignore or manage links" do
file[:links] = :manage
- Puppet::FileServing::Metadata.indirection.expects(:search).with { |key, options| options[:links] == :manage }
+ Puppet::FileServing::Metadata.expects(:search).with { |key, options| options[:links] == :manage }
file.perform_recursion(file[:path])
end
it "should pass its 'ignore' setting to the search if it has one" do
file[:ignore] = %w{.svn CVS}
- Puppet::FileServing::Metadata.indirection.expects(:search).with { |key, options| options[:ignore] == %w{.svn CVS} }
+ Puppet::FileServing::Metadata.expects(:search).with { |key, options| options[:ignore] == %w{.svn CVS} }
file.perform_recursion(file[:path])
end
end
diff --git a/test/language/parser.rb b/test/language/parser.rb
index f7e636a..070017e 100755
--- a/test/language/parser.rb
+++ b/test/language/parser.rb
@@ -436,9 +436,9 @@ def test_topnamespace
def test_virtualresources
tests = [:virtual]
if Puppet.features.rails?
- catalog_cache_class = Puppet::Resource::Catalog.indirection.cache_class
- facts_cache_class = Puppet::Node::Facts.indirection.cache_class
- node_cache_class = Puppet::Node.indirection.cache_class
+ catalog_cache_class = Puppet::Resource::Catalog.cache_class
+ facts_cache_class = Puppet::Node::Facts.cache_class
+ node_cache_class = Puppet::Node.cache_class
Puppet[:storeconfigs] = true
tests << :exported
end
@@ -499,18 +499,18 @@ def test_virtualresources
ensure
if Puppet.features.rails?
Puppet[:storeconfigs] = false
- Puppet::Resource::Catalog.indirection.cache_class = catalog_cache_class
- Puppet::Node::Facts.indirection.cache_class = facts_cache_class
- Puppet::Node.indirection.cache_class = node_cache_class
+ Puppet::Resource::Catalog.cache_class = catalog_cache_class
+ Puppet::Node::Facts.cache_class = facts_cache_class
+ Puppet::Node.cache_class = node_cache_class
end
end
def test_collections
tests = [:virtual]
if Puppet.features.rails?
- catalog_cache_class = Puppet::Resource::Catalog.indirection.cache_class
- facts_cache_class = Puppet::Node::Facts.indirection.cache_class
- node_cache_class = Puppet::Node.indirection.cache_class
+ catalog_cache_class = Puppet::Resource::Catalog.cache_class
+ facts_cache_class = Puppet::Node::Facts.cache_class
+ node_cache_class = Puppet::Node.cache_class
Puppet[:storeconfigs] = true
tests << :exported
end
@@ -538,9 +538,9 @@ def test_collections
ensure
if Puppet.features.rails?
Puppet[:storeconfigs] = false
- Puppet::Resource::Catalog.indirection.cache_class = catalog_cache_class
- Puppet::Node::Facts.indirection.cache_class = facts_cache_class
- Puppet::Node.indirection.cache_class = node_cache_class
+ Puppet::Resource::Catalog.cache_class = catalog_cache_class
+ Puppet::Node::Facts.cache_class = facts_cache_class
+ Puppet::Node.cache_class = node_cache_class
end
end
diff --git a/test/language/scope.rb b/test/language/scope.rb
index ccc3596..564f967 100755
--- a/test/language/scope.rb
+++ b/test/language/scope.rb
@@ -206,9 +206,9 @@ def test_virtual_definitions_do_not_get_evaluated
# run, whether it's in the same scope as a collection or a different
# scope.
def test_storeandcollect
- catalog_cache_class = Puppet::Resource::Catalog.indirection.cache_class
- facts_cache_class = Puppet::Node::Facts.indirection.cache_class
- node_cache_class = Puppet::Node.indirection.cache_class
+ catalog_cache_class = Puppet::Resource::Catalog.cache_class
+ facts_cache_class = Puppet::Node::Facts.cache_class
+ node_cache_class = Puppet::Node.cache_class
Puppet[:storeconfigs] = true
Puppet::Rails.init
sleep 1
@@ -233,9 +233,9 @@ class yay {
}
ensure
Puppet[:storeconfigs] = false
- Puppet::Resource::Catalog.indirection.cache_class = catalog_cache_class
- Puppet::Node::Facts.indirection.cache_class = facts_cache_class
- Puppet::Node.indirection.cache_class = node_cache_class
+ Puppet::Resource::Catalog.cache_class = catalog_cache_class
+ Puppet::Node::Facts.cache_class = facts_cache_class
+ Puppet::Node.cache_class = node_cache_class
end
else
$stderr.puts "No ActiveRecord -- skipping collection tests"
diff --git a/test/language/snippets.rb b/test/language/snippets.rb
index f34e368..7ec477e 100755
--- a/test/language/snippets.rb
+++ b/test/language/snippets.rb
@@ -495,7 +495,7 @@ def snippet_hash
catalog = nil
assert_nothing_raised("Could not compile catalog") {
- catalog = Puppet::Resource::Catalog.indirection.find(node)
+ catalog = Puppet::Resource::Catalog.find(node)
}
assert_nothing_raised("Could not convert catalog") {
diff --git a/test/network/handler/master.rb b/test/network/handler/master.rb
index 9326e4b..5fff751 100755
--- a/test/network/handler/master.rb
+++ b/test/network/handler/master.rb
@@ -13,7 +13,7 @@ def setup
@master = Puppet::Network::Handler.master.new(:Manifest => tempfile)
@catalog = stub 'catalog', :extract => ""
- Puppet::Resource::Catalog.indirection.stubs(:find).returns(@catalog)
+ Puppet::Resource::Catalog.stubs(:find).returns(@catalog)
end
def test_freshness_is_always_now
@@ -28,7 +28,7 @@ def test_freshness_is_always_now
def test_hostname_is_used_if_client_is_missing
@master.expects(:decode_facts).returns("hostname" => "yay")
facts = Puppet::Node::Facts.new("the_facts")
- Puppet::Node::Facts.indirection.stubs(:save).with(facts)
+ Puppet::Node::Facts.stubs(:save).with(facts, nil)
Puppet::Node::Facts.expects(:new).with { |name, facts| name == "yay" }.returns(facts)
@master.getconfig("facts")
@@ -37,7 +37,7 @@ def test_hostname_is_used_if_client_is_missing
def test_facts_are_saved
facts = Puppet::Node::Facts.new("the_facts")
Puppet::Node::Facts.expects(:new).returns(facts)
- Puppet::Node::Facts.indirection.expects(:save).with(facts)
+ Puppet::Node::Facts.expects(:save).with(facts, nil)
@master.stubs(:decode_facts)
@@ -46,12 +46,12 @@ def test_facts_are_saved
def test_catalog_is_used_for_compiling
facts = Puppet::Node::Facts.new("the_facts")
- Puppet::Node::Facts.indirection.stubs(:save).with(facts)
+ Puppet::Node::Facts.stubs(:save).with(facts, nil)
Puppet::Node::Facts.stubs(:new).returns(facts)
@master.stubs(:decode_facts)
- Puppet::Resource::Catalog.indirection.expects(:find).with("foo.com").returns(@catalog)
+ Puppet::Resource::Catalog.expects(:find).with("foo.com").returns(@catalog)
@master.getconfig("facts", "yaml", "foo.com")
end
@@ -61,13 +61,13 @@ class TestMasterFormats < Test::Unit::TestCase
def setup
@facts = Puppet::Node::Facts.new("the_facts")
Puppet::Node::Facts.stubs(:new).returns(@facts)
- Puppet::Node::Facts.indirection.stubs(:save)
+ Puppet::Node::Facts.stubs(:save)
@master = Puppet::Network::Handler.master.new(:Code => "")
@master.stubs(:decode_facts)
@catalog = stub 'catalog', :extract => ""
- Puppet::Resource::Catalog.indirection.stubs(:find).returns(@catalog)
+ Puppet::Resource::Catalog.stubs(:find).returns(@catalog)
end
def test_marshal_can_be_used
So if I can summarize? You now don't need to add the extra .indirection
method when calling the Indirector that you suddenly had to using 2.7?
Is that correct?
James
--
James Turnbull
Puppet Labs
1-503-734-8571
To schedule a meeting with me: http://tungle.me/jamtur01
Once this is merged, yes, that is correct. Code written to 2.6 spec
will work the same way in 2.7 and master.
Daniel
--
⎋ Puppet Labs Developer – http://puppetlabs.com
♲ Made with 100 percent post-consumer electrons
And I suppose that means all the current patches in flight should be
adjusted accordingly :(
--
Brice Figureau
My Blog: http://www.masterzen.fr/
It isn't absolutely necessary - and at the very least, wait until this
merges. The extra ceremony of `.indirection.whatever` will still
work; it isn't gone, just unnecessary, since this is part of a stable
release cycle.
I understand that is a painful requirement to change, though, and we
would absolutely take that into account when it came to merging
things. (eg: accept a post-hoc changes from you, or someone in-house,
to clean up afterwards, rather than forcing a rewrite of every
change.)
So, why aren't we just delivering?
--
Jacob Helwig
http://technosorcery.net/about/me
A bunch of reasons. One is time: pushing through the rest of (my
understanding of) the planned cleanup was substantially more
investment of effort, and one that I can't currently make.
Another is that, as I noted, I believe that a solution to this
currently would look very different from the original plan - our
understanding of the product direction, and the ways that we want to
structure the final state are now very different.
Ultimately, the move to a service oriented architecture underpinning
the Puppet platform means that a bunch of the ways we did want to
solve problems don't quite fit any longer.
Finally, as I noted, if we do go back to following the original plan,
the effort to rediscover these points is actually pretty minimal -
even if using this patch set to locate the changes isn't possible.