~ubuntu-branches/ubuntu/lucid/puppet/lucid-security

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2009-12-23 00:48:10 UTC
  • mfrom: (1.1.10 upstream) (3.1.7 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091223004810-3i4oryds922g5n59
Tags: 0.25.1-3ubuntu1
* Merge from debian testing.  Remaining changes:
  - debian/rules:
    + Don't start puppet when first installing puppet.
  - debian/puppet.conf, lib/puppet/defaults.rb:
    + Move templates to /etc/puppet
  - lib/puppet/defaults.rb:
    + Fix /var/lib/puppet/state ownership.
  - man/man8/puppet.conf.8: 
    + Fix broken URL in manpage.
  - debian/control:
    + Update maintainer accordint to spec.
    + Puppetmaster Recommends -> Suggests
    + Created puppet-testsuite as a seperate. Allow the users to run puppet's 
      testsuite.
  - tests/Rakefile: Fix rakefile so that the testsuite can acutally be ran.

Show diffs side-by-side

added added

removed removed

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