blob: a2e6d9c0419a4cdc9981b26cd1ac2f140e0b5efa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
require 'puppet/node'
require 'puppet/indirector'
# 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
# Use the node source as the indirection terminus.
indirects :facts
attr_accessor :name, :values
def initialize(name, values = {})
@name = name
@values = values
add_internal
end
private
# Add internal data to the facts for storage.
def add_internal
self.values[:_timestamp] = Time.now
end
# Strip out that internal data.
def strip_internal
newvals = values.dup
newvals.find_all { |name, value| name.to_s =~ /^_/ }.each { |name, value| newvals.delete(name) }
newvals
end
end
|