Class: Puppet::Node::Facts
- Extended by:
- Indirector, Util::Pson
- Defined in:
- lib/vendor/puppet/node/facts.rb
Overview
Manage a given node’s facts. This either accepts facts and stores them, or returns facts for a given node.
Defined Under Namespace
Modules: NodeExpirer Classes: ActiveRecord, Couch, Facter, InventoryActiveRecord, InventoryService, Memory, NetworkDevice, Rest, StoreConfigs, Yaml
Constant Summary
Constants included from Indirector
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#values ⇒ Object
Returns the value of attribute values.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #add_local_facts ⇒ Object
-
#add_timestamp ⇒ Object
Add internal data to the facts for storage.
- #downcase_if_necessary ⇒ Object
-
#initialize(name, values = {}) ⇒ Facts
constructor
A new instance of Facts.
-
#stringify ⇒ Object
Convert all fact values into strings.
- #timestamp ⇒ Object
- #timestamp=(time) ⇒ Object
- #to_pson(*args) ⇒ Object
Methods included from Indirector
Methods included from Util::Pson
Constructor Details
#initialize(name, values = {}) ⇒ Facts
Returns a new instance of Facts.
34 35 36 37 38 39 |
# File 'lib/vendor/puppet/node/facts.rb', line 34 def initialize(name, values = {}) @name = name @values = values end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
26 27 28 |
# File 'lib/vendor/puppet/node/facts.rb', line 26 def name @name end |
#values ⇒ Object
Returns the value of attribute values.
26 27 28 |
# File 'lib/vendor/puppet/node/facts.rb', line 26 def values @values end |
Class Method Details
Instance Method Details
#==(other) ⇒ Object
57 58 59 60 |
# File 'lib/vendor/puppet/node/facts.rb', line 57 def ==(other) return false unless self.name == other.name strip_internal == other.send(:strip_internal) end |
#add_local_facts ⇒ Object
28 29 30 31 32 |
# File 'lib/vendor/puppet/node/facts.rb', line 28 def add_local_facts values["clientcert"] = Puppet.settings[:certname] values["clientversion"] = Puppet.version.to_s values["environment"] ||= Puppet.settings[:environment] end |
#add_timestamp ⇒ Object
Add internal data to the facts for storage.
79 80 81 |
# File 'lib/vendor/puppet/node/facts.rb', line 79 def self. = Time.now end |
#downcase_if_necessary ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/vendor/puppet/node/facts.rb', line 41 def downcase_if_necessary return unless Puppet.settings[:downcasefacts] Puppet.warning "DEPRECATION NOTICE: Fact downcasing is deprecated; please disable (20080122)" values.each do |fact, value| values[fact] = value.downcase if value.is_a?(String) end end |
#stringify ⇒ Object
Convert all fact values into strings.
51 52 53 54 55 |
# File 'lib/vendor/puppet/node/facts.rb', line 51 def stringify values.each do |fact, value| values[fact] = value.to_s end end |
#timestamp ⇒ Object
87 88 89 |
# File 'lib/vendor/puppet/node/facts.rb', line 87 def self.values[:_timestamp] end |
#timestamp=(time) ⇒ Object
83 84 85 |
# File 'lib/vendor/puppet/node/facts.rb', line 83 def (time) self.values[:_timestamp] = time end |
#to_pson(*args) ⇒ Object
69 70 71 72 73 74 75 76 |
# File 'lib/vendor/puppet/node/facts.rb', line 69 def to_pson(*args) { 'expiration' => expiration, 'name' => name, 'timestamp' => , 'values' => strip_internal, }.to_pson(*args) end |