lib/onering/plugins/reporter.rb in onering-client-0.1.5 vs lib/onering/plugins/reporter.rb in onering-client-0.1.6
- old
+ new
@@ -175,11 +175,11 @@
:inventory => true,
:properties => {}
}
# loads plugins and populates @_report
- load_plugins
+ load_plugins()
return @_report.stringify_keys()
end
return {}
@@ -208,12 +208,11 @@
throw :retry if _update_cache_file(cachefile)
end
if options[:cacheregen] == true
Onering::Logger.debug("Forcing cache regeneration", "Onering::Reporter")
- _update_cache_file(cachefile)
- return _generated_report()
+ cache = _update_cache_file(cachefile)
end
# remove cached_at key
Onering::Logger.debug("Using cached data (#{Time.now.to_i - Time.parse(cache.get('cached_at')).to_i} seconds old)", "Onering::Reporter")
cache.delete('cached_at')
@@ -228,18 +227,20 @@
end
def _update_cache_file(cachefile=DEFAULT_CACHE_FILE)
begin
+ report = nil
+
File.open(cachefile, 'w+') do |file|
Onering::Logger.debug("Regenerating cache file at #{cachefile}", "Onering::Reporter")
report = _generated_report()
report['cached_at'] = Time.now.strftime('%Y-%m-%dT%H:%M:%S%z')
json = MultiJson.dump(report, :pretty => true)
file.puts(json)
end
- return true
+ return report
rescue Exception => e
Onering::Logger.info("Unable to write cache file #{cachefile}: #{e.class.name} - #{e.message}", "Onering::Reporter")
return false
end
end