aboutsummaryrefslogtreecommitdiffstats
path: root/lib/tasks/helpers/simple_interfaces.rb
diff options
context:
space:
mode:
authorZog2018-03-06 10:16:07 +0100
committerZog2018-03-06 10:17:44 +0100
commitfacce065c8cf455ab6e1fe44c6d9394b4f2aaa42 (patch)
tree27b9b0a4d8ca8920c69f17e230e87ea14000472f /lib/tasks/helpers/simple_interfaces.rb
parentcfdd12aa6b46331435bc62209c51cc14f470bd38 (diff)
downloadchouette-core-facce065c8cf455ab6e1fe44c6d9394b4f2aaa42.tar.bz2
Refs #6068; Add aggregated output for multiple interfaces
Diffstat (limited to 'lib/tasks/helpers/simple_interfaces.rb')
-rw-r--r--lib/tasks/helpers/simple_interfaces.rb19
1 files changed, 1 insertions, 18 deletions
diff --git a/lib/tasks/helpers/simple_interfaces.rb b/lib/tasks/helpers/simple_interfaces.rb
index 5b593be43..61dd38399 100644
--- a/lib/tasks/helpers/simple_interfaces.rb
+++ b/lib/tasks/helpers/simple_interfaces.rb
@@ -1,28 +1,11 @@
module SimpleInterfacesHelper
- def self.interface_output_to_csv interface, output_dir
- FileUtils.mkdir_p output_dir
- filepath = File.join output_dir, + "#{interface.configuration_name}_#{Time.now.strftime "%y%m%d%H%M"}_out.csv"
- cols = %w(line kind event message error)
- if interface.reload.journal.size > 0 && interface.journal.first["row"].present?
- keys = interface.journal.first["row"].map(&:first)
- CSV.open(filepath, "w") do |csv|
- csv << cols + keys
- interface.journal.each do |j|
- csv << cols.map{|c| j[c]} + j["row"].map(&:last)
- end
- end
- puts "Task Output written in #{filepath}"
- end
- end
-
def self.run_interface_controlling_interruption interface, method, args
begin
interface.send(method, verbose: true)
rescue Interrupt
+ interface.write_output_to_csv
raise
ensure
- puts "\n\e[33m***\e[0m Done, status: " + (interface.status == "success" ? "\e[32m" : "\e[31m" ) + (interface.status || "") + "\e[0m"
- interface_output_to_csv interface, args[:logs_output_dir]
end
end
end