diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-05-03 05:24:13 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-05-03 05:24:13 +0000 |
| commit | 8d7ec14836809f1433e645c3069691d2f6c70e52 (patch) | |
| tree | 185c06aaaade8fd87b863755eb911a3fde50821a /lib/puppet/util | |
| parent | 79dcd33aebf8749719e9eff009b8bb3fdaf77751 (diff) | |
| download | puppet-8d7ec14836809f1433e645c3069691d2f6c70e52.tar.gz puppet-8d7ec14836809f1433e645c3069691d2f6c70e52.tar.xz puppet-8d7ec14836809f1433e645c3069691d2f6c70e52.zip | |
Adding a fact handler, along with an abstract interface for fact stores and a simple yaml fact store, towards the Node Classification work.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2457 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/util')
| -rw-r--r-- | lib/puppet/util/fact_store.rb | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/lib/puppet/util/fact_store.rb b/lib/puppet/util/fact_store.rb new file mode 100644 index 000000000..f872ebb01 --- /dev/null +++ b/lib/puppet/util/fact_store.rb @@ -0,0 +1,60 @@ +# Created on 2007-05-02 +# Copyright Luke Kanies + +module Puppet::Util + # The abstract base class for client fact storage. + class FactStore + extend Puppet::Util + extend Puppet::Util::Docs + extend Puppet::Util::ClassGen + + @loader = Puppet::Util::Autoload.new(self, "puppet/fact_stores") + @stores = {} + + # Add a new report type. + def self.newstore(name, options = {}, &block) + klass = genclass(name, + :block => block, + :prefix => "FactStore", + :hash => @stores, + :attributes => options + ) + end + + # Remove a store; really only used for testing. + def self.rmstore(name) + rmclass(name, :hash => @stores) + end + + # Load a store. + def self.store(name) + name = symbolize(name) + unless @stores.include? name + if @loader.load(name) + unless @stores.include? name + Puppet.warning( + "Loaded report file for %s but report was not defined" % + name + ) + return nil + end + else + return nil + end + end + @stores[name] + end + + # Retrieve the facts for a node. + def get(node) + raise Puppet::DevError, "%s has not overridden get" % self.class.name + end + + # Set the facts for a node. + def set(node, facts) + raise Puppet::DevError, "%s has not overridden set" % self.class.name + end + end +end + +# $Id$ |
