lib/onering/util.rb in onering-client-0.1.7 vs lib/onering/util.rb in onering-client-0.2.0
- old
+ new
@@ -86,15 +86,16 @@
}.last.full_gem_path
end
end
def fact(name, default=nil)
+ reporter = Onering::Reporter.new()
name = name.to_s
if defined?(Facter)
if name.downcase == 'all'
- return Facter.to_hash
+ return Facter.to_hash()
else
case name.to_sym
when :hardwareid
if File.exists?('/etc/hardware.id')
fact = File.read('/etc/hardware.id').lines.first.strip.chomp
@@ -104,30 +105,32 @@
else
fact = Facter.value(name)
end
# short circuit nil responses
- return default if fact.nil?
+ if fact.nil?
+ return reporter.report().get(name, default)
+ end
# if we are asking for a nested object...
if name.include?('.')
# ...and the response IS an object...
if fact.is_a?(Hash)
# remove the first part and return the rest
name = name.sub(/^[^\.]+\./,'')
return fact.get(name, default)
else
# not an object, return default
- return default
+ return reporter.report().get(name, default)
end
else
# this is a simple request, return the fact
return fact
end
end
end
- return default
+ return reporter.report().get(name, default)
end
def make_filter(filter)
filter = filter.collect{|k,v| "#{k}/#{v}" } if filter.is_a?(Hash)
filter = filter.collect{|i| i.sub(':','/') }.join("/") if filter.is_a?(Array)
\ No newline at end of file