~lynxman/ubuntu/natty/mcollective/natty-upstart

« back to all changes in this revision

Viewing changes to lib/mcollective/facts.rb

  • Committer: Bazaar Package Importer
  • Author(s): Dustin Kirkland
  • Date: 2011-02-01 09:15:08 UTC
  • Revision ID: james.westby@ubuntu.com-20110201091508-9mev8fi5vixip5vs
Tags: upstream-1.0.0
ImportĀ upstreamĀ versionĀ 1.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
module MCollective
 
2
    # This is a class that gives access to the configured fact provider
 
3
    # such as MCollectives::Facts::Facter that uses Reductive Labs facter
 
4
    #
 
5
    # The actual provider is pluggable and configurable using the 'factsource'
 
6
    # configuration option.
 
7
    #
 
8
    # To develop a new factsource simply create a class under MCollective::Facts::
 
9
    # and provide the following classes:
 
10
    #
 
11
    #   self.get_fact(fact)
 
12
    #   self.has_fact?(fact)
 
13
    #
 
14
    # You can also just inherit from MCollective::Facts::Base and provide just the
 
15
    #
 
16
    #   self.get_facts
 
17
    #
 
18
    # method that should return a hash of facts.
 
19
        module Facts
 
20
        autoload :Base, "mcollective/facts/base"
 
21
 
 
22
                @@config = nil
 
23
 
 
24
                # True if we know of a specific fact else false
 
25
                def self.has_fact?(fact, value)
 
26
                        PluginManager["facts_plugin"].get_fact(fact) == value ? true : false
 
27
                end
 
28
 
 
29
                # Get the value of a fact
 
30
                def self.get_fact(fact)
 
31
                        PluginManager["facts_plugin"].get_fact(fact)
 
32
                end
 
33
 
 
34
                # Get the value of a fact
 
35
                def self.[](fact)
 
36
                        PluginManager["facts_plugin"].get_fact(fact)
 
37
                end
 
38
        end
 
39
end
 
40
# vi:tabstop=4:expandtab:ai