summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorshadoi <shadoi@980ebf18-57e1-0310-9a29-db15c13687c0>2007-05-12 00:25:25 +0000
committershadoi <shadoi@980ebf18-57e1-0310-9a29-db15c13687c0>2007-05-12 00:25:25 +0000
commit12e565614183a34fff0832a78833f3a6626e2727 (patch)
tree5ee9048233de7c1208839543966b59bcca3e256e /lib
parent426330c92f0d7706fe9ebde04b19afbfd6d66fbb (diff)
downloadpuppet-12e565614183a34fff0832a78833f3a6626e2727.tar.gz
puppet-12e565614183a34fff0832a78833f3a6626e2727.tar.xz
puppet-12e565614183a34fff0832a78833f3a6626e2727.zip
Initial configuration storage abstraction layer stuff.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2507 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/config_stores/rest.rb19
-rw-r--r--lib/puppet/util/config_store.rb56
2 files changed, 75 insertions, 0 deletions
diff --git a/lib/puppet/config_stores/rest.rb b/lib/puppet/config_stores/rest.rb
new file mode 100644
index 000000000..4f65f399b
--- /dev/null
+++ b/lib/puppet/config_stores/rest.rb
@@ -0,0 +1,19 @@
+Puppet::Util::ConfigStore.newstore(:rest) do
+ desc "Store client configurations via a REST web service."
+
+ # Get a client's config. (called in collector?)
+ def get(client, config)
+ # Assuming this come in as Puppet::Parser objects
+ # we may need way to choose which transport data type we use.
+ end
+
+ def initialize
+ # need config vars like puppetstore host, port, etc.
+ end
+
+ # Store config to the web service. (called in getconfig?)
+ def store(client, config)
+ # Probably store as yaml...
+ end
+
+end
diff --git a/lib/puppet/util/config_store.rb b/lib/puppet/util/config_store.rb
new file mode 100644
index 000000000..4483eaed8
--- /dev/null
+++ b/lib/puppet/util/config_store.rb
@@ -0,0 +1,56 @@
+module Puppet::Util
+ # The abstract base class for client configuration storage.
+ class ConfigStore
+ extend Puppet::Util
+ extend Puppet::Util::Docs
+ extend Puppet::Util::ClassGen
+
+ @loader = Puppet::Util::Autoload.new(self, "puppet/config_stores")
+ @stores = {}
+
+ # Add a new report type.
+ def self.newstore(name, options = {}, &block)
+ klass = genclass(name,
+ :block => block,
+ :prefix => "ConfigStore",
+ :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 config for a client.
+ def get(client)
+ raise Puppet::DevError, "%s has not overridden get" % self.class.name
+ end
+
+ # Store the config for a client.
+ def store(client, config)
+ raise Puppet::DevError, "%s has not overridden store" % self.class.name
+ end
+ end
+end
+