Module: WIKI
- Defined in:
- generators/gen_wiki.rb
Overview
Generate Confluence Wiki table, from the IBLinkinfo data.
Class Method Summary (collapse)
-
+ (Object) gen(ib, file = "iblinkinfo_wiki.txt")
Generate an new html style format confluence wiki table.
Class Method Details
+ (Object) gen(ib, file = "iblinkinfo_wiki.txt")
Generate an new html style format confluence wiki table.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'generators/gen_wiki.rb', line 6 def self.gen(ib, file="iblinkinfo_wiki.txt") #Output Wiki table syntax separated fields for current switch port to rack mappings #@switches.each do |k,v| File.open(file, "w") do |fd| ib.switch_location.each do |k,loc| if loc[1] == :leaf || loc[1] == :ex_spine fd.puts "<h3> #{k} </h3>" fd.puts "<table>\n <tbody>" v = ib.switches[k] if v != nil fd.puts "<tr>" (1..loc[4]).step(2) do |i| fd.puts "<th><p> </p></th>" if i == 19 fd.puts "<th><p>#{i}</p></th>" end fd.puts "</tr>" fd.puts "<tr>" (1..loc[4]).step(2) do |i| l = ib.location[v[i][9]] fd.puts "<td><p> </p></td>" if i == 19 fd.puts "<td><p>#{l == nil ? v[i][9] : "#{l[2]}/P#{"%02d"%v[i][7]}"}</p></td>" end fd.puts "</tr>" fd.puts "<tr>" (2..loc[4]).step(2) do |i| fd.puts "<th><p> </p></th>" if i == 20 fd.puts "<th><p>#{i}</p></th>" end fd.puts "</tr>" fd.puts "<tr>" (2..loc[4]).step(2) do |i| l = ib.location[v[i][9]] fd.puts "<td><p> </p></td>" if i == 20 fd.puts "<td><p>#{l == nil ? v[i][9] : "#{l[2]}/P#{"%02d"%v[i][7]}"}</p></td>" end fd.puts "</tr>" end fd.print " </tbody>\n</table>" end end end end |