From d53ad3181d3f5953b00512d7793945d238d1879f Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Fri, 23 Jan 2009 18:49:26 -0600 Subject: Converting the catalog as needed Converting to a Resource catalog for transmission, then converting to a RAL catalog on the client. Signed-off-by: Luke Kanies --- lib/puppet/agent.rb | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'lib/puppet/agent.rb') diff --git a/lib/puppet/agent.rb b/lib/puppet/agent.rb index 0046ed317..240005e3f 100644 --- a/lib/puppet/agent.rb +++ b/lib/puppet/agent.rb @@ -110,28 +110,36 @@ class Puppet::Agent result = nil begin duration = thinmark do - result = catalog_class.get(name, :use_cache => false) + result = catalog_class.find(name, :use_cache => false) end rescue => detail puts detail.backtrace if Puppet[:trace] Puppet.err "Could not retrieve catalog from remote server: %s" % detail end - begin - duration = thinmark do - result = catalog_class.get(name, :use_cache => true) + unless result + begin + duration = thinmark do + result = catalog_class.find(name, :use_cache => true) + end + rescue => detail + puts detail.backtrace if Puppet[:trace] + Puppet.err "Could not retrieve catalog from cache: %s" % detail end - rescue => detail - puts detail.backtrace if Puppet[:trace] - Puppet.err "Could not retrieve catalog from cache: %s" % detail end return nil unless result - result.retrieval_duration = duration - result.host_config = true - result.write_class_file - return result + convert_catalog(result, duration) + end + + # Convert a plain resource catalog into our full host catalog. + def convert_catalog(result, duration) + catalog = result.to_ral + catalog.retrieval_duration = duration + catalog.host_config = true + catalog.write_class_file + return catalog end # The code that actually runs the catalog. -- cgit