diff options
| author | Luke Kanies <luke@madstop.com> | 2007-09-04 16:59:30 -0500 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2007-09-04 16:59:30 -0500 |
| commit | b0a947589ea6c7abf5658d9e5038eb7d96a11339 (patch) | |
| tree | 484b6a7ac6f33b23cc022e3b972bde6982e1ff3f /lib | |
| parent | 11b127bd6708a18b512ca5b3018ccff1200cc47a (diff) | |
| download | puppet-b0a947589ea6c7abf5658d9e5038eb7d96a11339.tar.gz puppet-b0a947589ea6c7abf5658d9e5038eb7d96a11339.tar.xz puppet-b0a947589ea6c7abf5658d9e5038eb7d96a11339.zip | |
Flipped the switch so that compiles now return a Configuration instance instead of pre-extracting the configuration.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/puppet/network/handler/configuration.rb | 6 | ||||
| -rw-r--r-- | lib/puppet/network/handler/master.rb | 13 | ||||
| -rw-r--r-- | lib/puppet/node/configuration.rb | 2 | ||||
| -rw-r--r-- | lib/puppet/parser/compile.rb | 9 |
4 files changed, 21 insertions, 9 deletions
diff --git a/lib/puppet/network/handler/configuration.rb b/lib/puppet/network/handler/configuration.rb index 1dbb16370..05c86f22e 100644 --- a/lib/puppet/network/handler/configuration.rb +++ b/lib/puppet/network/handler/configuration.rb @@ -37,7 +37,9 @@ class Puppet::Network::Handler # Add any external data to the node. add_node_data(node) - return translate(compile(node)) + configuration = compile(node) + + return translate(configuration) end def initialize(options = {}) @@ -214,5 +216,3 @@ class Puppet::Network::Handler end end end - -# $Id$ diff --git a/lib/puppet/network/handler/master.rb b/lib/puppet/network/handler/master.rb index ace383e9f..18f37ca4a 100644 --- a/lib/puppet/network/handler/master.rb +++ b/lib/puppet/network/handler/master.rb @@ -77,7 +77,9 @@ class Puppet::Network::Handler fact_handler.set(client, facts) # And get the configuration from the config handler - return config_handler.configuration(client) + config = config_handler.configuration(client) + + return translate(config.extract) end def local=(val) @@ -139,5 +141,14 @@ class Puppet::Network::Handler end @fact_handler end + + # Translate our configuration appropriately for sending back to a client. + def translate(config) + if local? + config + else + CGI.escape(config.to_yaml(:UseBlock => true)) + end + end end end diff --git a/lib/puppet/node/configuration.rb b/lib/puppet/node/configuration.rb index e667007e9..4f93fdbe5 100644 --- a/lib/puppet/node/configuration.rb +++ b/lib/puppet/node/configuration.rb @@ -5,7 +5,7 @@ require 'puppet/external/gratr/digraph' # of the information in the configuration, including the resources # and the relationships between them. class Puppet::Node::Configuration < GRATR::Digraph - attr_accessor :name + attr_accessor :name, :version attr_reader :extraction_format # Add classes to our class list. diff --git a/lib/puppet/parser/compile.rb b/lib/puppet/parser/compile.rb index 841e58d4d..cc9938e50 100644 --- a/lib/puppet/parser/compile.rb +++ b/lib/puppet/parser/compile.rb @@ -82,7 +82,7 @@ class Puppet::Parser::Compile store() end - return @configuration.extract + return @configuration end # FIXME There are no tests for this. @@ -117,13 +117,13 @@ class Puppet::Parser::Compile # creates resource objects that point back to the classes, and then the # resources are themselves evaluated later in the process. def evaluate_classes(classes, scope) + unless scope.source + raise Puppet::DevError, "No source for scope passed to evaluate_classes" + end found = [] classes.each do |name| # If we can find the class, then make a resource that will evaluate it. if klass = scope.findclass(name) - unless scope.source - raise Puppet::DevError, "No source for %s" % scope.to_s - end # Create a resource to model this class, and then add it to the list # of resources. resource = Puppet::Parser::Resource.new(:type => "class", :title => klass.classname, :scope => scope, :source => scope.source) @@ -406,6 +406,7 @@ class Puppet::Parser::Compile # For maintaining the relationship between scopes and their resources. @configuration = Puppet::Node::Configuration.new(@node.name) + @configuration.version = @parser.version end # Set the node's parameters into the top-scope as variables. |
