diff options
| author | Luke Kanies <luke@madstop.com> | 2009-04-16 18:47:23 -0500 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2009-04-22 16:07:06 +1000 |
| commit | b249f87a8c9a7e358e8d82d658247cd4be01a3d7 (patch) | |
| tree | 1e292c9ed3d9e72234cf088b4636093606079b39 /lib/puppet/indirector | |
| parent | 1cde0ae606b0ea48d4dd8f7a0c0a4f84f7ed8af6 (diff) | |
| download | puppet-b249f87a8c9a7e358e8d82d658247cd4be01a3d7.tar.gz puppet-b249f87a8c9a7e358e8d82d658247cd4be01a3d7.tar.xz puppet-b249f87a8c9a7e358e8d82d658247cd4be01a3d7.zip | |
Fixing #2149 - Facts are passed as part of the catalog request
This removes the requirement of shared fact caching
on the servers, since the server responding to the catalog
request will receive the facts as part of the request.
The facts are serialized as a parameter to the request,
rather than each being set as a separate request parameter.
This hard-codes yaml as the serialization format for the
facts, because I couldn't get marshal to work and it's just not
as big a deal for such a small amount of data.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib/puppet/indirector')
| -rw-r--r-- | lib/puppet/indirector/catalog/compiler.rb | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/lib/puppet/indirector/catalog/compiler.rb b/lib/puppet/indirector/catalog/compiler.rb index 47635d88c..c9a216da1 100644 --- a/lib/puppet/indirector/catalog/compiler.rb +++ b/lib/puppet/indirector/catalog/compiler.rb @@ -12,17 +12,25 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code attr_accessor :code + def extract_facts_from_request(request) + return unless text_facts = request.options[:facts] + raise ArgumentError, "Facts but no fact format provided for %s" % request.name unless format = request.options[:facts_format] + + # If the facts were encoded as yaml, then the param reconstitution system + # in Network::HTTP::Handler will automagically deserialize the value. + if text_facts.is_a?(Puppet::Node::Facts) + facts = text_facts + else + facts = Puppet::Node::Facts.convert_from(format, text_facts) + end + facts.save + end + # Compile a node's catalog. def find(request) - unless node = request.options[:use_node] - # If the request is authenticated, then the 'node' info will - # be available; if not, then we use the passed-in key. We rely - # on our authorization system to determine whether this is allowed. - name = request.node || request.key - unless node = find_node(name) - raise ArgumentError, "Could not find node '%s'; cannot compile" % name - end - end + extract_facts_from_request(request) + + node = node_from_request(request) if catalog = compile(node) return catalog @@ -102,6 +110,24 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code node end + # Extract the node from the request, or use the request + # to find the node. + def node_from_request(request) + if node = request.options[:use_node] + return node + end + + # If the request is authenticated, then the 'node' info will + # be available; if not, then we use the passed-in key. We rely + # on our authorization system to determine whether this is allowed. + name = request.node || request.key + if node = find_node(name) + return node + end + + raise ArgumentError, "Could not find node '%s'; cannot compile" % name + end + # Initialize our server fact hash; we add these to each client, and they # won't change while we're running, so it's safe to cache the values. def set_server_facts |
