summaryrefslogtreecommitdiffstats
path: root/lib/puppet/agent.rb
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-01-23 18:49:26 -0600
committerLuke Kanies <luke@madstop.com>2009-02-06 18:08:42 -0600
commitd53ad3181d3f5953b00512d7793945d238d1879f (patch)
treef23104eada8d7baa2b82238124755ca90ebd8a78 /lib/puppet/agent.rb
parentf38277fb7d044394665db369892c01162b866863 (diff)
downloadpuppet-d53ad3181d3f5953b00512d7793945d238d1879f.tar.gz
puppet-d53ad3181d3f5953b00512d7793945d238d1879f.tar.xz
puppet-d53ad3181d3f5953b00512d7793945d238d1879f.zip
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 <luke@madstop.com>
Diffstat (limited to 'lib/puppet/agent.rb')
-rw-r--r--lib/puppet/agent.rb30
1 files changed, 19 insertions, 11 deletions
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.