diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-04-20 05:14:13 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-04-20 05:14:13 +0000 |
| commit | e24a299511f6a23019edfee16e2541c8078d3f5d (patch) | |
| tree | 304cd64de34e628f922ba3695a67b65308562894 /lib/puppet/server | |
| parent | ac049810032ed655b0ea32650127d38df39e1089 (diff) | |
| download | puppet-e24a299511f6a23019edfee16e2541c8078d3f5d.tar.gz puppet-e24a299511f6a23019edfee16e2541c8078d3f5d.tar.xz puppet-e24a299511f6a23019edfee16e2541c8078d3f5d.zip | |
A simple first version of an object (called "pelement") server is now in place. There is not yet a client, and the tests are pretty simple so far -- only files have been tested yet. I had to make a significant number of modifications to the file object in order to get this all to work, and one of the big changes I made is to the internals of the checksum state.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1123 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/server')
| -rwxr-xr-x | lib/puppet/server/pelement.rb | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/lib/puppet/server/pelement.rb b/lib/puppet/server/pelement.rb new file mode 100755 index 000000000..791576666 --- /dev/null +++ b/lib/puppet/server/pelement.rb @@ -0,0 +1,101 @@ +require 'puppet' +require 'puppet/server' + +module Puppet + +class Server::PElementServer + attr_accessor :local + + @interface = XMLRPC::Service::Interface.new("fileserver") { |iface| + iface.add_method("string describe(string, string, array, array)") + iface.add_method("string list(string, string, boolean, array)") + } + + # Describe a given object. This returns the 'is' values for every state + # available on the object type. + def describe(type, name, retrieve = nil, ignore = [], format = "yaml", client = nil, clientip = nil) + @local = true unless client + typeklass = nil + unless typeklass = Puppet.type(type) + raise Puppet::Error, "Puppet type %s is unsupported" % type + end + + obj = nil + + retrieve ||= :all + + if obj = typeklass[name] + obj[:check] = retrieve + else + begin + obj = typeklass.create(:name => name, :check => retrieve) + rescue Puppet::Error => detail + raise Puppet::Error, "%s[%s] could not be created: %s" % + [type, name, detail] + end + end + + trans = obj.to_trans + + # Now get rid of any attributes they specifically don't want + ignore.each do |st| + if trans.include? st + trans.delete(st) + end + end + + if @local + return trans + else + str = nil + case format + when "yaml": + str = YAML.dump(trans) + else + raise XMLRPC::FaultException.new( + 1, "Unavailable config format %s" % format + ) + end + return CGI.escape(str) + end + end + + # Create a new fileserving module. + def initialize(hash = {}) + if hash[:Local] + @local = hash[:Local] + else + @local = false + end + end + + def list(type, name, client = nil, clientip = nil) + end + + private + + def authcheck(file, mount, client, clientip) + unless mount.allowed?(client, clientip) + mount.warning "%s cannot access %s" % + [client, file] + raise Puppet::Server::AuthorizationError, "Cannot access %s" % mount + end + end + + # Deal with ignore parameters. + def handleignore(children, path, ignore) + ignore.each { |ignore| + Dir.glob(File.join(path,ignore), File::FNM_DOTMATCH) { |match| + children.delete(File.basename(match)) + } + } + return children + end + + def to_s + "pelementserver" + end +end +end + +# $Id$ |
