diff options
Diffstat (limited to 'lib/puppet/node')
| -rwxr-xr-x | lib/puppet/node/facts.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/puppet/node/facts.rb b/lib/puppet/node/facts.rb new file mode 100755 index 000000000..eddf44def --- /dev/null +++ b/lib/puppet/node/facts.rb @@ -0,0 +1,36 @@ +# Manage a given node's facts. This either accepts facts and stores them, or +# returns facts for a given node. +class Puppet::Node::Facts + # Set up indirection, so that nodes can be looked for in + # the node sources. + require 'puppet/indirector' + extend Puppet::Indirector + + # Use the node source as the indirection terminus. + indirects :facts, :to => :fact_store + + attr_accessor :name, :values + + def initialize(name, values = {}) + @name = name + @values = values + end + + private + + # FIXME These methods are currently unused. + + # Add internal data to the facts for storage. + def add_internal(facts) + facts = facts.dup + facts[:_puppet_timestamp] = Time.now + facts + end + + # Strip out that internal data. + def strip_internal(facts) + facts = facts.dup + facts.find_all { |name, value| name.to_s =~ /^_puppet_/ }.each { |name, value| facts.delete(name) } + facts + end +end |
