From b6ca062670b342344df08b53fb216db619ef42bc Mon Sep 17 00:00:00 2001 From: Nicolas Braud-Santoni Date: Sun, 7 Aug 2016 16:39:42 +0200 Subject: Import legacy manman source Copied from www.ffgraz.net --- app/controllers/export_controller.rb | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 app/controllers/export_controller.rb (limited to 'app/controllers/export_controller.rb') diff --git a/app/controllers/export_controller.rb b/app/controllers/export_controller.rb new file mode 100644 index 0000000..5d2ef85 --- /dev/null +++ b/app/controllers/export_controller.rb @@ -0,0 +1,38 @@ +class ExportController < ApplicationController + def smokeping + @locations = Location.find(:all, :order => "name") + if @locations != nil + text = "" + @locations.each do |location| + @nodes = Node.find(:all, :conditions => { :location_id => location.id, :smokeping => true } ) + if @nodes != nil and not @nodes.empty? + text += "++ #{location.name}\n" + text += "menu = #{location.name}\n" + text += "title = #{location.name} connectivity\n" + @nodes.each do |node| + text += "+++ #{node.name}\n" + text += "menu = #{node.name}\n" + text += "title = #{node.name} connectivity\n" + # prefer interfaces named wifi, even if they are not the first in the list + ip = Ip.find(:first, :conditions => ["node_id = ? AND name like ?", node.id, 'wifi%']) + if ip != nil + text += "host = #{ip.ip}\n" + else + # no 'wifi' interface found, use any old interface... + ip = Ip.find(:first, :conditions => ["node_id = ?", node.id]) + if ip != nil + text += "host = #{ip.ip}\n" + end + end + end + end + end + render_text text + end + end + + def all + @locations = Location.find(:all, :order => "name") + render :layout => false + end +end -- cgit v1.2.1