lib/onering/plugins/reporter.rb in onering-client-0.0.76 vs lib/onering/plugins/reporter.rb in onering-client-0.0.77

- old
+ new

@@ -1,7 +1,8 @@ #!/usr/bin/env ruby require 'rubygems' +require 'timeout' require 'optparse' require 'hashlib' def report(&block) Onering::Reporter.add(&block) @@ -98,25 +99,27 @@ def report() @id = (@options[:id] || Onering::Util.fact('hardwareid', nil)) if not @id.nil? - hostname = (Facter.value('fqdn') rescue %x{hostname -f}.strip.chomp) + Timeout.timeout((@options[:timeout] || 60).to_i) do + hostname = (Facter.value('fqdn') rescue %x{hostname -f}.strip.chomp) - @_report = { - :id => @id, - :name => hostname, - :aliases => @options[:aliases], - :tags => @options[:tags], - :status => (@options[:status] || 'online'), - :inventory => true, - :properties => {} - } + @_report = { + :id => @id, + :name => hostname, + :aliases => @options[:aliases], + :tags => @options[:tags], + :status => (@options[:status] || 'online'), + :inventory => true, + :properties => {} + } - # loads plugins and populates @_report - load_plugins + # loads plugins and populates @_report + load_plugins - return @_report.stringify_keys() + return @_report.stringify_keys() + end else raise "Cannot generate report without a hardware ID" end {}