diff options
author | Nick Lewis <nick@puppetlabs.com> | 2011-03-04 13:52:43 -0800 |
---|---|---|
committer | Nick Lewis <nick@puppetlabs.com> | 2011-03-04 13:52:43 -0800 |
commit | a75d4fab5260b7cbef78a5b352d10e29bbfe7796 (patch) | |
tree | 5e3c32fd2be0f5934a01de79cdb397681f1e9804 /lib/puppet | |
parent | c65ef89e533e73d0f9ec34244be630bae00b53d5 (diff) | |
parent | 8bd80a99a259e6409a9ac0a8a60325f94b5c5e9d (diff) | |
download | puppet-a75d4fab5260b7cbef78a5b352d10e29bbfe7796.tar.gz puppet-a75d4fab5260b7cbef78a5b352d10e29bbfe7796.tar.xz puppet-a75d4fab5260b7cbef78a5b352d10e29bbfe7796.zip |
Merge branch 'ticket/2.6.next/6602' into 2.6.next
Diffstat (limited to 'lib/puppet')
-rwxr-xr-x | lib/puppet/node/facts.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/puppet/node/facts.rb b/lib/puppet/node/facts.rb index 562690026..0a96e553b 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 @@ -62,6 +67,22 @@ class Puppet::Node::Facts self.values[:_timestamp] end + def self.from_pson(data) + result = new(data['name'], data['values']) + result.timestamp = Time.parse(data['timestamp']) + result.expiration = Time.parse(data['expiration']) + result + end + + def to_pson(*args) + { + 'expiration' => expiration, + 'name' => name, + 'timestamp' => timestamp, + 'values' => strip_internal, + }.to_pson(*args) + end + private # Add internal data to the facts for storage. |