module Puppet::Indirector::FactSearch
module containing common methods used by json and yaml facts indirection terminus
Public Instance Methods
compare_facts(operator, value1, value2)
click to toggle source
# File lib/puppet/indirector/fact_search.rb 26 def compare_facts(operator, value1, value2) 27 return false unless value1 28 29 case operator 30 when "eq" 31 value1.to_s == value2.to_s 32 when "le" 33 value1.to_f <= value2.to_f 34 when "ge" 35 value1.to_f >= value2.to_f 36 when "lt" 37 value1.to_f < value2.to_f 38 when "gt" 39 value1.to_f > value2.to_f 40 when "ne" 41 value1.to_s != value2.to_s 42 end 43 end
compare_timestamp(operator, value1, value2)
click to toggle source
# File lib/puppet/indirector/fact_search.rb 45 def compare_timestamp(operator, value1, value2) 46 case operator 47 when "eq" 48 value1 == value2 49 when "le" 50 value1 <= value2 51 when "ge" 52 value1 >= value2 53 when "lt" 54 value1 < value2 55 when "gt" 56 value1 > value2 57 when "ne" 58 value1 != value2 59 end 60 end
node_matches?(facts, options)
click to toggle source
# File lib/puppet/indirector/fact_search.rb 4 def node_matches?(facts, options) 5 options.each do |key, value| 6 type, name, operator = key.to_s.split(".") 7 operator ||= 'eq' 8 9 return false unless node_matches_option?(type, name, operator, value, facts) 10 end 11 return true 12 end
node_matches_option?(type, name, operator, value, facts)
click to toggle source
# File lib/puppet/indirector/fact_search.rb 14 def node_matches_option?(type, name, operator, value, facts) 15 case type 16 when "meta" 17 case name 18 when "timestamp" 19 compare_timestamp(operator, facts.timestamp, Time.parse(value)) 20 end 21 when "facts" 22 compare_facts(operator, facts.values[name], value) 23 end 24 end