summaryrefslogtreecommitdiffstats
path: root/lib
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
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')
-rw-r--r--lib/puppet/agent.rb30
-rw-r--r--lib/puppet/parser/interpreter.rb6
-rw-r--r--lib/puppet/resource/catalog.rb6
3 files changed, 27 insertions, 15 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.
diff --git a/lib/puppet/parser/interpreter.rb b/lib/puppet/parser/interpreter.rb
index 423c34a4e..c728b54a2 100644
--- a/lib/puppet/parser/interpreter.rb
+++ b/lib/puppet/parser/interpreter.rb
@@ -26,10 +26,10 @@ class Puppet::Parser::Interpreter
def compile(node)
raise Puppet::ParseError, "Could not parse configuration; cannot compile on node %s" % node.name unless env_parser = parser(node.environment)
begin
- return Puppet::Parser::Compiler.new(node, env_parser).compile
+ return Puppet::Parser::Compiler.new(node, env_parser).compile.to_resource
rescue => detail
- puts detail.backtrace if Puppet[:trace]
- raise Puppet::Error, detail.to_s + " on node %s" % node.name
+ puts detail.backtrace if Puppet[:trace]
+ raise Puppet::Error, detail.to_s + " on node %s" % node.name
end
end
diff --git a/lib/puppet/resource/catalog.rb b/lib/puppet/resource/catalog.rb
index 8f013e7db..e1341012c 100644
--- a/lib/puppet/resource/catalog.rb
+++ b/lib/puppet/resource/catalog.rb
@@ -485,7 +485,11 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph
resource.catalog = result
end
- newres = resource.send(convert)
+ if resource.is_a?(Puppet::Resource) and convert.to_s == "to_resource"
+ newres = resource
+ else
+ newres = resource.send(convert)
+ end
# We can't guarantee that resources don't munge their names
# (like files do with trailing slashes), so we have to keep track