Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
diff --git a/lib/puppet/network/client/master.rb b/lib/puppet/network/client/master.rb index 0de3a11..5f19894 100644 --- a/lib/puppet/network/client/master.rb +++ b/lib/puppet/network/client/master.rb @@ -143,15 +143,15 @@ class Puppet::Network::Client::Master < Puppet::Network::Client # If we can't retrieve the catalog, just return, which will either # fail, or use the in-memory catalog. - unless yaml_objects = get_actual_config(facts) + unless marshalled_objects = get_actual_config(facts) use_cached_config(true) return end begin - objects = YAML.load(yaml_objects) + objects = Marshal.load(marshalled_objects) rescue => detail - msg = "Configuration could not be translated from yaml" + msg = "Configuration could not be translated from Marshal" msg += "; using cached catalog" if use_cached_config(true) Puppet.warning msg return @@ -175,7 +175,7 @@ class Puppet::Network::Client::Master < Puppet::Network::Client end if ! @catalog.from_cache - self.cache(yaml_objects) + self.cache(marshalled_objects) end # Keep the state database up to date. @@ -442,7 +442,7 @@ class Puppet::Network::Client::Master < Puppet::Network::Client benchmark(:debug, "Retrieved catalog") do # error handling for this is done in the network client begin - textobjects = @driver.getconfig(textfacts, "yaml") + textobjects = @driver.getconfig(textfacts, "marshal") begin textobjects = CGI.unescape(textobjects) rescue => detail diff --git a/lib/puppet/network/handler/master.rb b/lib/puppet/network/handler/master.rb index a050b08..9682c46 100644 --- a/lib/puppet/network/handler/master.rb +++ b/lib/puppet/network/handler/master.rb @@ -64,7 +64,14 @@ class Puppet::Network::Handler catalog = Puppet::Node::Catalog.find(client) - return translate(catalog.extract) + case format + when "yaml": + return CGI.escape(catalog.extract.to_yaml(:UseBlock => true)) + when "marshal": + return CGI.escape(Marshal.dump(catalog.extract)) + else + raise "Invalid markup format '%s'" % format + end end # @@ -90,11 +97,6 @@ class Puppet::Network::Handler # 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
This paste will be private.
From the Design Piracy series on my blog: