summaryrefslogtreecommitdiffstats
path: root/lib/puppet/node
diff options
context:
space:
mode:
authorJesse Wolfe <jes5199@gmail.com>2010-11-03 20:00:46 -0700
committerJesse Wolfe <jes5199@gmail.com>2010-11-03 20:04:31 -0700
commit7236a33d6c5c9fbb0f46ffd7826965dbaae6a39b (patch)
tree2ca24f5af952c5ef5456ec85ad4fe9e5acf14ac3 /lib/puppet/node
parent9e2a0e41dfb253a19180aeea6b66f65ca8d63133 (diff)
parent4d3c41ee5316285bb0df38aeeb76746016803c16 (diff)
downloadpuppet-7236a33d6c5c9fbb0f46ffd7826965dbaae6a39b.tar.gz
puppet-7236a33d6c5c9fbb0f46ffd7826965dbaae6a39b.tar.xz
puppet-7236a33d6c5c9fbb0f46ffd7826965dbaae6a39b.zip
Merge branch 'next'
This marks the end of our first agile iteration.
Diffstat (limited to 'lib/puppet/node')
-rwxr-xr-xlib/puppet/node/facts.rb37
-rw-r--r--lib/puppet/node/inventory.rb7
2 files changed, 40 insertions, 4 deletions
diff --git a/lib/puppet/node/facts.rb b/lib/puppet/node/facts.rb
index b77ad22d5..d84d54113 100755
--- a/lib/puppet/node/facts.rb
+++ b/lib/puppet/node/facts.rb
@@ -1,12 +1,17 @@
+require 'time'
+
require 'puppet/node'
require 'puppet/indirector'
+require 'puppet/util/pson'
+
# 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.
extend Puppet::Indirector
+ extend Puppet::Util::Pson
# We want to expire any cached nodes if the facts are saved.
module NodeExpirer
@@ -30,7 +35,7 @@ class Puppet::Node::Facts
@name = name
@values = values
- add_internal
+ add_timestamp
end
def downcase_if_necessary
@@ -54,13 +59,37 @@ class Puppet::Node::Facts
strip_internal == other.send(:strip_internal)
end
- private
+ def self.from_pson(data)
+ result = new(data['name'], data['values'])
+ result.values[:_timestamp] = Time.parse(data['timestamp'])
+ result.expiration = Time.parse(data['expiration'])
+ result
+ end
+
+ def to_pson(*args)
+ {
+ 'expiration' => expiration,
+ 'name' => name,
+ 'timestamp' => values[:_timestamp],
+ 'values' => values.reject {|k,v| k == :_timestamp},
+ }.to_pson(*args)
+ end
# Add internal data to the facts for storage.
- def add_internal
- self.values[:_timestamp] = Time.now
+ def add_timestamp
+ self.timestamp = Time.now
end
+ def timestamp=(time)
+ self.values[:_timestamp] = time
+ end
+
+ def timestamp
+ self.values[:_timestamp]
+ end
+
+ private
+
# Strip out that internal data.
def strip_internal
newvals = values.dup
diff --git a/lib/puppet/node/inventory.rb b/lib/puppet/node/inventory.rb
new file mode 100644
index 000000000..fd99163b0
--- /dev/null
+++ b/lib/puppet/node/inventory.rb
@@ -0,0 +1,7 @@
+require 'puppet/node'
+require 'puppet/indirector'
+
+class Puppet::Node::Inventory
+ extend Puppet::Indirector
+ indirects :inventory, :terminus_setting => :inventory_terminus
+end