summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLuke Kanies <luke@reductivelabs.com>2010-03-23 23:58:54 -0700
committertest branch <puppet-dev@googlegroups.com>2010-02-17 06:50:53 -0800
commit7e1e76e91579a49c07aa5cb5917a9800d59b8137 (patch)
tree0777af992b41a5ba4fb2ba86bfaf6dd395d6f5c1 /lib
parentb28e21a47645cf982c1290530097db791f0095a5 (diff)
downloadpuppet-7e1e76e91579a49c07aa5cb5917a9800d59b8137.tar.gz
puppet-7e1e76e91579a49c07aa5cb5917a9800d59b8137.tar.xz
puppet-7e1e76e91579a49c07aa5cb5917a9800d59b8137.zip
Refactoring Configurer to enable the next feature
Signed-off-by: Luke Kanies <luke@reductivelabs.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/configurer.rb57
1 files changed, 30 insertions, 27 deletions
diff --git a/lib/puppet/configurer.rb b/lib/puppet/configurer.rb
index aa336b462..3b4f9ec90 100644
--- a/lib/puppet/configurer.rb
+++ b/lib/puppet/configurer.rb
@@ -94,47 +94,23 @@ class Puppet::Configurer
# Get the remote catalog, yo. Returns nil if no catalog can be found.
def retrieve_catalog
- name = Puppet[:certname]
- catalog_class = Puppet::Resource::Catalog
-
# 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.
fact_options = facts_for_uploading()
# First try it with no cache, then with the cache.
- result = nil
- begin
- duration = thinmark do
- result = catalog_class.find(name, fact_options.merge(:ignore_cache => true))
- end
- rescue SystemExit,NoMemoryError
- raise
- rescue Exception => detail
- puts detail.backtrace if Puppet[:trace]
- Puppet.err "Could not retrieve catalog from remote server: %s" % detail
- end
-
- unless result
+ unless result = retrieve_new_catalog(fact_options)
if ! Puppet[:usecacheonfailure]
Puppet.warning "Not using cache on failed catalog"
return nil
end
-
- begin
- duration = thinmark do
- result = catalog_class.find(name, fact_options.merge(:ignore_terminus => true))
- end
- Puppet.notice "Using cached catalog"
- rescue => detail
- puts detail.backtrace if Puppet[:trace]
- Puppet.err "Could not retrieve catalog from cache: %s" % detail
- end
+ result = retrieve_catalog_from_cache(fact_options)
end
return nil unless result
- convert_catalog(result, duration)
+ convert_catalog(result, @duration)
end
# Convert a plain resource catalog into our full host catalog.
@@ -230,4 +206,31 @@ class Puppet::Configurer
raise CommandHookError, "Could not run command from #{setting}: #{detail}"
end
end
+
+ def retrieve_catalog_from_cache(fact_options)
+ result = nil
+ @duration = thinmark do
+ result = Puppet::Resource::Catalog.find(Puppet[:certname], fact_options.merge(:ignore_terminus => true))
+ end
+ Puppet.notice "Using cached catalog"
+ result
+ rescue => detail
+ puts detail.backtrace if Puppet[:trace]
+ Puppet.err "Could not retrieve catalog from cache: %s" % detail
+ return nil
+ end
+
+ def retrieve_new_catalog(fact_options)
+ result = nil
+ @duration = thinmark do
+ result = Puppet::Resource::Catalog.find(Puppet[:certname], fact_options.merge(:ignore_cache => true))
+ end
+ result
+ rescue SystemExit,NoMemoryError
+ raise
+ rescue Exception => detail
+ puts detail.backtrace if Puppet[:trace]
+ Puppet.err "Could not retrieve catalog from remote server: %s" % detail
+ return nil
+ end
end