~ubuntu-branches/ubuntu/oneiric/puppet/oneiric-security

« back to all changes in this revision

Viewing changes to lib/puppet/util/config_store.rb

  • Committer: Bazaar Package Importer
  • Author(s): Micah Anderson
  • Date: 2008-07-26 15:43:45 UTC
  • mto: (3.1.1 lenny) (1.3.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20080726154345-1fmgo76b4l72ulvc
ImportĀ upstreamĀ versionĀ 0.24.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
module Puppet::Util
 
2
    # The abstract base class for client configuration storage.
 
3
    class ConfigStore
 
4
        extend Puppet::Util
 
5
        extend Puppet::Util::Docs
 
6
        extend Puppet::Util::ClassGen
 
7
 
 
8
        @loader = Puppet::Util::Autoload.new(self, "puppet/config_stores")
 
9
        @stores = {}
 
10
 
 
11
        # Add a new report type.
 
12
        def self.newstore(name, options = {}, &block)
 
13
            klass = genclass(name,
 
14
                :block => block,
 
15
                :prefix => "ConfigStore",
 
16
                :hash => @stores,
 
17
                :attributes => options
 
18
            )
 
19
        end
 
20
 
 
21
        # Remove a store; really only used for testing.
 
22
        def self.rmstore(name)
 
23
            rmclass(name, :hash => @stores)
 
24
        end
 
25
 
 
26
        # Load a store.
 
27
        def self.store(name)
 
28
            name = symbolize(name)
 
29
            unless @stores.include? name
 
30
                if @loader.load(name)
 
31
                    unless @stores.include? name
 
32
                        Puppet.warning(
 
33
                            "Loaded report file for %s but report was not defined" %
 
34
                            name
 
35
                        )
 
36
                        return nil
 
37
                    end
 
38
                else
 
39
                    return nil
 
40
                end
 
41
            end
 
42
            @stores[name]
 
43
        end
 
44
 
 
45
        # Retrieve the config for a client.
 
46
        def get(client)
 
47
            raise Puppet::DevError, "%s has not overridden get" % self.class.name
 
48
        end
 
49
 
 
50
        # Store the config for a client.
 
51
        def store(client, config)
 
52
            raise Puppet::DevError, "%s has not overridden store" % self.class.name
 
53
        end
 
54
 
 
55
        def collect_exported(client, conditions)
 
56
            raise Puppet::DevError, "%s has not overridden collect_exported" % self.class.name
 
57
        end   
 
58
          
 
59
    end
 
60
end
 
61