diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-01-12 21:04:06 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-01-12 21:04:06 +0000 |
| commit | f420135270ab66c7bad10ebc4b031ddac3b57659 (patch) | |
| tree | 558fd25f3b4e9881c20a7123fbef5d5b715ca7ff /lib/puppet/server | |
| parent | 8aa331d7b31033b1a7594a0020e8462f646241cf (diff) | |
Converting transport format to YAML instead of Marshal, and caching the file in a YAML format, also. This required a significant rework of both Transportable classes. Lastly, I am also now caching the list of classes in a class file in /etc/puppet.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@816 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/server')
| -rwxr-xr-x | lib/puppet/server/logger.rb | 6 | ||||
| -rw-r--r-- | lib/puppet/server/master.rb | 39 |
2 files changed, 37 insertions, 8 deletions
diff --git a/lib/puppet/server/logger.rb b/lib/puppet/server/logger.rb index d5feb0320..ae57370d8 100755 --- a/lib/puppet/server/logger.rb +++ b/lib/puppet/server/logger.rb @@ -1,3 +1,5 @@ +require 'yaml' + module Puppet class Server # :nodoc: class LoggerError < RuntimeError; end @@ -18,11 +20,11 @@ class Server # :nodoc: # if the client is set, then we're not local if client begin - message = Marshal::load(CGI.unescape(message)) + message = YAML.load(CGI.unescape(message)) #message = message rescue => detail raise XMLRPC::FaultException.new( - 1, "Could not unMarshal log message from %s" % client + 1, "Could not unYAML log message from %s" % client ) end end diff --git a/lib/puppet/server/master.rb b/lib/puppet/server/master.rb index e86663d0f..8d4ddbfde 100644 --- a/lib/puppet/server/master.rb +++ b/lib/puppet/server/master.rb @@ -3,6 +3,7 @@ require 'puppet' require 'puppet/parser/interpreter' require 'puppet/sslcertificates' require 'xmlrpc/server' +require 'yaml' module Puppet class Server @@ -57,7 +58,7 @@ class Server end end - def getconfig(facts, client = nil, clientip = nil) + def getconfig(facts, format = "marshal", client = nil, clientip = nil) if @local # we don't need to do anything, since we should already # have raw objects @@ -66,11 +67,26 @@ class Server Puppet.debug "Our client is remote" # XXX this should definitely be done in the protocol, somehow - begin - facts = Marshal::load(CGI.unescape(facts)) - rescue => detail + case format + when "marshal": + begin + facts = Marshal::load(CGI.unescape(facts)) + rescue => detail + raise XMLRPC::FaultException.new( + 1, "Could not rebuild facts" + ) + end + when "yaml": + begin + facts = YAML.load(CGI.unescape(facts)) + rescue => detail + raise XMLRPC::FaultException.new( + 1, "Could not rebuild facts" + ) + end + else raise XMLRPC::FaultException.new( - 1, "Could not rebuild facts" + 1, "Unavailable config format %s" % format ) end end @@ -95,7 +111,18 @@ class Server if @local return retobjects else - return CGI.escape(Marshal::dump(retobjects)) + str = nil + case format + when "marshal": + str = Marshal::dump(retobjects) + when "yaml": + str = YAML.dump(retobjects) + else + raise XMLRPC::FaultException.new( + 1, "Unavailable config format %s" % format + ) + end + return CGI.escape(str) end end end |
