lib/onering/plugins/reporter.rb in onering-client-0.0.46 vs lib/onering/plugins/reporter.rb in onering-client-0.0.50

- old
+ new

@@ -20,10 +20,12 @@ DEFAULT_FACTER_PATH = [ '/etc/facter' ] class<<self + include Onering::Util + attr_reader :facter_path def setup(config={}) @options = config @facter_path = DEFAULT_FACTER_PATH @@ -48,19 +50,10 @@ rescue LoadError STDERR.puts("Unable to load Facter library") end end - - def fact(name, default=nil) - if defined?(Facter) - return (Facter.value(name) or default) - end - - return nil - end - def load_plugins # load plugins from @path @path.compact.each do |root| begin Dir["#{root}/*"].each do |directory| @@ -101,12 +94,12 @@ def stat(name, value=nil) @_report[:properties][:metrics] ||= {} @_report[:properties][:metrics].set(name, value) if value end - def report - @id = (@options[:id] || (IO.read('/etc/hardware.id').to_s.nil_empty rescue nil)) + def report() + @id = (@options[:id] || Onering::Util.fact('hardwareid', nil)) if not @id.nil? hostname = (Facter.value('fqdn') rescue %x{hostname -f}.strip.chomp) @_report = { @@ -120,15 +113,15 @@ } # loads plugins and populates @_report load_plugins - return @_report + return @_report.stringify_keys() else raise "Cannot generate report without a hardware ID" end - nil + {} end end end end \ No newline at end of file