lib/mcollective/facts/base.rb in mcollective-client-2.5.3 vs lib/mcollective/facts/base.rb in mcollective-client-2.6.0

- old
+ new

@@ -32,16 +32,12 @@ tfacts = load_facts_from_source # Force reset to last known good state on empty facts raise "Got empty facts" if tfacts.empty? - @facts.clear + @facts = normalize_facts(tfacts) - tfacts.each_pair do |key,value| - @facts[key.to_s] = value.to_s - end - @last_good_facts = @facts.clone @last_facts_load = Time.now.to_i else Log.debug("Using cached facts now: #{Time.now.to_i} last-known-good: #{@last_facts_load}") end @@ -78,9 +74,26 @@ end # Plugins can override this to provide forced fact invalidation def force_reload? false + end + + private + + def normalize_facts(value) + case value + when Array + return value.map { |v| normalize_facts(v) } + when Hash + new_hash = {} + value.each do |k,v| + new_hash[k.to_s] = normalize_facts(v) + end + return new_hash + else + return value.to_s + end end end end end