From 5aa4440b6fb8c9199ee549bd8fe0e4afb296c259 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Tue, 11 Sep 2007 12:38:56 -0500 Subject: Doing an intermediate commit so rick can look at the work I have done so far. --- lib/puppet/node/facts.rb | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 lib/puppet/node/facts.rb (limited to 'lib/puppet/node') 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 -- cgit